gglstmp_info_site

The Google Sitemap by BestWebSoft gglstmp info site function.

Description

gglstmp_info_site( $webmasters, $site_verification ); 

Parameters (2)

0. $webmasters
The webmasters.
1. $site_verification
The site verification.

Usage

  1. if ( !function_exists( 'gglstmp_info_site' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-sitemap-by-bestwebsoft/google-sitemap-plugin.php'; 
  3.  
  4. // The webmasters. 
  5. $webmasters = null; 
  6.  
  7. // The site verification. 
  8. $site_verification = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = gglstmp_info_site($webmasters, $site_verification); 
  12.  

Defined (1)

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

/google-sitemap-plugin.php  
  1. function gglstmp_info_site( $webmasters, $site_verification ) { 
  2. global $gglstmp_options; 
  3.  
  4. $instruction_url = 'https://docs.google.com/document/d/1VOJx_OaasVskCqi9fsAbUmxfsckoagPU5Py97yjha9w/'; 
  5. $home_url = home_url( '/' ); 
  6. $wmt_sites_array = $wmt_sitemaps_arr = array(); 
  7.  
  8. $return = '<table id="gglstmp_manage_table"><tr><th>' . __( 'Website', 'google-sitemap-plugin' ) . '</th> 
  9. <td><a href="' . $home_url . '" target="_blank">' . $home_url . '</a></td></tr>'; 
  10.  
  11. try { 
  12. $wmt_sites = $webmasters->sites->listSites()->getSiteEntry(); 
  13.  
  14. foreach ( $wmt_sites as $site ) { 
  15. $wmt_sites_array[ $site->siteUrl ] = $site->permissionLevel; 
  16.  
  17. if ( ! array_key_exists( $home_url, $wmt_sites_array ) ) { 
  18. $return .= '<tr><th>' . __( 'Status', 'google-sitemap-plugin' ) . '</th> 
  19. <td>' . __( 'Not added', 'google-sitemap-plugin' ) . '</td></tr>'; 
  20. } else { 
  21.  
  22. $return .= '<tr><th>' . __( 'Status', 'google-sitemap-plugin' ) . '</th> 
  23. <td class="gglstmp_success">' . __( 'Added', 'google-sitemap-plugin' ) . '</td></tr>'; 
  24.  
  25. $return .= '<tr><th>' . __( 'Verification Status', 'google-sitemap-plugin' ) . '</th>'; 
  26. if ( $wmt_sites_array[ $home_url ] == 'siteOwner' ) 
  27. $return .= '<td>' . __( 'Verified', 'google-sitemap-plugin' ) . '</td></tr>'; 
  28. else 
  29. $return .= '<td>' . __( 'Not verified', 'google-sitemap-plugin' ) . '</td></tr>'; 
  30.  
  31. $webmasters_sitemaps = $webmasters->sitemaps->listSitemaps( $home_url )->getSitemap(); 
  32.  
  33. foreach ( $webmasters_sitemaps as $sitemap ) { 
  34. $wmt_sitemaps_arr[ $sitemap->path ] = ( $sitemap->errors > 0 || $sitemap->warnings > 0 ) ? true : false; 
  35.  
  36. $return .= '<tr><th>' . __( 'Sitemap Status', 'google-sitemap-plugin' ) . '</th>'; 
  37.  
  38. if ( isset( $gglstmp_options['sitemap']['loc'] ) ) { 
  39. $url_sitemap = $gglstmp_options['sitemap']['loc']; 
  40. if ( ! array_key_exists( $url_sitemap, $wmt_sitemaps_arr ) ) { 
  41. $return .= '<td>' . __( 'Not added', 'google-sitemap-plugin' ) . '</td></tr>'; 
  42. } else {  
  43. if ( ! $wmt_sitemaps_arr[ $url_sitemap ] ) { 
  44. $return .= '<td class="gglstmp_success">' . __( 'Added', 'google-sitemap-plugin' ) . '</td></tr>'; 
  45. } else { 
  46. $return .= '<td>' . __( 'Added with errors.', 'google-sitemap-plugin' ) . '<a href="https://www.google.com/webmasters/tools/sitemap-details?hl=en&siteUrl=' . urlencode( $home_url ) . '&sitemapUrl=' . urlencode( $url_sitemap ) . '#ISSUE_FILTER=-1">' . __( 'View errors in Google Webmaster Tools', 'google-sitemap-plugin' ) . '</a></td></tr>'; 
  47. $return .= '<tr><th>' . __( 'Sitemap URL', 'google-sitemap-plugin' ) . '</th> 
  48. <td><a href="' . $url_sitemap . '" target="_blank">' . $url_sitemap . '</a></td></tr>'; 
  49. } else { 
  50. $return .= '<td><strong>' . __( 'Error', 'google-sitemap-plugin' ) . ':</strong> ' . __( 'Please check the sitemap file manually.', 'google-sitemap-plugin' ) . ' <a target="_blank" href="' . $instruction_url . '">' . __( 'Learn More', 'google-sitemap-plugin' ) . '</a></td></tr>'; 
  51. } catch ( Google_Service_Exception $e ) { 
  52. $error = $e->getErrors(); 
  53. $sv_error = isset( $error[0]['message'] ) ? $error[0]['message'] : __( 'Unexpectederror, 'google-sitemap-plugin' ); 
  54. } catch ( Google_IO_Exception $e ) { 
  55. $sv_error = $e->getMessage(); 
  56. } catch ( Google_Auth_Exception $e ) { 
  57. $sv_error = true; 
  58. } catch ( Exception $e ) { 
  59. $sv_error = $e->getMessage(); 
  60.  
  61. if ( ! empty( $sv_error ) ) { 
  62. if ( $sv_error !== true ) { 
  63. $return .= '<tr><th></th><td><strong>' . __( 'Error', 'google-sitemap-plugin' ) . ':</strong> ' . $sv_error . '</td></tr>'; 
  64. $return .= '<tr><th></th><td>' . __( "Manual verification required.", 'google-sitemap-plugin' ) . ' <a target="_blank" href="' . $instruction_url . '">' . __( 'Learn More', 'google-sitemap-plugin' ) . '</a></td></tr>'; 
  65. $return .= '</table>'; 
  66. return $return;