Skip to content

Commit

Permalink
4.6.3 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian-rossi committed May 23, 2024
1 parent 8120c75 commit 7667a1d
Show file tree
Hide file tree
Showing 33 changed files with 1,001 additions and 1,274 deletions.
2 changes: 1 addition & 1 deletion all_in_one_seo_pack.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: SEO for WordPress. Features like XML Sitemaps, SEO for custom post types, SEO for blogs, business sites, ecommerce sites, and much more. More than 100 million downloads since 2007.
* Author: All in One SEO Team
* Author URI: https://aioseo.com/
* Version: 4.6.2
* Version: 4.6.3
* Text Domain: all-in-one-seo-pack
* Domain Path: /languages
*
Expand Down
1 change: 1 addition & 0 deletions app/Common/Api/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class Api {
'reset-settings' => [ 'callback' => [ 'Settings', 'resetSettings' ], 'access' => 'aioseo_tools_settings' ],
'search-statistics/sitemap/delete' => [ 'callback' => [ 'SearchStatistics', 'deleteSitemap' ], 'access' => [ 'aioseo_search_statistics_settings', 'aioseo_general_settings' ] ], // phpcs:ignore Generic.Files.LineLength.MaxExceeded
'search-statistics/sitemap/ignore' => [ 'callback' => [ 'SearchStatistics', 'ignoreSitemap' ], 'access' => [ 'aioseo_search_statistics_settings', 'aioseo_general_settings' ] ], // phpcs:ignore Generic.Files.LineLength.MaxExceeded
'settings/export' => [ 'callback' => [ 'Settings', 'exportSettings' ], 'access' => 'aioseo_tools_settings' ],
'settings/hide-setup-wizard' => [ 'callback' => [ 'Settings', 'hideSetupWizard' ], 'access' => 'any' ],
'settings/hide-upgrade-bar' => [ 'callback' => [ 'Settings', 'hideUpgradeBar' ], 'access' => 'any' ],
'settings/import' => [ 'callback' => [ 'Settings', 'importSettings' ], 'access' => 'aioseo_tools_settings' ],
Expand Down
6 changes: 3 additions & 3 deletions app/Common/Api/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ public static function deactivatePlugins( $request ) {
], 400 );
}

// Activate the plugin silently.
$activated = deactivate_plugins( $plugin['plugin'], false, $network );
deactivate_plugins( $plugin['plugin'], false, $network );

