Skip to content

Commit

Permalink
4.6.7.1 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian-rossi committed Jul 25, 2024
1 parent f63e200 commit 72f7712
Show file tree
Hide file tree
Showing 110 changed files with 17,488 additions and 15,835 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.5
* Version: 4.6.7
* Text Domain: all-in-one-seo-pack
* Domain Path: /languages
*
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Admin/Notices/Notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ private function blogVisibility() {
return;
}

if ( $notification->exists() ) {
if ( $notification->exists() || ! current_user_can( 'manage_options' ) ) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion app/Common/Admin/PostSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function getPostTypeOverview( $postType ) {
}
}

aioseo()->core->cache->update( $postType . '_overview_data', $overview, WEEK_IN_SECONDS );
aioseo()->core->cache->update( $postType . '_overview_data', $overview, HOUR_IN_SECONDS );

return $overview;
}
Expand Down
4 changes: 3 additions & 1 deletion app/Common/Api/PostsTerms.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ public static function loadPostDetailsColumn( $request ) {

$posts = [];
foreach ( $ids as $postId ) {
$headlineResult = aioseo()->standalone->headlineAnalyzer->getResult( html_entity_decode( get_the_title( $postId ) ) );
$postTitle = get_the_title( $postId );
$headline = ! empty( $postTitle ) ? sanitize_text_field( $postTitle ) : ''; // We need this to achieve consistency for the score when using special characters in titles
$headlineResult = aioseo()->standalone->headlineAnalyzer->getResult( $headline );

$posts[] = [
'id' => $postId,
Expand Down
45 changes: 32 additions & 13 deletions app/Common/Main/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ abstract class Filters {
public function __construct() {
add_filter( 'wp_optimize_get_tables', [ $this, 'wpOptimizeAioseoTables' ] );

// This action needs to run on AJAX/cron for scheduled rewritten posts in Yoast Duplicate Post.
add_action( 'duplicate_post_after_rewriting', [ $this, 'updateRescheduledPostMeta' ], 10, 2 );

if ( wp_doing_ajax() || wp_doing_cron() ) {
return;
}
Expand Down Expand Up @@ -171,33 +174,31 @@ function_exists( 'bbp_get_reply_post_type' ) &&
*
* @since 4.1.1
*
* @param integer $newPostId The new post ID.
* @param \WP_Post $originalPost The original post object.
* @param integer $targetPostId The target post ID.
* @param \WP_Post $sourcePost The source post object.
* @return void
*/
public function duplicatePost( $newPostId, $originalPost = null ) {
$originalPostId = is_object( $originalPost ) ? $originalPost->ID : $originalPost;
$originalAioseoPost = Models\Post::getPost( $originalPostId );
if ( ! $originalAioseoPost->exists() ) {
return;
}
public function duplicatePost( $targetPostId, $sourcePost = null ) {
$sourcePostId = ! empty( $sourcePost->ID ) ? $sourcePost->ID : $sourcePost;
$sourceAioseoPost = Models\Post::getPost( $sourcePostId );
$targetPost = Models\Post::getPost( $targetPostId );

$newAioseoPost = Models\Post::getPost( $newPostId );
$columns = $originalAioseoPost->getColumns();
$columns = $sourceAioseoPost->getColumns();
foreach ( $columns as $column => $value ) {
// Skip the ID column.
if ( 'id' === $column ) {
continue;
}

if ( 'post_id' === $column ) {
$newAioseoPost->$column = $newPostId;
$targetPost->$column = $targetPostId;
continue;
}

$newAioseoPost->$column = $originalAioseoPost->$column;
$targetPost->$column = $sourceAioseoPost->$column;
}
$newAioseoPost->save();

$targetPost->save();
}

/**
Expand All @@ -223,6 +224,24 @@ public function rewriteAndRepublish( $postId, $metaKey = '', $metaValue = '' ) {
$this->duplicatePost( (int) $metaValue, $originalPost );
}

/**
* Updates the model when a post is republished.
* Yoast Duplicate Post doesn't do this since we store our data in a custom table.
*
* @since 4.6.7
*
* @param int $scheduledPostId The ID of the scheduled post.
* @param int $originalPostId The ID of the original post.
* @return void
*/
public function updateRescheduledPostMeta( $scheduledPostId, $originalPostId ) {
$this->duplicatePost( $originalPostId, $scheduledPostId );

// Delete the AIOSEO post record for the scheduled post.
$scheduledAioseoPost = Models\Post::getPost( $scheduledPostId );
$scheduledAioseoPost->delete();
}

/**
* Schedules an action to duplicate our meta after the duplicated WooCommerce product has been saved.
*
Expand Down
24 changes: 23 additions & 1 deletion app/Common/Main/Updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,12 @@ public function migratePostSchemaHelper( $aioseoPost ) {
'preparation' => ! empty( $schemaTypeOptions->recipe->preparationTime ) ? $schemaTypeOptions->recipe->preparationTime : '',
'cooking' => ! empty( $schemaTypeOptions->recipe->cookingTime ) ? $schemaTypeOptions->recipe->cookingTime : ''
],
'instructions' => []
'instructions' => [],
'rating' => [
'minimum' => 1,
'maximum' => 5
],
'reviews' => []
]
];

Expand All @@ -1247,6 +1252,23 @@ public function migratePostSchemaHelper( $aioseoPost ) {
];
}
}

$reviews = ! empty( $schemaTypeOptions->recipe->reviews ) ? $schemaTypeOptions->recipe->reviews : [];
if ( ! empty( $reviews ) ) {
foreach ( $reviews as $reviewData ) {
$reviewData = json_decode( $reviewData );
if ( empty( $reviewData ) ) {
continue;
}

$graph['properties']['reviews'][] = [
'rating' => $reviewData->rating,
'headline' => $reviewData->headline,
'content' => $reviewData->content,
'author' => $reviewData->author
];
}
}
break;
case 'SoftwareApplication':
$graph = [
Expand Down
5 changes: 5 additions & 0 deletions app/Common/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ private static function runDynamicSchemaMigration( $post ) {
// is correctly propagated on the frontend after changing it.
$post->schema = self::getDefaultSchemaOptions( $post->schema );

// Filter out null or empty graphs.
$post->schema->graphs = array_filter( $post->schema->graphs, function( $graph ) {
return ! empty( $graph );
} );

foreach ( $post->schema->graphs as $graph ) {
// If the first character of the graph ID isn't a pound, add one.
// We have to do this because the schema migration in 4.2.5 didn't add the pound for custom graphs.
Expand Down
22 changes: 22 additions & 0 deletions app/Common/Options/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ public function translateDefaults() {
* @return void
*/
public function sanitizeAndSave( $options ) {
// Decode urls for additional pages to fix localization issues.
$options = $this->decodeAdditionalPagesUrl( $options );
$sitemapOptions = ! empty( $options['sitemap'] ) ? $options['sitemap'] : null;
$oldSitemapOptions = aioseo()->options->sitemap->all();
$generalSitemapOptions = ! empty( $options['sitemap']['general'] ) ? $options['sitemap']['general'] : null;
Expand Down Expand Up @@ -742,4 +744,24 @@ public function maybeFlushRewriteRules() {
delete_option( 'aioseo_flush_rewrite_rules_flag' );
}
}

/**
* Decode the URLs for additional pages to fix Unicode characters.
*
* @since 4.6.7
*
* @param array $options The options array.
* @return array $options The options array with the decoded URLs.
*/
public function decodeAdditionalPagesUrl( $options ) {
if ( ! empty( $options['sitemap']['general']['additionalPages']['pages'] ) ) {
foreach ( $options['sitemap']['general']['additionalPages']['pages'] as &$page ) {
$page = json_decode( $page, true );
$page['url'] = aioseo()->helpers->decodeUrl( $page['url'] );
$page = wp_json_encode( $page, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
}
}

return $options;
}
}
5 changes: 3 additions & 2 deletions app/Common/Schema/Graphs/KnowledgeGraph/KgOrganization.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ public function get() {

if (
$numberOfEmployeesData['isRange'] &&
! empty( $numberOfEmployeesData['from'] ) &&
! empty( $numberOfEmployeesData['to'] )
isset( $numberOfEmployeesData['from'] ) &&
isset( $numberOfEmployeesData['to'] ) &&
0 < $numberOfEmployeesData['to']
) {
$data['numberOfEmployees'] = [
'@type' => 'QuantitativeValue',
Expand Down
3 changes: 3 additions & 0 deletions app/Common/SearchStatistics/Api/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ public function delete( $force = false ) {
aioseo()->searchStatistics->api->auth->deleteProfile();
aioseo()->searchStatistics->reset();

// Resets the results for the Google meta tag.
aioseo()->options->webmasterTools->google = '';

return true;
}
}
82 changes: 82 additions & 0 deletions app/Common/Standalone/AdminBarNoindexWarning.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
namespace AIOSEO\Plugin\Common\Standalone;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

use AIOSEO\Plugin\Common\Models;

/**
* Handles the admin bar noindex warning.
*
* @since 4.6.7
*/
class AdminBarNoindexWarning {
/**
* Class constructor.
*
* @since 4.6.7
*/
public function __construct() {
add_action( 'init', [ $this, 'init' ] );
}

/**
* Initializes the standalone.
*
* @since 4.6.7
*
* @return void
*/
public function init() {
if ( wp_doing_ajax() || wp_doing_cron() ) {
return;
}

$isSitePublic = get_option( 'blog_public' );
if ( $isSitePublic ) {
return;
}

if ( ! current_user_can( 'manage_options' ) ) {
return;
}

add_action( 'admin_enqueue_scripts', [ $this, 'enqueueScript' ] );
add_action( 'wp_enqueue_scripts', [ $this, 'enqueueScript' ] );

add_action( 'admin_bar_menu', [ $this, 'addAdminBarElement' ], 99999 );
}

/**
* Enqueues the script.
*
* @since 4.6.7
*
* @return void
*/
public function enqueueScript() {
aioseo()->core->assets->load( 'src/vue/standalone/admin-bar-noindex-warning/main.js', [], [
'optionsReadingUrl' => admin_url( 'options-reading.php' ),
], 'aioseoAdminBarNoindexWarning' );
}

/**
* Adds the admin bar element.
*
* @since 4.6.7
*
* @param \WP_Admin_Bar $wpAdminBar The admin bar object.
* @return void
*/
public function addAdminBarElement( $wpAdminBar ) {
$wpAdminBar->add_node(
[
'id' => 'aioseo-admin-bar-noindex-warning',
'title' => __( 'Search Engines Blocked!', 'all-in-one-seo-pack' ),
'href' => admin_url( 'options-reading.php' )
]
);
}
}
4 changes: 2 additions & 2 deletions app/Common/Standalone/HeadlineAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function enqueue() {
}
require AIOSEO_DIR . $path;

aioseo()->core->assets->load( 'src/react/headline-analyzer/main.js' );
aioseo()->core->assets->load( 'src/vue/standalone/headline-analyzer/main.js' );
}

/**
Expand All @@ -69,7 +69,7 @@ public function enqueue() {
* @return array The result.
*/
public function getResult( $title ) {
$result = $this->getHeadlineScore( $title );
$result = $this->getHeadlineScore( html_entity_decode( $title ) );

if ( ! empty( $result->err ) ) {
return false;
Expand Down
5 changes: 3 additions & 2 deletions app/Common/Standalone/Standalone.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ public function __construct() {

aioseo()->pro ? new ProStandalone\DetailsColumn() : new DetailsColumn();

new UserProfileTab();
new PublishPanel();
new AdminBarNoindexWarning();
new LimitModifiedDate();
new Notifications();
new PublishPanel();
new UserProfileTab();
new WpCode();

$this->pageBuilderIntegrations = [
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Tools/RobotsTxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function extractRules( $lines ) {
}

$userAgent = $value;
$rules[ $userAgent ] = [];
$rules[ $userAgent ] = ! empty( $rules[ $userAgent ] ) ? $rules[ $userAgent ] : [];
} else {
$rules[ $userAgent ][] = "$directive: $value";
if ( $siblingsUserAgents ) {
Expand Down
17 changes: 17 additions & 0 deletions app/Common/Traits/Helpers/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,21 @@ public function getTld( $domain ) {

return $domain;
}

/**
* Returns a decoded URL string.
*
* @since 4.6.7
*
* @param string $url The URL string.
* @return string The decoded URL.
*/
public function decodeUrl( $url ) {
// Check if URL was encoded multiple times.
while ( rawurldecode( $url ) !== $url ) {
$url = rawurldecode( $url );
}

return $url;
}
}
Loading

0 comments on commit 72f7712

Please sign in to comment.