Commit inicial - WordPress Análisis de Precios Unitarios

- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,183 @@
<?php
/**
* The Compatibility wizard step.
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Wizard
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Wizard;
use RankMath\Helper;
defined( 'ABSPATH' ) || exit;
/**
* Step class.
*/
class Compatibility implements Wizard_Step {
/**
* Get Localized data to be used in the Compatibility step.
*
* @return array
*/
public static function get_localized_data() {
$php_version = phpversion();
return [
'conflictingPlugins' => self::get_conflicting_plugins(),
'phpVersion' => phpversion(),
'phpVersionOk' => version_compare( $php_version, rank_math()->php_version, '>' ),
'phpVersionRecommended' => version_compare( $php_version, '7.4', '<' ),
'extensions' => [
'dom' => extension_loaded( 'dom' ),
'simpleXml' => extension_loaded( 'SimpleXML' ),
'image' => extension_loaded( 'gd' ) || extension_loaded( 'imagick' ),
'mbString' => extension_loaded( 'mbstring' ),
'openSsl' => extension_loaded( 'openssl' ),
'base64Func' => function_exists( 'base64_encode' ) && function_exists( 'base64_decode' ) && (bool) base64_decode( base64_encode( '1' ) ), // phpcs:ignore -- Verified as safe usage.
],
];
}
/**
* Save handler for step.
*
* @param array $values Values to save.
*
* @return bool
*/
public static function save( $values ) {
$settings = wp_parse_args(
rank_math()->settings->all_raw(),
[ 'general' => '' ]
);
$settings['general']['setup_mode'] = ! empty( $values['setup_mode'] ) ? sanitize_text_field( $values['setup_mode'] ) : 'easy';
if ( 'custom' === $settings['general']['setup_mode'] ) {
// Don't change, use custom imported value.
return true;
}
Helper::update_all_settings( $settings['general'], null, null );
return true;
}
/**
* Get conflicting plugins.
*
* @return array
*/
private static function get_conflicting_plugins() {
$plugins_found = [];
$active_plugins = get_option( 'active_plugins' );
$conflicting_plugins = self::get_conflicting_plugins_list();
foreach ( $conflicting_plugins as $plugin_slug => $plugin_name ) {
if ( in_array( $plugin_slug, $active_plugins, true ) !== false ) {
$plugins_found[ $plugin_slug ] = $plugin_name;
}
}
return $plugins_found;
}
/**
* Return list of conflicting plugins.
*
* @return array List of plugins in path => name format.
*/
private static function get_conflicting_plugins_list() {
$plugins = [
'2-click-socialmedia-buttons/2-click-socialmedia-buttons.php' => '2 Click Social Media Buttons.',
'add-link-to-facebook/add-link-to-facebook.php' => 'Add Link to Facebook.',
'extended-wp-reset/extended-wp-reset.php' => 'Extended WP Reset.',
'add-meta-tags/add-meta-tags.php' => 'Add Meta Tags.',
'all-in-one-seo-pack/all_in_one_seo_pack.php' => 'All In One SEO Pack',
'easy-facebook-share-thumbnails/esft.php' => 'Easy Facebook Share Thumbnail.',
'facebook/facebook.php' => 'Facebook (official plugin).',
'facebook-awd/AWD_facebook.php' => 'Facebook AWD All in one.',
'facebook-featured-image-and-open-graph-meta-tags/fb-featured-image.php' => 'Facebook Featured Image & OG Meta Tags.',
'facebook-meta-tags/facebook-metatags.php' => 'Facebook Meta Tags.',
'wonderm00ns-simple-facebook-open-graph-tags/wonderm00n-open-graph.php' => 'Facebook Open Graph Meta Tags for WordPress.',
'facebook-revised-open-graph-meta-tag/index.php' => 'Facebook Revised Open Graph Meta Tag.',
'facebook-thumb-fixer/_facebook-thumb-fixer.php' => 'Facebook Thumb Fixer.',
'facebook-and-digg-thumbnail-generator/facebook-and-digg-thumbnail-generator.php' => 'Fedmich\'s Facebook Open Graph Meta.',
'network-publisher/networkpub.php' => 'Network Publisher.',
'nextgen-facebook/nextgen-facebook.php' => 'NextGEN Facebook OG.',
'opengraph/opengraph.php' => 'Open Graph.',
'open-graph-protocol-framework/open-graph-protocol-framework.php' => 'Open Graph Protocol Framework.',
'seo-facebook-comments/seofacebook.php' => 'SEO Facebook Comments.',
'seo-ultimate/seo-ultimate.php' => 'SEO Ultimate.',
'sexybookmarks/sexy-bookmarks.php' => 'Shareaholic.',
'shareaholic/sexy-bookmarks.php' => 'Shareaholic.',
'sharepress/sharepress.php' => 'SharePress.',
'simple-facebook-connect/sfc.php' => 'Simple Facebook Connect.',
'social-discussions/social-discussions.php' => 'Social Discussions.',
'social-sharing-toolkit/social_sharing_toolkit.php' => 'Social Sharing Toolkit.',
'socialize/socialize.php' => 'Socialize.',
'only-tweet-like-share-and-google-1/tweet-like-plusone.php' => 'Tweet, Like, Google +1 and Share.',
'wordbooker/wordbooker.php' => 'Wordbooker.',
'wordpress-seo/wp-seo.php' => 'Yoast SEO',
'wordpress-seo-premium/wp-seo-premium.php' => 'Yoast SEO Premium',
'wp-seopress/seopress.php' => 'SEOPress',
'wp-seopress-pro/seopress-pro.php' => 'SEOPress Pro',
'wpsso/wpsso.php' => 'WordPress Social Sharing Optimization.',
'wp-caregiver/wp-caregiver.php' => 'WP Caregiver.',
'wp-facebook-like-send-open-graph-meta/wp-facebook-like-send-open-graph-meta.php' => 'WP Facebook Like Send & Open Graph Meta.',
'wp-facebook-open-graph-protocol/wp-facebook-ogp.php' => 'WP Facebook Open Graph protocol.',
'wp-ogp/wp-ogp.php' => 'WP-OGP.',
'zoltonorg-social-plugin/zosp.php' => 'Zolton.org Social Plugin.',
'all-in-one-schemaorg-rich-snippets/index.php' => 'All In One Schema Rich Snippets.',
'wp-schema-pro/wp-schema-pro.php' => 'Schema Pro',
'no-category-base-wpml/no-category-base-wpml.php' => 'No Category Base (WPML)',
'all-404-redirect-to-homepage/all-404-redirect-to-homepage.php' => 'All 404 Redirect to Homepage',
'remove-category-url/remove-category-url.php' => 'Remove Category URL',
];
$plugins = Helper::is_module_active( 'redirections' ) ? array_merge( $plugins, self::get_redirection_conflicting_plugins() ) : $plugins;
$plugins = Helper::is_module_active( 'sitemap' ) ? array_merge( $plugins, self::get_sitemap_conflicting_plugins() ) : $plugins;
return $plugins;
}
/**
* Redirection: conflicting plugins.
*
* @return array
*/
private static function get_redirection_conflicting_plugins() {
return [
'redirection/redirection.php' => 'Redirection',
];
}
/**
* Sitemap: conflicting plugins.
*
* @return array
*/
private static function get_sitemap_conflicting_plugins() {
return [
'google-sitemap-plugin/google-sitemap-plugin.php' => 'Google Sitemap (BestWebSoft).',
'xml-sitemaps/xml-sitemaps.php' => 'XML Sitemaps (Denis de Bernardy and Mike Koepke).',
'bwp-google-xml-sitemaps/bwp-simple-gxs.php' => 'Better WordPress Google XML Sitemaps (Khang Minh).',
'google-sitemap-generator/sitemap.php' => 'Google XML Sitemaps (Arne Brachhold).',
'xml-sitemap-feed/xml-sitemap.php' => 'XML Sitemap & Google News feeds (RavanH).',
'google-monthly-xml-sitemap/monthly-xml-sitemap.php' => 'Google Monthly XML Sitemap (Andrea Pernici).',
'simple-google-sitemap-xml/simple-google-sitemap-xml.php' => 'Simple Google Sitemap XML (iTx Technologies).',
'another-simple-xml-sitemap/another-simple-xml-sitemap.php' => 'Another Simple XML Sitemap.',
'xml-maps/google-sitemap.php' => 'Xml Sitemap (Jason Martens).',
'google-xml-sitemap-generator-by-anton-dachauer/adachauer-google-xml-sitemap.php' => 'Google XML Sitemap Generator by Anton Dachauer (Anton Dachauer).',
'wp-xml-sitemap/wp-xml-sitemap.php' => 'WP XML Sitemap (Team Vivacity).',
'sitemap-generator-for-webmasters/sitemap.php' => 'Sitemap Generator for Webmasters (iwebslogtech).',
'xml-sitemap-xml-sitemapcouk/xmls.php' => 'XML Sitemap - XML-Sitemap.co.uk (Simon Hancox).',
'sewn-in-xml-sitemap/sewn-xml-sitemap.php' => 'Sewn In XML Sitemap (jcow).',
'rps-sitemap-generator/rps-sitemap-generator.php' => 'RPS Sitemap Generator (redpixelstudios).',
];
}
}

