/** * prints a list of records called by a shortcode * * this function is called statically to instantiate the PDb_List object, * which captures the output and returns it for display * * @param array $shortcode_atts parameters passed by the shortcode * @return string form HTML */ public static function get_list($shortcode_atts) { self::$instance = new PDb_List($shortcode_atts); return self::$instance->output; }
/** * provides the list output from an AJAX search * * @param object $post the current post object * @param int $instance the instance index of the targeted list * @return null */ private static function print_list_search_result($post, $instance) { /* * get the attributes array; these values were saved in the session array by * the Shortcode class when it was instantiated */ $session = self::$session->getArray('shortcode_atts'); $shortcode_atts = $session[$post->ID]['list'][$instance]; if (!is_array($shortcode_atts)) { printf('session for list instance %s not found', $instance); return; } // add the AJAX filtering flag $shortcode_atts['filtering'] = 1; $shortcode_atts['module'] = 'list'; // output the filtered shortcode content header("Content-Type:\ttext/html"); echo PDb_List::get_list($shortcode_atts); return; }
/** * prints the list with filtering parameters applied * * called by the wp_ajax_nopriv_pdb_list_filter action: this happens when a * user submits a search or sort on a record list * * @return null */ public static function pdb_list_filter() { if (!wp_verify_nonce($_POST['filterNonce'], self::$prefix . 'list-filter-nonce')) { die('nonce check failed'); } global $post; if (!is_object($post)) { $post = get_post($_POST['postID']); } /* * get the attributes array; these values were saved in the session array by * the Shortcode class when it was instantiated */ $shortcode_atts = self::$session->get(self::$prefix . 'shortcode_atts'); $atts = $shortcode_atts['list'][$_POST['instance_index']] !== false ? $shortcode_atts['list'][$_POST['instance_index']] : current($shortcode_atts['list']); // add the AJAX filtering flag $atts['filtering'] = 1; $atts['module'] = 'list'; // output the filtered shortcode content header("Content-Type:\ttext/html"); echo PDb_List::get_list($atts); exit; }