*/ namespace RankMath\Wizard; use RankMath\KB; use RankMath\Helper; defined( 'ABSPATH' ) || exit; /** * Step class. */ class Search_Console implements Wizard_Step { /** * Render step body. * * @param object $wizard Wizard class instance. * * @return void */ public function render( $wizard ) { ?>

' . esc_html__( 'Read more about it here.', 'rank-math' ) . '' ); ?>

cmb->show_form(); ?> cmb->add_field([ 'id' => 'search-console', 'type' => 'switch', 'name' => esc_html__( 'Search Console', 'rank-math' ), 'desc' => esc_html__( 'Connect Rank Math with Google Search Console to see the most important information from Google directly in your WordPress dashboard.', 'rank-math' ), 'default' => 'off', ]); $dep = [ [ 'search-console', 'on' ] ]; } $wizard->cmb->add_field([ 'id' => 'rank_math_sc_step2', 'type' => 'raw', /* translators: count */ 'content' => '
', ]); $wizard->cmb->add_field([ 'id' => 'console_authorization_code', 'type' => 'text', 'name' => esc_html__( 'Search Console', 'rank-math' ), 'desc' => esc_html__( 'Authorize Rank Math to access data from the Google Search Console.', 'rank-math' ), 'attributes' => [ 'data-authorized' => $data['authorized'] ? 'true' : 'false' ], 'after' => $this->get_buttons(), 'dep' => $dep, ]); $profile = Helper::get_settings( 'general.console_profile' ); $profile_label = str_replace( 'sc-domain:', __( 'Domain Property: ', 'rank-math' ), $profile ); foreach ( $data['profiles'] as $key => $value ) { $data['profiles'][ $key ] = str_replace( 'sc-domain:', __( 'Domain Property: ', 'rank-math' ), $value ); } $wizard->cmb->add_field([ 'id' => 'console_profile', 'type' => 'select', 'name' => esc_html__( 'Search Console Profile', 'rank-math' ), 'desc' => esc_html__( 'After authenticating with Google Search Console, select your website from the dropdown list.', 'rank-math' ) . ' ' . /* translators: Link to setting screen */ '

' . sprintf( __( 'Is your site not listed? Click here to get your website verified.', 'rank-math' ), Helper::get_admin_url( 'options-general#setting-panel-webmaster' ) ) . '', 'options' => $profile ? [ $profile => $profile_label ] : $data['profiles'], 'default' => $profile, 'after' => '', 'attributes' => $data['authorized'] ? [ 'data-s2' => '' ] : [ 'disabled' => 'disabled', 'data-s2' => '', ], 'dep' => $dep, ]); } /** * Save handler for step. * * @param array $values Values to save. * @param object $wizard Wizard class instance. * * @return bool */ public function save( $values, $wizard ) { $module = 'off'; $settings = rank_math()->settings->all_raw(); if ( isset( $values['console_profile'] ) ) { $module = 'on'; $settings['general']['console_profile'] = $values['console_profile']; } Helper::update_modules( [ 'search-console' => $module ] ); Helper::update_all_settings( $settings['general'], null, null ); return true; } /** * Get buttons html. * * @return string */ private function get_buttons() { $data = Helper::search_console_data(); $primary = ''; $secondary = '
'; return $primary . $secondary; } }