Skip to content

Commit

Permalink
4.5.7.1 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian-rossi committed Feb 22, 2024
1 parent 1f3c8ed commit 70bdd9b
Show file tree
Hide file tree
Showing 54 changed files with 2,102 additions and 1,791 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.5.6
* Version: 4.5.7.1
* Text Domain: all-in-one-seo-pack
* Domain Path: /languages
*
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Api/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function validateAccess( $request ) {
// Any user is able to access the route.
return true;
default:
return current_user_can( apply_filters( 'aioseo_manage_seo', 'aioseo_manage_seo' ) );
return aioseo()->access->hasCapability( $routeData['access'] );
}
}

Expand Down
9 changes: 3 additions & 6 deletions app/Common/Api/PostsTerms.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,6 @@ public static function processContent( $request ) {
], 400 );
}

// Check if the content was passed, otherwise get it from the post.
$content = $body['content'] ?? '';
if ( empty( $content ) ) {
$content = aioseo()->helpers->getPostContent( $args['postId'] );
}

// Check if we can process it using a page builder integration.
$pageBuilder = aioseo()->helpers->getPostPageBuilderName( $args['postId'] );
if ( ! empty( $pageBuilder ) ) {
Expand All @@ -505,6 +499,9 @@ public static function processContent( $request ) {
], 200 );
}

// Check if the content was passed, otherwise get it from the post.
$content = $body['content'] ?? aioseo()->helpers->getPostContent( $args['postId'] );

return new \WP_REST_Response( [
'success' => true,
'content' => apply_filters( 'the_content', $content ),
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Api/Sitemaps.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static function validateHtmlSitemapSlug( $request ) {
], 400 );
}

$pathExists = self::pathExists( $parsedPageUrl['path'], $isUrl );
$pathExists = self::pathExists( $parsedPageUrl['path'], false );

return new \WP_REST_Response( [
'exists' => $pathExists
Expand Down
9 changes: 3 additions & 6 deletions app/Common/ImportExport/RankMath/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,18 @@ protected function getMacros( $pageType = null ) {
'%term_description%' => '#taxonomy_description',
'%currentdate%' => '#current_date',
'%currentday%' => '#current_day',
'%currentyear%' => '#current_year',
'%currentmonth%' => '#current_month',
'%name%' => '#author_first_name #author_last_name',
'%author%' => '#author_first_name #author_last_name',
'%date%' => '#post_date',
'%year%' => '#current_year',
'%search_query%' => '#search_term',
// RSS Content tags.
'%AUTHORLINK%' => '#author_link',
'%POSTLINK%' => '#post_link',
'%BLOGLINK%' => '#site_link',
/* '%seo_description%' => '',
'%user_description%' => '',
'%wc_price%' => '',
'%page%' => '',
'%FEATUREDIMAGE%' => '',
'%filename%' => '',*/
'%FEATUREDIMAGE%' => '#featured_image'
];

switch ( $pageType ) {
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Models/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#[\AllowDynamicProperties]
class Model implements \JsonSerializable {
/**
* Fields that should be null when saving to the database.
* Fields that can be null when saving to the database.
*
* @since 4.0.0
*
Expand Down
11 changes: 11 additions & 0 deletions app/Common/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ class Post extends Model {
'limit_modified_date',
];

/**
* Fields that can be null when saved.
*
* @since 4.5.7
*
* @var array
*/
protected $nullFields = [
'priority'
];

/**
* Returns a Post with a given ID.
*
Expand Down
2 changes: 2 additions & 0 deletions app/Common/Options/DynamicOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ protected function addDynamicTaxonomyDefaults() {
]
);

$this->setDynamicSitemapOptions( 'taxonomies', $taxonomy['name'] );

$this->defaults['searchAppearance']['taxonomies'][ $taxonomy['name'] ] = $defaultOptions;
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/Common/Sitemap/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ public function author() {
// e.g. there might be additional roles/conditions that need to be checked here.
$authors = apply_filters( 'aioseo_sitemap_authors', [] );
if ( empty( $authors ) ) {
$authors = aioseo()->core->db->start( 'users as u' )
$usersTableName = aioseo()->core->db->db->users; // We get the table name from WPDB since multisites share the same table.
$authors = aioseo()->core->db->start( "$usersTableName as u", true )
->select( 'u.ID as ID, u.user_nicename as nicename, MAX(p.post_modified_gmt) as lastModified' )
->join( 'posts as p', 'u.ID = p.post_author' )
->where( 'p.post_status', 'publish' )
Expand Down
27 changes: 27 additions & 0 deletions app/Common/Sitemap/Html/Sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function __construct() {
$this->block = new Block();

add_action( 'widgets_init', [ $this, 'registerWidget' ] );
add_filter( 'aioseo_canonical_url', [ $this, 'getCanonicalUrl' ] );

if ( ! is_admin() || wp_doing_ajax() || wp_doing_cron() ) {
add_action( 'template_redirect', [ $this, 'checkForDedicatedPage' ] );
Expand Down Expand Up @@ -163,6 +164,32 @@ private function generatePage() {
// Setting is_404 is not sufficient, so we still need to change the status code.
status_header( 200 );
}

/**
* Get the canonical URL for the dedicated HTML sitemap page.
*
* @since 4.5.7
*
* @param string $originalUrl The canonical URL.
* @return string The canonical URL.
*/
public function getCanonicalUrl( $originalUrl ) {
$sitemapOptions = aioseo()->options->sitemap->html;

if ( ! $sitemapOptions->enable || ! $this->isDedicatedPage ) {
return $originalUrl;
}

// If the user has set a custom URL for the sitemap page, use that.
if ( $sitemapOptions->pageUrl ) {
return $sitemapOptions->pageUrl;
}

// Return the current URL of WP.
global $wp;

return home_url( $wp->request );
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Common/Sitemap/Priority.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private function defaultPriority( $pageType ) {
'archive' => 0.5,
'author' => 0.3,
'taxonomies' => 0.3,
'other' => 0.5,
'other' => 0.5
];

if ( array_key_exists( $pageType, $defaults ) ) {
Expand Down
5 changes: 3 additions & 2 deletions app/Common/Sitemap/Root.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function indexes() {
! aioseo()->options->searchAppearance->advanced->globalRobotsMeta->noindex
)
) {
$usersTable = aioseo()->core->db->db->users;
$usersTable = aioseo()->core->db->db->users; // We get the table name from WPDB since multisites share the same table.
$authorPostTypes = aioseo()->sitemap->helpers->getAuthorPostTypes();
$implodedPostTypes = aioseo()->helpers->implodeWhereIn( $authorPostTypes, true );
$result = aioseo()->core->db->execute(
Expand Down Expand Up @@ -271,7 +271,8 @@ private function buildAuthorIndexes( $amountOfAuthors ) {
for ( $i = 0; $i < $chunks; $i++ ) {
$indexNumber = 1 < $chunks ? $i + 1 : '';

$lastModified = aioseo()->core->db->start( 'users as u' )
$usersTableName = aioseo()->core->db->db->users; // We get the table name from WPDB since multisites share the same table.
$lastModified = aioseo()->core->db->start( "$usersTableName as u", true )
->select( 'MAX(p.post_modified_gmt) as lastModified' )
->join( 'posts as p', 'u.ID = p.post_author' )
->where( 'p.post_status', 'publish' )
Expand Down
5 changes: 3 additions & 2 deletions app/Common/Sitemap/Xsl.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ public function generate() {
$charset = aioseo()->helpers->getCharset();
$sitemapUrl = wp_get_referer();
$sitemapPath = aioseo()->helpers->getPermalinkPath( $sitemapUrl );
$sitemapName = strtoupper( pathinfo( $sitemapPath, PATHINFO_EXTENSION ) );

// Get Sitemap info by URL.
// Figure out which sitemap we're serving.
preg_match( '/\/(.*?)-?sitemap([0-9]*)\.xml/', $sitemapPath, $sitemapInfo );
$sitemapName = ! empty( $sitemapInfo[1] ) ? strtoupper( $sitemapInfo[1] ) : '';

if ( ! empty( $sitemapInfo[1] ) ) {
switch ( $sitemapInfo[1] ) {
case 'addl':
Expand Down
6 changes: 5 additions & 1 deletion app/Common/Standalone/PageBuilders/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ public function processContent( $postId, $content = '' ) {
}
}

return apply_filters( 'the_content', $content );
if ( aioseo()->helpers->isAjaxCronRestRequest() ) {
return apply_filters( 'the_content', $content );
}

return $content;
}
}
4 changes: 3 additions & 1 deletion app/Common/Standalone/PageBuilders/WPBakery.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ public function limitModifiedDate( $postId ) {
* @return string The processed content.
*/
public function processContent( $postId, $content = '' ) {
\WPBMap::addAllMappedShortcodes();
if ( method_exists( '\WPBMap', 'addAllMappedShortcodes' ) ) {
\WPBMap::addAllMappedShortcodes();
}

return parent::processContent( $postId, $content );
}
Expand Down
9 changes: 8 additions & 1 deletion app/Common/Traits/Helpers/WpContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,14 @@ public function getPostContent( $post = null ) {
return $content[ $post->ID ];
}

$content[ $post->ID ] = $this->theContent( $post->post_content );
// We need to process the content for page builders.
$postContent = $post->post_content;
$pageBuilder = aioseo()->helpers->getPostPageBuilderName( $post->ID );
if ( ! empty( $pageBuilder ) ) {
$postContent = aioseo()->standalone->pageBuilderIntegrations[ $pageBuilder ]->processContent( $post->ID, $postContent );
}

$content[ $post->ID ] = $this->theContent( $postContent );

if ( apply_filters( 'aioseo_description_include_custom_fields', true, $post ) ) {
$content[ $post->ID ] .= $this->theContent( $this->getPostCustomFieldsContent( $post ) );
Expand Down
3 changes: 2 additions & 1 deletion app/Common/Utils/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class Database {
'aioseo_redirects_hits',
'aioseo_redirects_logs',
'aioseo_terms',
'aioseo_search_statistics_objects'
'aioseo_search_statistics_objects',
'aioseo_revisions'
];

/**
Expand Down
Loading

0 comments on commit 70bdd9b

Please sign in to comment.