Esempio n. 1
0
 /**
  * method gets data to be display inside the table sets pagination data and sets items fields of the parent class 
  * 
  */
 function prepare_items()
 {
     global $wpdb, $_wp_column_headers;
     $show_private = false;
     if (isset($_POST['posttype']) && (!isset($_POST['show_private']) || '1' != $_POST['show_private'])) {
         $show_private = false;
     } elseif (isset($_REQUEST['show_private']) && '1' == $_REQUEST['show_private']) {
         $show_private = true;
     }
     if (isset($_POST['posttype'])) {
         $post_type = $_POST['posttype'];
     } elseif (isset($_REQUEST['posttype'])) {
         $post_type = $_REQUEST['posttype'];
     } else {
         $post_type = '';
     }
     $this->_post_type = $post_type;
     $this->_show_private = $show_private;
     $screen = get_current_screen();
     // sorting
     $orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : 'post_title';
     $order = !empty($_GET['order']) ? $_GET['order'] : 'asc';
     //How many to display per page?
     $perpage = getCurrentScreenPerPage();
     if (isset($_REQUEST['wp_screen_options'])) {
         if (isset($_REQUEST['wp_screen_options']['option']) && 'cred_per_page' == $_REQUEST['wp_screen_options']['option'] && isset($_REQUEST['wp_screen_options']['value'])) {
             $perpage = intval($_REQUEST['wp_screen_options']['value']);
         }
     } elseif (isset($_REQUEST['per_page'])) {
         $perpage = intval($_REQUEST['per_page']);
     }
     //Which page is this?
     $paged = intval(array_key_exists('paged', $_GET) ? $_GET['paged'] : 1);
     /**
      * sanitize paged
      */
     if ($paged < 1) {
         $paged = 1;
     }
     $this->items = array();
     $totalitems = 0;
     $fm = CRED_Loader::get('MODEL/Fields');
     /* -- Fetch the items -- */
     if (!empty($post_type)) {
         $totalitems = $fm->getPostTypeCustomFields($post_type, array(), $show_private, -1, $perpage);
         if (($paged - 1) * $perpage > $totalitems) {
             $paged = 1;
         }
         $this->items = $fm->getPostTypeCustomFields($post_type, array(), $show_private, $paged, $perpage, $orderby, $order);
     }
     /* -- Register the pagination -- */
     //How many pages do we have in total?
     $totalpages = ceil($totalitems / $perpage);
     $this->set_pagination_args(array("total_items" => $totalitems, "total_pages" => $totalpages, "per_page" => $perpage, 'paged' => $paged, 'posttype' => $post_type, 'show_private' => $show_private ? '1' : '0'));
     //The pagination links are automatically built according to those parameters
     /* � Register the Columns � */
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
 }
Esempio n. 2
0
 /**
  * method gets data to be display inside the table sets pagination data and sets items fields of the parent class 
  * 
  */
 function prepare_items()
 {
     global $wpdb, $_wp_column_headers;
     $screen = get_current_screen();
     // sorting
     $orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : 'post_title';
     $order = !empty($_GET['order']) ? $_GET['order'] : 'asc';
     //How many to display per page?
     $perpage = getCurrentScreenPerPage();
     if (isset($_REQUEST['wp_screen_options'])) {
         if (isset($_REQUEST['wp_screen_options']['option']) && 'cred_per_page' == $_REQUEST['wp_screen_options']['option'] && isset($_REQUEST['wp_screen_options']['value'])) {
             $perpage = intval($_REQUEST['wp_screen_options']['value']);
         }
     } elseif (isset($_REQUEST['per_page'])) {
         $perpage = intval($_REQUEST['per_page']);
     }
     //Which page is this?
     $paged = intval(array_key_exists('paged', $_GET) ? $_GET['paged'] : 1);
     /**
      * sanitize paged
      */
     if ($paged < 1) {
         $paged = 1;
     }
     $totalitems = 0;
     $this->items = array();
     $fm = CRED_Loader::get('MODEL/UserForms');
     /* -- Fetch the items -- */
     $totalitems = $fm->getFormsCount();
     //count($this->items);
     if (($paged - 1) * $perpage > $totalitems) {
         $paged = 1;
     }
     $this->items = $fm->getFormsForTable($paged, $perpage, $orderby, $order);
     /* -- Register the pagination -- */
     //How many pages do we have in total?
     $totalpages = ceil($totalitems / $perpage);
     $this->set_pagination_args(array("total_items" => $totalitems, "total_pages" => $totalpages, "per_page" => $perpage, "paged" => $paged));
     //The pagination links are automatically built according to those parameters
     /* � Register the Columns � */
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
 }