LLMS_Analytics_Memberships::search_form()

Builds Search Form


Description Description


Source Source

File: includes/admin/analytics/class.llms.analytics.memberships.php

	public function search_form() {

		//get session data if it exists
		$search = LLMS()->session->get( 'llms_analytics_membership' );

		$product_id = isset( $search->product_id ) ? $search->product_id : '';
		$date_filter = isset( $search->date_filter ) ? $search->date_filter : 'none';
		$start_date = isset( $search->start_date ) ? LLMS_Date::pretty_date( $search->start_date ) : '';
		$end_date = isset( $search->end_date ) ? LLMS_Date::pretty_date( $search->end_date ) : '';

		//get products
		$products = LLMS_Analytics::get_products();
		//get date filters
		$date_filters = LLMS_Date::date_filters();

		//start building html
		$html = '<div class="llms-search-form-wrapper">';

		//Product Select ( Memberships )
		$html .= '<div class="llms-select">';
		$html .= '<label>' . __( 'Select a Membership', 'lifterlms' ) . '</label>';
		$html .= '<select id="llms-product-select" name="llms_product_select" class="chosen-select-width">';

		//all products option
		$html .= '<option value="all_memberships" ' . ( 'all_memberships' == $product_id ? 'selected' : '' ) . '>' . __( 'All Memberships', 'lifterlms' ) . '</option>';

		//loop through posts
		if ( $products ) {
			foreach ( $products as $key => $product ) {
				if ( 'llms_membership' === $product->post_type ) {
						$html .= '<option value="' . $product->ID . '"
						' . ( $product_id == $product->ID  ? 'selected' : '' ) . '>
						' . $product->post_title . '</option>';
				}
			}
		}

		$html .= '</select>';
		$html .= '</div>';

		//Date filters
		$html .= '<div class="llms-select">';
		$html .= '<label>' . __( 'Filter Date Range', 'lifterlms' ) . '</label>';
		$html .= '<select id="llms-date-filter-select" name="llms_date_filter" class="chosen-select-width">';

		foreach ( $date_filters as $key => $value ) {
			$html .= '<option value="' . $key . '" 
				' . ( $date_filter == $key ? 'selected' : '' ) . '>
				' . $value . '</option>';

		}

		$html .= '</select>';
		$html .= '</div>';

		//start date
		$html .= '<div class="llms-filter-options date-filter">';
		$html .= '<div class="llms-date-select">';
		$html .= '<label>' . __( 'Start date', 'lifterlms' ) . '</label>';
		$html .= '<input type="text" name="llms-start-date" class="llms-date-range-select-start" value="' . $start_date . '">';
		$html .= '</div>';

		//end date
		$html .= '<div class="llms-date-select">';
		$html .= '<label>' . __( 'End date', 'lifterlms' ) . '</label>';
		$html .= '<input type="text" name="llms-end-date" class="llms-date-range-select-end" value="' . $end_date . '">';
		$html .= '</div>';
		$html .= '</div>'; //end date filters

		$html .= wp_nonce_field( 'search_analytics_membership', '_wpnonce', true, false );
		$html .= '<input type="hidden" name="action" value="llms-analytics-membership" />';

		//search button
		$html .= '<div class="llms-search-button">';
		//$html .= '<input type="submit" name="llms_search" class="button button-primary" id="llms_analytics_search" value="Filter Results" />';
		$html .= get_submit_button( 'Filter Results', 'primary', 'llms_search', true, array(
			'id' => 'llms_analytics_search',
		) );
		$html .= '</div>';

		$html .= '</div>';

		return $html;

	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink: