Skip to content

Commit

Permalink
4.7.7 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian-rossi committed Dec 12, 2024
1 parent 76db715 commit f065a31
Show file tree
Hide file tree
Showing 177 changed files with 1,500 additions and 880 deletions.
6 changes: 3 additions & 3 deletions 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.7.6
* Version: 4.7.7
* Text Domain: all-in-one-seo-pack
* Domain Path: /languages
* License: GPL-3.0+
Expand Down Expand Up @@ -59,8 +59,8 @@

// We require WordPress 5.3+ for the whole plugin to work.
// Support for 5.3 is scheduled to be dropped in April 2025. 5.4, 5.5 and 5.6 will be dropped at the end of 2025.
global $wp_version;
if ( version_compare( $wp_version, '5.3', '<' ) ) {
global $wp_version; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
if ( version_compare( $wp_version, '5.3', '<' ) ) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName
add_action( 'admin_notices', 'aioseo_wordpress_notice' );

// Do not process the plugin code further.
Expand Down
12 changes: 6 additions & 6 deletions app/AIOSEOAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,11 @@ abstract class AIOSEOAbstract {
public $thirdParty = null;

/**
* WritingAssistant class instance.
*
* @since 4.7.4
*
* @var null|\AIOSEO\Plugin\Common\WritingAssistant\WritingAssistant
*/
* WritingAssistant class instance.
*
* @since 4.7.4
*
* @var \AIOSEO\Plugin\Common\WritingAssistant\WritingAssistant
*/
public $writingAssistant = null;
}
140 changes: 84 additions & 56 deletions app/Common/Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ class Admin {
*/
public $connect = null;

/**
* Whether we're editing a post or term.
*
* @since 4.7.7
*
* @var bool
*/
private $isEditor = false;

/**
* Construct method.
*
Expand Down Expand Up @@ -135,7 +144,7 @@ public function deactivationSurvey() {
* @return string The possibly modified HTML language attribute.
*/
public function alwaysAddHtmlDirAttribute( $output ) {
if ( is_rtl() || preg_match( '/dir=[\'"](ltr|rtl|auto)[\'"]/i', $output ) ) {
if ( is_rtl() || preg_match( '/dir=[\'"](ltr|rtl|auto)[\'"]/i', (string) $output ) ) {
return $output;
}

Expand Down Expand Up @@ -276,8 +285,8 @@ private function registerLinkFormatHooks() {

add_action( 'wp_enqueue_editor', [ $this, 'addClassicLinkFormatScript' ], 999999 );

global $wp_version;
if ( version_compare( $wp_version, '5.3', '>=' ) || is_plugin_active( 'gutenberg/gutenberg.php' ) ) {
global $wp_version; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
if ( version_compare( $wp_version, '5.3', '>=' ) || is_plugin_active( 'gutenberg/gutenberg.php' ) ) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName
add_action( 'current_screen', [ $this, 'addGutenbergLinkFormatScript' ] );
add_action( 'enqueue_block_editor_assets', [ $this, 'enqueueBlockEditorLinkFormat' ] );
}
Expand Down Expand Up @@ -418,7 +427,6 @@ public function addGutenbergLinkFormatScript() {
*/
public function adminBarMenu() {
if ( false === apply_filters( 'aioseo_show_in_admin_bar', true ) ) {
// API filter hook to disable showing SEO in admin bar.
return;
}

Expand All @@ -427,21 +435,21 @@ public function adminBarMenu() {
return;
}

$classes = is_admin()
$classes = is_admin()
? 'wp-core-ui wp-ui-notification aioseo-menu-notification-counter'
: 'aioseo-menu-notification-counter aioseo-menu-notification-counter-frontend';
$count = count( Models\Notification::getAllActiveNotifications() );
$htmlCount = 10 > $count ? $count : '!';
$htmlCount = $htmlCount ? "<div class=\"{$classes}\">" . $htmlCount . '</div>' : '';
$htmlCount .= '<div id="aioseo-menu-new-notifications"></div>';
$notificationCount = count( Models\Notification::getAllActiveNotifications() );
$htmlCount = 10 > $notificationCount ? $notificationCount : '!';
$htmlCount = $htmlCount ? "<div class=\"{$classes}\">" . $htmlCount . '</div>' : '';
$htmlCount .= '<div id="aioseo-menu-new-notifications"></div>';

$this->adminBarMenuItems[] = [
'id' => 'aioseo-main',
'title' => '<div class="ab-item aioseo-logo svg"></div><span class="text">' . esc_html__( 'SEO', 'all-in-one-seo-pack' ) . '</span>' . wp_kses_post( $htmlCount ),
'href' => esc_url( admin_url( 'admin.php?page=' . $firstPageSlug ) )
];

if ( $count ) {
if ( $notificationCount ) {
$this->adminBarMenuItems[] = [
'parent' => 'aioseo-main',
'id' => 'aioseo-notifications',
Expand All @@ -452,14 +460,22 @@ public function adminBarMenu() {

$this->adminBarMenuItems[] = aioseo()->standalone->seoPreview->getAdminBarMenuItemNode();

$currentScreen = aioseo()->helpers->getCurrentScreen();
if (
is_admin() &&
( 'post' === $currentScreen->base || 'term' === $currentScreen->base )
) {
$this->isEditor = true;
}

$htmlSitemapRequested = aioseo()->htmlSitemap->isDedicatedPage;
if ( ! is_admin() && ! $htmlSitemapRequested ) {
if ( $htmlSitemapRequested || ! is_admin() || $this->isEditor ) {
$this->addPageAnalyzerMenuItems();
}

if ( $htmlSitemapRequested ) {
global $wp_admin_bar;
$wp_admin_bar->remove_node( 'edit' );
global $wp_admin_bar; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
$wp_admin_bar->remove_node( 'edit' ); // phpcs:ignore Squiz.NamingConventions.ValidVariableName
}

$this->addSettingsMenuItems();
Expand All @@ -477,9 +493,9 @@ public function adminBarMenu() {
* @return void
*/
protected function addAdminBarMenuItems() {
global $wp_admin_bar;
global $wp_admin_bar; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
foreach ( $this->adminBarMenuItems as $item ) {
$wp_admin_bar->add_menu( $item );
$wp_admin_bar->add_menu( $item ); // phpcs:ignore Squiz.NamingConventions.ValidVariableName
}
}

Expand All @@ -491,9 +507,31 @@ protected function addAdminBarMenuItems() {
* @return void
*/
public function addPageAnalyzerMenuItems() {
global $wp;
// Make sure the trailing slash matches the site configuration.
$url = user_trailingslashit( home_url( $wp->request ) );
$url = '';
$currentScreen = aioseo()->helpers->getCurrentScreen();
if (
is_singular() ||
( is_admin() && 'post' === $currentScreen->base )
) {
$post = aioseo()->helpers->getPost();
if ( is_a( $post, 'WP_Post' ) && 'publish' === $post->post_status && '' !== $post->post_name ) {
$url = get_permalink( $post->ID );
}
}

if (
is_category() ||
is_tag() ||
is_tax() ||
( is_admin() && 'term' === $currentScreen->base )
) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, HM.Security.NonceVerification.Recommended
$termId = ! empty( $_REQUEST['tag_ID'] ) ? intval( $_REQUEST['tag_ID'] ) : 0;
$term = is_admin() && $termId ? get_term( $termId ) : get_queried_object();
if ( is_a( $term, 'WP_Term' ) ) {
$url = get_term_link( $term );
}
}

if ( ! $url ) {
return;
Expand All @@ -502,61 +540,51 @@ public function addPageAnalyzerMenuItems() {
$this->adminBarMenuItems[] = [
'id' => 'aioseo-analyze-page',
'parent' => 'aioseo-main',
'title' => esc_html__( 'Analyze this page', 'all-in-one-seo-pack' ),
'title' => esc_html__( 'Analyze this page', 'all-in-one-seo-pack' )
];

$url = urlencode( $url );

$submenuItems = [
[
'id' => 'aioseo-analyze-page-inlinks',
'title' => esc_html__( 'Check links to this URL', 'all-in-one-seo-pack' ),
'href' => 'https://search.google.com/search-console/links/drilldown?resource_id=' . urlencode( get_option( 'siteurl' ) ) . '&type=EXTERNAL&target=' . $url . '&domain=',
'id' => 'aioseo-analyze-page-pagespeed',
'title' => esc_html__( 'Google Page Speed Test', 'all-in-one-seo-pack' ),
'href' => 'https://pagespeed.web.dev/report?url=' . $url
],
[
'id' => 'aioseo-analyze-page-cache',
'title' => esc_html__( 'Check Google Cache', 'all-in-one-seo-pack' ),
'href' => '//webcache.googleusercontent.com/search?strip=1&q=cache:' . $url,
'id' => 'aioseo-analyze-page-structureddata',
'title' => esc_html__( 'Google Rich Results Test', 'all-in-one-seo-pack' ),
'href' => 'https://search.google.com/test/rich-results?url=' . $url
],
[
'id' => 'aioseo-analyze-page-structureddata',
'title' => esc_html__( 'Google Rich Results Test', 'all-in-one-seo-pack' ),
'href' => 'https://search.google.com/test/rich-results?url=' . $url,
'title' => esc_html__( 'Schema.org Validator', 'all-in-one-seo-pack' ),
'href' => 'https://validator.schema.org/?url=' . $url
],
[
'id' => 'aioseo-analyze-page-inlinks',
'title' => esc_html__( 'Inbound Links', 'all-in-one-seo-pack' ),
'href' => 'https://search.google.com/search-console/links/drilldown?resource_id=' . urlencode( get_option( 'siteurl' ) ) . '&type=EXTERNAL&target=' . $url . '&domain='
],
[
'id' => 'aioseo-analyze-page-facebookdebug',
'title' => esc_html__( 'Facebook Debugger', 'all-in-one-seo-pack' ),
'href' => 'https://developers.facebook.com/tools/debug/?q=' . $url,
'href' => 'https://developers.facebook.com/tools/debug/?q=' . $url
],
[
'id' => 'aioseo-analyze-page-pinterestvalidator',
'title' => esc_html__( 'Pinterest Rich Pins Validator', 'all-in-one-seo-pack' ),
'href' => 'https://developers.pinterest.com/tools/url-debugger/?link=' . $url,
'id' => 'aioseo-external-tools-linkedin-post-inspector',
'title' => esc_html__( 'LinkedIn Post Inspector', 'all-in-one-seo-pack' ),
'href' => "https://www.linkedin.com/post-inspector/inspect/$url"
],
[
'id' => 'aioseo-analyze-page-htmlvalidation',
'title' => esc_html__( 'HTML Validator', 'all-in-one-seo-pack' ),
'href' => '//validator.w3.org/check?uri=' . $url,
'href' => '//validator.w3.org/check?uri=' . $url
],
[
'id' => 'aioseo-analyze-page-cssvalidation',
'title' => esc_html__( 'CSS Validator', 'all-in-one-seo-pack' ),
'href' => '//jigsaw.w3.org/css-validator/validator?uri=' . $url,
],
[
'id' => 'aioseo-analyze-page-pagespeed',
'title' => esc_html__( 'Google Page Speed Test', 'all-in-one-seo-pack' ),
'href' => 'https://pagespeed.web.dev/report?url=' . $url,
],
[
'id' => 'aioseo-analyze-page-google-mobile-friendly',
'title' => esc_html__( 'Mobile-Friendly Test', 'all-in-one-seo-pack' ),
'href' => 'https://www.google.com/webmasters/tools/mobile-friendly/?url=' . $url,
],
[
'id' => 'aioseo-external-tools-linkedin-post-inspector',
'title' => esc_html__( 'LinkedIn Post Inspector', 'all-in-one-seo-pack' ),
'href' => "https://www.linkedin.com/post-inspector/inspect/$url"
'href' => '//jigsaw.w3.org/css-validator/validator?uri=' . $url
]
];

Expand All @@ -566,7 +594,7 @@ public function addPageAnalyzerMenuItems() {
'id' => $item['id'],
'title' => $item['title'],
'href' => $item['href'],
'meta' => [ 'target' => '_blank' ],
'meta' => [ 'target' => '_blank' ]
];
}
}
Expand Down Expand Up @@ -610,7 +638,7 @@ protected function addEditSeoMenuItem() {
* @return void
*/
protected function addSettingsMenuItems() {
if ( ! is_admin() ) {
if ( ! is_admin() || $this->isEditor ) {
$this->adminBarMenuItems[] = [
'id' => 'aioseo-settings-main',
'parent' => 'aioseo-main',
Expand All @@ -619,7 +647,7 @@ protected function addSettingsMenuItems() {
];
}

$parent = is_admin() ? 'aioseo-main' : 'aioseo-settings-main';
$parent = is_admin() && ! $this->isEditor ? 'aioseo-main' : 'aioseo-settings-main';
foreach ( $this->pages as $id => $page ) {
// Remove page from admin bar menu.
if ( ! empty( $page['hide_admin_bar_menu'] ) ) {
Expand Down Expand Up @@ -791,9 +819,9 @@ public function page() {
*/
public function hooks() {
$currentScreen = aioseo()->helpers->getCurrentScreen();
global $admin_page_hooks;
global $admin_page_hooks; // phpcs:ignore Squiz.NamingConventions.ValidVariableName

if ( ! is_object( $currentScreen ) || empty( $currentScreen->id ) || empty( $admin_page_hooks ) ) {
if ( ! is_object( $currentScreen ) || empty( $currentScreen->id ) || empty( $admin_page_hooks ) ) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName
return;
}

Expand Down Expand Up @@ -822,7 +850,7 @@ public function hooks() {
$addScripts = true;
}

if ( ! empty( $admin_page_hooks['aioseo'] ) && $currentScreen->id === $admin_page_hooks['aioseo'] ) {
if ( ! empty( $admin_page_hooks['aioseo'] ) && $currentScreen->id === $admin_page_hooks['aioseo'] ) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName
$addScripts = true;
}

Expand Down Expand Up @@ -968,13 +996,13 @@ public function addFooterText() {
);

// Stop WP Core from outputting its version number and instead add both theirs & ours.
global $wp_version;
global $wp_version; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
printf(
wp_kses_post( '<p class="alignright">%1$s</p>' ),
sprintf(
// Translators: 1 - WP Core version number, 2 - AIOSEO version number.
esc_html__( 'WordPress %1$s | AIOSEO %2$s', 'all-in-one-seo-pack' ),
esc_html( $wp_version ),
esc_html( $wp_version ), // phpcs:ignore Squiz.NamingConventions.ValidVariableName
esc_html( AIOSEO_VERSION )
)
);
Expand Down
4 changes: 2 additions & 2 deletions app/Common/Admin/Notices/DeprecatedWordPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct() {
* @return void
*/
public function maybeShowNotice() {
global $wp_version;
global $wp_version; // phpcs:ignore Squiz.NamingConventions.ValidVariableName

$dismissed = get_option( '_aioseo_deprecated_wordpress_dismissed', true );
if ( '1' === $dismissed ) {
Expand All @@ -42,7 +42,7 @@ public function maybeShowNotice() {
}

// Only show if WordPress version is deprecated.
if ( version_compare( $wp_version, '5.3', '>=' ) ) {
if ( version_compare( $wp_version, '5.3', '>=' ) ) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName
return;
}

Expand Down
4 changes: 2 additions & 2 deletions app/Common/Admin/Notices/Notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ public function validateType( $type ) {
*/
public function versionMatch( $currentVersion, $compareVersion ) {
if ( is_array( $compareVersion ) ) {
foreach ( $compareVersion as $compare_single ) {
$recursiveResult = $this->versionMatch( $currentVersion, $compare_single );
foreach ( $compareVersion as $compare_single ) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName
$recursiveResult = $this->versionMatch( $currentVersion, $compare_single ); // phpcs:ignore Squiz.NamingConventions.ValidVariableName
if ( $recursiveResult ) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion app/Common/Admin/PostSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public function changeClausesToFilterPosts( $clauses, $query = null ) {
*/
public function filterPostsAfterChangingClauses() {
remove_action( 'wp', [ $this, 'filterPostsAfterChangingClauses' ] );

// phpcs:disable Squiz.NamingConventions.ValidVariableName
global $wp_query;
if ( ! empty( $wp_query->posts ) && is_array( $wp_query->posts ) ) {
$wp_query->posts = array_filter( $wp_query->posts, function ( $post ) {
Expand All @@ -419,5 +419,6 @@ public function filterPostsAfterChangingClauses() {
$wp_query->post_count = count( $wp_query->posts );
}
}
// phpcs:enable Squiz.NamingConventions.ValidVariableName
}
}
5 changes: 3 additions & 2 deletions app/Common/Api/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ class Api {
'email-debug-info' => [ 'callback' => [ 'Tools', 'emailDebugInfo' ], 'access' => 'aioseo_tools_settings' ],
'migration/fix-blank-formats' => [ 'callback' => [ 'Migration', 'fixBlankFormats' ], 'access' => 'any' ],
'notification/blog-visibility-reminder' => [ 'callback' => [ 'Notifications', 'blogVisibilityReminder' ], 'access' => 'any' ],
'notification/description-format-reminder' => [ 'callback' => [ 'Notifications', 'descriptionFormatReminder' ], 'access' => 'any' ],
'notification/conflicting-plugins-reminder' => [ 'callback' => [ 'Notifications', 'conflictingPluginsReminder' ], 'access' => 'any' ],
'notification/description-format-reminder' => [ 'callback' => [ 'Notifications', 'descriptionFormatReminder' ], 'access' => 'any' ],
'notification/email-reports-enable' => [ 'callback' => [ 'EmailSummary', 'enableEmailReports' ], 'access' => 'any' ],
'notification/install-addons-reminder' => [ 'callback' => [ 'Notifications', 'installAddonsReminder' ], 'access' => 'any' ],
'notification/install-aioseo-image-seo-reminder' => [ 'callback' => [ 'Notifications', 'installImageSeoReminder' ], 'access' => 'any' ],
'notification/install-aioseo-local-business-reminder' => [ 'callback' => [ 'Notifications', 'installLocalBusinessReminder' ], 'access' => 'any' ],
Expand Down Expand Up @@ -327,7 +328,7 @@ protected function getRouteData( $request ) {
if ( empty( $routeData ) ) {
foreach ( $this->getRoutes()[ $request->get_method() ] as $routeRegex => $routeInfo ) {
$routeRegex = str_replace( '@', '\@', $routeRegex );
if ( preg_match( "@{$routeRegex}@", $route ) ) {
if ( preg_match( "@{$routeRegex}@", (string) $route ) ) {
$routeData = $routeInfo;
break;
}
Expand Down
Loading

0 comments on commit f065a31

Please sign in to comment.