Skip to content

Commit

Permalink
4.7.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudbroes committed Oct 14, 2024
1 parent 5e87528 commit a9e2244
Show file tree
Hide file tree
Showing 58 changed files with 1,268 additions and 940 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.2
* Version: 4.7.3
* Text Domain: all-in-one-seo-pack
* Domain Path: /languages
* License: GPL-3.0+
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ public function addPublishScore( $post ) {
return;
}

if ( aioseo()->helpers->isPageAnalysisEligible( $post->ID ) ) {
if ( aioseo()->helpers->isTruSeoEligible( $post->ID ) ) {
$score = (int) Models\Post::getPost( $post->ID )->seo_score;
$path = 'M10 20C15.5228 20 20 15.5228 20 10C20 4.47715 15.5228 0 10 0C4.47716 0 0 4.47715 0 10C0 15.5228 4.47716 20 10 20ZM8.40767 3.65998C8.27222 3.45353 8.02129 3.357 7.79121 3.43828C7.52913 3.53087 7.27279 3.63976 7.02373 3.76429C6.80511 3.87361 6.69542 4.12332 6.74355 4.36686L6.91501 5.23457C6.95914 5.45792 6.86801 5.68459 6.69498 5.82859C6.42152 6.05617 6.16906 6.31347 5.94287 6.59826C5.80229 6.77526 5.58046 6.86908 5.36142 6.82484L4.51082 6.653C4.27186 6.60473 4.02744 6.71767 3.92115 6.94133C3.86111 7.06769 3.80444 7.19669 3.75129 7.32826C3.69815 7.45983 3.64929 7.59212 3.60464 7.72495C3.52562 7.96007 3.62107 8.21596 3.82396 8.35351L4.54621 8.84316C4.73219 8.96925 4.82481 9.19531 4.80234 9.42199C4.7662 9.78671 4.76767 10.1508 4.80457 10.5089C4.82791 10.7355 4.73605 10.9619 4.55052 11.0886L3.82966 11.5811C3.62734 11.7193 3.53274 11.9753 3.61239 12.2101C3.70314 12.4775 3.80985 12.7391 3.93188 12.9932C4.03901 13.2163 4.28373 13.3282 4.5224 13.2791L5.37279 13.1042C5.59165 13.0591 5.8138 13.1521 5.95491 13.3287C6.17794 13.6077 6.43009 13.8653 6.70918 14.0961C6.88264 14.2396 6.97459 14.4659 6.93122 14.6894L6.76282 15.5574C6.71551 15.8013 6.8262 16.0507 7.04538 16.1591C7.16921 16.2204 7.29563 16.2782 7.42457 16.3324C7.55352 16.3867 7.68316 16.4365 7.81334 16.4821C8.19418 16.6154 8.72721 16.1383 9.1213 15.7855C9.31563 15.6116 9.4355 15.3654 9.43677 15.1018C9.43677 15.1004 9.43678 15.099 9.43678 15.0976L9.43677 13.6462C9.43677 13.6308 9.43736 13.6155 9.43852 13.6004C8.27454 13.3165 7.40918 12.248 7.40918 10.9732V9.43198C7.40918 9.31483 7.50224 9.21986 7.61706 9.21986H8.338V7.70343C8.338 7.49405 8.50433 7.32432 8.70952 7.32432C8.9147 7.32432 9.08105 7.49405 9.08105 7.70343V9.21986H11.0316V7.70343C11.0316 7.49405 11.1979 7.32432 11.4031 7.32432C11.6083 7.32432 11.7746 7.49405 11.7746 7.70343V9.21986H12.4956C12.6104 9.21986 12.7034 9.31483 12.7034 9.43198V10.9732C12.7034 12.2883 11.7825 13.3838 10.5628 13.625C10.5631 13.632 10.5632 13.6391 10.5632 13.6462L10.5632 15.0914C10.5632 15.36 10.6867 15.6107 10.8868 15.7853C11.2879 16.1351 11.8302 16.6079 12.2088 16.4742C12.4708 16.3816 12.7272 16.2727 12.9762 16.1482C13.1949 16.0389 13.3046 15.7891 13.2564 15.5456L13.085 14.6779C13.0408 14.4545 13.132 14.2278 13.305 14.0838C13.5785 13.8563 13.8309 13.599 14.0571 13.3142C14.1977 13.1372 14.4195 13.0434 14.6385 13.0876L15.4892 13.2595C15.7281 13.3077 15.9725 13.1948 16.0788 12.9711C16.1389 12.8448 16.1955 12.7158 16.2487 12.5842C16.3018 12.4526 16.3507 12.3204 16.3953 12.1875C16.4744 11.9524 16.3789 11.6965 16.176 11.559L15.4537 11.0693C15.2678 10.9432 15.1752 10.7171 15.1976 10.4905C15.2338 10.1258 15.2323 9.76167 15.1954 9.40357C15.1721 9.17699 15.2639 8.95062 15.4495 8.82387L16.1703 8.33141C16.3726 8.1932 16.4672 7.93715 16.3876 7.70238C16.2968 7.43495 16.1901 7.17337 16.0681 6.91924C15.961 6.69615 15.7162 6.58422 15.4776 6.63333L14.6272 6.8083C14.4083 6.85333 14.1862 6.76033 14.0451 6.58377C13.822 6.30474 13.5699 6.04713 13.2908 5.81632C13.1173 5.67287 13.0254 5.44652 13.0688 5.22301L13.2372 4.35503C13.2845 4.11121 13.1738 3.86179 12.9546 3.75334C12.8308 3.69208 12.7043 3.63424 12.5754 3.58002C12.4465 3.52579 12.3168 3.47593 12.1866 3.43037C11.9562 3.34974 11.7055 3.44713 11.5707 3.65416L11.0908 4.39115C10.9672 4.58093 10.7457 4.67543 10.5235 4.65251C10.1661 4.61563 9.80932 4.61712 9.45837 4.65477C9.23633 4.6786 9.01448 4.58486 8.89027 4.39554L8.40767 3.65998Z'; // phpcs:ignore Generic.Files.LineLength.MaxExceeded
?>
Expand Down
117 changes: 56 additions & 61 deletions app/Common/Admin/PostSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,24 +271,17 @@ public function clearPostTypeOverviewCache( $postId ) {
* @return array The list of post types with the overview.
*/
public function getPostTypesOverview() {
$postTypes = [];
$dynamicOptions = aioseo()->dynamicOptions->noConflict();

$overviewData = [];
$eligiblePostTypes = aioseo()->helpers->getTruSeoEligiblePostTypes();
foreach ( aioseo()->helpers->getPublicPostTypes( true ) as $postType ) {
if (
! $dynamicOptions->searchAppearance->postTypes->has( $postType ) ||
! $dynamicOptions->searchAppearance->postTypes->$postType->show ||
! $dynamicOptions->searchAppearance->postTypes->$postType->advanced->showMetaBox ||
'attachment' === $postType ||
aioseo()->helpers->isBBPressPostType( $postType )
) {
if ( ! in_array( $postType, $eligiblePostTypes, true ) ) {
continue;
}

$postTypes[ $postType ] = $this->getPostTypeOverview( $postType );
$overviewData[ $postType ] = $this->getPostTypeOverview( $postType );
}

return $postTypes;
return $overviewData;
}

/**
Expand All @@ -297,62 +290,64 @@ public function getPostTypesOverview() {
* @since 4.2.0
*
* @param string $postType The post type name.
* @return array The overview for the given post type.
* @return array The overview data for the given post type.
*/
public function getPostTypeOverview( $postType ) {
$overview = aioseo()->core->cache->get( $postType . '_overview_data' );
if ( null !== $overview ) {
return $overview;
$overviewData = aioseo()->core->cache->get( $postType . '_overview_data' );
if ( null !== $overviewData ) {
return $overviewData;
}

$posts = aioseo()->core->db->start( 'posts as p' )
->select( 'p.ID, ap.seo_score, ap.keyphrases' )
->leftJoin( 'aioseo_posts as ap', 'ap.post_id = p.ID' )
->where( 'p.post_status', 'publish' )
->where( 'p.post_type', $postType )
->run()
->result();

$overview = [
'total' => 0,
'needsImprovement' => 0,
'okay' => 0,
'good' => 0,
'withoutFocusKeyphrase' => 0,
];

foreach ( $posts as $post ) {
if ( ! aioseo()->helpers->isPageAnalysisEligible( $post->ID ) ) {
continue;
}

$overview['total']++;

if ( empty( $post->keyphrases ) || strpos( $post->keyphrases, '{"focus":{"keyphrase":""' ) === 0 ) {
$overview['withoutFocusKeyphrase']++;

// We skip to the next since we will just consider posts with focus keyphrase in the counts.
continue;
}

if ( 50 > $post->seo_score ) {
$overview['needsImprovement']++;
continue;
}

if ( 50 <= $post->seo_score && 80 >= $post->seo_score ) {
$overview['okay']++;
continue;
}
$eligiblePostTypes = aioseo()->helpers->getTruSeoEligiblePostTypes();
if ( ! in_array( $postType, $eligiblePostTypes, true ) ) {
return [
'total' => 0,
'withoutFocusKeyphrase' => 0,
'needsImprovement' => 0,
'okay' => 0,
'good' => 0
];
}

if ( 80 < $post->seo_score ) {
$overview['good']++;
}
$specialPageIds = aioseo()->helpers->getSpecialPageIds();
$implodedPageIdPlaceholders = array_fill( 0, count( $specialPageIds ), '%d' );
$implodedPageIdPlaceholders = implode( ', ', $implodedPageIdPlaceholders );

global $wpdb;
$overviewData = $wpdb->get_row(
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber
$wpdb->prepare(
"SELECT
COUNT(*) as total,
COALESCE( SUM(CASE WHEN ap.keyphrases = '' OR ap.keyphrases IS NULL OR ap.keyphrases LIKE %s THEN 1 ELSE 0 END), 0) as withoutFocusKeyphrase,
COALESCE( SUM(CASE WHEN ap.seo_score < 50 AND NOT (ap.keyphrases = '' OR ap.keyphrases IS NULL OR ap.keyphrases LIKE %s) THEN 1 ELSE 0 END), 0) as needsImprovement,
COALESCE( SUM(CASE WHEN ap.seo_score BETWEEN 50 AND 80 AND NOT (ap.keyphrases = '' OR ap.keyphrases IS NULL OR ap.keyphrases LIKE %s) THEN 1 ELSE 0 END), 0) as okay,
COALESCE( SUM(CASE WHEN ap.seo_score > 80 AND NOT (ap.keyphrases = '' OR ap.keyphrases IS NULL OR ap.keyphrases LIKE %s) THEN 1 ELSE 0 END), 0) as good
FROM {$wpdb->posts} as p
LEFT JOIN {$wpdb->prefix}aioseo_posts as ap ON ap.post_id = p.ID
WHERE p.post_status = 'publish'
AND p.post_type = %s
AND p.ID NOT IN ( $implodedPageIdPlaceholders )",
// phpcs:enable
'{"focus":{"keyphrase":""%',
'{"focus":{"keyphrase":""%',
'{"focus":{"keyphrase":""%',
'{"focus":{"keyphrase":""%',
$postType,
...$specialPageIds
),
ARRAY_A
);

// Ensure sure all the values are integers.
foreach ( $overviewData as $key => $value ) {
$overviewData[ $key ] = (int) $value;
}

aioseo()->core->cache->update( $postType . '_overview_data', $overview, HOUR_IN_SECONDS );
// Give me the raw SQL of the query.
aioseo()->core->cache->update( $postType . '_overview_data', $overviewData, HOUR_IN_SECONDS );

return $overview;
return $overviewData;
}

/**
Expand Down Expand Up @@ -415,7 +410,7 @@ public function filterPostsAfterChangingClauses() {
global $wp_query;
if ( ! empty( $wp_query->posts ) && is_array( $wp_query->posts ) ) {
$wp_query->posts = array_filter( $wp_query->posts, function ( $post ) {
return aioseo()->helpers->isPageAnalysisEligible( $post->ID );
return aioseo()->helpers->isTruSeoEligible( $post->ID );
} );

// Update `post_count` for pagination.
Expand Down
4 changes: 2 additions & 2 deletions app/Common/Api/Analyze.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public static function analyzeSite( $request ) {
return new \WP_REST_Response( $competitors, 200 );
}

$results = $responseBody[ $analyzeOrHomeUrl ]->results;
$results = $responseBody[ $analyzeOrHomeUrl ]['results'];

aioseo()->internalOptions->internal->siteAnalysis->results = wp_json_encode( $results );
aioseo()->internalOptions->internal->siteAnalysis->score = $responseBody[ $analyzeOrHomeUrl ]->score;
aioseo()->internalOptions->internal->siteAnalysis->score = $responseBody[ $analyzeOrHomeUrl ]['score'];

return new \WP_REST_Response( $responseBody[ $analyzeOrHomeUrl ], 200 );
}
Expand Down
5 changes: 4 additions & 1 deletion app/Common/Breadcrumbs/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,10 @@ public function maybeGetWooCommerceShopCrumb() {
public function getWooCommerceShopCrumb() {
$crumb = [];

if ( ! function_exists( 'wc_get_page_id' ) ) {
if (
! function_exists( 'wc_get_page_id' ) ||
apply_filters( 'aioseo_woocommerce_breadcrumb_hide_shop', false )
) {
return $crumb;
}

Expand Down
12 changes: 6 additions & 6 deletions app/Common/EmailReports/Summary/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Content {
/**
* The featured image placeholder URL.
*
* @since {next}
* @since 4.7.3
*
* @var string
*/
Expand Down Expand Up @@ -166,7 +166,7 @@ public function getPostsStatistics() {
$result['winning']['items'][] = [
'title' => $row['objectTitle'],
'url' => get_permalink( $postId ),
'tru_seo' => aioseo()->helpers->isPageAnalysisEligible( $postId ) ? $this->parseSeoScore( $row['seoScore'] ?? 0 ) : [],
'tru_seo' => aioseo()->helpers->isTruSeoEligible( $postId ) ? $this->parseSeoScore( $row['seoScore'] ?? 0 ) : [],
'clicks' => $this->parseClicks( $row['clicks'] ),
'difference' => [
'clicks' => $this->parseDifference( $row['difference']['clicks'] ?? '' ),
Expand All @@ -181,7 +181,7 @@ public function getPostsStatistics() {
$result['losing']['items'][] = [
'title' => $row['objectTitle'],
'url' => get_permalink( $postId ),
'tru_seo' => aioseo()->helpers->isPageAnalysisEligible( $postId ) ? $this->parseSeoScore( $row['seoScore'] ?? 0 ) : [],
'tru_seo' => aioseo()->helpers->isTruSeoEligible( $postId ) ? $this->parseSeoScore( $row['seoScore'] ?? 0 ) : [],
'clicks' => $this->parseClicks( $row['clicks'] ),
'difference' => [
'clicks' => $this->parseDifference( $row['difference']['clicks'] ?? '' ),
Expand Down Expand Up @@ -451,7 +451,7 @@ public function getAioPosts() {
'title' => $row['objectTitle'],
'url' => get_permalink( $postId ),
'image_url' => $this->getThumbnailUrl( $postId ),
'tru_seo' => aioseo()->helpers->isPageAnalysisEligible( $postId ) ? $this->parseSeoScore( $row['seoScore'] ?? 0 ) : [],
'tru_seo' => aioseo()->helpers->isTruSeoEligible( $postId ) ? $this->parseSeoScore( $row['seoScore'] ?? 0 ) : [],
'decay_percent' => $this->parseDifference( $row['decayPercent'] ?? '', true ),
'issues' => [
'url' => $this->searchStatisticsUrl . "#/post-detail?postId=$postId",
Expand Down Expand Up @@ -491,7 +491,7 @@ public function getResources() {
/**
* Returns if Search Statistics content is allowed.
*
* @since {next}
* @since 4.7.3
*
* @return bool Whether Search Statistics content is allowed.
*/
Expand Down Expand Up @@ -597,7 +597,7 @@ private function parsePosts( $posts ) {
'title' => aioseo()->helpers->truncate( $item->post_title, 75 ),
'url' => get_permalink( $item->ID ),
'image_url' => $this->getThumbnailUrl( $item->ID ),
'tru_seo' => aioseo()->helpers->isPageAnalysisEligible( $item->ID ) ? $this->parseSeoScore( $item->seo_score ?? 0 ) : [],
'tru_seo' => aioseo()->helpers->isTruSeoEligible( $item->ID ) ? $this->parseSeoScore( $item->seo_score ?? 0 ) : [],
'stats' => []
];

Expand Down
2 changes: 1 addition & 1 deletion app/Common/EmailReports/Summary/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private function getAllowedFrequencies() {
/**
* Retrieves the date range data based on the frequency.
*
* @since {next}
* @since 4.7.3
*
* @return array The date range data.
*/
Expand Down
34 changes: 17 additions & 17 deletions app/Common/Help/Help.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Help {
private $settings = [
'docsUrl' => 'https://aioseo.com/docs/',
'supportTicketUrl' => 'https://aioseo.com/account/support/',
'upgradeUrl' => 'https://aioseo.com/pricing/',
'upgradeUrl' => 'https://aioseo.com/pricing/'
];

/**
Expand All @@ -45,31 +45,31 @@ private function getUrl() {
}

/**
* Get docs from the network cache.
* Returns the help docs for our menus.
*
* @since 4.0.0
*
* @return array Docs data.
* @return array The help docs.
*/
public function getDocs() {
$aioseoAdminHelpDocs = aioseo()->core->networkCache->get( 'admin_help_docs' );
$aioseoAdminHelpDocsCacheTime = WEEK_IN_SECONDS;
if ( null === $aioseoAdminHelpDocs ) {
$request = aioseo()->helpers->wpRemoteGet( $this->getUrl() );

if ( is_wp_error( $request ) ) {
return [];
$helpDocs = aioseo()->core->networkCache->get( 'admin_help_docs' );
if ( null !== $helpDocs ) {
if ( is_array( $helpDocs ) ) {
return $helpDocs;
}

$response = $request['response'];
return json_decode( $helpDocs, true );
}

if ( ( $response['code'] <= 200 ) && ( $response['code'] > 299 ) ) {
$aioseoAdminHelpDocsCacheTime = 10 * MINUTE_IN_SECONDS;
}
$aioseoAdminHelpDocs = wp_remote_retrieve_body( $request );
aioseo()->core->networkCache->update( 'admin_help_docs', $aioseoAdminHelpDocs, $aioseoAdminHelpDocsCacheTime );
$request = aioseo()->helpers->wpRemoteGet( $this->getUrl() );
if ( is_wp_error( $request ) ) {
aioseo()->core->networkCache->update( 'admin_help_docs', [], DAY_IN_SECONDS );
}

return $aioseoAdminHelpDocs ? json_decode( $aioseoAdminHelpDocs, true ) : [];
$helpDocs = wp_remote_retrieve_body( $request );

aioseo()->core->networkCache->update( 'admin_help_docs', $helpDocs, WEEK_IN_SECONDS );

return json_decode( $helpDocs, true );
}
}
31 changes: 30 additions & 1 deletion app/Common/ImportExport/RankMath/PostMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function importPostMeta() {
'rank_math_twitter_image' => 'twitter_image_custom_url',
'rank_math_twitter_card_type' => 'twitter_card',
'rank_math_primary_category' => 'primary_term',
'rank_math_pillar_content' => 'pillar_content',
];

foreach ( $posts as $post ) {
Expand All @@ -99,7 +100,19 @@ public function importPostMeta() {
->result();

$meta = [
'post_id' => $post->ID,
'post_id' => $post->ID,
'robots_default' => true,
'robots_noarchive' => false,
'canonical_url' => '',
'robots_nofollow' => false,
'robots_noimageindex' => false,
'robots_noindex' => false,
'robots_noodp' => false,
'robots_nosnippet' => false,
'keyphrases' => [
'focus' => [ 'keyphrase' => '' ],
'additional' => []
],
];

if ( ! $postMeta || ! count( $postMeta ) ) {
Expand Down Expand Up @@ -154,7 +167,14 @@ public function importPostMeta() {
case 'rank_math_robots':
$value = aioseo()->helpers->maybeUnserialize( $value );
if ( ! empty( $value ) ) {
$supportedValues = [ 'index', 'noindex', 'nofollow', 'noarchive', 'noimageindex', 'nosnippet' ];
$meta['robots_default'] = false;

foreach ( $supportedValues as $val ) {
$meta[ "robots_$val" ] = false;
}

// This is a separated foreach as we can import any and all values.
foreach ( $value as $robotsName ) {
$meta[ "robots_$robotsName" ] = true;
}
Expand All @@ -163,12 +183,15 @@ public function importPostMeta() {
case 'rank_math_advanced_robots':
$value = aioseo()->helpers->maybeUnserialize( $value );
if ( isset( $value['max-snippet'] ) && is_numeric( $value['max-snippet'] ) ) {
$meta['robots_default'] = false;
$meta['robots_max_snippet'] = intval( $value['max-snippet'] );
}
if ( isset( $value['max-video-preview'] ) && is_numeric( $value['max-video-preview'] ) ) {
$meta['robots_default'] = false;
$meta['robots_max_videopreview'] = intval( $value['max-video-preview'] );
}
if ( ! empty( $value['max-image-preview'] ) ) {
$meta['robots_default'] = false;
$meta['robots_max_imagepreview'] = aioseo()->helpers->sanitizeOption( lcfirst( $value['max-image-preview'] ) );
}
break;
Expand Down Expand Up @@ -200,6 +223,12 @@ public function importPostMeta() {
$value = aioseo()->helpers->pregReplace( '#%excerpt%#', '', $value );
}
$value = aioseo()->importExport->rankMath->helpers->macrosToSmartTags( $value );

$meta[ $mappedMeta[ $name ] ] = esc_html( wp_strip_all_tags( strval( $value ) ) );
break;
case 'rank_math_pillar_content':
$meta['pillar_content'] = 'on' === $value ? 1 : 0;
break;
default:
$meta[ $mappedMeta[ $name ] ] = esc_html( wp_strip_all_tags( strval( $value ) ) );
break;
Expand Down
Loading

0 comments on commit a9e2244

Please sign in to comment.