gglstmp_del_site

The Google Sitemap by BestWebSoft gglstmp del site function.

Description

gglstmp_del_site( $webmasters, $site_verification ); 

Parameters (2)

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

Usage

  1. if ( !function_exists( 'gglstmp_del_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_del_site($webmasters, $site_verification); 
  12.  

Defined (1)

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

/google-sitemap-plugin.php  
  1. function gglstmp_del_site( $webmasters, $site_verification ) { 
  2. global $gglstmp_options; 
  3.  
  4. $home_url = home_url('/'); 
  5. $return = '<table id="gglstmp_manage_table"><tr><th>' . __( 'Website', 'google-sitemap-plugin' ) . '</th> 
  6. <td><a href="' . $home_url . '" target="_blank">' . $home_url . '</a></td></tr>'; 
  7.  
  8. try { 
  9. $webmasters_sitemaps = $webmasters->sitemaps->listSitemaps( $home_url )->getSitemap(); 
  10. foreach ( $webmasters_sitemaps as $sitemap ) { 
  11. try { 
  12. $webmasters->sitemaps->delete( $home_url, $sitemap->path ); 
  13. } catch ( Google_Service_Exception $e ) { 
  14. } catch ( Google_IO_Exception $e ) { 
  15. } catch ( Google_Auth_Exception $e ) { 
  16. } catch ( Exception $e ) {} 
  17.  
  18. $webmasters->sites->delete( $home_url ); 
  19.  
  20. $return .= '<tr><th>' . __( 'Status', 'google-sitemap-plugin' ) . '</th> 
  21. <td>' . __( 'Deleted', 'google-sitemap-plugin' ) . '</td></tr>'; 
  22. unset( $gglstmp_options['site_vererification_code'] ); 
  23. update_option( 'gglstmp_options', $gglstmp_options ); 
  24.  
  25. } catch ( Google_Service_Exception $e ) { 
  26. $error = $e->getErrors(); 
  27. $sv_error = isset( $error[0]['message'] ) ? $error[0]['message'] : __( 'Unexpectederror, 'google-sitemap-plugin' ); 
  28. } catch ( Google_IO_Exception $e ) { 
  29. $sv_error = $e->getMessage(); 
  30. } catch ( Google_Auth_Exception $e ) { 
  31. $sv_error = true; 
  32. } catch ( Exception $e ) { 
  33. $sv_error = $e->getMessage(); 
  34. if ( ! empty( $sv_error ) ) { 
  35. $return .= '<tr><th>' . __( 'Status', 'google-sitemap-plugin' ) . '</th> 
  36. <td>' . __( 'Not added', 'google-sitemap-plugin' ) . '</td></tr>'; 
  37. if ( $sv_error !== true ) 
  38. $return .= '<tr><th></th><td><strong>' . __( 'Error', 'google-sitemap-plugin' ) . ':</strong> ' . $sv_error . '</td></tr>'; 
  39. $return .= '</table>'; 
  40. return $return;