Skip to content

Commit

Permalink
4.3.5 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian-rossi committed Apr 13, 2023
1 parent aca15d1 commit c6721f6
Show file tree
Hide file tree
Showing 46 changed files with 431 additions and 277 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
dist
.DS_STORE
*.pem
.env
*.env
.idea
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.3.4.1
* Version: 4.3.5
* Text Domain: all-in-one-seo-pack
* Domain Path: /languages
*
Expand Down
3 changes: 3 additions & 0 deletions app/Common/ImportExport/RankMath/PostMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ public function importPostMeta() {
$aioseoPost->save();

aioseo()->migration->meta->migrateAdditionalPostMeta( $post->ID );

// Clear the Overview cache.
aioseo()->postSettings->clearPostTypeOverviewCache( $post->ID );
}

if ( count( $posts ) === $postsPerAction ) {
Expand Down
3 changes: 3 additions & 0 deletions app/Common/ImportExport/SeoPress/PostMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public function importPostMeta() {
$aioseoPost->save();

aioseo()->migration->meta->migrateAdditionalPostMeta( $post->ID );

// Clear the Overview cache.
aioseo()->postSettings->clearPostTypeOverviewCache( $post->ID );
}

if ( count( $posts ) === $postsPerAction ) {
Expand Down
3 changes: 3 additions & 0 deletions app/Common/ImportExport/YoastSeo/PostMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ public function importPostMeta() {
$aioseoPost->save();

aioseo()->migration->meta->migrateAdditionalPostMeta( $post->ID );

// Clear the Overview cache.
aioseo()->postSettings->clearPostTypeOverviewCache( $post->ID );
}

if ( count( $posts ) === $postsPerAction ) {
Expand Down
11 changes: 9 additions & 2 deletions app/Common/Main/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public function __construct() {
/**
* Removes emoji detection scripts on WP 6.2 which broke our Emojis.
*
* @since 4.3.4
* @since 4.3.4.1
*
* @return void
*/
public function removeEmojiDetectionScripts() {
global $wp_version;
if ( version_compare( $wp_version, '6.2', '>=' ) ) {
if ( version_compare( $wp_version, '6.2', '>=' ) ) {
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
}
}
Expand All @@ -102,6 +102,7 @@ public function removeEmojiDetectionScripts() {
* Resets the current user if bbPress is active.
* We have to do this because our calls to wp_get_current_user() set the current user early and this breaks core functionality in bbPress.
*
*
* @since 4.1.5
*
* @return void
Expand Down Expand Up @@ -430,6 +431,12 @@ public function dequeueThirdPartyAssets() {
wp_dequeue_script( 'vue' );
wp_dequeue_script( 'vx:backend.js' );
}

// Meta tags for seo plugin.
if ( class_exists( '\Pagup\MetaTags\Settings' ) ) {
wp_dequeue_script( 'pmt__vuejs' );
wp_dequeue_script( 'pmt__script' );
}
}

/**
Expand Down
15 changes: 12 additions & 3 deletions app/Common/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public static function getPost( $postId ) {
$post->post_id = $postId;
$post = self::setDynamicDefaults( $post, $postId );
} else {
$post = self::migrateRemovedQaSchema( $post );
$post = self::runDynamicMigrations( $post );
}

Expand Down Expand Up @@ -177,6 +176,7 @@ private static function migrateRemovedQaSchema( $aioseoPost ) {
* @return Post The modified Post object.
*/
private static function runDynamicMigrations( $post ) {
$post = self::migrateRemovedQaSchema( $post );
$post = self::migrateImageTypes( $post );
$post = self::runDynamicSchemaMigration( $post );

Expand All @@ -201,8 +201,17 @@ private static function runDynamicSchemaMigration( $post ) {
$post = aioseo()->updates->migratePostSchemaHelper( $post );
}

if ( ! property_exists( $post->schema, 'default' ) ) {
$post->schema = self::getDefaultSchemaOptions( $post->schema );
// If the schema prop isn't set yet, we want to set it here.
// We also want to run this regardless of whether it is already set to make sure the default schema graph
// is correctly propagated on the frontend after changing it.
$post->schema = self::getDefaultSchemaOptions( $post->schema );

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.
if ( '#' !== substr( $graph->id, 0, 1 ) ) {
$graph->id = '#' . $graph->id;
}
}

return $post;
Expand Down
4 changes: 3 additions & 1 deletion app/Common/Schema/Graphs/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
exit;
}

use AIOSEO\Plugin\Common\Traits as CommonTraits;

/**
* The base graph class.
*
* @since 4.0.0
*/
abstract class Graph {
use Traits\Image;
use Traits\SocialProfiles;
use CommonTraits\SocialProfiles;

/**
* Returns the graph data.
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Schema/Graphs/KnowledgeGraph/KgOrganization.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function get() {
$data['image'] = [ '@id' => $homeUrl . '#organizationLogo' ];
}

$socialUrls = $this->getOrganizationProfiles();
$socialUrls = array_values( $this->getOrganizationProfiles() );
if ( $socialUrls ) {
$data['sameAs'] = $socialUrls;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Schema/Graphs/KnowledgeGraph/KgPerson.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private function manual() {
$data['image'] = $logo;
}

$socialUrls = $this->getOrganizationProfiles();
$socialUrls = array_values( $this->getOrganizationProfiles() );
if ( $socialUrls ) {
$data['sameAs'] = $socialUrls;
}
Expand Down
18 changes: 15 additions & 3 deletions app/Common/Social/Facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
exit;
}

use AIOSEO\Plugin\Common\Traits;

/**
* Handles the Open Graph meta.
*
* @since 4.0.0
*/
class Facebook {
use Traits\SocialProfiles;

/**
* Returns the Open Graph image URL.
*
Expand Down Expand Up @@ -356,13 +360,21 @@ public function getModifiedTime() {
*/
public function getAuthor() {
$post = aioseo()->helpers->getPost();
if ( ! $post || ! aioseo()->options->social->facebook->general->showAuthor ) {
if ( ! is_a( $post, 'WP_Post' ) || ! aioseo()->options->social->facebook->general->showAuthor ) {
return '';
}

$postAuthor = get_the_author_meta( 'aioseo_facebook', $post->post_author );
$author = '';
$userProfiles = $this->getUserProfiles( $post->post_author );
if ( ! empty( $userProfiles['facebookPageUrl'] ) ) {
$author = $userProfiles['facebookPageUrl'];
}

if ( empty( $author ) ) {
$author = aioseo()->options->social->facebook->advanced->authorUrl;
}

return ! empty( $postAuthor ) ? $postAuthor : aioseo()->options->social->facebook->advanced->authorUrl;
return $author;
}

/**
Expand Down
25 changes: 19 additions & 6 deletions app/Common/Social/Twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
exit;
}

use AIOSEO\Plugin\Common\Traits;

/**
* Handles the Twitter meta.
*
* @since 4.0.0
*/
class Twitter {
use Traits\SocialProfiles;

/**
* Returns the Twitter URL for the site.
*
Expand Down Expand Up @@ -56,14 +60,23 @@ public function getCardType() {
* @return string The creator.
*/
public function getCreator() {
$author = '';
$post = aioseo()->helpers->getPost();
if ( $post && aioseo()->options->social->twitter->general->showAuthor ) {
$twitterUser = get_the_author_meta( 'aioseo_twitter', $post->post_author );
$author = $twitterUser ? $twitterUser : aioseo()->social->twitter->getTwitterUrl();
$author = aioseo()->social->twitter->prepareUsername( $author );
$post = aioseo()->helpers->getPost();
if ( ! is_a( $post, 'WP_Post' ) || ! aioseo()->options->social->twitter->general->showAuthor ) {
return '';
}

$author = '';
$userProfiles = $this->getUserProfiles( $post->post_author );
if ( ! empty( $userProfiles['twitterUrl'] ) ) {
$author = $userProfiles['twitterUrl'];
}

if ( empty( $author ) ) {
$author = aioseo()->social->twitter->getTwitterUrl();
}

$author = aioseo()->social->twitter->prepareUsername( $author );

return $author;
}

Expand Down
81 changes: 64 additions & 17 deletions app/Common/Standalone/PageBuilders/Elementor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
exit;
}

use Elementor\Plugin as ElementorPlugin;
use Elementor\Controls_Manager as ControlsManager;
use Elementor\Core\DocumentTypes\PageBase;

Expand Down Expand Up @@ -58,6 +57,37 @@ public function init() {
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue' ] );
add_action( 'elementor/documents/register_controls', [ $this, 'registerDocumentControls' ] );
add_action( 'elementor/editor/footer', [ $this, 'addContainers' ] );

// Add the SEO tab to the main Elementor panel.
add_action( 'elementor/editor/footer', [ $this, 'startCapturing' ], 0 );
add_action( 'elementor/editor/footer', [ $this, 'endCapturing' ], 999 );
}

/**
* Start capturing buffer.
*
* @since 4.3.5
*
* @return void
*/
public function startCapturing() {
ob_start();
}

/**
* End capturing buffer and add button.
* This is a hack to add the SEO tab to the main Elementor panel.
* We need to do this because Elementor doesn't provide a filter to add tabs to the main panel.
*
* @since 4.3.5
*
* @return void
*/
public function endCapturing() {
$output = ob_get_clean();
$search = '/(<div class="elementor-component-tab elementor-panel-navigation-tab" data-tab="global">.*<\/div>)/m';
$replace = '${1}<div class="elementor-component-tab elementor-panel-navigation-tab" data-tab="aioseo">SEO</div>';
echo preg_replace( $search, $replace, $output ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

/**
Expand Down Expand Up @@ -88,7 +118,7 @@ public function registerDocumentControls( $document ) {
$document->start_controls_section(
'aioseo_section',
[
'label' => __( 'AIOSEO', 'all-in-one-seo-pack' ),
'label' => AIOSEO_PLUGIN_SHORT_NAME,
'tab' => 'aioseo',
]
);
Expand All @@ -101,20 +131,16 @@ public function registerDocumentControls( $document ) {
*
* @since 4.1.7
*
* @param int $postId The Post ID.
* @return boolean Whether or not the Post was built with Elementor.
* @param int $postId The Post ID.
* @return boolean Whether or not the Post was built with Elementor.
*/
public function isBuiltWith( $postId ) {
if ( ! class_exists( '\Elementor\Plugin' ) ) {
return false;
}

$elementorPost = ElementorPlugin::instance()->documents->get( $postId );
if ( empty( $elementorPost ) ) {
$document = $this->getElementorDocument( $postId );
if ( ! $document ) {
return false;
}

return ElementorPlugin::instance()->documents->get( $postId )->is_built_with_elementor();
return $document->is_built_with_elementor();
}

/**
Expand All @@ -126,12 +152,8 @@ public function isBuiltWith( $postId ) {
* @return string The Edit URL.
*/
public function getEditUrl( $postId ) {
if ( ! class_exists( '\Elementor\Plugin' ) ) {
return '';
}

$document = ElementorPlugin::instance()->documents->get( $postId );
if ( empty( $document ) || ! $document->is_editable_by_current_user() ) {
$document = $this->getElementorDocument( $postId );
if ( ! $document || ! $document->is_editable_by_current_user() ) {
return '';
}

Expand All @@ -148,4 +170,29 @@ public function getEditUrl( $postId ) {
public function addContainers() {
echo '<div id="aioseo-admin"></div>';
}

/**
* Returns the Elementor Document instance for the given Post ID.
*
* @since 4.3.5
*
* @param int $postId The Post ID.
* @return object The Elementor Document instance.
*/
private function getElementorDocument( $postId ) {
if (
! class_exists( '\Elementor\Plugin' ) ||
! is_object( \Elementor\Plugin::instance()->documents ) ||
! method_exists( \Elementor\Plugin::instance()->documents, 'get' )
) {
return false;
}

$elementorDocument = \Elementor\Plugin::instance()->documents->get( $postId );
if ( empty( $elementorDocument ) ) {
return false;
}

return $elementorDocument;
}
}
Loading

0 comments on commit c6721f6

Please sign in to comment.