GPI_List_Table

The Google Pagespeed Insights GPI List Table class.

Defined (1)

The class is defined in the following location(s).

/core/admin.php  
  1. class GPI_List_Table extends WP_List_Table { 
  2.  
  3. function __construct() { 
  4. global $status, $page, $hook_suffix; 
  5.  
  6. //Set parent defaults 
  7. parent::__construct( array( 
  8. 'singular' => 'gpi_page_report',  
  9. 'plural' => 'gpi_page_reports',  
  10. 'ajax' => false 
  11. ) ); 
  12.  
  13.  
  14. // here for compatibility with 4.3 
  15. function get_columns() 
  16. // Get options 
  17. $gpi_options = $this->getOptions(); 
  18.  
  19. return $this->gpi_get_columns(false, false, false, $gpi_options['strategy']); 
  20.  
  21. // humanTiming used to calculate time since last report check 
  22. function humanTiming($time) 
  23. if(empty($time)) return 'N/A'; 
  24. $time = time() - $time; 
  25.  
  26. $tokens = array ( 
  27. 31536000 => 'year',  
  28. 2592000 => 'month',  
  29. 604800 => 'week',  
  30. 86400 => 'day',  
  31. 3600 => 'hour',  
  32. 60 => 'minute',  
  33. 1 => 'second' 
  34. ); 
  35.  
  36. foreach ($tokens as $unit => $text) { 
  37. if ($time < $unit) continue; 
  38. $numberOfUnits = floor($time / $unit); 
  39. return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s ago':' ago'); 
  40.  
  41.  
  42. function no_items() { 
  43. $pagetype = isset( $_GET['render'] ) ? $_GET['render'] : 'list'; 
  44.  
  45. switch($pagetype) 
  46. case 'list': 
  47. _e( 'No Pagespeed Reports Found. Google Pagespeed may still be checking your pages. If problems persist, see the following possible solutions:', 'gpagespeedi' ); 
  48. ?> 
  49. <ul class="no-items"> 
  50. <li><?php _e( 'Make sure that you have entered your Google API key on the ', 'gpagespeedi' );?><a href="?page=<?php echo $_REQUEST['page']; ?>&render=options">Options</a> page.</li> 
  51. <li><?php _e( 'Make sure that you have enabled "PageSpeed Insights API" from the Services page of the ', 'gpagespeedi' );?><a href="https://code.google.com/apis/console/">Google Console</a>.</li> 
  52. <li><?php _e( 'The Google Pagespeed API may be temporarily unavailable.', 'gpagespeedi' );?></li> 
  53. </ul> 
  54. <?php 
  55. break; 
  56.  
  57. case 'ignored-urls': 
  58. _e( 'No Ignored URLs found. A URL can be ignored from the <a href="?page=' . $_REQUEST['page'] . '&render=list">Report List</a> page if you would like to remove it from report pages', 'gpagespeedi' ); 
  59. break; 
  60.  
  61.  
  62. // Get our plugin options 
  63. function getOptions($option_name = 'gpagespeedi_options') { 
  64. $gpi_options = get_option($option_name); 
  65.  
  66. return $gpi_options; 
  67.  
  68. // Figure out which types to query for based on the plugin options 
  69. function getTypesToCheck($restrict_type = 'all') { 
  70.  
  71. $types = array(); 
  72. $gpi_options = $this->getOptions(); 
  73. $typestocheck = array(); 
  74.  
  75. if($gpi_options['check_pages']) { 
  76. if($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'pages') { 
  77. $typestocheck[] = 'type = %s'; 
  78. $types[1][] = "page"; 
  79.  
  80. if($gpi_options['check_posts']) { 
  81. if($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'posts') { 
  82. $typestocheck[] = 'type = %s'; 
  83. $types[1][] = "post"; 
  84.  
  85. if($gpi_options['check_categories']) { 
  86. if($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'categories') { 
  87. $typestocheck[] = 'type = %s'; 
  88. $types[1][] = "category"; 
  89. if($gpi_options['cpt_whitelist']) { 
  90. if($restrict_type == 'all' || $restrict_type == 'ignored' || stristr($restrict_type, 'gpi_custom_posts')) { 
  91.  
  92. $cpt_whitelist_arr = false; 
  93. if(!empty($gpi_options['cpt_whitelist'])) { 
  94. $cpt_whitelist_arr = unserialize($gpi_options['cpt_whitelist']); 
  95. $args=array( 
  96. 'public' => true,  
  97. '_builtin' => false 
  98. );  
  99. $custom_post_types = get_post_types($args, 'names', 'and'); 
  100. if($restrict_type != 'gpi_custom_posts' && $restrict_type != 'all' && $restrict_type != 'ignored') { 
  101. $restrict_type = str_replace('gpi_custom_posts-', '', $restrict_type); 
  102. foreach($custom_post_types as $post_type) 
  103. if($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) { 
  104. if($post_type == $restrict_type) { 
  105. $typestocheck[] = 'type = %s'; 
  106. $types[1][] = $custom_post_types[$post_type]; 
  107. } else { 
  108. foreach($custom_post_types as $post_type) 
  109. if($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) { 
  110. $typestocheck[] = 'type = %s'; 
  111. $types[1][] = $custom_post_types[$post_type]; 
  112.  
  113. if(!empty($typestocheck)) { 
  114. $types[0] = ''; 
  115. foreach($typestocheck as $type) 
  116. if(!is_array($type)) { 
  117. $types[0] .= $type . ' OR '; 
  118. } else { 
  119. foreach($type as $custom_post_type) 
  120. $types[0] .= 'type = %s OR '; 
  121. $types[1][] = $custom_post_type; 
  122. $types[0] = rtrim($types[0], ' OR '); 
  123. return $types; 
  124. return null; 
  125.  
  126. // Default Column handling behaviors 
  127. function column_default($item, $column_name) { 
  128. switch($column_name) { 
  129. case 'desktop_last_modified': 
  130. $formatted_time = $this->humanTiming($item['desktop_last_modified']); 
  131. return $formatted_time; 
  132. case 'mobile_last_modified': 
  133. $formatted_time = $this->humanTiming($item['mobile_last_modified']); 
  134. return $formatted_time; 
  135. case 'type': 
  136. return $item['type']; 
  137. default: 
  138. return print_r($item, true); //Show the whole array for troubleshooting purposes 
  139.  
  140. // URL column handling behavior 
  141. function column_URL($item) { 
  142.  
  143. //Strip domain from URL 
  144. $siteurl = get_site_url(); 
  145. $siteurl_ssl = get_site_url('', '', 'https'); 
  146.  
  147. $search_urls = array($siteurl, $siteurl_ssl); 
  148.  
  149. $cleaned_url = str_replace($search_urls, '', $item['URL']); 
  150.  
  151. //Build row actions 
  152. $actions = array( 
  153. 'view_details' => sprintf('<a href="?page=%s&render=%s&page_id=%s">%s</a>', $_REQUEST['page'], 'details', $item['ID'], __('Details', 'gpagespeedi')),  
  154. 'ignore' => sprintf('?page=%s&render=%s&action=%s&id=%s', $_REQUEST['page'], 'list', 'ignore', $item['ID']),  
  155. 'visit' => sprintf('<a href="%s" target="_blank">%s</a>', $item['URL'], __('View URL', 'gpagespeedi')),  
  156. ); 
  157.  
  158. $url_to_nonce = $actions['ignore']; 
  159. $nonced_url = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($url_to_nonce, 'bulk-gpi_page_reports') : $url_to_nonce; 
  160. $actions['ignore'] = '<a href="'.$nonced_url.'">'.__('Ignore', 'gpagespeedi').'</a>'; 
  161.  
  162. //Return the url contents 
  163. return sprintf('<a href="?page=%3$s&render=%4$s&page_id=%5$s">%1$s</a> %2$s',  
  164. /**$1%s*/ $cleaned_url,  
  165. /**$2%s*/ $this->row_actions($actions),  
  166. /**$3%s*/ $_REQUEST['page'],  
  167. /**$4%s*/ 'details',  
  168. /**$5%s*/ $item['ID'] 
  169. ); 
  170.  
  171. // Ignored URL column handling behavior 
  172. function column_Ignored_URL($item) { 
  173.  
  174. //Strip domain from URL 
  175. $siteurl = get_site_url(); 
  176. $siteurl_ssl = get_site_url('', '', 'https'); 
  177.  
  178. $search_urls = array($siteurl, $siteurl_ssl); 
  179.  
  180. $cleaned_url = str_replace($search_urls, '', $item['URL']); 
  181.  
  182. //Build row actions 
  183. $actions = array( 
  184. 'activate' => sprintf('?page=%s&render=%s&action=%s&id=%s', $_REQUEST['page'], 'ignored-urls', 'activate', $item['ID']),  
  185. 'visit' => sprintf('<a href="%s" target="_blank">%s</a>', $item['URL'], __('View URL', 'gpagespeedi')),  
  186. ); 
  187.  
  188. $url_to_nonce = $actions['activate']; 
  189. $nonced_url = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($url_to_nonce, 'bulk-gpi_page_reports') : $url_to_nonce; 
  190. $actions['activate'] = '<a href="'.$nonced_url.'">'.__('Reactivate', 'gpagespeedi').'</a>'; 
  191.  
  192. //Return the url contents 
  193. return sprintf('%1$s %2$s',  
  194. /**$1%s*/ $cleaned_url,  
  195. /**$2%s*/ $this->row_actions($actions) 
  196. ); 
  197.  
  198. // Mobile Score column handling behavior 
  199. function column_mobile_score($item) { 
  200.  
  201. if(empty($item['mobile_score'])) return 'N/A'; 
  202.  
  203. $gradient = array("", "FF0000", "FE0500", "FE0A00", "FE0F00", "FE1400", "FE1900", "FE1E00", "FE2300", "FE2800", "FE2D00", "FE3300", "FE3800", "FE3D00", "FE4200", "FE4700", "FE4C00", "FE5100", "FD5600", "FD5B00", "FD6000", "FD6600", "FD6B00", "FD7000", "FD7500", "FD7A00", "FD7F00", "FD8400", "FD8900", "FD8E00", "FD9300", "FD9900", "FD9E00", "FDA300", "FDA800", "FCAD00", "FCB200", "FCB700", "FCBC00", "FCC100", "FCC600", "FCCC00", "FCD100", "FCD600", "FCDB00", "FCE000", "FCE500", "FCEA00", "FCEF00", "FCF400", "FCF900", "FCFF00", "F7FF00", "F2FF00", "EEFF00", "E9FF00", "E4FF00", "E0FF00", "DBFF00", "D6FF00", "D2FF00", "CDFF00", "C8FF00", "C4FF00", "BFFF00", "BAFF00", "B6FF00", "B1FF00", "ACFF00", "A8FF00", "A3FF00", "9EFF00", "9AFF00", "95FF00", "90FF00", "8CFF00", "87FF00", "83FF00", "7EFF00", "79FF00", "75FF00", "70FF00", "6BFF00", "67FF00", "62FF00", "5DFF00", "59FF00", "54FF00", "4FFF00", "4BFF00", "46FF00", "41FF00", "3DFF00", "38FF00", "33FF00", "2FFF00", "2AFF00", "25FF00", "21FF00", "1CFF00", "18FF00"); 
  204. $barcolor = $gradient[$item['mobile_score']]; 
  205. $innerdiv_css = "background-color:#".$barcolor.";width:".$item['mobile_score']."%"; 
  206.  
  207. //Return the score contents 
  208. return sprintf('<span class="scorenum">%1$s</span><div class="reportscore_outter_bar"><div class="reportscore_inner_bar" style="%2$s"></div></div>', $item['mobile_score'], $innerdiv_css); 
  209.  
  210. // Desktop Score column handling behavior 
  211. function column_desktop_score($item) { 
  212.  
  213. if(empty($item['desktop_score'])) return 'N/A'; 
  214.  
  215. $gradient = array("", "FF0000", "FE0500", "FE0A00", "FE0F00", "FE1400", "FE1900", "FE1E00", "FE2300", "FE2800", "FE2D00", "FE3300", "FE3800", "FE3D00", "FE4200", "FE4700", "FE4C00", "FE5100", "FD5600", "FD5B00", "FD6000", "FD6600", "FD6B00", "FD7000", "FD7500", "FD7A00", "FD7F00", "FD8400", "FD8900", "FD8E00", "FD9300", "FD9900", "FD9E00", "FDA300", "FDA800", "FCAD00", "FCB200", "FCB700", "FCBC00", "FCC100", "FCC600", "FCCC00", "FCD100", "FCD600", "FCDB00", "FCE000", "FCE500", "FCEA00", "FCEF00", "FCF400", "FCF900", "FCFF00", "F7FF00", "F2FF00", "EEFF00", "E9FF00", "E4FF00", "E0FF00", "DBFF00", "D6FF00", "D2FF00", "CDFF00", "C8FF00", "C4FF00", "BFFF00", "BAFF00", "B6FF00", "B1FF00", "ACFF00", "A8FF00", "A3FF00", "9EFF00", "9AFF00", "95FF00", "90FF00", "8CFF00", "87FF00", "83FF00", "7EFF00", "79FF00", "75FF00", "70FF00", "6BFF00", "67FF00", "62FF00", "5DFF00", "59FF00", "54FF00", "4FFF00", "4BFF00", "46FF00", "41FF00", "3DFF00", "38FF00", "33FF00", "2FFF00", "2AFF00", "25FF00", "21FF00", "1CFF00", "18FF00"); 
  216. $barcolor = $gradient[$item['desktop_score']]; 
  217. $innerdiv_css = "background-color:#".$barcolor.";width:".$item['desktop_score']."%"; 
  218.  
  219. //Return the score contents 
  220. return sprintf('<span class="scorenum">%1$s</span><div class="reportscore_outter_bar"><div class="reportscore_inner_bar" style="%2$s"></div></div>', $item['desktop_score'], $innerdiv_css); 
  221.  
  222. // Checkboxes column handling 
  223. function column_cb($item) { 
  224. return sprintf( 
  225. '<input type="checkbox" name="%1$s[]" value="%2$s" />',  
  226. /**$1%s*/ $this->_args['singular'],  
  227. /**$2%s*/ $item['ID'] 
  228. ); 
  229.  
  230. // Setup available column types 
  231. function gpi_get_columns($ignored = false, $strategy) { 
  232. if($ignored) { 
  233. $columns = array( 
  234. 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text 
  235. 'ignored_url' => __('Ignored URL', 'gpagespeedi'),  
  236. 'type' => __('Page Type', 'gpagespeedi'),  
  237. ); 
  238. } elseif($strategy == "desktop") { 
  239. $columns = array( 
  240. 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text 
  241. 'url' => __('URL', 'gpagespeedi'),  
  242. 'desktop_score' => __('Score', 'gpagespeedi'),  
  243. 'type' => __('Page Type', 'gpagespeedi'),  
  244. 'desktop_last_modified' => __('Last Checked', 'gpagespeedi'),  
  245. ); 
  246. } elseif($strategy == "mobile") { 
  247. $columns = array( 
  248. 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text 
  249. 'url' => __('URL', 'gpagespeedi'),  
  250. 'mobile_score' => __('Score', 'gpagespeedi'),  
  251. 'type' => __('Page Type', 'gpagespeedi'),  
  252. 'mobile_last_modified' => __('Last Checked', 'gpagespeedi') 
  253. ); 
  254. } else { 
  255. $columns = array( 
  256. 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text 
  257. 'url' => __('URL', 'gpagespeedi'),  
  258. 'desktop_score' => __('Score (Desktop)', 'gpagespeedi'),  
  259. 'mobile_score' => __('Score (Mobile)', 'gpagespeedi'),  
  260. 'type' => __('Page Type', 'gpagespeedi'),  
  261. 'desktop_last_modified' => __('Last Checked (Desktop)', 'gpagespeedi'),  
  262. 'mobile_last_modified' => __('Last Checked (Mobile)', 'gpagespeedi') 
  263. ); 
  264. return $columns; 
  265.  
  266. // Setup sortable columns 
  267. function get_sortable_columns($ignored_urls = false) { 
  268. $filter = (isset($_GET['filter'])) ? $_GET['filter'] : 'all'; 
  269. if($ignored_urls) { 
  270. $sortable_columns = array( 
  271. 'type' => array('type', false) 
  272. ); 
  273. } elseif($filter == "all" || $filter == "custom_posts") { 
  274. $sortable_columns = array( 
  275. 'desktop_score' => array('desktop_score', false),  
  276. 'mobile_score' => array('mobile_score', false),  
  277. 'type' => array('type', false) 
  278. ); 
  279. } else { 
  280. $sortable_columns = array( 
  281. 'desktop_score' => array('desktop_score', false),  
  282. 'mobile_score' => array('mobile_score', false) 
  283. ); 
  284. return $sortable_columns; 
  285.  
  286. // Setup bulk actions 
  287. function get_bulk_actions() { 
  288. $filter = (isset($_GET['filter'])) ? $_GET['filter'] : ''; 
  289. $render = (isset($_GET['render'])) ? $_GET['render'] : ''; 
  290. if($render == "ignored-urls") { 
  291. $actions = array( 
  292. 'activate' => __('Reactivate', 'gpagespeedi') 
  293. ); 
  294. } else { 
  295. $actions = array( 
  296. 'ignore' => __('Ignore', 'gpagespeedi') 
  297. //'recheck' => __('Recheck', 'gpagespeedi') 
  298. ); 
  299. return $actions; 
  300.  
  301. function extra_tablenav( $which ) { 
  302.  
  303. $gpi_options = $this->getOptions(); 
  304.  
  305. // Filter report type 
  306. $report_filter = 'all'; 
  307. if(isset($_GET['filter'])) { 
  308. $report_filter = $_GET['filter']; 
  309.  
  310. // Custom Posts Filter 
  311. $args=array( 
  312. 'public' => true,  
  313. '_builtin' => false 
  314. );  
  315. $custom_post_types = get_post_types($args, 'names', 'and'); 
  316. $subfilters['custom_posts'] = $custom_post_types; 
  317.  
  318. // Custom URLs Filter 
  319. global $wpdb; 
  320.  
  321. $post_per_page = ( isset($_GET['post-per-page']) ) ? $_GET['post-per-page'] : 25 ; 
  322.  
  323. if ( 'top' == $which ) { 
  324. ?> 
  325.  
  326. <div class="alignleft actions"> 
  327. <?php if( isset( $_GET['render'] ) && ( $_GET['render'] == "list" || $_GET['render'] == "summary") ) { ?> 
  328. <select name="filter" id="filter"> 
  329. <option value="all"><?php _e('All Reports', 'gpagespeedi'); ?></option> 
  330. <?php if($gpi_options['check_pages']) { ?> 
  331. <option <?php if($report_filter == 'pages') { echo 'selected="selected"'; } ?> value="pages"><?php _e('Pages', 'gpagespeedi'); ?></option> 
  332. <?php } ?> 
  333. <?php if($gpi_options['check_posts']) { ?> 
  334. <option <?php if($report_filter == 'posts') { echo 'selected="selected"'; } ?> value="posts"><?php _e('Posts', 'gpagespeedi'); ?></option> 
  335. <?php } ?> 
  336. <?php if($gpi_options['check_categories']) { ?> 
  337. <option <?php if($report_filter == 'categories') { echo 'selected="selected"'; } ?> value="categories"><?php _e('Categories', 'gpagespeedi'); ?></option> 
  338. <?php } ?> 
  339. <?php if($gpi_options['cpt_whitelist']) { 
  340.  
  341. $cpt_whitelist_arr = false; 
  342. if(!empty($gpi_options['cpt_whitelist'])) { 
  343. $cpt_whitelist_arr = unserialize($gpi_options['cpt_whitelist']); 
  344.  
  345. if($cpt_whitelist_arr) { 
  346. ?> 
  347. <optgroup label="<?php _e('Custom Post Types', 'gpagespeedi'); ?>"> 
  348. <option <?php if($report_filter == 'gpi_custom_posts') { echo 'selected="selected"'; } ?> value="gpi_custom_posts"><?php _e('All Custom Post Types', 'gpagespeedi'); ?></option> 
  349. <?php 
  350. $check_filter = str_replace('gpi_custom_posts-', '', $report_filter); 
  351. foreach($subfilters['custom_posts'] as $filter) 
  352. if(in_array($filter, $cpt_whitelist_arr)) { 
  353. ?> 
  354. <option <?php if($check_filter == $filter) { echo 'selected="selected"'; } ?> value='gpi_custom_posts-<?php echo $filter; ?>'><?php echo $filter; ?></option> 
  355. <?php 
  356. ?> 
  357. </optgroup> 
  358. <?php 
  359. } ?> 
  360. </select> 
  361. <?php } ?> 
  362. <?php if( isset( $_GET['render'] ) && $_GET['render'] != "summary") { ?> 
  363. <select name="post-per-page" id="post-per-page"> 
  364. <option value="25" <?php if($post_per_page == 25) {echo 'selected="selected"';} ?>><?php _e('25 Results/Page', 'gpagespeedi'); ?></option> 
  365. <option value="50" <?php if($post_per_page == 50) {echo 'selected="selected"';} ?>><?php _e('50 Results/Page', 'gpagespeedi'); ?></option> 
  366. <option value="100" <?php if($post_per_page == 100) {echo 'selected="selected"';} ?>><?php _e('100 Results/Page', 'gpagespeedi'); ?></option> 
  367. <option value="500" <?php if($post_per_page == 500) {echo 'selected="selected"';} ?>><?php _e('500 Results/Page', 'gpagespeedi'); ?></option> 
  368. <option value="1000" <?php if($post_per_page == 1000) {echo 'selected="selected"';} ?>><?php _e('1000 Results/Page', 'gpagespeedi'); ?></option> 
  369. </select> 
  370. <?php } ?> 
  371. <?php 
  372. submit_button( __( 'Filter', 'gpagespeedi' ), 'button', false, false, array( 'id' => 'post-query-submit' ) ); 
  373. ?> 
  374. </div> 
  375. <?php 
  376.  
  377. // Prepare our data for display - Active items 
  378. function prepare_items($ignored_query = false, $type = '', $per_page = 25) { 
  379. global $wpdb; //This is used only if making any database queries 
  380.  
  381. // Get options 
  382. $gpi_options = $this->getOptions(); 
  383.  
  384. // Setup Columns 
  385. $columns = $this->gpi_get_columns($ignored_query, $gpi_options['strategy']); 
  386. $hidden = array(); 
  387. $sortable = $this->get_sortable_columns($ignored_query); 
  388. $this->_column_headers = array($columns, $hidden, $sortable);  
  389.  
  390. // Figure out which page types we are checking (set in options) 
  391. $typestocheck = $this->getTypesToCheck($type); 
  392.  
  393. // Not Null check for Report List scores 
  394. switch($gpi_options['strategy']) { 
  395.  
  396. case 'both': 
  397. $nullcheck = 'desktop_score IS NOT NULL AND mobile_score IS NOT NULL'; 
  398. break; 
  399.  
  400. case 'mobile': 
  401. $nullcheck = 'mobile_score IS NOT NULL'; 
  402. break; 
  403.  
  404. case 'desktop': 
  405. $nullcheck = 'desktop_score IS NOT NULL'; 
  406. break; 
  407.  
  408.  
  409. // Get our Data 
  410. if(!is_null($typestocheck) && !$ignored_query) { 
  411. $gpi_page_stats = $wpdb->prefix . 'gpi_page_stats'; 
  412. if(isset($_GET['orderby'])) $orderby = $_GET['orderby']; 
  413. if(isset($_GET['order'])) $order = $_GET['order']; 
  414.  
  415. if(isset($orderby)) { 
  416.  
  417. $data = $wpdb->get_results( 
  418. $wpdb->prepare( 
  419. "SELECT ID, URL, desktop_score, mobile_score, desktop_last_modified, mobile_last_modified, type 
  420. FROM $gpi_page_stats 
  421. WHERE ($typestocheck[0]) 
  422. AND $nullcheck 
  423. ORDER BY $orderby $order",  
  424. $typestocheck[1] 
  425. ),  
  426. ARRAY_A  
  427. ); 
  428.  
  429. } else { 
  430.  
  431. $data = $wpdb->get_results( 
  432. $wpdb->prepare( 
  433. "SELECT ID, URL, desktop_score, mobile_score, desktop_last_modified, mobile_last_modified, type 
  434. FROM $gpi_page_stats 
  435. WHERE ($typestocheck[0]) 
  436. AND $nullcheck",  
  437. $typestocheck[1] 
  438. ),  
  439. ARRAY_A  
  440. ); 
  441.  
  442.  
  443. } elseif($ignored_query) { 
  444. $gpi_page_blacklist = $wpdb->prefix . 'gpi_page_blacklist'; 
  445. if(isset($_GET['orderby'])) $orderby = $_GET['orderby']; 
  446. if(isset($_GET['order'])) $order = $_GET['order']; 
  447. if(isset($orderby)) { 
  448.  
  449. $data = $wpdb->get_results(  
  450. "SELECT ID, URL, type 
  451. FROM $gpi_page_blacklist 
  452. ORDER BY $orderby $order",  
  453. ARRAY_A  
  454. ); 
  455.  
  456. } else { 
  457.  
  458. $data = $wpdb->get_results( 
  459. "SELECT ID, URL, type 
  460. FROM $gpi_page_blacklist 
  461. ORDER BY ID DESC",  
  462. ARRAY_A 
  463. ); 
  464.  
  465.  
  466. } else { 
  467. $data = array(); 
  468.  
  469. // Figure out which page of results we are on 
  470. $current_page = $this->get_pagenum(); 
  471.  
  472. // Total number of results 
  473. $total_items = count($data); 
  474.  
  475. // Slice up our data for Pagination 
  476. $data = array_slice($data, (($current_page-1)*$per_page), $per_page); 
  477.  
  478. // Return sorted data to be used 
  479. $this->items = $data; 
  480.  
  481. // Register pagination 
  482. $this->set_pagination_args( array( 
  483. 'total_items' => $total_items,  
  484. 'per_page' => $per_page,  
  485. 'total_pages' => ceil($total_items/$per_page) 
  486. ) ); 
  487.