Skip to content

Commit 95c252e

Browse files
committed
4.8.7 Release
1 parent 20dd973 commit 95c252e

File tree

248 files changed

+1707
-15235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

248 files changed

+1707
-15235
lines changed

all_in_one_seo_pack.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 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.
66
* Author: All in One SEO Team
77
* Author URI: https://aioseo.com/
8-
* Version: 4.8.6
8+
* Version: 4.8.7
99
* Text Domain: all-in-one-seo-pack
1010
* Domain Path: /languages
1111
* License: GPL-3.0+

app/AIOSEO.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ private function includes() {
153153
$dependencies = [
154154
'/vendor/autoload.php' => true,
155155
'/vendor/woocommerce/action-scheduler/action-scheduler.php' => true,
156-
'/vendor/jwhennessey/phpinsight/autoload.php' => false,
157-
'/vendor_prefixed/monolog/monolog/src/Monolog/Logger.php' => false
156+
'/vendor/jwhennessey/phpinsight/autoload.php' => false
158157
];
159158

160159
foreach ( $dependencies as $path => $shouldRequire ) {

app/Common/Ai/Ai.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ public function __construct() {
4343
add_action( $this->creditFetchAction, [ $this, 'updateCredits' ] );
4444

4545
// If param is set, fetch credits but just once per 5 minutes to prevent abuse.
46-
if ( isset( $_REQUEST['aioseo-ai-credits'] ) && ! aioseo()->core->cache->get( 'ai_get_credits' ) ) { // phpcs:ignore HM.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Recommended
46+
if (
47+
isset( $_REQUEST['aioseo-ai-credits'] ) && // phpcs:ignore HM.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Recommended
48+
! aioseo()->core->cache->get( 'ai_get_credits' )
49+
) {
4750
add_action( 'init', [ $this, 'updateCredits' ] );
4851

4952
aioseo()->core->cache->update( 'ai_get_credits', true, 5 * MINUTE_IN_SECONDS );

app/Common/Api/Api.php

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ class Api {
3131
protected $routes = [
3232
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
3333
'GET' => [
34-
'options' => [ 'callback' => [ 'Settings', 'getOptions' ], 'access' => 'everyone' ],
35-
'ping' => [ 'callback' => [ 'Ping', 'ping' ], 'access' => 'everyone' ],
36-
'post' => [ 'callback' => [ 'PostsTerms', 'getPostData' ], 'access' => 'everyone' ],
34+
'options' => [ 'callback' => [ 'Settings', 'getOptions' ], 'access' => 'any' ],
35+
'ping' => [ 'callback' => [ 'Ping', 'ping' ], 'access' => 'any' ],
36+
'post' => [ 'callback' => [ 'PostsTerms', 'getPostData' ], 'access' => 'any' ],
3737
'post/(?P<postId>[\d]+)/first-attached-image' => [ 'callback' => [ 'PostsTerms', 'getFirstAttachedImage' ], 'access' => 'aioseo_page_social_settings' ],
3838
'user/(?P<userId>[\d]+)/image' => [ 'callback' => [ 'User', 'getUserImage' ], 'access' => 'aioseo_page_social_settings' ],
39-
'tags' => [ 'callback' => [ 'Tags', 'getTags' ], 'access' => 'everyone' ],
39+
'tags' => [ 'callback' => [ 'Tags', 'getTags' ], 'access' => 'any' ],
4040
'search-statistics/url/auth' => [ 'callback' => [ 'SearchStatistics', 'getAuthUrl' ], 'access' => [ 'aioseo_search_statistics_settings', 'aioseo_general_settings', 'aioseo_setup_wizard' ] ], // phpcs:ignore Generic.Files.LineLength.MaxExceeded
4141
'search-statistics/url/reauth' => [ 'callback' => [ 'SearchStatistics', 'getReauthUrl' ], 'access' => [ 'aioseo_search_statistics_settings', 'aioseo_general_settings' ] ],
4242
'writing-assistant/keyword/(?P<postId>[\d]+)' => [ 'callback' => [ 'WritingAssistant', 'getPostKeyword' ], 'access' => 'aioseo_page_writing_assistant_settings' ],
@@ -74,7 +74,7 @@ class Api {
7474
'terms-list/update-details-column' => [ 'callback' => [ 'PostsTerms', 'updateTermDetailsColumn' ], 'access' => 'aioseo_page_general_settings' ],
7575
'keyphrases' => [ 'callback' => [ 'PostsTerms', 'updatePostKeyphrases' ], 'access' => 'aioseo_page_analysis' ],
7676
'analyze' => [ 'callback' => [ 'Analyze', 'analyzeSite' ], 'access' => 'aioseo_seo_analysis_settings' ],
77-
'analyze-headline' => [ 'callback' => [ 'Analyze', 'analyzeHeadline' ], 'access' => 'everyone' ],
77+
'analyze-headline' => [ 'callback' => [ 'Analyze', 'analyzeHeadline' ], 'access' => 'any' ],
7878
'analyze-headline/delete' => [ 'callback' => [ 'Analyze', 'deleteHeadline' ], 'access' => 'aioseo_seo_analysis_settings' ],
7979
'analyze/delete-site' => [ 'callback' => [ 'Analyze', 'deleteSite' ], 'access' => 'aioseo_seo_analysis_settings' ],
8080
'clear-log' => [ 'callback' => [ 'Tools', 'clearLog' ], 'access' => 'aioseo_tools_settings' ],
@@ -100,7 +100,7 @@ class Api {
100100
'notification/v3-migration-schema-number-reminder' => [ 'callback' => [ 'Notifications', 'migrationSchemaNumberReminder' ], 'access' => 'any' ],
101101
'notifications/dismiss' => [ 'callback' => [ 'Notifications', 'dismissNotifications' ], 'access' => 'any' ],
102102
'objects' => [ 'callback' => [ 'PostsTerms', 'searchForObjects' ], 'access' => [ 'aioseo_search_appearance_settings', 'aioseo_sitemap_settings' ] ], // phpcs:ignore Generic.Files.LineLength.MaxExceeded
103-
'options' => [ 'callback' => [ 'Settings', 'saveChanges' ], 'access' => 'any' ],
103+
'options' => [ 'callback' => [ 'Settings', 'saveChanges' ], 'access' => 'options' ],
104104
'plugins/deactivate' => [ 'callback' => [ 'Plugins', 'deactivatePlugins' ], 'access' => 'aioseo_feature_manager_settings' ],
105105
'plugins/install' => [ 'callback' => [ 'Plugins', 'installPlugins' ], 'access' => [ 'install_plugins', 'aioseo_feature_manager_settings' ] ],
106106
'plugins/upgrade' => [ 'callback' => [ 'Plugins', 'upgradePlugins' ], 'access' => [ 'update_plugins', 'aioseo_feature_manager_settings' ] ],
@@ -308,9 +308,34 @@ public function validateAccess( $request ) {
308308
}
309309

310310
switch ( $routeData['access'] ) {
311-
case 'everyone':
312-
// Any user is able to access the route.
313-
return true;
311+
case 'any':
312+
// The user has access if he has any of our capabilities.
313+
$user = wp_get_current_user();
314+
$aioseoCaps = aioseo()->access->getCapabilityList();
315+
foreach ( $user->get_role_caps() as $capability => $enabled ) {
316+
if ( $enabled && in_array( $capability, $aioseoCaps, true ) ) {
317+
return true;
318+
}
319+
}
320+
321+
return false;
322+
case 'options':
323+
// Check that user has access to any of the options pages.
324+
$user = wp_get_current_user();
325+
$aioseoCaps = aioseo()->access->getCapabilityList();
326+
327+
// Remove all caps that start with aioseo_page_
328+
$aioseoCaps = array_filter( $aioseoCaps, function( $capability ) {
329+
return strpos( $capability, 'aioseo_page_' ) !== 0;
330+
} );
331+
332+
foreach ( $user->get_role_caps() as $capability => $enabled ) {
333+
if ( $enabled && in_array( $capability, $aioseoCaps, true ) ) {
334+
return true;
335+
}
336+
}
337+
338+
return false;
314339
default:
315340
return aioseo()->access->hasCapability( $routeData['access'] );
316341
}

app/Common/Api/PostsTerms.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,33 @@ public static function searchForObjects( $request ) {
129129
* @return \WP_REST_Response The response.
130130
*/
131131
public static function getPostData( $request ) {
132-
$args = $request->get_query_params();
132+
$args = $request->get_query_params();
133+
$postId = $args['postId'] ?? null;
133134

134-
if ( empty( $args['postId'] ) ) {
135+
if ( empty( $postId ) ) {
135136
return new \WP_REST_Response( [
136137
'success' => false,
137138
'message' => 'No post ID was provided.'
138139
], 400 );
139140
}
140141

142+
if ( ! current_user_can( 'edit_post', $postId ) ) {
143+
return new \WP_REST_Response( [
144+
'success' => false,
145+
'message' => 'You are not allowed to access the data for this post.'
146+
], 403 );
147+
}
148+
149+
$data = aioseo()->helpers->getVueData( 'post', $postId, $args['integrationSlug'] ?? null );
150+
141151
return new \WP_REST_Response( [
142152
'success' => true,
143-
'data' => aioseo()->helpers->getVueData( 'post', $args['postId'], $args['integrationSlug'] ?? null )
153+
'data' => [
154+
// We just send the minimum data that is needed for the post settings. See #7461
155+
'currentPost' => $data['currentPost'],
156+
'redirects' => ! empty( $data['redirects'] ) ? $data['redirects'] : null,
157+
'seoRevisions' => ! empty( $data['seoRevisions'] ) ? $data['seoRevisions'] : null
158+
]
144159
], 200 );
145160
}
146161

app/Common/Breadcrumbs/Block.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ class Block {
2121
*/
2222
private $primaryTerm = [];
2323

24+
/**
25+
* The post title.
26+
*
27+
* @since 4.8.7
28+
*
29+
* @var string
30+
*/
31+
private $postTitle = '';
32+
2433
/**
2534
* The breadcrumb settings.
2635
*
@@ -63,6 +72,10 @@ public function register() {
6372
'type' => 'string',
6473
'default' => null
6574
],
75+
'postTitle' => [
76+
'type' => 'string',
77+
'default' => null
78+
],
6679
'breadcrumbSettings' => [
6780
'type' => 'object',
6881
'default' => $this->breadcrumbSettings
@@ -90,6 +103,8 @@ public function render( $blockAttributes ) { // phpcs:ignore VariableAnalysis.Co
90103
$this->primaryTerm = json_decode( $blockAttributes['primaryTerm'], true );
91104
}
92105

106+
$this->postTitle = $blockAttributes['postTitle'] ?? null;
107+
93108
if ( ! empty( $blockAttributes['breadcrumbSettings'] ) ) {
94109
$this->breadcrumbSettings = $blockAttributes['breadcrumbSettings'];
95110
}
@@ -156,7 +171,9 @@ public function temporarilyAddTerm( $terms, $objectIds, $taxonomies ) {
156171
private function getBlockOverrides() {
157172
$default = filter_var( $this->breadcrumbSettings['default'], FILTER_VALIDATE_BOOLEAN );
158173
if ( true === $default || ! aioseo()->pro ) {
159-
return [];
174+
return [
175+
'postTitle' => ! empty( $this->postTitle ) ? $this->postTitle : null
176+
];
160177
}
161178

162179
return [
@@ -174,7 +191,8 @@ private function getBlockOverrides() {
174191
'templateType' => 'custom',
175192
'template' => aioseo()->helpers->decodeHtmlEntities( aioseo()->helpers->encodeOutputHtml( $this->breadcrumbSettings['parentTemplate'] ) )
176193
],
177-
'primaryTerm' => ! empty( $this->primaryTerm[ $this->breadcrumbSettings['taxonomy'] ] ) ? $this->primaryTerm[ $this->breadcrumbSettings['taxonomy'] ] : null
194+
'primaryTerm' => ! empty( $this->primaryTerm[ $this->breadcrumbSettings['taxonomy'] ] ) ? $this->primaryTerm[ $this->breadcrumbSettings['taxonomy'] ] : null,
195+
'postTitle' => ! empty( $this->postTitle ) ? $this->postTitle : null
178196
];
179197
}
180198
}

app/Common/Breadcrumbs/Breadcrumbs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ public function getOverride( $optionName = null ) {
765765
return $optionName ? null : [];
766766
}
767767

768-
$value = $this->override[ $optionName ] ?? null;
768+
$value = isset( $this->override[ $optionName ] ) ? $this->override[ $optionName ] : null;
769769

770770
return $optionName ? $value : $this->override;
771771
}

app/Common/EmailReports/Summary/Summary.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ public function maybeSchedule() {
132132
$addToStart += aioseo()->helpers->generateRandomTimeOffset( aioseo()->helpers->getSiteDomain( true ), 1440 * 3 ) * MINUTE_IN_SECONDS;
133133

134134
foreach ( $allowedFrequencies as $frequency => $data ) {
135+
if ( aioseo()->actionScheduler->isScheduled( $this->actionHook, compact( 'frequency' ) ) ) {
136+
continue;
137+
}
138+
135139
aioseo()->actionScheduler->scheduleRecurrent( $this->actionHook, $data['start'] + $addToStart, $data['interval'], compact( 'frequency' ) );
136140
}
137141
}

app/Common/Integrations/Semrush.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ public static function getKeyphrases( $keyphrase, $database ) {
201201
return $results;
202202
}
203203

204+
$accessToken = aioseo()->internalOptions->integrations->semrush->accessToken;
205+
if ( empty( $accessToken ) ) {
206+
return false;
207+
}
208+
204209
$params = [
205210
'phrase' => $keyphrase,
206211
'export_columns' => 'Ph,Nq,Td',
@@ -209,13 +214,28 @@ public static function getKeyphrases( $keyphrase, $database ) {
209214
'display_offset' => 0,
210215
'display_sort' => 'nq_desc',
211216
'display_filter' => '%2B|Nq|Lt|1000',
212-
'access_token' => aioseo()->internalOptions->integrations->semrush->accessToken
217+
'access_token' => $accessToken
213218
];
214219

215220
$url = 'https://oauth.semrush.com/api/v1/keywords/phrase_fullsearch?' . http_build_query( $params );
216221

217-
$response = wp_remote_get( $url );
218-
$body = json_decode( wp_remote_retrieve_body( $response ) );
222+
$response = wp_remote_get( $url, [
223+
'timeout' => 30,
224+
'headers' => [
225+
'User-Agent' => 'AIOSEO/' . AIOSEO_VERSION
226+
]
227+
] );
228+
229+
if ( is_wp_error( $response ) ) {
230+
return false;
231+
}
232+
233+
$responseCode = wp_remote_retrieve_response_code( $response );
234+
if ( 200 !== $responseCode ) {
235+
return false;
236+
}
237+
238+
$body = json_decode( wp_remote_retrieve_body( $response ) );
219239

220240
aioseo()->core->cache->update( $transientKey, $body );
221241

app/Common/Llms/Llms.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private function getSitemapUrl() {
173173
return '';
174174
}
175175

176-
$sitemapUrl = site_url( 'sitemap.xml' );
176+
$sitemapUrl = aioseo()->sitemap->helpers->getUrl( 'general' );
177177

178178
return "## Sitemaps\n\n- [XML Sitemap]({$sitemapUrl}): Contains all public/indexable URLs for this website.\n\n";
179179
}
@@ -267,7 +267,7 @@ public function headers() {
267267
* @return array The LLMs.txt URL if accessible, null otherwise.
268268
*/
269269
public function getUrl() {
270-
$url = site_url( '/llms.txt' );
270+
$url = home_url( '/llms.txt' );
271271
$isAccessible = false;
272272

273273
if ( aioseo()->options->advanced->llmsTxt ) {

0 commit comments

Comments
 (0)