field-bulk-edit.php
8 months ago
field-meta-box-news.php
7 months ago
field-meta-box.php
6 months ago
field-news-categories.php
7 months ago
field-news-hierarchical.php
6 months ago
field-news-keywords.php
6 months ago
field-news-name.php
9 months ago
field-news-notifier.php
5 months ago
field-news-post-type.php
8 months ago
field-news-stocktickers.php
6 months ago
field-quick-edit.php
11 months ago
field-robots.php
11 months ago
field-sitemap-author-settings.php
6 months ago
field-sitemap-authors.php
7 months ago
field-sitemap-custom.php
11 months ago
field-sitemap-disable.php
11 months ago
field-sitemap-notifier.php
2 months ago
field-sitemap-post-type-settings.php
2 months ago
field-sitemap-post-types-limit.php
11 months ago
field-sitemap-post-types.php
7 months ago
field-sitemap-server.php
6 months ago
field-sitemap-slug.php
8 months ago
field-sitemap-taxonomies.php
7 months ago
field-sitemap-taxonomy-settings.php
6 months ago
field-sitemap-urls.php
11 months ago
field-sitemaps.php
11 months ago
help-tab-advanced.php
6 months ago
help-tab-authors.php
6 months ago
help-tab-news-categories.php
11 months ago
help-tab-news-hierarchical.php
8 months ago
help-tab-news-keywords.php
11 months ago
help-tab-news-name.php
11 months ago
help-tab-news-notifier.php
6 months ago
help-tab-news-post-types.php
11 months ago
help-tab-news-sidebar.php
11 months ago
help-tab-news-stocktickers.php
11 months ago
help-tab-news.php
11 months ago
help-tab-post-types-general.php
11 months ago
help-tab-post-types.php
6 months ago
help-tab-robots.php
11 months ago
help-tab-sidebar.php
11 months ago
help-tab-sitemaps.php
11 months ago
help-tab-support.php
6 months ago
help-tab-taxonomies.php
6 months ago
notice-xmlsf-advanced-news.php
11 months ago
notice-xmlsf-advanced.php
11 months ago
page-sitemap-news.php
6 months ago
page-sitemap.php
7 months ago
section-advanced-compat-message.php
9 months ago
section-advanced-intro.php
11 months ago
section-advanced-news-compat-message.php
9 months ago
section-bwt-data.php
2 months ago
section-bwt-oauth-intro.php
6 months ago
section-bwt-oauth-stage-1.php
6 months ago
section-bwt-oauth-stage-2.php
6 months ago
section-gsc-data-news.php
3 months ago
section-gsc-data.php
2 months ago
section-gsc-oauth-intro.php
6 months ago
section-gsc-oauth-stage-1-2.php
2 months ago
section-gsc-oauth-stage-3.php
6 months ago
section-ping-log.php
3 months ago
sidebar-advanced-plug.php
2 months ago
sidebar-bwt-connect.php
6 months ago
sidebar-contribute.php
9 months ago
sidebar-gsc-connect.php
6 months ago
sidebar-help.php
6 months ago
sidebar-links.php
6 months ago
sidebar-news-advanced-plug.php
6 months ago
sidebar-news-links.php
6 months ago
sidebar-news-tools.php
7 months ago
sidebar-priority-support.php
7 months ago
sidebar-tools.php
7 months ago
section-gsc-data.php
115 lines
| 1 | <?php |
| 2 | /** |
| 3 | * GSC data section |
| 4 | * |
| 5 | * @package XML Sitemap & Google News |
| 6 | */ |
| 7 | |
| 8 | if ( ! \XMLSF\GSC_Connect::is_connected() ) { |
| 9 | // Initiate button. |
| 10 | ?> |
| 11 | <p> |
| 12 | <?php printf( /* translators: %s: Google Search Console */ esc_html_x( 'Connect to %s for sitemap data retrieval and sitemap submissions.', 'Google Search Console connection', 'xml-sitemap-feed' ), esc_html__( 'Google Search Console', 'xml-sitemap-feed' ) ); ?> |
| 13 | </p> |
| 14 | <p> |
| 15 | <a href="<?php echo esc_url( add_query_arg( 'ref', 'xmlsf', \XMLSF\Admin\GSC_Connect::get_settings_url() ) ); ?>" class="button button-small"> |
| 16 | <?php esc_html_e( 'Connect', 'xml-sitemap-feed' ); ?> |
| 17 | </a> |
| 18 | </p> |
| 19 | <?php |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | // Get connect data. |
| 24 | $sitemap = xmlsf()->sitemap->get_sitemap_url(); |
| 25 | $parsed_url = parse_url( $sitemap ); |
| 26 | $path = $parsed_url['path']; |
| 27 | $data = \XMLSF\GSC_Connect::get( $sitemap ); |
| 28 | |
| 29 | ?> |
| 30 | <p><?php esc_html_e( 'Your sitemap data as reported by Google Search Console.', 'xml-sitemap-feed' ); ?></p> |
| 31 | <?php |
| 32 | if ( \is_wp_error( $data ) ) { |
| 33 | $error_message = $data->get_error_message(); |
| 34 | |
| 35 | // Display error message. |
| 36 | ?> |
| 37 | <p style="color:#d63638"> |
| 38 | <?php esc_html_e( 'There was an error requesting sitemap data from Google Search Console.', 'xml-sitemap-feed' ); ?> |
| 39 | <br> |
| 40 | <?php |
| 41 | if ( str_contains( $error_message, 'is not a submitted or a known sitemap' ) ) { |
| 42 | printf( /* translators: %s: Google Search Console */ esc_html__( 'Your sitemap was not found on %s. Maybe submit it first?', 'xml-sitemap-feed' ), esc_html__( 'Google Search Console', 'xml-sitemap-feed' ) ); |
| 43 | } else { |
| 44 | echo esc_html( $data->get_error_message() ); |
| 45 | } |
| 46 | ?> |
| 47 | </p> |
| 48 | <p> |
| 49 | <a href="" class="button button-small"><?php echo esc_html( translate( 'Retry' ) ); // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction ?></a> |
| 50 | </p> |
| 51 | <?php |
| 52 | |
| 53 | return; |
| 54 | } |
| 55 | |
| 56 | $format = get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ); |
| 57 | $last_submitted = isset( $data['lastSubmitted'] ) ? wp_date( $format, strtotime( $data['lastSubmitted'] ) ) : __( 'Unknown', 'xml-sitemap-feed' ); |
| 58 | $is_pending = isset( $data['isPending'] ) ? $data['isPending'] : false; |
| 59 | $last_downloaded = isset( $data['lastDownloaded'] ) ? wp_date( $format, strtotime( $data['lastDownloaded'] ) ) : __( 'Unknown', 'xml-sitemap-feed' ); |
| 60 | $_warnings = isset( $data['warnings'] ) ? $data['warnings'] : 0; |
| 61 | $_errors = isset( $data['errors'] ) ? $data['errors'] : 0; |
| 62 | $property = \XMLSF\Admin\GSC_Connect::get_property_url(); |
| 63 | $gsc_link = add_query_arg( |
| 64 | array( |
| 65 | 'resource_id' => rawurlencode( $property ), |
| 66 | 'sitemap_index' => rawurlencode( $data['path'] ), |
| 67 | ), |
| 68 | 'https://search.google.com/search-console/sitemaps/sitemap-index-drilldown' |
| 69 | ); |
| 70 | $links_submitted = 0; |
| 71 | $links_indexed = 0; |
| 72 | if ( isset( $data['contents'] ) && is_array( $data['contents'] ) ) { |
| 73 | foreach ( $data['contents'] as $content ) { |
| 74 | if ( isset( $content['type'] ) && 'web' === $content['type'] ) { |
| 75 | $links_submitted = $content['submitted']; |
| 76 | $links_indexed = $content['indexed']; |
| 77 | break; |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | ?> |
| 83 | <table class="widefat"> |
| 84 | <thead> |
| 85 | <tr> |
| 86 | <th><?php esc_html_e( 'XML Sitemap Index', 'xml-sitemap-feed' ); ?></th> |
| 87 | <th><?php esc_html_e( 'Status', 'xml-sitemap-feed' ); ?></th> |
| 88 | <th><?php esc_html_e( 'Last submitted', 'xml-sitemap-feed' ); ?></th> |
| 89 | <th><?php esc_html_e( 'Last crawled', 'xml-sitemap-feedcomplet' ); ?></th> |
| 90 | <th><?php esc_html_e( 'URLs', 'xml-sitemap-feed' ); ?></th> |
| 91 | <th><?php esc_html_e( 'Issues', 'xml-sitemap-feed' ); ?></th> |
| 92 | </tr> |
| 93 | </thead> |
| 94 | <tbody> |
| 95 | <tr> |
| 96 | <th> |
| 97 | <a href="<?php echo esc_url( $gsc_link ); ?>" target="_blank" title="<?php esc_html_e( 'View this sitemap in Google Search Console', 'xml-sitemap-feed' ); ?>"> |
| 98 | <?php echo esc_html( $parsed_url['path'] ); ?> |
| 99 | <span class="dashicons dashicons-external"></span> |
| 100 | </a> |
| 101 | </th> |
| 102 | <td><?php if ( $is_pending ) : ?> |
| 103 | <span class="dashicons dashicons-clock" style="color:#dba617" title="<?php esc_html_e( 'Pending', 'xml-sitemap-feed' ); ?>"></span> |
| 104 | <?php else : ?> |
| 105 | <span class="dashicons dashicons-yes-alt" style="color:#00a32a" title="<?php esc_html_e( 'Processed', 'xml-sitemap-feed' ); ?>"></span> |
| 106 | <?php endif; ?> |
| 107 | </td> |
| 108 | <td><?php echo esc_html( $last_submitted ); ?></td> |
| 109 | <td><?php echo esc_html( $last_downloaded ); ?></td> |
| 110 | <td><?php echo esc_html__( 'Found:', 'xml-sitemap-feed' ) . ' ' . esc_html( $links_submitted ) . '<br>' . esc_html__( 'Indexed:', 'xml-sitemap-feed' ) . ' ' . esc_html( $links_indexed ); ?></td> |
| 111 | <td style="color:<?php echo $_errors ? '#d63638' : ( $_warnings ? '#dba617' : 'inherit' ); ?>"><?php echo esc_html__( 'Warnings:', 'xml-sitemap-feed' ) . ' ' . esc_html( $_warnings ) . '<br>' . esc_html__( 'Errors:', 'xml-sitemap-feed' ) . ' ' . esc_html( $_errors ); ?></td> |
| 112 | </tr> |
| 113 | </tbody> |
| 114 | </table> |
| 115 |