* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio * @copyright Copyright (c) 2016, Ernest Marcinko */ class wd_CFSearchCallBack extends wpdreamsType { private $args = array( 'callback' => '', // javacsript function name in the windows scope | if empty, shows results 'placeholder' => 'Search custom fields..', 'search_values' => 0, 'limit' => 10, 'delimiter' => '!!!CFRES!!!', 'controls_position' => 'right', 'class' => '' ); public function getType() { parent::getType(); $this->processData(); ?>
args['class'] : "";?>' id='wd_cf_search-'> args['controls_position'] == 'left') $this->printControls(); ?> label; ?> args['controls_position'] != 'left') $this->printControls(); ?>
prepare( "SELECT DISTINCT(meta_key) FROM $wpdb->postmeta WHERE meta_key LIKE '%s' OR meta_value LIKE '%s' LIMIT %d", $phrase, $phrase, $data['limit']); else $cf_query = $wpdb->prepare( "SELECT DISTINCT(meta_key) FROM $wpdb->postmeta WHERE meta_key LIKE '%s' LIMIT %d", $phrase, $data['limit']); $cf_results = $wpdb->get_results( $cf_query, OBJECT ); print_r($data['delimiter'] . json_encode($cf_results) . $data['delimiter']); die(); } public function processData() { // Get the args first if exists if ( is_array($this->data) && isset($this->data['args']) ) $this->args = array_merge($this->args, $this->data['args']); if ( is_array($this->data) && isset($this->data['value']) ) { // If called from back-end non-post context $this->data = $this->data['value']; } } public final function getData() { return $this->data; } } } if ( !has_action('wp_ajax_wd_search_cf') ) add_action('wp_ajax_wd_search_cf', 'wd_CFSearchCallBack::searchCF');