start_date'] ) ? $args['start_date'] : $dates['start_date']; $end_date = isset( $args['end_date'] ) ? $args['end_date'] : $dates['end_date']; $dimensions = isset( $args['dimensions'] ) ? $args['dimensions'] : 'date'; $row_limit = isset( $args['row_limit'] ) ? $args['row_limit'] : Api::get()->get_row_limit(); $params = [ 'startDate' => $start_date, 'endDate' => $end_date, 'rowLimit' => $row_limit, 'dimensions' => \is_array( $dimensions ) ? $dimensions : [ $dimensions ], ]; $stored = get_option( 'rank_math_google_analytic_profile', [ 'country' => '', 'profile' => '', 'enable_index_status' => '', ] ); $country = isset( $args['country'] ) ? $args['country'] : $stored['country']; $profile = isset( $args['profile'] ) ? $args['profile'] : $stored['profile']; if ( 'all' !== $country ) { $params['dimensionFilterGroups'] = [ [ 'filters' => [ [ 'dimension' => 'country', 'operator' => 'equals', 'expression' => $country, ], ], ], ]; } if ( empty( $profile ) ) { $profile = trailingslashit( strtolower( home_url() ) ); } $workflow = 'console'; $this->set_workflow( $workflow ); $response = $this->http_post( 'https://www.googleapis.com/webmasters/v3/sites/' . rawurlencode( $profile ) . '/searchAnalytics/query', $params ); $this->log_failed_request( $response, $workflow, $start_date, func_get_args() ); if ( ! $this->is_success() ) { return new WP_Error( 'request_failed', __( 'The Google Search Console request failed.', 'rank-math' ) ); } if ( ! isset( $response['rows'] ) ) { return false; } return $response['rows']; } /** * Is site verified. * * @param string $url Site to verify. * * @return boolean */ public function is_site_verified( $url ) { $response = $this->http_get( 'https://www.googleapis.com/siteVerification/v1/webResource/' . rawurlencode( $url ) ); if ( ! $this->is_success() ) { return false; } return isset( $response['owners'] ); } /** * Sync sitemaps with google search console. */ public function sync_sitemaps() { $site_url = self::get_site_url(); $data = $this->get_sitemap_to_sync(); // Submit it. if ( ! $data['sitemaps_in_list'] ) { $this->add_sitemap( $site_url, $data['local_sitemap'] ); } if ( empty( $data['delete_sitemaps'] ) ) { return; } // Delete it. foreach ( $data['delete_sitemaps'] as $sitemap ) { $this->delete_sitemap( $site_url, $sitemap ); } } /** * Get sitemaps to sync. * * @return array */ private function get_sitemap_to_sync() { $delete_sitemaps = []; $sitemaps_in_list = false; $site_url = self::get_site_url(); $sitemaps = $this->get_sitemaps( $site_url ); $local_sitemap = trailingslashit( $site_url ) . Sitemap::get_sitemap_index_slug() . '.xml'; // Early Bail if there are no sitemaps. if ( empty( $sitemaps ) ) { return compact( 'delete_sitemaps', 'sitemaps_in_list', 'local_sitemap' ); } foreach ( $sitemaps as $sitemap ) { if ( $sitemap['path'] === $local_sitemap ) { $sitemaps_in_list = true; continue; } $delete_sitemaps[] = $sitemap['path']; } return compact( 'delete_sitemaps', 'sitemaps_in_list', 'local_sitemap' ); } /** * Get site url. * * @return string */ public static function get_site_url() { static $rank_math_site_url; if ( is_null( $rank_math_site_url ) ) { $default = trailingslashit( strtolower( home_url() ) ); $rank_math_site_url = get_option( 'rank_math_google_analytic_profile', [ 'profile' => $default ] ); $rank_math_site_url = empty( $rank_math_site_url['profile'] ) ? $default : $rank_math_site_url['profile']; if ( Str::contains( 'sc-domain:', $rank_math_site_url ) ) { $rank_math_site_url = str_replace( 'sc-domain:', '', $rank_math_site_url ); $rank_math_site_url = ( is_ssl() ? 'https://' : 'http://' ) . $rank_math_site_url; } } return $rank_math_site_url; } /** * Check if console is connected. * * @return boolean Returns True if the console is connected, otherwise False. */ public static function is_console_connected() { $profile = wp_parse_args( get_option( 'rank_math_google_analytic_profile' ), [ 'profile' => '', 'country' => 'all', ] ); return ! empty( $profile['profile'] ); } }
Fatal error: Uncaught Error: Class 'RankMath\Google\Console' not found in /home/rahjooian/public_html/wp-content/plugins/seo-by-rank-math/includes/helpers/class-analytics.php:31 Stack trace: #0 /home/rahjooian/public_html/wp-content/plugins/seo-by-rank-math/includes/modules/analytics/class-analytics-stats.php(30): RankMath\Helper::can_add_frontend_stats() #1 /home/rahjooian/public_html/wp-content/plugins/seo-by-rank-math/includes/modules/analytics/class-analytics-common.php(49): RankMath\Analytics\Analytics_Stats->__construct() #2 /home/rahjooian/public_html/wp-content/plugins/seo-by-rank-math/includes/module/class-manager.php(500): RankMath\Analytics\Analytics_Common->__construct() #3 /home/rahjooian/public_html/wp-content/plugins/seo-by-rank-math/includes/module/class-manager.php(480): RankMath\Module\Manager->load_module_common(Object(RankMath\Module\Module)) #4 /home/rahjooian/public_html/wp-content/plugins/seo-by-rank-math/includes/module/class-manager.php(467): RankMath\Module\Manager->load_module('analytics', Objec in /home/rahjooian/public_html/wp-content/plugins/seo-by-rank-math/includes/helpers/class-analytics.php on line 31