Skip to content

Commit

Permalink
4.5.4 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudbroes committed Jan 12, 2024
1 parent 3c97800 commit 4660154
Show file tree
Hide file tree
Showing 60 changed files with 1,269 additions and 380 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.3.1
* Version: 4.5.4
* Text Domain: all-in-one-seo-pack
* Domain Path: /languages
*
Expand Down
1 change: 1 addition & 0 deletions app/Common/Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ public function addMenu() {
$slug,
[ $this, 'page' ]
);

add_action( "load-{$hook}", [ $this, 'hooks' ] );
}

Expand Down
9 changes: 8 additions & 1 deletion app/Common/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ private static function sanitizePageAnalysis( $data ) {
* @param array $data The data.
* @return Post The Post object with data set.
*/
private static function sanitizeAndSetDefaults( $postId, $thePost, $data ) {
protected static function sanitizeAndSetDefaults( $postId, $thePost, $data ) {
// General
$thePost->post_id = $postId;
$thePost->title = ! empty( $data['title'] ) ? sanitize_text_field( $data['title'] ) : null;
Expand Down Expand Up @@ -464,6 +464,13 @@ private static function sanitizeAndSetDefaults( $postId, $thePost, $data ) {
$thePost->created = gmdate( 'Y-m-d H:i:s' );
}

// Update defaults from addons.
foreach ( aioseo()->addons->getLoadedAddons() as $addon ) {
if ( isset( $addon->postModel ) && method_exists( $addon->postModel, 'sanitizeAndSetDefaults' ) ) {
$thePost = $addon->postModel->sanitizeAndSetDefaults( $postId, $thePost, $data );
}
}

return $thePost;
}

Expand Down
10 changes: 10 additions & 0 deletions app/Common/Schema/Graphs/Article/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ public function get( $graphData = null ) {
$data['pagination'] = $pageNumber;
}

// Check if our addons need to modify this graph.
$addonsArticleData = array_filter( aioseo()->addons->doAddonFunction( 'article', 'get', [
'postId' => $post->ID,
'data' => $data
] ) );

foreach ( $addonsArticleData as $addonArticleData ) {
$data = array_merge( $data, $addonArticleData );
}

return $data;
}

Expand Down
31 changes: 24 additions & 7 deletions app/Common/Schema/Graphs/WebPage/PersonAuthor.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,29 @@ class PersonAuthor extends Graphs\Graph {
*
* @since 4.0.0
*
* @return array $data The graph data.
* @param int $userId The user ID.
* @return array $data The graph data.
*/
public function get() {
public function get( $userId = null ) {
$post = aioseo()->helpers->getPost();
$user = get_queried_object();
$isAuthorPage = is_author() && is_a( $user, 'WP_User' );
if (
( ! is_singular() && ! $isAuthorPage ) ||
( is_singular() && ! is_a( $post, 'WP_Post' ) )
(
( ! is_singular() && ! $isAuthorPage ) ||
( is_singular() && ! is_a( $post, 'WP_Post' ) )
) &&
! $userId
) {
return [];
}

$userId = $isAuthorPage ? $user->ID : $post->post_author;
if ( function_exists( 'bp_is_user' ) && bp_is_user() ) {
$userId = intval( wp_get_current_user()->ID );
// Dynamically determine the User ID.
if ( ! $userId ) {
$userId = $isAuthorPage ? $user->ID : $post->post_author;
if ( function_exists( 'bp_is_user' ) && bp_is_user() ) {
$userId = intval( wp_get_current_user()->ID );
}
}

if ( ! $userId ) {
Expand Down Expand Up @@ -67,6 +74,16 @@ public function get() {
];
}

// Check if our addons need to modify this graph.
$addonsPersonAuthorData = array_filter( aioseo()->addons->doAddonFunction( 'personAuthor', 'get', [
'userId' => $userId,
'data' => $data
] ) );

foreach ( $addonsPersonAuthorData as $addonPersonAuthorData ) {
$data = array_merge( $data, $addonPersonAuthorData );
}

return $data;
}
}
20 changes: 16 additions & 4 deletions app/Common/Schema/Graphs/WebPage/ProfilePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,23 @@
*/
class ProfilePage extends WebPage {
/**
* The graph type.
* Returns the graph data.
*
* @since 4.0.0
* @since 4.5.4
*
* @var string
* @return array The graph data.
*/
protected $type = 'ProfilePage';
public function get() {
$data = parent::get();

$data['@type'] = 'ProfilePage';

// Check if our addons need to add more data.
$addonsPersonAuthorData = array_filter( aioseo()->addons->doAddonFunction( 'profilePage', 'get' ) );
foreach ( $addonsPersonAuthorData as $addonPersonAuthorData ) {
$data = array_merge( $data, $addonPersonAuthorData );
}

return $data;
}
}
5 changes: 2 additions & 3 deletions app/Common/Schema/Graphs/WebPage/WebPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ public function get() {
'breadcrumb' => [ '@id' => aioseo()->schema->context['url'] . '#breadcrumblist' ]
];

if ( is_singular() && ! is_page() ) {
if ( is_singular() && 'page' !== get_post_type() ) {
$post = aioseo()->helpers->getPost();

if ( is_a( $post, 'WP_Post' ) ) {
if ( is_a( $post, 'WP_Post' ) && post_type_supports( $post->post_type, 'author' ) ) {
$author = get_author_posts_url( $post->post_author );
if ( ! empty( $author ) ) {
if ( ! in_array( 'PersonAuthor', aioseo()->schema->graphs, true ) ) {
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Schema/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ protected function determineSmartGraphsAndContext( $isValidator = false ) {
}

if ( is_author() ) {
$this->graphs[] = 'CollectionPage';
$this->graphs[] = 'ProfilePage';
$this->graphs[] = 'PersonAuthor';
$this->context = $contextInstance->author();
}
Expand Down
10 changes: 10 additions & 0 deletions app/Common/Standalone/Standalone.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ class Standalone {
*/
public $primaryTerm = null;

/**
* UserProfileTab class instance.
*
* @since 4.5.4
*
* @var UserProfileTab
*/
public $userProfileTab = null;

/**
* List of page builder integration class instances.
*
Expand Down Expand Up @@ -83,6 +92,7 @@ public function __construct() {
$this->seoPreview = new SeoPreview();
$this->setupWizard = new SetupWizard();
$this->primaryTerm = aioseo()->pro ? new ProStandalone\PrimaryTerm() : new PrimaryTerm();
$this->userProfileTab = new UserProfileTab();

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

Expand Down
2 changes: 1 addition & 1 deletion app/Common/Standalone/UserProfileTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function enqueueScript() {
*
* @return array
*/
private function getVueData() {
public function getVueData() {
global $user_id;

$socialProfiles = $this->getSocialProfiles();
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Traits/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ public function skipModuleTag( $handle ) {
* sub-domains that don't have the proper CORS headers. Those sites will need
* manual fixes.
*
* 4.1.10
* @since 4.1.10
*
* @param string $path The path to normalize.
* @return string The normalized path.
Expand Down
51 changes: 50 additions & 1 deletion app/Common/Traits/Helpers/Arrays.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public function arrayReplaceRecursive( $targetArray, $replacementArray ) {
* Recursively intersects the two given arrays.
* You can pass in an optional argument (allowedKey) to restrict the intersect to arrays with a specific key.
* This is needed when we are e.g. sanitizing array values before setting/saving them to an option.
* This helper method was mainly built to support our complex options architecture.
*
* @since 4.2.5
*
Expand All @@ -137,7 +138,7 @@ public function arrayReplaceRecursive( $targetArray, $replacementArray ) {
*/
public function arrayIntersectRecursive( $array1, $array2, $allowedKey = '', $parentKey = '' ) {
if ( ! $allowedKey || $allowedKey === $parentKey ) {
$array1 = array_intersect_assoc( $array1, $array2 );
$array1 = $this->arrayIntersectRecursiveHelper( $array1, $array2 );
}

if ( empty( $array1 ) ) {
Expand All @@ -157,6 +158,54 @@ public function arrayIntersectRecursive( $array1, $array2, $allowedKey = '', $pa
return $array1;
}

/**
* Recursively intersects the two given arrays. Supports arrays with a mix of nested arrays and primitive values.
* Helper function for arrayIntersectRecursive().
*
* @since 4.5.4
*
* @param array $array1 The first array.
* @param array $array2 The second array.
* @return array The intersected array.
*/
private function arrayIntersectRecursiveHelper( $array1, $array2 ) {
if ( null === $array2 ) {
$array2 = [];
}

if ( is_array( $array1 ) ) {
// First, check with keys are nested arrays and which are primitive values.
$arrays = [];
$primitives = [];
foreach ( $array1 as $k => $v ) {
if ( is_array( $v ) ) {
$arrays[ $k ] = $v;
} else {
$primitives[ $k ] = $v;
}
}

// Then, intersect the primitive values.
$intersectedPrimitives = array_intersect_assoc( $primitives, $array2 );

// Finally, recursively intersect the nested arrays.
$intersectedArrays = [];
foreach ( $arrays as $k => $v ) {
if ( isset( $array2[ $k ] ) ) {
$intersectedArrays[ $k ] = $this->arrayIntersectRecursiveHelper( $v, $array2[ $k ] );
} else {
// If the nested array doesn't exist in the second array, we can just unset it.
unset( $arrays[ $k ] );
}
}

// Merge the intersected arrays and primitive values.
return array_merge( $intersectedPrimitives, $intersectedArrays );
}

return array_intersect_assoc( $array1, $array2 );
}

/**
* Sorts the keys of an array alphabetically.
* The array is passed by reference, so it's not returned the same as in `ksort()`.
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Traits/Helpers/Strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ public function isValidRegex( $pattern ) {

$isValid = true;

if ( false === preg_match( $pattern, null ) ) {
if ( false === preg_match( $pattern, '' ) ) {
$isValid = false;
}

Expand Down
5 changes: 5 additions & 0 deletions app/Common/Traits/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,11 @@ public function sanitizeField( $value, $type, $preserveHtml = false ) {
case 'array':
$array = [];
foreach ( (array) $value as $k => $v ) {
if ( is_array( $v ) ) {
$array[ $k ] = $this->sanitizeField( $v, 'array' );
continue;
}

$array[ $k ] = sanitize_text_field( $preserveHtml ? htmlspecialchars( $v, ENT_NOQUOTES, 'UTF-8' ) : $v );
}

Expand Down
51 changes: 50 additions & 1 deletion app/Common/Utils/Addons.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,23 @@ class Addons {
private $videoSitemap = null;

/**
* The main LinkAssistant addon class.
* The main Link Assistant addon class.
*
* @since 4.4.2
*
* @var \AIOSEO\Plugin\Addon\LinkAssistant\LinkAssistant
*/
private $linkAssistant = null;

/**
* The main EEAT addon class.
*
* @since 4.5.4
*
* @var \AIOSEO\Plugin\Addon\LinkAssistant\LinkAssistant
*/
private $eeat = null;

/**
* Returns our addons.
*
Expand Down Expand Up @@ -131,6 +140,10 @@ public function getAddons( $flushCache = false ) {

$installedPlugins = array_keys( get_plugins() );
foreach ( $addons as $key => $addon ) {
if ( ! is_object( $addon ) ) {
continue;
}

$addons[ $key ]->basename = $this->getAddonBasename( $addon->sku );
$addons[ $key ]->installed = in_array( $this->getAddonBasename( $addon->sku ), $installedPlugins, true );
$addons[ $key ]->isActive = is_plugin_active( $addons[ $key ]->basename );
Expand Down Expand Up @@ -201,6 +214,10 @@ public function unlicensedAddons() {

$addons = $this->getAddons();
foreach ( $addons as $addon ) {
if ( ! is_object( $addon ) ) {
continue;
}

if ( $addon->isActive ) {
$unlicensed['addons'][] = $addon;
}
Expand Down Expand Up @@ -568,6 +585,38 @@ public function getDefaultAddon( $sku ) {
*/
protected function getDefaultAddons() {
return json_decode( wp_json_encode( [
[
'sku' => 'aioseo-eeat',
'name' => 'Author SEO (E-E-A-T)',
'version' => '1.0.0',
'image' => null,
'icon' => 'svg-eeat',
'levels' => [
'plus',
'pro',
'elite',
],
'currentLevels' => [
'plus',
'pro',
'elite'
],
'requiresUpgrade' => true,
'description' => '<p>Optimize your site for Google\'s E-E-A-T ranking factor by proving your writer\'s expertise through author schema markup and new UI elements.</p>',
'descriptionVersion' => 0,
'productUrl' => 'https://aioseo.com/author-seo-eeat/',
'learnMoreUrl' => 'https://aioseo.com/author-seo-eeat/',
'manageUrl' => '',
'basename' => 'aioseo-eeat/aioseo-eeat.php',
'installed' => false,
'isActive' => false,
'canInstall' => false,
'canActivate' => false,
'canUpdate' => false,
'capability' => $this->getManageCapability( 'aioseo-eeat' ),
'minimumVersion' => '0.0.0',
'hasMinimumVersion' => false
],
[
'sku' => 'aioseo-redirects',
'name' => 'Redirection Manager',
Expand Down
6 changes: 1 addition & 5 deletions app/Common/Utils/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -930,11 +930,7 @@ public function getTagValue( $tag, $id, $sampleData = false ) {
case 'taxonomy_title':
$title = $this->getTaxonomyTitle( $postId );

if ( empty( $postId ) ) {
return $sampleData ? __( 'Sample Taxonomy Title', 'all-in-one-seo-pack' ) : '';
}

return $title;
return ! $title && $sampleData ? __( 'Sample Taxonomy Title', 'all-in-one-seo-pack' ) : $title;
case 'tax_parent_name':
$termObject = get_term( $id );
$parentTermObject = ! empty( $termObject->parent ) ? get_term( $termObject->parent ) : '';
Expand Down
Loading

0 comments on commit 4660154

Please sign in to comment.