/wp-content/plugins/wordpress-seo/admin/google_search_console/views/gsc-display.php

https://bitbucket.org/carloskikea/helpet · PHP · 149 lines · 106 code · 26 blank · 17 comment · 13 complexity · 5e752f4be779af3fd28ee0c1d3822980 MD5 · raw file

  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Google_Search_Console
  6. */
  7. // Admin header.
  8. Yoast_Form::get_instance()->admin_header( false, 'wpseo-gsc', false, 'yoast_wpseo_gsc_options' );
  9. $platform_tabs = new WPSEO_GSC_Platform_Tabs();
  10. if ( defined( 'WP_DEBUG' ) && WP_DEBUG && WPSEO_GSC_Settings::get_profile() !== '' ) { ?>
  11. <form action="" method="post" class="wpseo-gsc-reload-crawl-issues-form">
  12. <input type='hidden' name='reload-crawl-issues-nonce' value='<?php echo esc_attr( wp_create_nonce( 'reload-crawl-issues' ) ); ?>' />
  13. <input type="submit" name="reload-crawl-issues" id="reload-crawl-issue" class="button button-primary alignright"
  14. value="<?php esc_attr_e( 'Reload crawl issues', 'wordpress-seo' ); ?>">
  15. </form>
  16. <?php } ?>
  17. <h2 class="nav-tab-wrapper" id="wpseo-tabs">
  18. <?php echo $platform_tabs; ?>
  19. </h2>
  20. <?php
  21. // Video explains about the options when connected only.
  22. if ( null !== $this->service->get_client()->getAccessToken() ) {
  23. $video_url = WPSEO_Shortlinker::get( 'https://yoa.st/screencast-search-console' );
  24. }
  25. else {
  26. $video_url = WPSEO_Shortlinker::get( 'https://yoa.st/screencast-connect-search-console' );
  27. }
  28. $tab = new WPSEO_Option_Tab( 'GSC', __( 'Google Search Console', 'wordpress-seo' ), array( 'video_url' => $video_url ) );
  29. $gsc_help_center = new WPSEO_Help_Center( 'google-search-console', $tab, WPSEO_Utils::is_yoast_seo_premium() );
  30. $gsc_help_center->localize_data();
  31. $gsc_help_center->mount();
  32. switch ( $platform_tabs->current_tab() ) {
  33. case 'settings':
  34. // Check if there is an access token.
  35. if ( null === $this->service->get_client()->getAccessToken() ) {
  36. // Print auth screen.
  37. echo '<p>';
  38. printf(
  39. /* Translators: %1$s: expands to Yoast SEO, %2$s expands to Google Search Console. */
  40. esc_html__( 'To allow %1$s to fetch your %2$s information, please enter your Google Authorization Code. Clicking the button below will open a new window.', 'wordpress-seo' ),
  41. 'Yoast SEO',
  42. 'Google Search Console'
  43. );
  44. echo "</p>\n";
  45. echo '<input type="hidden" id="gsc_auth_url" value="', esc_url( $this->service->get_client()->createAuthUrl() ) , '" />';
  46. echo "<button type='button' id='gsc_auth_code' class='button'>" , esc_html__( 'Get Google Authorization Code', 'wordpress-seo' ) ,"</button>\n";
  47. echo '<p id="gsc-enter-code-label">' . esc_html__( 'Enter your Google Authorization Code and press the Authenticate button.', 'wordpress-seo' ) . "</p>\n";
  48. echo "<form action='" . esc_url( admin_url( 'admin.php?page=wpseo_search_console&tab=settings' ) ) . "' method='post'>\n";
  49. echo "<input type='text' name='gsc[authorization_code]' value='' class='textinput' aria-labelledby='gsc-enter-code-label' />";
  50. echo "<input type='hidden' name='gsc[gsc_nonce]' value='" . esc_attr( wp_create_nonce( 'wpseo-gsc_nonce' ) ) . "' />";
  51. echo "<input type='submit' name='gsc[Submit]' value='" . esc_attr__( 'Authenticate', 'wordpress-seo' ) . "' class='button button-primary' />";
  52. echo "</form>\n";
  53. }
  54. else {
  55. $reset_button = '<a class="button" href="' . esc_url( add_query_arg( 'gsc_reset', 1 ) ) . '">' . esc_html__( 'Reauthenticate with Google ', 'wordpress-seo' ) . '</a>';
  56. echo '<h3>', esc_html__( 'Current profile', 'wordpress-seo' ), '</h3>';
  57. $profile = WPSEO_GSC_Settings::get_profile();
  58. if ( $profile !== '' ) {
  59. echo '<p>';
  60. echo $profile;
  61. echo '</p>';
  62. echo '<p>';
  63. echo $reset_button;
  64. echo '</p>';
  65. }
  66. else {
  67. echo "<form action='" . esc_url( admin_url( 'options.php' ) ) . "' method='post'>";
  68. settings_fields( 'yoast_wpseo_gsc_options' );
  69. Yoast_Form::get_instance()->set_option( 'wpseo-gsc' );
  70. echo '<p>';
  71. $profiles = $this->service->get_sites();
  72. if ( ! empty( $profiles ) ) {
  73. $show_save = true;
  74. echo Yoast_Form::get_instance()->select( 'profile', __( 'Profile', 'wordpress-seo' ), $profiles );
  75. }
  76. else {
  77. $show_save = false;
  78. esc_html_e( 'There were no profiles found', 'wordpress-seo' );
  79. }
  80. echo '</p>';
  81. echo '<p>';
  82. if ( $show_save ) {
  83. echo '<input type="submit" name="submit" id="submit" class="button button-primary wpseo-gsc-save-profile" value="' . esc_attr__( 'Save Profile', 'wordpress-seo' ) . '" /> ' . __( 'or', 'wordpress-seo' ) , ' ';
  84. }
  85. echo $reset_button;
  86. echo '</p>';
  87. echo '</form>';
  88. }
  89. }
  90. break;
  91. default:
  92. $form_action_url = add_query_arg( 'page', esc_attr( filter_input( INPUT_GET, 'page' ) ) );
  93. get_current_screen()->set_screen_reader_content( array(
  94. // There are no views links in this screen, so no need for the views heading.
  95. 'heading_views' => null,
  96. 'heading_pagination' => __( 'Crawl issues list navigation', 'wordpress-seo' ),
  97. 'heading_list' => __( 'Crawl issues list', 'wordpress-seo' ),
  98. ) );
  99. // Open <form>.
  100. echo "<form id='wpseo-crawl-issues-table-form' action='" . esc_url( $form_action_url ) . "' method='post'>\n";
  101. // AJAX nonce.
  102. echo "<input type='hidden' class='wpseo-gsc-ajax-security' value='" . esc_attr( wp_create_nonce( 'wpseo-gsc-ajax-security' ) ) . "' />\n";
  103. $this->display_table();
  104. // Close <form>.
  105. echo "</form>\n";
  106. break;
  107. }
  108. ?>
  109. <?php
  110. // Add link to Knowledge Base article about crawl issues.
  111. echo '<p>';
  112. printf(
  113. /* translators: %1$s expands anchor to knowledge base article, %2$s expands to </a> */
  114. esc_html__( 'Please refer to %1$sour article about how to connect your website to Google Search Console%2$s if you need assistance.', 'wordpress-seo' ),
  115. '<a href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/1zy' ) ) . '" target="_blank" rel="noopener noreferrer">',
  116. '</a>'
  117. );
  118. echo '</p>';
  119. ?>
  120. <br class="clear" />
  121. <?php
  122. // Admin footer.
  123. Yoast_Form::get_instance()->admin_footer( false );