PageRenderTime 22ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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