gpi_action_recheck_page

The WordPress Core gpi action recheck page function.

Description

gpi_action_recheck_page( $page_id, $page_report ); 

Parameters (2)

0. $page_id
The page id.
1. $page_report
The page report.

Usage

  1. if ( !function_exists( 'gpi_action_recheck_page' ) ) { 
  2. require_once '/includes/actions/recheck.php'; 
  3.  
  4. // The page id. 
  5. $page_id = null; 
  6.  
  7. // The page report. 
  8. $page_report = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = gpi_action_recheck_page($page_id, $page_report); 
  12.  

Defined (1)

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

/includes/actions/recheck.php  
  1. function gpi_action_recheck_page($page_id, $page_report) { 
  2.  
  3. global $wpdb; 
  4. $gpi_page_stats = $wpdb->prefix . 'gpi_page_stats'; 
  5.  
  6. if(is_array($page_report) && !empty($page_report)) { 
  7.  
  8. // Build our where clauses for selecting URLs 
  9. $page_report_count = count($page_report); 
  10. $x = 1; 
  11. $where_clause = ''; 
  12. foreach($page_report as $page) 
  13. if($x < $page_report_count) { 
  14. $where_clause .= 'ID = ' . $page . ' OR '; 
  15. } else { 
  16. $where_clause .= 'ID = ' . $page; 
  17. $x++; 
  18.  
  19. // Set Force Recheck to 1 on selected URLs 
  20. $wpdb->query(" 
  21. UPDATE $gpi_page_stats SET force_recheck = 1 
  22. WHERE $where_clause 
  23. "); 
  24.  
  25. // Schedule the api to check pages immediately 
  26. $GPI_ListTable = new GPI_List_Table(); 
  27. $gpi_options = $GPI_ListTable->getOptions(); 
  28.  
  29. require_once GPI_DIRECTORY . '/core/core.php'; 
  30. $googlePagespeedInsights = new googlePagespeedInsights($gpi_options); 
  31.  
  32. $googlePagespeedInsights->google_pagespeed_insights_Update_Options('last_run_finished', false, 'gpagespeedi_options'); 
  33. wp_schedule_event( time(), 'gpi_lastrun_checker', 'googlepagespeedinsightschecker' ); 
  34.  
  35. $return_message = $page_report_count; 
  36.  
  37. } elseif(!empty($page_id)) { 
  38.  
  39. // Set Force Recheck to 1 on selected URL 
  40. $wpdb->query(" 
  41. UPDATE $gpi_page_stats SET force_recheck = 1 
  42. WHERE ID = $page_id 
  43. "); 
  44.  
  45. // Schedule the api to check pages immediately 
  46. $GPI_ListTable = new GPI_List_Table(); 
  47. $gpi_options = $GPI_ListTable->getOptions(); 
  48.  
  49. require_once GPI_DIRECTORY . '/core/core.php'; 
  50. $googlePagespeedInsights = new googlePagespeedInsights($gpi_options); 
  51.  
  52. $googlePagespeedInsights->google_pagespeed_insights_Update_Options('last_run_finished', false, 'gpagespeedi_options'); 
  53. wp_schedule_event( time(), 'gpi_lastrun_checker', 'googlepagespeedinsightschecker' ); 
  54.  
  55. $return_message = '1'; 
  56.  
  57. return $return_message;