function prepare_items($post_id) { $screen = get_current_screen(); $data = array('post_id' => $post_id); $events_data = new events_data(); /* -- Ordering parameters -- */ //Parameters that are going to be used to order the result $orderby = !empty($_GET["orderby"]) ? mysql_real_escape_string($_GET["orderby"]) : 'created_date'; $order = !empty($_GET["order"]) ? mysql_real_escape_string($_GET["order"]) : 'DESC'; /* -- Pagination parameters -- */ //Number of elements in your table? $totalitems = $events_data->count($data); //return the total number of affected rows // //How many to display per page? $perpage = 5; //Which page is this? $paged = !empty($_GET["paged"]) ? mysql_real_escape_string($_GET["paged"]) : ''; //Page Number if (empty($paged) || !is_numeric($paged) || $paged <= 0) { $paged = 1; } $page_offset = $perpage * ($paged - 1); //How many pages do we have in total? $totalpages = ceil($totalitems / $perpage); //adjust the query to take pagination into account /* -- Register the pagination -- */ $this->set_pagination_args(array("total_items" => $totalitems, "total_pages" => $totalpages, "per_page" => $perpage)); $this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns()); //The pagination links are automatically built according to those parameters /* -- Fetch the items -- */ $data = array('post_id' => $post_id, 'orderby' => $orderby, 'order' => $order, 'limit' => $perpage, 'offset' => $page_offset); $this->items = $events_data->query($data); }
/** * When the plugin is updated to a newer version the code here * will make any ammendments which are required. */ public function upgrade() { global $wpdb; if (version_compare($this->plugin_installed_version(), '1.1.3') < 0) { $result = $wpdb->update($wpdb->term_taxonomy, array('taxonomy' => 'syn_rest_menu'), array('taxonomy' => 'syn_rest_menu')); $result = $wpdb->update($wpdb->term_taxonomy, array('taxonomy' => 'syn_rest_course'), array('taxonomy' => 'syn_menu_course')); $result = $wpdb->update($wpdb->term_taxonomy, array('taxonomy' => 'syn_rest_diet'), array('taxonomy' => 'syn_dietary_type')); $result = $wpdb->update($wpdb->term_taxonomy, array('taxonomy' => 'syn_rest_cuisine'), array('taxonomy' => 'syn_cuisine_type')); } if (version_compare($this->plugin_installed_version(), '1.2.0') < 0) { $events_data = new events_data(); $events_data->create_table(); $eventmeta_data = new eventmeta_data(); $eventmeta_data->create_table(); } }