/** * Extra controls to be displayed before pagination, which * includes our Filters: Customers, Event Types, Event Dates * * @see WP_List_Table::extra_tablenav(); * @since 1.0 * @param string $which the placement, one of 'top' or 'bottom' */ public function extra_tablenav($which) { global $woocommerce; if ('top' == $which) { echo '<div class="alignleft actions">'; // Customers, products ?> <select id="dropdown_customers" name="_customer_user"> <option value=""><?php _e('Show All Customers', 'wc_points_rewards'); ?> </option> <?php if (!empty($_GET['_customer_user'])) { $user = get_user_by('id', absint($_GET['_customer_user'])); echo '<option value="' . absint($user->ID) . '" '; selected(1, 1); echo '>' . esc_html($user->display_name) . ' (#' . absint($user->ID) . ' – ' . esc_html($user->user_email) . ')</option>'; } ?> </select> <select id="dropdown_event_types" name="_event_type"> <option value=""><?php _e('Show All Event Types', 'wc_points_rewards'); ?> </option> <?php foreach (WC_Points_Rewards_Points_Log::get_event_types() as $event_type) { echo '<option value="' . esc_attr($event_type->type) . '" ' . selected($event_type->type, isset($_GET['_event_type']) ? $_GET['_event_type'] : null, false) . '>' . esc_html(sprintf("%s (%d)", $event_type->name, $event_type->count)) . '</option>'; } ?> </select> <?php $this->render_dates_dropdown(); submit_button(__('Filter'), 'button', false, false, array('id' => 'post-query-submit')); echo '</div>'; // javascript $js = "\n\t\t\t\t// Ajax Chosen Product Selectors\n\t\t\t\t\$('select#dropdown_dates').css('width', '250px').chosen();\n\n\t\t\t\t\$('select#dropdown_event_types').css('min-width', '190px').chosen();\n\n\t\t\t\t\$('select#dropdown_customers').css('width', '250px').ajaxChosen({\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\turl: '" . admin_url('admin-ajax.php') . "',\n\t\t\t\t\tdataType: 'json',\n\t\t\t\t\tafterTypeDelay: 100,\n\t\t\t\t\tminTermLength: 1,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\taction: 'woocommerce_json_search_customers',\n\t\t\t\t\t\tsecurity: '" . wp_create_nonce("search-customers") . "',\n\t\t\t\t\t\tdefault: '" . esc_js(__('Show All Customers', 'wc_points_rewards')) . "'\n\t\t\t\t\t}\n\t\t\t\t}, function (data) {\n\n\t\t\t\t\tvar terms = {};\n\n\t\t\t\t\t\$.each(data, function (i, val) {\n\t\t\t\t\t\tterms[i] = val;\n\t\t\t\t\t});\n\n\t\t\t\t\treturn terms;\n\t\t\t\t});\n\t\t\t"; if (function_exists('wc_enqueue_js')) { wc_enqueue_js($js); } else { $woocommerce->add_inline_js($js); } } }