if ( is_wp_error( $activated ) ) {
$stillActive = $network ? is_plugin_active_for_network( $plugin['plugin'] ) : is_plugin_active( $plugin['plugin'] );
if ( $stillActive ) {
$failed[] = $plugin['plugin'];
}

Expand Down
1 change: 1 addition & 0 deletions app/Common/Core/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Core {
*/
private $aioseoTables = [
'aioseo_cache',
'aioseo_crawl_cleanup_logs',
'aioseo_links',
'aioseo_links_suggestions',
'aioseo_notifications',
Expand Down
2 changes: 1 addition & 1 deletion app/Common/ImportExport/RankMath/PostMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function scheduleImport() {
* @return void
*/
public function importPostMeta() {
$postsPerAction = 100;
$postsPerAction = apply_filters( 'aioseo_import_rank_math_posts_per_action', 100 );
$publicPostTypes = implode( "', '", aioseo()->helpers->getPublicPostTypes( true ) );
$timeStarted = gmdate( 'Y-m-d H:i:s', aioseo()->core->cache->get( 'import_post_meta_rank_math' ) );

Expand Down
2 changes: 1 addition & 1 deletion app/Common/ImportExport/SeoPress/PostMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function scheduleImport() {
* @return void
*/
public function importPostMeta() {
$postsPerAction = 100;
$postsPerAction = apply_filters( 'aioseo_import_seopress_posts_per_action', 100 );
$publicPostTypes = implode( "', '", aioseo()->helpers->getPublicPostTypes( true ) );
$timeStarted = gmdate( 'Y-m-d H:i:s', aioseo()->core->cache->get( 'import_post_meta_seopress' ) );

Expand Down
2 changes: 1 addition & 1 deletion app/Common/ImportExport/YoastSeo/PostMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function scheduleImport() {
* @return void
*/
public function importPostMeta() {
$postsPerAction = 100;
$postsPerAction = apply_filters( 'aioseo_import_yoast_seo_posts_per_action', 100 );
$publicPostTypes = implode( "', '", aioseo()->helpers->getPublicPostTypes( true ) );
$timeStarted = gmdate( 'Y-m-d H:i:s', aioseo()->core->cache->get( 'import_post_meta_yoast_seo' ) );

Expand Down
5 changes: 2 additions & 3 deletions app/Common/Schema/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ public function cleanAndParseData( $data, $parentKey = '', $replaceTags = true )
* @since 4.2.7
*
* @param array $schema The schema data.
* @param bool $isValidator Whether we're grabbing the output for the validator.
* @param bool $replaceTags Whether the smart tags should be replaced.
* @return string The schema as JSON.
*/
public function getOutput( $schema, $isValidator = false, $replaceTags = true ) {
public function getOutput( $schema, $replaceTags = true ) {
$schema['@graph'] = apply_filters( 'aioseo_schema_output', $schema['@graph'] );
$schema['@graph'] = $this->cleanAndParseData( $schema['@graph'], '', $replaceTags );

Expand All @@ -100,7 +99,7 @@ public function getOutput( $schema, $isValidator = false, $replaceTags = true )
// Some users report better SEO performance when non-Latin unicode characters are not escaped.
$jsonFlags = apply_filters( 'aioseo_schema_json_flags', 0 );

$json = isset( $_GET['aioseo-dev'] ) || $isValidator // phpcs:ignore HM.Security.NonceVerification.Recommended
$json = isset( $_GET['aioseo-dev'] ) || aioseo()->schema->generatingValidatorOutput // phpcs:ignore HM.Security.NonceVerification.Recommended
? aioseo()->helpers->wpJsonEncode( $schema, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE )
: aioseo()->helpers->wpJsonEncode( $schema, $jsonFlags );

Expand Down
19 changes: 13 additions & 6 deletions app/Common/Schema/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ class Schema {
]
];

/**
* Whether we are generating the validator output.
*
* @since 4.6.3
*
* @var bool
*/
public $generatingValidatorOutput = false;

/**
* Class constructor.
*/
Expand Down Expand Up @@ -209,10 +218,9 @@ protected function getGraphNamespace( $graphName ) {
*
* @since 4.2.5
*
* @param bool $isValidator Whether the current call is for the validator.
* @return void
*/
protected function determineSmartGraphsAndContext( $isValidator = false ) {
protected function determineSmartGraphsAndContext() {
$this->graphs = array_merge( $this->graphs, $this->getDefaultGraphs() );

$contextInstance = new Context();
Expand All @@ -233,7 +241,7 @@ protected function determineSmartGraphsAndContext( $isValidator = false ) {
}

if ( is_singular() ) {
$this->determineContextSingular( $contextInstance, $isValidator );
$this->determineContextSingular( $contextInstance );
}

if ( is_category() || is_tag() || is_tax() ) {
Expand Down Expand Up @@ -281,10 +289,9 @@ protected function determineSmartGraphsAndContext( $isValidator = false ) {
* @since 4.2.6
*
* @param Context $contextInstance The Context class instance.
* @param bool $isValidator Whether we're getting the output for the validator.
* @return void
*/
protected function determineContextSingular( $contextInstance, $isValidator ) {
protected function determineContextSingular( $contextInstance ) {
// Check if we're on a BuddyPress member page.
if ( function_exists( 'bp_is_user' ) && bp_is_user() ) {
$this->graphs[] = 'ProfilePage';
Expand All @@ -293,7 +300,7 @@ protected function determineContextSingular( $contextInstance, $isValidator ) {
// If the current request is for the validator, we can't include the default graph here.
// We need to include the default graph that the validator sent.
// Don't do this if we're in Pro since we then need to get it from the post meta.
if ( ! $isValidator ) {
if ( ! $this->generatingValidatorOutput ) {
$this->graphs[] = $this->getDefaultPostGraph();
}

Expand Down
60 changes: 32 additions & 28 deletions app/Common/SearchStatistics/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function init() {
}

/**
* Check whether the site is verified on Google Search Console.
* Check whether the site is verified on Google Search Console and verifies it if needed.
*
* @since 4.6.2
*
Expand All @@ -61,28 +61,15 @@ public function worker() {
return;
}

$siteStatus = $this->check();
$siteStatus = $this->checkStatus();
if ( empty( $siteStatus ) ) {
// If it failed to communicate with the server, try again in a few hours.
aioseo()->actionScheduler->scheduleSingle( $this->action, wp_rand( HOUR_IN_SECONDS, 4 * HOUR_IN_SECONDS ) );
aioseo()->actionScheduler->scheduleSingle( $this->action, wp_rand( HOUR_IN_SECONDS, 2 * HOUR_IN_SECONDS ), [], true );

return;
}

switch ( $siteStatus['code'] ) {
case 'site_verified':
aioseo()->internalOptions->searchStatistics->site->verified = true;
aioseo()->internalOptions->searchStatistics->site->lastFetch = time();
break;
case 'verification_needed':
$this->verify( $siteStatus['data'] );
break;
case 'site_not_found':
case 'couldnt_get_token':
default:
aioseo()->internalOptions->searchStatistics->site->verified = false;
aioseo()->internalOptions->searchStatistics->site->lastFetch = time();
}
$this->processStatus( $siteStatus );

// Schedule a new check for the next week.
aioseo()->actionScheduler->scheduleSingle( $this->action, WEEK_IN_SECONDS + wp_rand( 0, 3 * DAY_IN_SECONDS ), [], true );
Expand All @@ -100,20 +87,12 @@ public function maybeVerify() {
return;
}

$siteStatus = $this->check();
$siteStatus = $this->checkStatus();
if ( empty( $siteStatus ) ) {
return;
}

switch ( $siteStatus['code'] ) {
case 'site_verified':
aioseo()->internalOptions->searchStatistics->site->verified = true;
aioseo()->internalOptions->searchStatistics->site->lastFetch = time();
break;
case 'verification_needed':
$this->verify( $siteStatus['data'] );
break;
}
$this->processStatus( $siteStatus );
}

/**
Expand All @@ -123,7 +102,7 @@ public function maybeVerify() {
*
* @return array The site status.
*/
private function check() {
private function checkStatus() {
$api = new Api\Request( 'google-search-console/site/check/' );
$response = $api->request();

Expand All @@ -134,6 +113,31 @@ private function check() {
return $response;
}

/**
* Processes the site status.
*
* @since 4.6.3
*
* @param array $siteStatus The site status.
* @return void
*/
private function processStatus( $siteStatus ) {
switch ( $siteStatus['code'] ) {
case 'site_verified':
aioseo()->internalOptions->searchStatistics->site->verified = true;
aioseo()->internalOptions->searchStatistics->site->lastFetch = time();
break;
case 'verification_needed':
$this->verify( $siteStatus['data'] );
break;
case 'site_not_found':
case 'couldnt_get_token':
default:
aioseo()->internalOptions->searchStatistics->site->verified = false;
aioseo()->internalOptions->searchStatistics->site->lastFetch = time();
}
}

/**
* Verifies the site on Google Search Console.
*
Expand Down
76 changes: 39 additions & 37 deletions app/Common/SearchStatistics/Sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Sitemap {
*/
public function __construct() {
add_action( 'admin_init', [ $this, 'init' ] );
add_action( $this->action, [ $this, 'sync' ] );
add_action( $this->action, [ $this, 'worker' ] );
}

/**
Expand All @@ -41,6 +41,7 @@ public function __construct() {
public function init() {
if (
! aioseo()->searchStatistics->api->auth->isConnected() ||
! aioseo()->internalOptions->searchStatistics->site->verified ||
aioseo()->actionScheduler->isScheduled( $this->action )
) {
return;
Expand All @@ -49,6 +50,35 @@ public function init() {
aioseo()->actionScheduler->scheduleAsync( $this->action );
}

/**
* Sync the sitemap.
*
* @since 4.6.3
*
* @return void
*/
public function worker() {
if ( ! $this->canSync() ) {
return;
}

$api = new Api\Request( 'google-search-console/sitemap/sync/', [ 'sitemaps' => aioseo()->sitemap->helpers->getSitemapUrls() ] );
$response = $api->request();

if ( is_wp_error( $response ) ) {
// If it failed to communicate with the server, try again in a few hours.
aioseo()->actionScheduler->scheduleSingle( $this->action, wp_rand( HOUR_IN_SECONDS, 2 * HOUR_IN_SECONDS ), [], true );

return;
}

aioseo()->internalOptions->searchStatistics->sitemap->list = $response['data'];
aioseo()->internalOptions->searchStatistics->sitemap->lastFetch = time();

// Schedule a new sync for the next week.
aioseo()->actionScheduler->scheduleSingle( $this->action, WEEK_IN_SECONDS + wp_rand( 0, 3 * DAY_IN_SECONDS ), [], true );
}

/**
* Maybe sync the sitemap after updating the options.
* It will check whether the sitemap options have changed and sync the sitemap if needed.
Expand Down Expand Up @@ -89,31 +119,7 @@ public function maybeSync( $oldSitemapOptions, $newSitemapOptions ) {
}

aioseo()->actionScheduler->unschedule( $this->action );
$this->sync();
}

/**
* Sync the sitemap.
*
* @since 4.6.2
*
* @return void
*/
public function sync() {
if ( ! $this->canSync() ) {
return;
}

$api = new Api\Request( 'google-search-console/sitemap/sync/', [ 'sitemaps' => aioseo()->sitemap->helpers->getSitemapUrls() ] );
$response = $api->request();

if ( ! is_wp_error( $response ) ) {
aioseo()->internalOptions->searchStatistics->sitemap->list = $response['data'];
aioseo()->internalOptions->searchStatistics->sitemap->lastFetch = time();
}

// Schedule a new sync.
aioseo()->actionScheduler->scheduleSingle( $this->action, WEEK_IN_SECONDS + wp_rand( 1, 3 * DAY_IN_SECONDS ), [], true );
aioseo()->actionScheduler->scheduleAsync( $this->action );
}

/**
Expand All @@ -130,18 +136,14 @@ public function getSitemapsWithErrors() {
return [];
}

$errors = [];
$errors = [];
$pluginSitemaps = aioseo()->sitemap->helpers->getSitemapUrls();
foreach ( $sitemaps as $sitemap ) {
if ( empty( $sitemap['errors'] ) ) {
continue;
}

// Skip user-ignored sitemaps.
if ( in_array( $sitemap['path'], $ignored, true ) ) {
continue;
}

if ( in_array( $sitemap['path'], aioseo()->sitemap->helpers->getSitemapUrls(), true ) ) {
if (
empty( $sitemap['errors'] ) ||
in_array( $sitemap['path'], $ignored, true ) || // Skip user-ignored sitemaps.
in_array( $sitemap['path'], $pluginSitemaps, true ) // Skip plugin sitemaps.
) {
continue;
}

Expand Down
Loading

0 comments on commit 7667a1d

Please sign in to comment.