View File

@@ -0,0 +1,96 @@
<?php
/**
* The Import wizard step
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Wizard
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Wizard;
use RankMath\KB;
use RankMath\Admin\Importers\Detector;
defined( 'ABSPATH' ) || exit;
/**
* Step class.
*/
class Import implements Wizard_Step {
/**
* Get Localized data to be used in the Analytics step.
*
* @return array
*/
public static function get_localized_data() {
$detector = new Detector();
$plugins = $detector->detect();
$plugins = self::set_priority( $plugins );
return [
'importablePlugins' => $plugins,
];
}
/**
* Save handler for step.
*
* @param array $values Values to save.
*
* @return bool
*/
public static function save( $values ) {
delete_option( 'rank_math_yoast_block_posts' );
return true;
}
/**
* Set plugins priority.
*
* @param array $plugins Array of detected plugins.
*
* @return array
*/
private static function set_priority( $plugins ) {
$checked = false;
$priority = array_intersect( [ 'seopress', 'yoast', 'yoast-premium', 'aioseo' ], array_keys( $plugins ) );
foreach ( $priority as $slug ) {
if ( ! $checked ) {
$checked = true;
$plugins[ $slug ]['checked'] = true;
continue;
}
$plugins[ $slug ]['checked'] = false;
}
return $plugins;
}
/**
* Get description for choice field.
*
* @param string $slug Plugin slug.
* @param array $plugin Plugin info array.
* @param boolean $is_active Is plugin active.
*
* @return string
*/
private function get_choice_description( $slug, $plugin, $is_active ) {
/* translators: 1 is plugin name */
$desc = 'aio-rich-snippet' === $slug ? esc_html__( 'Import meta data from the %1$s plugin.', 'rank-math' ) : esc_html__( 'Import settings and meta data from the %1$s plugin.', 'rank-math' );
/* translators: 2 is link to Knowledge Base article */
$desc .= ' ' . __( 'The process may take a few minutes if you have a large number of posts or pages <a href="%2$s" target="_blank">Learn more about the import process here.</a>', 'rank-math' );
if ( $is_active ) {
/* translators: 1 is plugin name */
$desc .= '<br>' . __( ' %1$s plugin will be disabled automatically moving forward to avoid conflicts. <strong>It is thus recommended to import the data you need now.</strong>', 'rank-math' );
}
return sprintf( wp_kses_post( $desc ), $plugin['name'], KB::get( 'seo-import', 'SW Import Step' ) );
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* The Monitor Redirection wizard step
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Wizard
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Wizard;
use RankMath\Helper;
defined( 'ABSPATH' ) || exit;
/**
* Step class.
*/
class Monitor_Redirection implements Wizard_Step {
/**
* Get Localized data to be used in the Compatibility step.
*
* @return array
*/
public static function get_localized_data() {
return [
'404-monitor' => Helper::is_module_active( '404-monitor' ),
'redirections' => Helper::is_module_active( 'redirections' ),
];
}
/**
* Save handler for step.
*
* @param array $values Values to save.
*
* @return bool
*/
public static function save( $values ) {
Helper::update_modules(
[
'404-monitor' => $values['404-monitor'] ? 'on' : 'off',
'redirections' => $values['redirections'] ? 'on' : 'off',
]
);
return true;
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* The Optimization wizard step
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Wizard
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Wizard;
use RankMath\Helper;
defined( 'ABSPATH' ) || exit;
/**
* Step class.
*/
class Optimization implements Wizard_Step {
/**
* Get Localized data to be used in the Compatibility step.
*
* @return array
*/
public static function get_localized_data() {
return [
'noindex_empty_taxonomies' => Helper::get_settings( 'titles.noindex_empty_taxonomies' ),
'nofollow_external_links' => Helper::get_settings( 'general.nofollow_external_links' ),
'new_window_external_links' => Helper::get_settings( 'general.new_window_external_links' ),
];
}
/**
* Save handler for step.
*
* @param array $values Values to save.
*
* @return bool
*/
public static function save( $values ) {
$settings = rank_math()->settings->all_raw();
$settings['titles']['noindex_empty_taxonomies'] = $values['noindex_empty_taxonomies'] ? 'on' : 'off';
if ( isset( $values['attachment_redirect_urls'] ) && 'on' === $values['attachment_redirect_urls'] ) {
$settings['general']['attachment_redirect_urls'] = 'on';
$settings['general']['attachment_redirect_default'] = sanitize_url( $values['attachment_redirect_default'] );
}
$settings['general']['nofollow_external_links'] = ! empty( $values['nofollow_external_links'] ) ? 'on' : 'off';
$settings['general']['new_window_external_links'] = $values['new_window_external_links'] ? 'on' : 'off';
Helper::update_all_settings( $settings['general'], $settings['titles'], null );
Helper::schedule_flush_rewrite();
return true;
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* The Ready wizard step
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Wizard
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Wizard;
use RankMath\Helper;
defined( 'ABSPATH' ) || exit;
/**
* Step class.
*/
class Ready implements Wizard_Step {
/**
* Get Localized data to be used in the Compatibility step.
*
* @return array
*/
public static function get_localized_data() {
Helper::is_configured( true );
return [
'scoreImg' => esc_url( rank_math()->plugin_url() . 'assets/admin/img/score-100.png' ),
'dashboardUrl' => Helper::get_dashboard_url(),
'enable_auto_update' => boolval( Helper::get_auto_update_setting() ),
];
}
/**
* Save handler for step.
*
* @param array $values Values to save.
*
* @return bool
*/
public static function save( $values ) {
$value = ! empty( $values['enable_auto_update'] ) ? 'on' : 'off';
Helper::toggle_auto_update_setting( $value );
return true;
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* The Role wizard step
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Wizard
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Wizard;
use RankMath\Helper;
use RankMath\Role_Manager\Capability_Manager;
defined( 'ABSPATH' ) || exit;
/**
* Step class.
*/
class Role implements Wizard_Step {
/**
* Get Localized data to be used in the Compatibility step.
*
* @return array
*/
public static function get_localized_data() {
Helper::is_configured( true );
return array_merge(
Helper::get_roles_capabilities(),
[
'role_manager' => Helper::is_module_active( 'role-manager' ),
'roles' => Helper::get_roles(),
'capabilities' => Capability_Manager::get()->get_capabilities(),
]
);
}
/**
* Save handler for step.
*
* @param array $values Values to save.
*
* @return bool
*/
public static function save( $values ) {
if ( empty( $values ) ) {
return false;
}
Helper::update_modules( [ 'role-manager' => $values['role_manager'] ? 'on' : 'off' ] );
Helper::set_capabilities( $values );
return true;
}
}

View File

@@ -0,0 +1,111 @@
<?php
/**
* The Schema_Markup wizard step
*
* @since 1.0.32
* @package RankMath
* @subpackage RankMath\Wizard
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Wizard;
use RankMath\Helper;
defined( 'ABSPATH' ) || exit;
/**
* Step class.
*/
class Schema_Markup implements Wizard_Step {
/**
* Get Localized data to be used in the Compatibility step.
*
* @return array
*/
public static function get_localized_data() {
return array_merge(
self::get_default_values(),
[
'rich_snippet' => Helper::is_module_active( 'rich-snippet' ),
'accessiblePostTypes' => Helper::get_accessible_post_types(),
'knowledgegraph_type' => Helper::get_settings( 'titles.knowledgegraph_type' ),
'schemaTypes' => Helper::choices_rich_snippet_types( esc_html__( 'None (Click here to set one)', 'rank-math' ) ),
'reviewPosts' => Helper::get_review_posts(),
]
);
}
/**
* Save handler for step.
*
* @param array $values Values to save.
*
* @return bool
*/
public static function save( $values ) {
$settings = rank_math()->settings->all_raw();
Helper::update_modules( [ 'rich-snippet' => $values['rich_snippet'] ? 'on' : 'off' ] );
// Schema.
if ( $values['rich_snippet'] ) {
self::save_rich_snippet( $settings, $values );
}
Helper::update_all_settings( $settings['general'], $settings['titles'], null );
return Helper::get_admin_url();
}
/**
* Save rich snippet values for post type.
*
* @param array $settings Array of setting.
* @param array $values Values to save.
*/
private static function save_rich_snippet( &$settings, $values ) {
foreach ( Helper::get_accessible_post_types() as $post_type ) {
if ( 'attachment' === $post_type ) {
continue;
}
$id = 'pt_' . $post_type . '_default_rich_snippet';
$article_type = 'pt_' . $post_type . '_default_article_type';
$settings['titles'][ $id ] = sanitize_text_field( $values[ $id ] );
$settings['titles'][ $article_type ] = sanitize_text_field( $values[ $article_type ] );
}
}
/**
* Get Default values for the schemas used for Post types.
*/
private static function get_default_values() {
$richsnp_default = [
'post' => 'article',
'product' => 'product',
];
$data = [];
foreach ( Helper::get_accessible_post_types() as $post_type ) {
if ( 'attachment' === $post_type ) {
continue;
}
$field_id = 'pt_' . $post_type . '_default_rich_snippet';
$default = $post_type === 'product' ? 'product' : 'off';
$value = Helper::get_settings( 'titles.pt_' . $post_type . '_default_rich_snippet', ( isset( $richsnp_default[ $post_type ] ) ? $richsnp_default[ $post_type ] : $default ) );
$data[ $field_id ] = $value ? $value : 'off';
if ( $post_type === 'product' ) {
continue;
}
$data[ 'pt_' . $post_type . '_default_article_type' ] = Helper::get_settings( 'titles.pt_' . $post_type . '_default_article_type', 'post' === $post_type ? 'BlogPosting' : 'Article' );
}
return $data;
}
}

View File

@@ -0,0 +1,153 @@
<?php
/**
* The Search Console wizard step
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Wizard
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Wizard;
use RankMath\Helper;
use RankMath\Helpers\Param;
use RankMath\Admin\Admin_Helper;
use RankMath\Google\Authentication;
use RankMath\Google\Permissions;
use RankMath\Analytics\Email_Reports;
use RankMath\Analytics\Workflow\Objects;
use RankMath\Analytics\Workflow\Console;
use RankMath\Analytics\Workflow\Inspections;
defined( 'ABSPATH' ) || exit;
/**
* Step class.
*/
class Search_Console implements Wizard_Step {
/**
* Get Localized data to be used in the Analytics step.
*
* @return array
*/
public static function get_localized_data() {
$all_services = get_option(
'rank_math_analytics_all_services',
[
'isVerified' => '',
'inSearchConsole' => '',
'hasSitemap' => '',
'hasAnalytics' => '',
'hasAnalyticsProperty' => '',
'homeUrl' => '',
'sites' => '',
'accounts' => [],
'adsenseAccounts' => [],
]
);
$analytics = wp_parse_args(
get_option( 'rank_math_google_analytic_options' ),
[
'adsense_id' => '',
'account_id' => '',
'property_id' => '',
'view_id' => '',
'measurement_id' => '',
'stream_name' => '',
'country' => 'all',
'install_code' => false,
'anonymize_ip' => false,
'local_ga_js' => false,
'exclude_loggedin' => false,
]
);
$page = Param::get( 'page', '', FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK );
$page = in_array( $page, [ 'rank-math-options-general', 'rank-math-analytics' ], true ) ? 'rank-math-options-general' : 'rank-math-wizard&step=analytics';
$activate_url = Admin_Helper::get_activate_url( admin_url( 'admin.php?analytics=1&page=' . $page ) );
$profile = wp_parse_args(
get_option( 'rank_math_google_analytic_profile' ),
[
'profile' => '',
'country' => 'all',
'enable_index_status' => true,
'sites' => $all_services['sites'],
]
);
return [
'isSiteConnected' => Helper::is_site_connected(),
'isAuthorized' => Authentication::is_authorized(),
'isSiteUrlValid' => Admin_Helper::is_site_url_valid(),
'hasConsolePermission' => Permissions::has_console(),
'hasAnalyticsPermission' => Permissions::has_analytics(),
'hasAdsensePermission' => Permissions::has_adsense(),
'activateUrl' => $activate_url,
'authUrl' => Authentication::get_auth_url(),
'reconnectGoogleUrl' => wp_nonce_url( admin_url( 'admin.php?reconnect=google' ), 'rank_math_reconnect_google' ),
'showEmailReports' => ! Email_Reports::are_fields_hidden(),
'searchConsole' => $profile,
'console_email_reports' => Helper::get_settings( 'general.console_email_reports' ),
'analyticsData' => $analytics,
'allServices' => $all_services,
];
}
/**
* Save handler for step.
*
* @param array $values Values to save.
*
* @return bool
*/
public static function save( $values ) {
if ( isset( $values['console_email_reports'] ) ) {
$settings = rank_math()->settings->all_raw();
$settings['general']['console_email_reports'] = $values['console_email_reports'] ? 'on' : 'off';
Helper::update_all_settings( $settings['general'], null, null );
}
// For Search console.
if ( isset( $values['searchConsole'] ) && ! empty( $values['searchConsole'] ) ) {
$search_console_data = $values['searchConsole'];
$value = [
'country' => sanitize_text_field( $search_console_data['country'] ),
'profile' => sanitize_text_field( $search_console_data['profile'] ?? '' ),
'enable_index_status' => sanitize_text_field( $search_console_data['enable_index_status'] ),
];
update_option( 'rank_math_google_analytic_profile', $value );
}
// For Analytics.
if ( isset( $values['analyticsData'] ) && ! empty( $values['analyticsData'] ) ) {
$analytics_data = $values['analyticsData'];
$analytic_value = [
'adsense_id' => sanitize_text_field( $analytics_data['adsense_id'] ),
'account_id' => sanitize_text_field( $analytics_data['account_id'] ),
'property_id' => sanitize_text_field( $analytics_data['property_id'] ),
'view_id' => sanitize_text_field( $analytics_data['view_id'] ),
'measurement_id' => sanitize_text_field( $analytics_data['measurement_id'] ),
'stream_name' => sanitize_text_field( $analytics_data['stream_name'] ),
'country' => sanitize_text_field( $analytics_data['country'] ),
'install_code' => sanitize_text_field( $analytics_data['install_code'] ),
'anonymize_ip' => sanitize_text_field( $analytics_data['anonymize_ip'] ),
'local_ga_js' => sanitize_text_field( $analytics_data['local_ga_js'] ),
'exclude_loggedin' => sanitize_text_field( $analytics_data['exclude_loggedin'] ),
];
update_option( 'rank_math_google_analytic_options', $analytic_value );
}
$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
if ( 'rank-math-wizard' === $page ) {
new Objects();
new Console();
new Inspections();
}
return true;
}
}

View File

@@ -0,0 +1,151 @@
<?php
/**
* The Sitemap wizard step
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Wizard
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Wizard;
use RankMath\Helper;
defined( 'ABSPATH' ) || exit;
/**
* Step class.
*/
class Sitemap implements Wizard_Step {
/**
* Get Localized data to be used in the Compatibility step.
*
* @return array
*/
public static function get_localized_data() {
$post_types = self::get_post_types();
$taxonomies = self::get_taxonomies();
return [
'sitemap' => Helper::is_module_active( 'sitemap' ),
'include_images' => Helper::get_settings( 'sitemap.include_images' ),
'postTypes' => $post_types['post_types'],
'sitemap_post_types' => $post_types['defaults'],
'taxonomies' => $taxonomies['taxonomies'],
'sitemap_taxonomies' => $taxonomies['defaults'],
];
}
/**
* Save handler for step.
*
* @param array $values Values to save.
*
* @return bool
*/
public static function save( $values ) {
$settings = rank_math()->settings->all_raw();
Helper::update_modules( [ 'sitemap' => $values['sitemap'] ? 'on' : 'off' ] );
if ( $values['sitemap'] ) {
$settings['sitemap']['include_images'] = $values['include_images'] ? 'on' : 'off';
$settings = self::save_post_types( $settings, $values );
$settings = self::save_taxonomies( $settings, $values );
Helper::update_all_settings( null, null, $settings['sitemap'] );
}
Helper::schedule_flush_rewrite();
return true;
}
/**
* Get post type data.
*
* @return array
*/
private static function get_post_types() {
$p_defaults = [];
$post_types = Helper::choices_post_types();
if ( Helper::get_settings( 'general.attachment_redirect_urls', true ) ) {
unset( $post_types['attachment'] );
}
foreach ( $post_types as $post_type => $object ) {
if ( true === Helper::get_settings( "sitemap.pt_{$post_type}_sitemap" ) ) {
$p_defaults[] = $post_type;
}
}
return [
'defaults' => $p_defaults,
'post_types' => $post_types,
];
}
/**
* Get taxonomies data.
*
* @return array
*/
private static function get_taxonomies() {
$t_defaults = [];
$taxonomies = Helper::get_accessible_taxonomies();
unset( $taxonomies['post_tag'], $taxonomies['post_format'], $taxonomies['product_tag'] );
$taxonomies = wp_list_pluck( $taxonomies, 'label', 'name' );
foreach ( $taxonomies as $taxonomy => $label ) {
if ( true === Helper::get_settings( "sitemap.tax_{$taxonomy}_sitemap" ) ) {
$t_defaults[] = $taxonomy;
}
}
return [
'defaults' => $t_defaults,
'taxonomies' => $taxonomies,
];
}
/**
* Save Post Types
*
* @param array $settings Array of all settings.
* @param array $values Array of posted values.
*
* @return array
*/
private static function save_post_types( $settings, $values ) {
$post_types = Helper::choices_post_types();
if ( ! isset( $values['sitemap_post_types'] ) ) {
$values['sitemap_post_types'] = [];
}
foreach ( $post_types as $post_type => $object ) {
$settings['sitemap'][ "pt_{$post_type}_sitemap" ] = in_array( $post_type, $values['sitemap_post_types'], true ) ? 'on' : 'off';
}
return $settings;
}
/**
* Save Taxonomies
*
* @param array $settings Array of all settings.
* @param array $values Array of posted values.
*
* @return array
*/
private static function save_taxonomies( $settings, $values ) {
$taxonomies = Helper::get_accessible_taxonomies();
$taxonomies = wp_list_pluck( $taxonomies, 'label', 'name' );
if ( ! isset( $values['sitemap_taxonomies'] ) ) {
$values['sitemap_taxonomies'] = [];
}
foreach ( $taxonomies as $taxonomy => $label ) {
$settings['sitemap'][ "tax_{$taxonomy}_sitemap" ] = in_array( $taxonomy, $values['sitemap_taxonomies'], true ) ? 'on' : 'off';
}
return $settings;
}
}

View File

@@ -0,0 +1,279 @@
<?php
/**
* The Your Site wizard step
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Wizard
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Wizard;
use RankMath\Helper;
use RankMath\Admin\Admin_Helper;
defined( 'ABSPATH' ) || exit;
/**
* Step class.
*/
class Your_Site implements Wizard_Step {
/**
* Get Localized data to be used in the Compatibility step.
*
* @return array
*/
public static function get_localized_data() {
$displayname = self::get_site_display_name();
$data = [
'site_type' => self::get_default_site_type(),
'businessTypesChoices' => Helper::choices_business_types(),
'business_type' => Helper::get_settings( 'titles.local_business_type' ),
'website_name' => Helper::get_settings( 'titles.website_name', $displayname ),
'website_alternate_name' => Helper::get_settings( 'titles.website_alternate_name', '' ),
'company_name' => Helper::get_settings( 'titles.knowledgegraph_name', $displayname ),
'open_graph_image' => Helper::get_settings( 'titles.open_graph_image' ),
];
$company_logo = self::get_default_logo();
if ( $company_logo ) {
$data['company_logo'] = $company_logo;
$data['company_logo_id'] = attachment_url_to_postid( $company_logo );
}
$open_graph_image = Helper::get_settings( 'titles.open_graph_image' );
if ( $open_graph_image ) {
$data['open_graph_image'] = $open_graph_image;
$data['open_graph_image_id'] = attachment_url_to_postid( $open_graph_image );
}
return $data;
}
/**
* Save handler for step.
*
* @param array $values Values to save.
*
* @return bool
*/
public static function save( $values ) {
$settings = wp_parse_args(
rank_math()->settings->all_raw(),
[
'titles' => '',
'sitemap' => '',
]
);
$values = wp_parse_args(
$values,
[
'company_name' => '',
'company_logo' => '',
'company_logo_id' => '',
'open_graph_image' => '',
'open_graph_image_id' => '',
]
);
// Save these settings.
$functions = [ 'save_local_seo', 'save_open_graph', 'save_post_types', 'save_taxonomies' ];
foreach ( $functions as $function ) {
$settings = self::$function( $settings, $values );
}
$business_type = [ 'news', 'business', 'webshop', 'otherbusiness' ];
$modules = [ 'local-seo' => in_array( $values['site_type'], $business_type, true ) ? 'on' : 'off' ];
$users = get_users( [ 'role__in' => [ 'administrator', 'editor', 'author', 'contributor' ] ] );
if ( count( $users ) > 1 && ! is_plugin_active( 'members/members.php' ) ) {
$modules['role-manager'] = 'on';
}
set_transient( '_rank_math_site_type', sanitize_text_field( $values['site_type'] ) );
Helper::update_modules( $modules );
Helper::update_all_settings( null, $settings['titles'], null );
return true;
}
/**
* Save Local Seo
*
* @param array $settings Array of all settings.
* @param array $values Array of posted values.
*
* @return array
*/
private static function save_local_seo( $settings, $values ) {
switch ( $values['site_type'] ) {
case 'blog':
case 'portfolio':
$settings['titles']['knowledgegraph_type'] = 'person';
$settings['titles']['knowledgegraph_name'] = sanitize_text_field( $values['company_name'] );
$settings['titles']['knowledgegraph_logo'] = sanitize_url( $values['company_logo'] );
$settings['titles']['knowledgegraph_logo_id'] = absint( $values['company_logo_id'] );
break;
case 'news':
case 'webshop':
case 'business':
case 'otherbusiness':
$settings['titles']['knowledgegraph_type'] = 'company';
$settings['titles']['knowledgegraph_name'] = sanitize_text_field( $values['company_name'] );
$settings['titles']['knowledgegraph_logo'] = sanitize_url( $values['company_logo'] );
$settings['titles']['local_business_type'] = sanitize_text_field( $values['business_type'] );
$settings['titles']['knowledgegraph_logo_id'] = absint( $values['company_logo_id'] );
break;
case 'otherpersonal':
$settings['titles']['knowledgegraph_type'] = 'person';
$settings['titles']['knowledgegraph_name'] = sanitize_text_field( $values['company_name'] );
break;
}
foreach ( [ 'website_name', 'website_alternate_name' ] as $key ) {
if ( empty( $values[ $key ] ) ) {
continue;
}
$settings['titles'][ $key ] = sanitize_text_field( $values[ $key ] );
}
return $settings;
}
/**
* Save Open Graph
*
* @param array $settings Array of all settings.
* @param array $values Array of posted values.
*
* @return array
*/
private static function save_open_graph( $settings, $values ) {
if ( ! empty( $values['open_graph_image_id'] ) ) {
$settings['titles']['open_graph_image'] = sanitize_url( $values['open_graph_image'] );
$settings['titles']['open_graph_image_id'] = absint( $values['open_graph_image_id'] );
}
if ( empty( $values['company_logo_id'] ) ) {
unset( $settings['titles']['knowledgegraph_logo'] );
unset( $settings['titles']['knowledgegraph_logo_id'] );
}
return $settings;
}
/**
* Save Post Types
*
* @param array $settings Array of all settings.
* @param array $values Array of posted values.
*
* @return array
*/
private static function save_post_types( $settings, $values ) {
foreach ( Helper::get_accessible_post_types() as $post_type => $label ) {
if ( 'attachment' === $post_type ) {
continue;
}
$settings['titles'][ "pt_{$post_type}_add_meta_box" ] = 'on';
}
return $settings;
}
/**
* Save Taxonomies
*
* @param array $settings Array of all settings.
* @param array $values Array of posted values.
*
* @return array
*/
private static function save_taxonomies( $settings, $values ) {
$taxonomies = Admin_Helper::get_taxonomies_options();
array_shift( $taxonomies );
foreach ( $taxonomies as $taxonomy => $label ) {
$settings['titles'][ "tax_{$taxonomy}_add_meta_box" ] = 'on';
}
return $settings;
}
/**
* Get site display name.
*
* @return string
*/
protected static function get_site_display_name() {
$siteurl = get_bloginfo( 'url' );
$sitename = get_bloginfo( 'title' );
return $sitename ? $sitename : $siteurl;
}
/**
* Get default logo.
*
* @return string
*/
private static function get_default_logo() {
if ( defined( 'MTS_THEME_NAME' ) && MTS_THEME_NAME ) {
$theme_options = get_option( MTS_THEME_NAME );
if ( isset( $theme_options['mts_logo'] ) ) {
return wp_get_attachment_url( $theme_options['mts_logo'] );
}
}
if ( current_theme_supports( 'custom-logo' ) && ! empty( get_theme_mod( 'custom_logo' ) ) ) {
return wp_get_attachment_url( get_theme_mod( 'custom_logo' ) );
}
return Helper::get_settings( 'titles.knowledgegraph_logo' );
}
/**
* Get default site type.
*
* @return string
*/
private static function get_default_site_type() {
$default_type = get_transient( '_rank_math_site_type' );
return $default_type ? $default_type : ( class_exists( 'Easy_Digital_Downloads' ) || class_exists( 'WooCommerce' ) ? 'webshop' : 'blog' );
}
/**
* Get type dependecy.
*
* @return array
*/
private function get_type_dependency() {
return [
[ 'site_type', 'news' ],
[ 'site_type', 'business' ],
[ 'site_type', 'webshop' ],
[ 'site_type', 'otherbusiness' ],
];
}
/**
* Get type choices.
*
* @return array
*/
private function get_type_choices() {
return [
'blog' => esc_html__( 'Personal Blog', 'rank-math' ),
'news' => esc_html__( 'Community Blog/News Site', 'rank-math' ),
'portfolio' => esc_html__( 'Personal Portfolio', 'rank-math' ),
'business' => esc_html__( 'Small Business Site', 'rank-math' ),
'webshop' => esc_html__( 'Webshop', 'rank-math' ),
'otherpersonal' => esc_html__( 'Other Personal Website', 'rank-math' ),
'otherbusiness' => esc_html__( 'Other Business Website', 'rank-math' ),
];
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* The wizard step contract.
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Wizard
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath\Wizard;
defined( 'ABSPATH' ) || exit;
/**
* Wizard step contract.
*/
interface Wizard_Step {
/**
* Localized data to be used in the step.
*
* @return array
*/
public static function get_localized_data();
/**
* Save handler for step.
*
* @param array $values Values to save.
*
* @return bool
*/
public static function save( $values );
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Setup wizard content template.
*
* @package RankMath
* @subpackage RankMath\Admin\Wizard
*/
use RankMath\KB;
defined( 'ABSPATH' ) || exit;
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta name="viewport" content="width=device-width"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title><?php esc_html_e( 'Setup Wizard - Rank Math', 'rank-math' ); ?></title>
<?php wp_print_head_scripts(); ?>
<?php wp_print_styles( 'rank-math-wizard' ); ?>
</head>
<body class="rank-math-wizard rank-math-page <?php echo is_rtl() ? ' rtl' : ''; ?>">
<div id="rank-math-wizard-wrapper"></div>
</body>
<?php
rank_math()->json->output();
if ( function_exists( 'wp_print_media_templates' ) ) {
wp_print_media_templates();
}
wp_print_footer_scripts();
?>
</html>

View File

@@ -0,0 +1,40 @@
<?php
/**
* Search console ui.
*
* @package RankMath
* @subpackage RankMath\Admin\Wizard
*/
use RankMath\KB;
use RankMath\Google\Authentication;
defined( 'ABSPATH' ) || exit;
// phpcs:disable
$is_authorized = Authentication::is_authorized();
$authorize = ! $is_authorized ? ( '<div class="connect-wrap" style="margin-top: 30px;"><a href="' . esc_url( Authentication::get_auth_url() ) . '" class="button button-primary button-animated rank-math-authorize-account">' . esc_html__( 'Connect Google Services', 'rank-math' ) . '</a></div>' ) : '';
$deauthorize = $is_authorized ? '<button class="button button-primary rank-math-deauthorize-account">' . esc_html__( 'Disconnect Account', 'rank-math' ) . '</button>' : '';
echo $authorize . $deauthorize;
?>
<div id="rank-math-pro-cta" class="analytics">
<div class="rank-math-cta-box width-100 no-shadow no-padding no-border">
<h3><?php echo esc_attr__( 'Benefits of Connecting Google Account', 'rank-math' ); ?></h3>
<ul>
<li><?php echo esc_attr__( 'Verify site ownership on Google Search Console in a single click', 'rank-math' ); ?></li>
<li><?php echo esc_attr__( 'Track page and keyword rankings with the Advanced Analytics module', 'rank-math' ); ?></li>
<li><?php echo esc_attr__( 'Easily set up Google Analytics without using another 3rd party plugin', 'rank-math' ); ?></li>
<li><?php echo esc_attr__( 'Automatically submit sitemaps to the Google Search Console', 'rank-math' ); ?></li>
<li><a href="<?php echo KB::get( 'help-analytics', 'SW Analytics Step Benefits' ); ?>" target="_blank"><?php echo esc_html__( 'Learn more about the benefits of connecting your account here.', 'rank-math' ); ?></a></li>
</ul>
</div>
</div>
<div id="rank-math-pro-cta" class="rank-math-privacy-box">
<div class="rank-math-cta-table">
<div class="rank-math-cta-body less-padding">
<i class="dashicons dashicons-lock"></i>
<p><?php printf( esc_html__( 'We do not store any of the data from your Google account on our servers, everything is processed & stored on your server. We take your privacy extremely seriously and ensure it is never misused. %s', 'rank-math' ), '<a href="' . KB::get( 'usage-policy', 'Analytics Privacy Notice' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Learn more.', 'rank-math' ) . '</a>' ); ?></p>
</div>
</div>
</div>

View File

@@ -0,0 +1 @@
<?php // Silence is golden.

View File

@@ -0,0 +1,53 @@
<?php
/**
* Search console ui.
*
* @package RankMath
* @subpackage RankMath\Admin\Wizard
*/
use RankMath\KB;
use RankMath\Helpers\Param;
use RankMath\Admin\Admin_Helper;
defined( 'ABSPATH' ) || exit;
$sw_page = Param::get( 'page', '', FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK );
$sw_page = in_array( $sw_page, [ 'rank-math-options-general', 'rank-math-analytics' ], true ) ? 'rank-math-options-general' : 'rank-math-wizard&step=analytics';
$url = Admin_Helper::get_activate_url( admin_url( 'admin.php?analytics=1&page=' . $sw_page ) );
$site_url_valid = Admin_Helper::is_site_url_valid();
$button_class = 'button button-primary button-connect' . ( $site_url_valid ? ' button-animated' : ' disabled' );
?>
<?php Admin_Helper::maybe_show_invalid_siteurl_notice(); ?>
<div class="wp-core-ui rank-math-ui connect-wrap" style="margin-top: 30px;">
<a href="<?php echo esc_url( $url ); ?>" class="<?php echo esc_attr( $button_class ); ?>" name="rank_math_activate"><?php echo esc_attr__( 'Connect Your Rank Math Account', 'rank-math' ); ?></a>
</div>
<div id="rank-math-pro-cta" class="analytics">
<div class="rank-math-cta-box width-100 no-shadow no-padding no-border">
<h3><?php echo esc_attr__( 'Benefits of Connecting Rank Math Account', 'rank-math' ); ?></h3>
<ul>
<li><?php echo esc_attr__( 'Verify site ownership on Google Search Console in a single click', 'rank-math' ); ?></li>
<li><?php echo esc_attr__( 'Track page and keyword rankings with the Advanced Analytics module', 'rank-math' ); ?></li>
<li><?php echo esc_attr__( 'Easily set up Google Analytics without using another 3rd party plugin', 'rank-math' ); ?></li>
<li><?php echo esc_attr__( 'Automatically submit sitemaps to the Google Search Console', 'rank-math' ); ?></li>
<li><?php echo esc_attr__( 'Free keyword suggestions when entering a focus keyword', 'rank-math' ); ?></li>
<li><?php echo esc_attr__( 'Use our revolutionary SEO Analyzer to scan your website for SEO errors', 'rank-math' ); ?></li>
<li><a href="<?php echo esc_url( KB::get( 'free-account-benefits', 'SW Analytics Step' ) ); ?>" target="_blank"><?php echo esc_html__( 'Learn more about the benefits of connecting your account here.', 'rank-math' ); ?></a></li>
</ul>
</div>
</div>
<div id="rank-math-pro-cta" class="rank-math-privacy-box">
<div class="rank-math-cta-table">
<div class="rank-math-cta-body less-padding">
<i class="dashicons dashicons-lock"></i>
<p>
<?php
// Translators: placeholder is the KB link.
printf( esc_html__( 'We do not store any of the data from your Google account on our servers, everything is processed & stored on your server. We take your privacy extremely seriously and ensure it is never misused. %s', 'rank-math' ), '<a href="' . esc_url( KB::get( 'usage-policy', 'Analytics Privacy Notice' ) ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Learn more.', 'rank-math' ) . '</a>' );
?>
</p>
</div>
</div>
</div>

View File

@@ -0,0 +1,404 @@
<?php
/**
* Search console UI.
*
* @package RankMath
* @subpackage RankMath\Admin\Wizard
*/
use RankMath\KB;
use RankMath\Helper;
use RankMath\Google\Authentication;
use RankMath\Google\Permissions;
use RankMath\Analytics\Url_Inspection;
use RankMath\Helpers\Str;
use RankMath\Google\Analytics;
use RankMath\Google\Console;
defined( 'ABSPATH' ) || exit;
if ( ! Helper::is_site_connected() ) {
require_once 'rank-math-connect.php';
return;
}
$is_authorized = Authentication::is_authorized();
if ( ! $is_authorized ) {
require_once 'google-connect.php';
return;
}
$profile = wp_parse_args(
get_option( 'rank_math_google_analytic_profile' ),
[
'profile' => '',
'country' => 'all',
]
);
$analytics = wp_parse_args(
get_option( 'rank_math_google_analytic_options' ),
[
'adsense_id' => '',
'account_id' => '',
'property_id' => '',
'view_id' => '',
'measurement_id' => '',
'stream_name' => '',
'country' => 'all',
'install_code' => false,
'anonymize_ip' => false,
'local_ga_js' => false,
'exclude_loggedin' => false,
]
);
$is_profile_connected = Console::is_console_connected();
$is_adsense_connected = ! empty( $analytics['adsense_id'] );
$is_analytics_connected = Analytics::is_analytics_connected();
$is_index_status_enabled = Url_Inspection::is_enabled() || ! $is_profile_connected;
$all_services = get_option(
'rank_math_analytics_all_services',
[
'isVerified' => '',
'inSearchConsole' => '',
'hasSitemap' => '',
'hasAnalytics' => '',
'hasAnalyticsProperty' => '',
'homeUrl' => '',
'sites' => '',
'accounts' => [],
'adsenseAccounts' => [],
]
);
$is_pro_active = defined( 'RANK_MATH_PRO_FILE' );
?>
<input type="hidden" class="cmb2-id-check-all-services" value="<?php echo $is_profile_connected && $is_analytics_connected ? '1' : '0'; ?>" />
<?php
$connections = [
'reconnect' => [
'link' => wp_nonce_url( admin_url( 'admin.php?reconnect=google' ), 'rank_math_reconnect_google' ),
'class' => 'rank-math-reconnect-google',
'text' => esc_html__( 'Reconnect', 'rank-math' ),
],
'disconnect' => [
'link' => '#',
'class' => 'rank-math-disconnect-google',
'text' => esc_html__( 'Disconnect', 'rank-math' ),
],
];
if ( Helper::is_advanced_mode() && ( $is_profile_connected || $is_adsense_connected || $is_analytics_connected ) ) {
$connections['test-connections'] = [
'link' => '#',
'class' => 'rank-math-test-connection-google',
'text' => esc_html__( 'Test Connections', 'rank-math' ),
];
}
$connections = apply_filters( 'rank_math/analytics/connect_actions', $connections );
?>
<div class="connect-actions">
<?php foreach ( $connections as $connection ) { ?>
<a href="<?php echo esc_attr( $connection['link'] ); ?>" class="button button-link <?php echo esc_attr( $connection['class'] ); ?>"><?php echo esc_html( $connection['text'] ); ?></a>
<?php } ?>
</div>
<?php
$console_classes = Helper::classnames(
'rank-math-box no-padding rank-math-accordion rank-math-connect-search-console',
[
'connected' => $is_profile_connected,
'disconnected' => ! $is_profile_connected,
'disabled' => ! Permissions::has_console(),
]
);
$console_status_classes = Helper::classnames(
'rank-math-connection-status',
[
'rank-math-connection-status-success' => Console::is_valid_connection(),
'rank-math-connection-status-error' => ! Console::is_valid_connection(),
]
);
$console_status = $is_profile_connected ? 'Connected' : 'Not Connected';
?>
<div class="<?php echo esc_attr( $console_classes ); ?>" tabindex="0">
<header>
<h3><span class="rank-math-connection-status-wrap"><span class="<?php echo esc_attr( $console_status_classes ); ?>" title="<?php echo esc_attr( $console_status ); ?>"></span></span> <?php esc_html_e( 'Search Console', 'rank-math' ); ?></h3>
</header>
<div class="rank-math-accordion-content">
<?php
if ( ! Permissions::has_console() ) {
Permissions::print_warning();
}
?>
<div class="cmb-row cmb-type-select">
<div class="cmb-row-col">
<label for="site-console-profile"><?php esc_html_e( 'Site', 'rank-math' ); ?></label>
<select class="cmb2_select site-console-profile notrack" name="site-console-profile" id="site-console-profile" data-selected="<?php echo esc_attr( $profile['profile'] ); ?>" disabled="disabled">
<?php if ( $is_profile_connected ) : ?>
<option value="<?php echo esc_attr( $profile['profile'] ); ?>"><?php echo esc_attr( $profile['profile'] ); ?></option>
<?php endif; ?>
</select>
</div>
<?php do_action( 'rank_math/analytics/options/console' ); ?>
</div>
<div class="cmb-row cmb-type-toggle">
<div class="cmb-td">
<label class="cmb2-toggle">
<input type="checkbox" class="regular-text notrack" name="enable-index-status" id="enable-index-status" value="on" <?php checked( $is_index_status_enabled ); ?> <?php disabled( ! $is_profile_connected ); ?>>
<span class="cmb2-slider">
<svg width="3" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 6" class="toggle_on" role="img" aria-hidden="true" focusable="false"><path d="M0 0h2v6H0z"></path></svg>
<svg width="8" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 6 6" class="toggle_off" role="img" aria-hidden="true" focusable="false"><path d="M3 1.5c.8 0 1.5.7 1.5 1.5S3.8 4.5 3 4.5 1.5 3.8 1.5 3 2.2 1.5 3 1.5M3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"></path></svg>
</span>
</label>
<label for="enable-index-status"><?php esc_html_e( 'Enable the Index Status tab', 'rank-math' ); ?></label>
<div class="cmb2-metabox-description"><?php esc_html_e( 'Enable this option to show the Index Status tab in the Analytics module.', 'rank-math' ); ?> <a href="<?php echo KB::get( 'url-inspection-api', 'SW Analytics Index Status Option' ); // phpcs:ignore ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Learn more.', 'rank-math' ); ?></a></div>
</div>
</div>
<?php if ( ! Console::is_valid_connection() ) : ?>
<div class="rank-math-notice rank-math-notice--error">
<p><?php esc_html_e( 'Data import will not work for this service as sufficient permissions are not given.', 'rank-math' ); ?></p>
</div>
<?php endif; ?>
</div>
</div>
<?php
$analytic_classes = Helper::classnames(
'rank-math-box no-padding rank-math-accordion rank-math-connect-analytics',
[
'connected' => $is_analytics_connected,
'disconnected' => ! $is_analytics_connected,
'disabled' => ! Permissions::has_analytics(),
]
);
$analytic_status_classes = Helper::classnames(
'rank-math-connection-status',
[
'rank-math-connection-status-success' => Analytics::is_valid_connection(),
'rank-math-connection-status-error' => ! Analytics::is_valid_connection(),
]
);
$analytic_status = $is_analytics_connected ? 'Connected' : 'Not Connected';
?>
<div class="<?php echo esc_attr( $analytic_classes ); ?>" tabindex="0">
<header>
<h3><span class="rank-math-connection-status-wrap"><span class="<?php echo esc_attr( $analytic_status_classes ); ?>" title="<?php echo esc_attr( $analytic_status ); ?>"></span></span><?php esc_html_e( 'Analytics', 'rank-math' ); ?></h3>
</header>
<div class="rank-math-accordion-content rank-math-analytics-content">
<?php
if ( ! Permissions::has_analytics() ) {
Permissions::print_warning();
}
?>
<p class="warning yellow">
<strong class="note"><?php echo esc_html__( 'Note', 'rank-math' ); ?></strong>
<?php
printf(
/* translators: %s: Link to KB article */
esc_html__( 'Ready to switch to Google Analytics 4? %s', 'rank-math' ),
'<a href="' . KB::get( 'using-ga4', 'Analytics GA4 KB' ) . '" target="_blank">' . esc_html__( 'Click here to know how', 'rank-math' ) . '</a>.' // phpcs:ignore
);
?>
</p>
<div class="cmb-row cmb-type-select">
<div class="cmb-row-col">
<label for="site-analytics-account"><?php esc_html_e( 'Account', 'rank-math' ); ?></label>
<select class="cmb2_select site-analytics-account notrack" name="site-analytics-account" id="site-analytics-account" data-selected="<?php echo esc_attr( $analytics['account_id'] ); ?>" disabled="disabled">
<?php
if ( $is_analytics_connected ) :
$analytic_account = $all_services['accounts'][ $analytics['account_id'] ]['name'] ?? '';
?>
<option value="<?php echo esc_attr( $analytics['account_id'] ); ?>"><?php echo esc_attr( $analytic_account ); ?></option>
<?php endif; ?>
</select>
</div>
<div class="cmb-row-col">
<label for="site-analytics-property"><?php esc_html_e( 'Property', 'rank-math' ); ?></label>
<select class="cmb2_select site-analytics-property notrack" name="site-analytics-property" id="site-analytics-property" data-selected="<?php echo esc_attr( $analytics['property_id'] ); ?>" disabled="disabled">
<?php
if ( $is_analytics_connected ) :
$analytic_property = $all_services['accounts'][ $analytics['account_id'] ]['properties'][ $analytics['property_id'] ]['name'] ?? '';
?>
<option value="<?php echo esc_attr( $analytics['property_id'] ); ?>"><?php echo esc_html( $analytic_property ); ?></option>
<?php endif; ?>
</select>
</div>
<div class="cmb-row-col">
<label for="site-analytics-view">
<?php echo esc_html__( 'Data Stream', 'rank-math' ); ?>
</label>
<select class="cmb2_select site-analytics-view notrack" name="site-analytics-view" id="site-analytics-view" data-selected="<?php echo esc_attr( $analytics['view_id'] ); ?>" disabled="disabled">
<?php
if ( $is_analytics_connected ) :
$analytic_view = $analytics['stream_name'] ? $analytics['stream_name'] : 'Website';
?>
<option value="<?php echo esc_attr( $analytics['view_id'] ); ?>"><?php echo esc_attr( $analytic_view ); ?></option>
<?php
endif;
?>
</select>
</div>
<input type="hidden" id="rank-math-analytics-measurement-id" name="measurementID" value="<?php echo esc_attr( $analytics['measurement_id'] ); ?>" />
<input type="hidden" id="rank-math-analytics-stream-name" name="streamName" value="<?php echo esc_attr( $analytics['stream_name'] ); ?>" />
<?php do_action( 'rank_math/analytics/options/analytics' ); ?>
</div>
<div class="cmb-row cmb-type-toggle">
<div class="cmb-td">
<label class="cmb2-toggle">
<input type="checkbox" class="regular-text notrack" name="install-code" id="install-code" value="on"<?php checked( $analytics['install_code'] ); ?>>
<span class="cmb2-slider">
<svg width="3" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 6" class="toggle_on" role="img" aria-hidden="true" focusable="false"><path d="M0 0h2v6H0z"></path></svg>
<svg width="8" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 6 6" class="toggle_off" role="img" aria-hidden="true" focusable="false"><path d="M3 1.5c.8 0 1.5.7 1.5 1.5S3.8 4.5 3 4.5 1.5 3.8 1.5 3 2.2 1.5 3 1.5M3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"></path></svg>
</span>
</label>
<label for="install-code"><?php esc_html_e( 'Install analytics code', 'rank-math' ); ?></label>
<div class="cmb2-metabox-description"><?php esc_html_e( 'Enable this option only if you are not using any other plugin/theme to install Google Analytics code.', 'rank-math' ); ?></div>
</div>
</div>
<div class="cmb-row cmb-type-toggle <?php echo ! $is_pro_active ? 'cmb-redirector-element' : ''; ?>" <?php echo ! $is_pro_active ? 'data-url="' . KB::the( 'free-vs-pro', 'Anonymize IP' ) . '"' : ''; // phpcs:ignore ?>>
<div class="cmb-td">
<label class="cmb2-toggle">
<input type="checkbox" class="regular-text notrack" name="anonymize-ip" id="anonymize-ip" value="on"<?php checked( $analytics['anonymize_ip'] ); ?><?php disabled( ! $is_pro_active ); ?>>
<span class="cmb2-slider<?php echo ! $is_pro_active ? ' disabled' : ''; ?> ">
<svg width="3" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 6" class="toggle_on" role="img" aria-hidden="true" focusable="false"><path d="M0 0h2v6H0z"></path></svg>
<svg width="8" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 6 6" class="toggle_off" role="img" aria-hidden="true" focusable="false"><path d="M3 1.5c.8 0 1.5.7 1.5 1.5S3.8 4.5 3 4.5 1.5 3.8 1.5 3 2.2 1.5 3 1.5M3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"></path></svg>
</span>
</label>
<label for="anonymize-ip">
<?php esc_html_e( 'Anonymize IP addresses', 'rank-math' ); ?>
<?php if ( ! $is_pro_active ) : ?>
<span class="rank-math-pro-badge">
<a href="<?php KB::the( 'pro', 'Anonymize IP' ); ?>" target="_blank" rel="noopener noreferrer">
<?php esc_html_e( 'PRO', 'rank-math' ); ?>
</a>
</span>
<?php endif; ?>
</label>
<div class="rank-math-cmb-dependency hidden" data-relation="or">
<span class="hidden" data-field="install-code" data-comparison="=" data-value="on"></span>
</div>
</div>
</div>
<div class="cmb-row cmb-type-toggle <?php echo ! $is_pro_active ? 'cmb-redirector-element' : ''; ?>" <?php echo ! $is_pro_active ? 'data-url="' . KB::the( 'pro', 'Localjs IP' ) . '"' : ''; // phpcs:ignore ?>>
<div class="cmb-td">
<label class="cmb2-toggle">
<input type="checkbox" class="regular-text notrack" name="local-ga-js" id="local-ga-js" value="on"<?php checked( $analytics['local_ga_js'] ); ?><?php disabled( ! $is_pro_active ); ?>>
<span class="cmb2-slider<?php echo ! $is_pro_active ? ' disabled' : ''; ?> ">
<svg width="3" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 6" class="toggle_on" role="img" aria-hidden="true" focusable="false"><path d="M0 0h2v6H0z"></path></svg>
<svg width="8" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 6 6" class="toggle_off" role="img" aria-hidden="true" focusable="false"><path d="M3 1.5c.8 0 1.5.7 1.5 1.5S3.8 4.5 3 4.5 1.5 3.8 1.5 3 2.2 1.5 3 1.5M3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"></path></svg>
</span>
</label>
<label for="local-ga-js">
<?php esc_html_e( 'Self-Hosted Analytics JS File', 'rank-math' ); ?>
<?php if ( ! $is_pro_active ) : ?>
<span class="rank-math-pro-badge">
<a href="<?php KB::the( 'pro', 'Localjs IP' ); ?>" target="_blank" rel="noopener noreferrer">
<?php esc_html_e( 'PRO', 'rank-math' ); ?>
</a>
</span>
<?php endif; ?>
</label>
<div class="rank-math-cmb-dependency hidden" data-relation="or">
<span class="hidden" data-field="install-code" data-comparison="=" data-value="on"></span>
</div>
</div>
</div>
<div class="cmb-row cmb-type-toggle">
<div class="cmb-td">
<label class="cmb2-toggle">
<input type="checkbox" class="regular-text notrack" name="exclude-loggedin" id="exclude-loggedin" value="on"<?php checked( $analytics['exclude_loggedin'] ); ?>>
<span class="cmb2-slider">
<svg width="3" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 6" class="toggle_on" role="img" aria-hidden="true" focusable="false"><path d="M0 0h2v6H0z"></path></svg>
<svg width="8" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 6 6" class="toggle_off" role="img" aria-hidden="true" focusable="false"><path d="M3 1.5c.8 0 1.5.7 1.5 1.5S3.8 4.5 3 4.5 1.5 3.8 1.5 3 2.2 1.5 3 1.5M3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"></path></svg>
</span>
</label>
<label for="exclude-loggedin"><?php esc_html_e( 'Exclude Logged-in users', 'rank-math' ); ?></label>
<div class="rank-math-cmb-dependency hidden" data-relation="or">
<span class="hidden" data-field="install-code" data-comparison="=" data-value="on"></span>
</div>
</div>
</div>
<?php if ( ! Analytics::is_valid_connection() ) : ?>
<div class="rank-math-notice rank-math-notice--error">
<p><?php esc_html_e( 'Data import will not work for this service as sufficient permissions are not given.', 'rank-math' ); ?></p>
</div>
<?php endif; ?>
</div>
</div>
<?php ob_start(); ?>
<div class="rank-math-box no-padding rank-math-accordion rank-math-connect-adsense disconnected" tabindex="0">
<header>
<h3>
<span class="rank-math-connection-status-wrap">
<span class="rank-math-connection-status rank-math-connection-status-error" title="Not Connected"></span>
</span><?php esc_html_e( 'AdSense', 'rank-math' ); ?>
</h3>
</header>
<div class="rank-math-accordion-content">
<div class="cmb-row cmb-type-select">
<div class="cmb-row-col">
<label for="site-adsense-account"><?php esc_html_e( 'Account', 'rank-math' ); ?></label>
<select class="cmb2_select site-adsense-account notrack" name="site-adsense-account" id="site-adsense-account" data-selected="" disabled="disabled">
<option value=""><?php esc_html_e( 'Select Account', 'rank-math' ); ?></option>
</select>
</div>
</div>
<div id="rank-math-pro-cta" class="no-margin">
<div class="rank-math-cta-text">
<span class="rank-math-pro-badge">
<a href="<?php KB::the( 'pro', 'AdSense Toggle' ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'PRO', 'rank-math' ); ?></a></span> <?php esc_html_e( "Google AdSense support is only available in Rank Math Pro's Advanced Analytics module.", 'rank-math' ); ?>
</div>
</div>
</div>
</div>
<?php echo apply_filters( 'rank_math/analytics/adsense', ob_get_clean(), $analytics, $all_services ); // phpcs:ignore ?>
<div id="rank-math-pro-cta" class="rank-math-privacy-box width-100">
<div class="rank-math-cta-table">
<div class="rank-math-cta-body less-padding">
<i class="dashicons dashicons-lock"></i>
<p>
<?php
/* translators: %s: Link to KB article */
printf( esc_html__( 'We do not store any of the data from your Google account on our servers, everything is processed & stored on your server. We take your privacy extremely seriously and ensure it is never misused. %s', 'rank-math' ), '<a href="' . KB::get( 'usage-policy', 'Analytics Privacy Notice' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Learn more.', 'rank-math' ) . '</a>' ); // phpcs:ignore
?>
</p>
</div>
</div>
</div>
<?php
// phpcs:enable
if ( Helper::is_wizard() && ! RankMath\Analytics\Email_Reports::are_fields_hidden() ) {
?>
<div class="cmb-row email-reports-header text-center" style="border-top:0;">
<h1><?php esc_html_e( 'Email Reports', 'rank-math' ); ?></h1>
<div class="email-reports-desc text-center"><?php esc_html_e( 'Receive Analytics reports periodically in email.', 'rank-math' ); ?> <a href="#" target="_blank"><?php esc_html_e( 'Learn more about Email Reports.', 'rank-math' ); ?></a></div>
</div>
<div class="cmb-row cmb-type-toggle cmb2-id-console-email-reports" data-fieldtype="toggle">
<div class="cmb-th">
<label for="console_email_reports"><?php esc_html_e( 'Email Reports', 'rank-math' ); ?></label>
</div>
<div class="cmb-td">
<label class="cmb2-toggle"><input type="checkbox" class="regular-text" name="console_email_reports" id="console_email_reports" value="on" <?php checked( Helper::get_settings( 'general.console_email_reports' ) ); ?> data-hash="7e0rimtbvig0"><span class="cmb2-slider"><svg width="3" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 6" class="toggle_on" role="img" aria-hidden="true" focusable="false"><path d="M0 0h2v6H0z"></path></svg><svg width="8" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 6 6" class="toggle_off" role="img" aria-hidden="true" focusable="false"><path d="M3 1.5c.8 0 1.5.7 1.5 1.5S3.8 4.5 3 4.5 1.5 3.8 1.5 3 2.2 1.5 3 1.5M3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"></path></svg></span></label>
</div>
</div>
<?php
do_action( 'rank_math/analytics/options/wizard_after_email_report' );
}