/**
  * initializes and outputs the list on the frontend as called by the shortcode
  *
  * @param array $shortcode_atts display customization parameters
  *                              from the shortcode
  */
 public function __construct($shortcode_atts)
 {
     $this->set_instance_index();
     // define the default settings for the shortcode
     $shortcode_defaults = array('sort' => 'false', 'search' => 'false', 'list_limit' => Participants_Db::plugin_setting('list_limit', '10'), 'class' => 'participants-database', 'filter' => '', 'orderby' => Participants_Db::plugin_setting('list_default_sort'), 'order' => Participants_Db::plugin_setting('list_default_sort_order'), 'fields' => '', 'single_record_link' => '', 'display_count' => Participants_Db::plugin_setting('show_count'), 'template' => 'default', 'module' => 'list', 'action' => '', 'suppress' => '');
     // run the parent class initialization to set up the parent methods
     parent::__construct($shortcode_atts, $shortcode_defaults);
     $this->list_anchor = 'participants-list-' . $this->instance_index;
     $this->list_page = Participants_Db::$list_page;
     $this->_set_page_number();
     //    error_log( __METHOD__.' $this->shortcode_atts:'.print_r( $this->shortcode_atts,1 ));
     $this->registration_page_url = get_bloginfo('url') . '/' . Participants_Db::plugin_setting('registration_page', '');
     $this->_setup_i18n();
     $this->_set_single_record_url();
     /*
      * if the 'suppress' shortcode attribute is set
      */
     if (!empty($this->shortcode_atts['suppress'])) {
         $this->suppress = filter_var($this->shortcode_atts['suppress'], FILTER_VALIDATE_BOOLEAN);
     }
     // enqueue the filter/sort AJAX script
     if (Participants_Db::plugin_setting_is_true('ajax_search')) {
         global $wp_query;
         $ajax_params = array('ajaxurl' => admin_url('admin-ajax.php'), 'filterNonce' => Participants_Db::nonce(self::$list_filter_nonce_key), 'postID' => isset($wp_query->post) ? $wp_query->post->ID : '', 'prefix' => Participants_Db::$prefix, 'loading_indicator' => Participants_Db::get_loading_spinner());
         wp_localize_script(Participants_Db::$prefix . 'list-filter', 'PDb_ajax', $ajax_params);
         wp_enqueue_script(Participants_Db::$prefix . 'list-filter');
     }
     /*
      * instantiate the List Query object
      */
     $this->set_list_query_object();
     if ($search_error = $this->list_query->get_search_error()) {
         $this->search_error($search_error);
     }
     // set up the iteration data
     $this->_setup_iteration();
     /*
      * set the initial sortable field list; this is the set of all fields that are 
      * both marked "sortable" and currently displayed in the list
      */
     $this->_set_default_sortables();
     $this->is_search_result = $this->list_query->is_search_result();
     $this->_print_from_template();
 }
Пример #2
0
 /**
  * initializes and outputs the list on the frontend as called by the shortcode
  *
  * @param array $shortcode_atts display customization parameters
  *                              from the shortcode
  */
 public function __construct($shortcode_atts)
 {
     // set the list limit value; this can be overridden by the shortcode atts later
     $this->page_list_limit = intval((!isset($_POST['list_limit']) or !is_numeric($_POST['list_limit']) or $_POST['list_limit'] < 1) ? Participants_Db::$plugin_options['list_limit'] : $_POST['list_limit']);
     // define the default settings for the shortcode
     $shortcode_defaults = array('sort' => 'false', 'search' => 'false', 'list_limit' => $this->page_list_limit, 'class' => 'participants-database', 'filter' => '', 'orderby' => Participants_Db::$plugin_options['list_default_sort'], 'order' => Participants_Db::$plugin_options['list_default_sort_order'], 'fields' => '', 'single_record_link' => '', 'display_count' => Participants_Db::$plugin_options['show_count'], 'template' => 'default', 'module' => 'list', 'action' => '', 'suppress' => '');
     // run the parent class initialization to set up the parent methods
     parent::__construct($shortcode_atts, $shortcode_defaults);
     //    error_log( __METHOD__.' $this->shortcode_atts:'.print_r( $this->shortcode_atts,1 ));
     $this->registration_page_url = get_bloginfo('url') . '/' . (isset(Participants_Db::$plugin_options['registration_page']) ? Participants_Db::$plugin_options['registration_page'] : '');
     /*
      * set the initial sortable field list; this is the set of all fields that are 
      * both marked "sortable" and currently displayed in the list
      */
     $this->sortables = Participants_Db::get_sortables();
     //    $this->sortables = Participants_Db::get_sortables(Participants_Db::get_sortables() + $this->display_columns);
     $this->_setup_i18n();
     $this->_set_single_record_url();
     /*
      * if the 'suppress' shortcode attribute is set
      */
     if (!empty($this->shortcode_atts['suppress'])) {
         $this->suppress = true;
     }
     // enqueue the filter/sort AJAX script
     if ($this->_sort_filter_mode() !== 'none' and Participants_Db::$plugin_options['ajax_search'] == 1) {
         global $wp_query;
         $ajax_params = array('ajaxurl' => admin_url('admin-ajax.php'), 'filterNonce' => wp_create_nonce(Participants_Db::$prefix . 'list-filter-nonce'), 'postID' => isset($wp_query->post) ? $wp_query->post->ID : '', 'prefix' => Participants_Db::$prefix, 'loading_indicator' => Participants_Db::get_loading_spinner(), 'i18n' => $this->i18n);
         wp_localize_script(Participants_Db::$prefix . 'list-filter', 'PDb_ajax', $ajax_params);
         wp_enqueue_script(Participants_Db::$prefix . 'list-filter');
     }
     // set up the iteration data
     $this->_setup_iteration();
     $this->_print_from_template();
 }