Skip to content

Commit

Permalink
4.7.9.1 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudbroes committed Feb 17, 2025
1 parent 50bc931 commit 4c4ecfe
Show file tree
Hide file tree
Showing 51 changed files with 545 additions and 222 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.7.8
* Version: 4.7.9.1
* Text Domain: all-in-one-seo-pack
* Domain Path: /languages
* License: GPL-3.0+
Expand Down
8 changes: 0 additions & 8 deletions app/Common/Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,14 +715,6 @@ public function addMenu() {
];
}

if ( current_user_can( $this->getPageRequiredCapability( 'aioseo-search-statistics' ) ) ) {
$submenu['index.php'][] = [
esc_html__( 'SEO Statistics', 'all-in-one-seo-pack' ),
$this->getPageRequiredCapability( 'aioseo-search-statistics' ),
admin_url( '/admin.php?page=aioseo-search-statistics' )
];
}

if ( current_user_can( $this->getPageRequiredCapability( 'aioseo-search-appearance' ) ) ) {
$submenu['users.php'][] = [
esc_html__( 'Author SEO', 'all-in-one-seo-pack' ),
Expand Down
7 changes: 7 additions & 0 deletions app/Common/Api/Analyze.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ public static function analyzeHeadline( $request ) {

$result = aioseo()->standalone->headlineAnalyzer->getResult( $headline );

if ( ! $result['analysed'] ) {
return new \WP_REST_Response( [
'success' => false,
'message' => $result['result']->msg
], 400 );
}

$headlines = aioseo()->internalOptions->internal->headlineAnalysis->headlines;
$headlines = array_reverse( $headlines, true );

Expand Down
2 changes: 1 addition & 1 deletion app/Common/Api/Integrations/Semrush.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function semrushGetKeyphrases( $request ) {
if ( false === $keyphrases ) {
return new \WP_REST_Response( [
'success' => false,
'message' => 'Tokens expired and could not be refreshed.'
'message' => 'You may have sent too many requests to Semrush. Please wait a few minutes and try again.'
], 400 );
}

Expand Down
22 changes: 19 additions & 3 deletions app/Common/Api/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,12 +586,28 @@ public static function exportContent( $request ) {

// Generate content to CSV or JSON.
if ( ! empty( $posts ) ) {
// Change the order of keys so the post_title shows up at the beginning.
$data = [];
foreach ( $posts as $p ) {
$item = [
'id' => '',
'post_id' => '',
'post_title' => '',
'title' => ''
];

$p['title'] = aioseo()->helpers->decodeHtmlEntities( $p['title'] );
$p['post_title'] = aioseo()->helpers->decodeHtmlEntities( $p['post_title'] );

$data[] = array_merge( $item, $p );
}

if ( 'csv' === $typeFile ) {
$contentPostType = self::dataToCsv( $posts );
$contentPostType = self::dataToCsv( $data );
}

if ( 'json' === $typeFile ) {
$contentPostType['postOptions']['content']['posts'] = $posts;
$contentPostType['postOptions']['content']['posts'] = $data;
}
}
}
Expand All @@ -616,7 +632,7 @@ public static function exportContent( $request ) {
*/
private static function getPostTypesData( $postOptions, $notAllowedFields = [] ) {
$posts = aioseo()->core->db->start( 'aioseo_posts as ap' )
->select( 'ap.*' )
->select( 'ap.*, p.post_title' )
->join( 'posts as p', 'ap.post_id = p.ID' )
->whereIn( 'p.post_type', $postOptions )
->orderBy( 'ap.id' )
Expand Down
13 changes: 9 additions & 4 deletions app/Common/EmailReports/Summary/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Summary {
*
* @var string
*/
private $actionHook = 'aioseo_report_summary';
public $actionHook = 'aioseo_report_summary';

/**
* Recipient for the email. Multiple recipients can be separated by a comma.
Expand Down Expand Up @@ -52,7 +52,7 @@ public function __construct() {
}

// No need to keep trying scheduling unless on admin.
add_action( 'admin_init', [ $this, 'maybeSchedule' ] );
add_action( 'admin_init', [ $this, 'maybeSchedule' ], 20 );

add_action( $this->actionHook, [ $this, 'cronTrigger' ] );
}
Expand Down Expand Up @@ -123,8 +123,13 @@ public function run( $data ) {
*/
public function maybeSchedule() {
$allowedFrequencies = $this->getAllowedFrequencies();
$addToStart = HOUR_IN_SECONDS * 6; // Add 6 hours after the day starts, so the email is sent at 6 AM.
$addToStart -= aioseo()->helpers->getTimeZoneOffset();

// Add at least 6 hours after the day starts.
$addToStart = HOUR_IN_SECONDS * 6;
// Add the timezone offset.
$addToStart -= aioseo()->helpers->getTimeZoneOffset();
// Add a random time offset to avoid all emails being sent at the same time. 1440 * 3 = 3 days range.
$addToStart += aioseo()->helpers->generateRandomTimeOffset( aioseo()->helpers->getSiteDomain( true ), 1440 * 3 ) * MINUTE_IN_SECONDS;

foreach ( $allowedFrequencies as $frequency => $data ) {
aioseo()->actionScheduler->scheduleRecurrent( $this->actionHook, $data['start'] + $addToStart, $data['interval'], compact( 'frequency' ) );
Expand Down
39 changes: 39 additions & 0 deletions app/Common/Main/Updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ public function runUpdates() {
$this->disableEmailReports();
}

if ( version_compare( $lastActiveVersion, '4.7.9', '<' ) ) {
$this->fixSavedHeadlines();
$this->rescheduleEmailReport();
}

do_action( 'aioseo_run_updates', $lastActiveVersion );

// Always clear the cache if the last active version is different from our current.
Expand Down Expand Up @@ -1798,4 +1803,38 @@ private function disableEmailReports() {
// Schedule a notification to remind the user to enable email reports in 2 weeks.
aioseo()->actionScheduler->scheduleSingle( 'aioseo_email_reports_enable_reminder', 2 * WEEK_IN_SECONDS );
}

/**
* Cancels all occurrences of the report summary task.
* This is needed in order to force the scheduled date to be reset.
*
* @since 4.7.9
*
* @return void
*/
private function rescheduleEmailReport() {
as_unschedule_all_actions( aioseo()->emailReports->summary->actionHook );
}

/**
* Fixes headlines that could not be analyzed.
*
* @since 4.7.9
*
* @return void
*/
private function fixSavedHeadlines() {
$headlines = aioseo()->internalOptions->internal->headlineAnalysis->headlines;
if ( empty( $headlines ) ) {
return;
}

foreach ( $headlines as $key => $headline ) {
if ( ! json_decode( $headline ) ) {
unset( $headlines[ $key ] );
}
}

aioseo()->internalOptions->internal->headlineAnalysis->headlines = $headlines;
}
}
66 changes: 65 additions & 1 deletion app/Common/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ private static function runDynamicSchemaMigration( $post ) {
$graph->properties->review->rating = $graph->properties->rating->value;
unset( $graph->properties->rating->value );
}

// If the graph has audience data, we need to migrate it to the correct one.
if (
property_exists( $graph, 'id' ) &&
preg_match( '/(product|product-review)/', $graph->id ) &&
property_exists( $graph->properties, 'audience' )
) {
$graph->properties->audience = self::migratePostAudienceAgeSchema( $graph->properties->audience );
}
}

return $post;
Expand Down Expand Up @@ -795,7 +804,62 @@ public static function getDefaultOpenAiOptions( $existingOptions = [] ) {
return json_decode( wp_json_encode( $existingOptions ) );
}

/**
/**
* Migrates the post's audience age schema data when it is loaded.
* Min age: [0 => newborns, 0.25 => infants, 1 => toddlers, 5 => kids, 13 => adults]
* Max age: [0.25 => newborns, 1 => infants, 5 => toddlers, 13 => kids]
*
* @since 4.7.9
*
* @param object $audience The audience data.
* @return object
*/
public static function migratePostAudienceAgeSchema( $audience ) {
$ages = [ 0, 0.25, 1, 5, 13 ];

// converts variable to integer if it's a number otherwise is null.
$parsedMinAge = filter_var( $audience->minimumAge, FILTER_VALIDATE_FLOAT, FILTER_NULL_ON_FAILURE );
$parsedMaxAge = filter_var( $audience->maximumAge, FILTER_VALIDATE_FLOAT, FILTER_NULL_ON_FAILURE );

if ( null === $parsedMinAge && null === $parsedMaxAge ) {
return $audience;
}

$minAge = is_numeric( $parsedMinAge ) ? $parsedMinAge : 0;
$maxAge = is_numeric( $parsedMaxAge ) ? $parsedMaxAge : null;

// get the minimumAge if available or the nearest bigger one.
foreach ( $ages as $age ) {
if ( $age >= $minAge ) {
$audience->minimumAge = $age;
break;
}
}

// get the maximumAge if available or the nearest bigger one.
foreach ( $ages as $age ) {
if ( $age >= $maxAge ) {
$maxAge = $age;
break;
}
}

// makes sure the maximumAge is 13 below
if ( null !== $maxAge ) {
$audience->maximumAge = 13 < $maxAge ? 13 : $maxAge;
}

// Minimum age 13 is for adults.
// If minimumAge is still higher or equal 13 then it's for adults and maximumAge should be empty.
if ( 13 <= $audience->minimumAge ) {
$audience->minimumAge = 13;
$audience->maximumAge = null;
}

return $audience;
}

/**
* Migrates update Korea country code for Person, Product, Event, and JobsPosting schemas.
*
* @since 4.7.1
Expand Down
4 changes: 2 additions & 2 deletions app/Common/Options/DynamicBackup.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function updateBackup() {
if ( $this->shouldBackup ) {
$this->shouldBackup = false;
$backup = aioseo()->dynamicOptions->convertOptionsToValues( $this->backup, 'value' );
update_option( $this->optionsName, wp_json_encode( $backup ) );
update_option( $this->optionsName, wp_json_encode( $backup ), 'no' );
}
}

Expand All @@ -114,7 +114,7 @@ public function init() {

$backup = json_decode( get_option( $this->optionsName ), true );
if ( empty( $backup ) ) {
update_option( $this->optionsName, '{}' );
update_option( $this->optionsName, '{}', 'no' );

return;
}
Expand Down
11 changes: 6 additions & 5 deletions app/Common/Schema/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ class Schema {
* @var array
*/
public $nullableFields = [
'price', // Needs to be 0 if free for Software Application.
'ratingValue', // Needs to be 0 for 0 star ratings.
'value', // Needs to be 0 if free for product shipping details.
'minValue', // Needs to be 0 for product delivery time.
'maxValue' // Needs to be 0 for product delivery time.
'price', // Needs to be 0 if free for Software Application.
'ratingValue', // Needs to be 0 for 0 star ratings.
'value', // Needs to be 0 if free for product shipping details.
'minValue', // Needs to be 0 for product delivery time.
'maxValue', // Needs to be 0 for product delivery time.
'suggestedMinAge' // Needs to be 0 for PeopleAudience minimum age.
];

/**
Expand Down
9 changes: 7 additions & 2 deletions app/Common/Sitemap/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -859,15 +859,20 @@ public function productAttributes( $count = false ) {
$wcAttributeTaxonomiesTable = aioseo()->core->db->prefix . 'woocommerce_attribute_taxonomies';
$termTaxonomyTable = aioseo()->core->db->prefix . 'term_taxonomy';

$selectClause = $count ? 'COUNT(*) as childProductAttributes' : 'tt.term_id, at.frequency, at.priority';
$selectClause = 'COUNT(*) as childProductAttributes';
if ( ! $count ) {
$selectClause = aioseo()->pro ? 'tt.term_id, at.frequency, at.priority' : 'tt.term_id';
}

$joinClause = aioseo()->pro ? "LEFT JOIN {$aioseoTermsTable} AS at ON tt.term_id = at.term_id" : '';
$whereClause = aioseo()->pro ? 'AND (at.robots_noindex IS NULL OR at.robots_noindex = 0)' : '';
$limitClause = $count ? '' : 'LIMIT 50000';

$result = aioseo()->core->db->execute(
"SELECT {$selectClause}
FROM {$termTaxonomyTable} AS tt
JOIN {$wcAttributeTaxonomiesTable} AS wat ON tt.taxonomy = CONCAT('pa_', wat.attribute_name)
LEFT JOIN {$aioseoTermsTable} AS at ON tt.term_id = at.term_id
{$joinClause}
WHERE wat.attribute_public = 1
{$whereClause}
AND tt.count > 0
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Sitemap/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function chunkEntries( $entries ) {
* @return string The formatted datetime.
*/
public function lastModifiedAdditionalPage( $page ) {
return gmdate( 'c', strtotime( $page->lastModified ) );
return gmdate( 'c', strtotime( (string) $page->lastModified ) );
}

/**
Expand Down
Loading

0 comments on commit 4c4ecfe

Please sign in to comment.