WPSEO_GSC_Settings

Class WPSEO_GSC_Settings.

Defined (1)

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

/admin/google_search_console/class-gsc-settings.php  
  1. class WPSEO_GSC_Settings { 
  2.  
  3. /** 
  4. * Clear all data from the database 
  5. * @param WPSEO_GSC_Service $service Service class instance. 
  6. */ 
  7. public static function clear_data( WPSEO_GSC_Service $service ) { 
  8. // Remove issue and issue counts. 
  9. self::remove(); 
  10.  
  11. // Removes the GSC options. 
  12. self::remove_gsc_option(); 
  13.  
  14. // Clear the service data. 
  15. $service->clear_data(); 
  16.  
  17. /** 
  18. * Reloading all the issues 
  19. */ 
  20. public static function reload_issues() { 
  21. // Remove issue and issue counts. 
  22. self::remove(); 
  23.  
  24. /** 
  25. * When authorization is successful return true, otherwise false 
  26. * @param string $authorization_code Code to validate. 
  27. * @param Yoast_Api_Google_Client $client Client object instance. 
  28. * @return bool 
  29. */ 
  30. public static function validate_authorization( $authorization_code, Yoast_Api_Google_Client $client ) { 
  31. return ( $authorization_code !== '' && $client->authenticate_client( $authorization_code ) ); 
  32.  
  33. /** 
  34. * Get the GSC profile 
  35. * @return string 
  36. */ 
  37. public static function get_profile() { 
  38. // Get option. 
  39. $option = get_option( WPSEO_GSC::OPTION_WPSEO_GSC, array( 'profile' => '' ) ); 
  40.  
  41. // Set the profile. 
  42. $profile = ''; 
  43. if ( ! empty( $option['profile'] ) ) { 
  44. $profile = $option['profile']; 
  45.  
  46. // Return the profile. 
  47. return trim( $profile, '/' ); 
  48.  
  49. /** 
  50. * Removes the issue counts and all the issues from the options 
  51. */ 
  52. private static function remove() { 
  53. // Remove the issue counts from the options. 
  54. self::remove_issue_counts(); 
  55.  
  56. // Removing all issues from the database. 
  57. self::remove_issues(); 
  58.  
  59. /** 
  60. * Remove the issue counts 
  61. */ 
  62. private static function remove_issue_counts() { 
  63. // Remove the options which are holding the counts. 
  64. delete_option( WPSEO_GSC_Count::OPTION_CI_COUNTS ); 
  65. delete_option( WPSEO_GSC_Count::OPTION_CI_LAST_FETCH ); 
  66.  
  67. /** 
  68. * Delete the issues and their meta data from the database 
  69. */ 
  70. private static function remove_issues() { 
  71. global $wpdb; 
  72.  
  73. // Remove local crawl issues by running a delete query. 
  74. $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpseo-gsc-issues-%'" ); 
  75.  
  76. /** 
  77. * Removes the options for GSC 
  78. */ 
  79. private static function remove_gsc_option() { 
  80. delete_option( WPSEO_GSC::OPTION_WPSEO_GSC );