plugin updates
This commit is contained in:
@@ -308,7 +308,7 @@ class Front_End_Integration implements Integration_Interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns correct adjacent pages when QUery loop block does not inherit query from template.
|
||||
* Returns correct adjacent pages when Query loop block does not inherit query from template.
|
||||
*
|
||||
* @param string $link The current link.
|
||||
* @param string $rel Link relationship, prev or next.
|
||||
@@ -322,26 +322,16 @@ class Front_End_Integration implements Integration_Interface {
|
||||
}
|
||||
|
||||
if ( $rel === 'next' || $rel === 'prev' ) {
|
||||
|
||||
// WP_HTML_Tag_Processor was introduced in WordPress 6.2.
|
||||
// Reconstruct url if it's relative.
|
||||
if ( \class_exists( WP_HTML_Tag_Processor::class ) ) {
|
||||
$processor = new WP_HTML_Tag_Processor( $this->$rel );
|
||||
while ( $processor->next_tag( [ 'tag_name' => 'a' ] ) ) {
|
||||
$href = $processor->get_attribute( 'href' );
|
||||
if ( $href ) {
|
||||
if ( $href && \strpos( $href, '/' ) === 0 ) {
|
||||
return $presentation->permalink . \substr( $href, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove else when dropping support for WordPress 6.1 and lower.
|
||||
else {
|
||||
$pattern = '/"(.*?)"/';
|
||||
// Find all matches of the pattern in the HTML string.
|
||||
\preg_match_all( $pattern, $this->$rel, $matches );
|
||||
if ( isset( $matches[1] ) && isset( $matches[1][0] ) && $matches[1][0] ) {
|
||||
return $presentation->permalink . \substr( $matches[1][0], 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $link;
|
||||
|
||||
@@ -11,6 +11,7 @@ use WPSEO_Admin_Editor_Specific_Replace_Vars;
|
||||
use WPSEO_Admin_Recommended_Replace_Vars;
|
||||
use WPSEO_Option_Titles;
|
||||
use WPSEO_Options;
|
||||
use WPSEO_Plugin_Availability;
|
||||
use WPSEO_Replace_Vars;
|
||||
use WPSEO_Shortlinker;
|
||||
use WPSEO_Sitemaps_Router;
|
||||
@@ -453,10 +454,24 @@ class Settings_Integration implements Integration_Interface {
|
||||
$page_on_front = \get_option( 'page_on_front' );
|
||||
$page_for_posts = \get_option( 'page_for_posts' );
|
||||
|
||||
$wpseo_plugin_availability_checker = new WPSEO_Plugin_Availability();
|
||||
$woocommerce_seo_file = 'wpseo-woocommerce/wpseo-woocommerce.php';
|
||||
$woocommerce_seo_active = $wpseo_plugin_availability_checker->is_active( $woocommerce_seo_file );
|
||||
|
||||
if ( empty( $page_on_front ) ) {
|
||||
$page_on_front = $page_for_posts;
|
||||
}
|
||||
|
||||
$business_settings_url = \get_admin_url( null, 'admin.php?page=wpseo_local' );
|
||||
if ( \defined( 'WPSEO_LOCAL_FILE' ) ) {
|
||||
$local_options = \get_option( 'wpseo_local' );
|
||||
$multiple_locations = $local_options['use_multiple_locations'];
|
||||
$same_organization = $local_options['multiple_locations_same_organization'];
|
||||
if ( $multiple_locations === 'on' && $same_organization !== 'on' ) {
|
||||
$business_settings_url = \get_admin_url( null, 'edit.php?post_type=wpseo_locations' );
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'isPremium' => $this->product_helper->is_premium(),
|
||||
'isRtl' => \is_rtl(),
|
||||
@@ -466,6 +481,7 @@ class Settings_Integration implements Integration_Interface {
|
||||
'isWooCommerceActive' => $this->woocommerce_helper->is_active(),
|
||||
'isLocalSeoActive' => \defined( 'WPSEO_LOCAL_FILE' ),
|
||||
'isNewsSeoActive' => \defined( 'WPSEO_NEWS_FILE' ),
|
||||
'isWooCommerceSEOActive' => $woocommerce_seo_active,
|
||||
'promotions' => \YoastSEO()->classes->get( Promotion_Manager::class )->get_current_promotions(),
|
||||
'siteUrl' => \get_bloginfo( 'url' ),
|
||||
'siteTitle' => \get_bloginfo( 'name' ),
|
||||
@@ -473,6 +489,7 @@ class Settings_Integration implements Integration_Interface {
|
||||
'hasWooCommerceShopPage' => $shop_page_id !== -1,
|
||||
'editWooCommerceShopPageUrl' => \get_edit_post_link( $shop_page_id, 'js' ),
|
||||
'wooCommerceShopPageSettingUrl' => \get_admin_url( null, 'admin.php?page=wc-settings&tab=products' ),
|
||||
'localSeoPageSettingUrl' => $business_settings_url,
|
||||
'homepageIsLatestPosts' => $homepage_is_latest_posts,
|
||||
'homepagePageEditUrl' => \get_edit_post_link( $page_on_front, 'js' ),
|
||||
'homepagePostsEditUrl' => \get_edit_post_link( $page_for_posts, 'js' ),
|
||||
@@ -548,7 +565,7 @@ class Settings_Integration implements Integration_Interface {
|
||||
* @param int $policy The policy id to check.
|
||||
* @param string $key The option key name.
|
||||
*
|
||||
* @return array The policy data.
|
||||
* @return array<int,string> The policy data.
|
||||
*/
|
||||
private function maybe_add_policy( $policies, $policy, $key ) {
|
||||
$policy_array = [
|
||||
@@ -575,7 +592,7 @@ class Settings_Integration implements Integration_Interface {
|
||||
/**
|
||||
* Returns settings for the Call to Buy (CTB) buttons.
|
||||
*
|
||||
* @return string[] The array of CTB settings.
|
||||
* @return array<string> The array of CTB settings.
|
||||
*/
|
||||
public function get_upsell_settings() {
|
||||
return [
|
||||
@@ -614,6 +631,64 @@ class Settings_Integration implements Integration_Interface {
|
||||
}
|
||||
}
|
||||
|
||||
if ( \defined( 'WPSEO_LOCAL_FILE' ) ) {
|
||||
$defaults = $this->get_defaults_from_local_seo( $defaults );
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the organization schema values from Local SEO for defaults in Site representation fields.
|
||||
* Specifically for the org-vat-id, org-tax-id, org-email and org-phone options.
|
||||
*
|
||||
* @param array<string|int|bool> $defaults The settings defaults.
|
||||
*
|
||||
* @return array<string|int|bool> The settings defaults with local seo overides.
|
||||
*/
|
||||
protected function get_defaults_from_local_seo( $defaults ) {
|
||||
$local_options = \get_option( 'wpseo_local' );
|
||||
$multiple_locations = $local_options['use_multiple_locations'];
|
||||
$same_organization = $local_options['multiple_locations_same_organization'];
|
||||
$shared_info = $local_options['multiple_locations_shared_business_info'];
|
||||
if ( $multiple_locations !== 'on' || ( $multiple_locations === 'on' && $same_organization === 'on' && $shared_info === 'on' ) ) {
|
||||
$defaults['wpseo_titles']['org-vat-id'] = $local_options['location_vat_id'];
|
||||
$defaults['wpseo_titles']['org-tax-id'] = $local_options['location_tax_id'];
|
||||
$defaults['wpseo_titles']['org-email'] = $local_options['location_email'];
|
||||
$defaults['wpseo_titles']['org-phone'] = $local_options['location_phone'];
|
||||
}
|
||||
|
||||
if ( \wpseo_has_primary_location() ) {
|
||||
$primary_location = $local_options['multiple_locations_primary_location'];
|
||||
|
||||
$location_keys = [
|
||||
'org-phone' => [
|
||||
'is_overridden' => '_wpseo_is_overridden_business_phone',
|
||||
'value' => '_wpseo_business_phone',
|
||||
],
|
||||
'org-email' => [
|
||||
'is_overridden' => '_wpseo_is_overridden_business_email',
|
||||
'value' => '_wpseo_business_email',
|
||||
],
|
||||
'org-tax-id' => [
|
||||
'is_overridden' => '_wpseo_is_overridden_business_tax_id',
|
||||
'value' => '_wpseo_business_tax_id',
|
||||
],
|
||||
'org-vat-id' => [
|
||||
'is_overridden' => '_wpseo_is_overridden_business_vat_id',
|
||||
'value' => '_wpseo_business_vat_id',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ( $location_keys as $key => $meta_keys ) {
|
||||
$is_overridden = ( $shared_info === 'on' ) ? \get_post_meta( $primary_location, $meta_keys['is_overridden'], true ) : false;
|
||||
if ( $is_overridden === 'on' || $shared_info !== 'on' ) {
|
||||
$post_meta_value = \get_post_meta( $primary_location, $meta_keys['value'], true );
|
||||
$defaults['wpseo_titles'][ $key ] = ( $post_meta_value ) ? $post_meta_value : '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Yoast\WP\SEO\Integrations\Watchers;
|
||||
|
||||
use wpdb;
|
||||
use Yoast\WP\SEO\Builders\Indexable_Hierarchy_Builder;
|
||||
use Yoast\WP\SEO\Conditionals\Migrations_Conditional;
|
||||
use Yoast\WP\SEO\Helpers\Permalink_Helper;
|
||||
@@ -40,13 +39,6 @@ class Indexable_Ancestor_Watcher implements Integration_Interface {
|
||||
*/
|
||||
protected $indexable_hierarchy_repository;
|
||||
|
||||
/**
|
||||
* Represents the WordPress database object.
|
||||
*
|
||||
* @var wpdb
|
||||
*/
|
||||
protected $wpdb;
|
||||
|
||||
/**
|
||||
* Represents the permalink helper.
|
||||
*
|
||||
@@ -67,7 +59,6 @@ class Indexable_Ancestor_Watcher implements Integration_Interface {
|
||||
* @param Indexable_Repository $indexable_repository The indexable repository.
|
||||
* @param Indexable_Hierarchy_Builder $indexable_hierarchy_builder The indexable hierarchy builder.
|
||||
* @param Indexable_Hierarchy_Repository $indexable_hierarchy_repository The indexable hierarchy repository.
|
||||
* @param wpdb $wpdb The wpdb object.
|
||||
* @param Permalink_Helper $permalink_helper The permalink helper.
|
||||
* @param Post_Type_Helper $post_type_helper The post type helper.
|
||||
*/
|
||||
@@ -75,13 +66,11 @@ class Indexable_Ancestor_Watcher implements Integration_Interface {
|
||||
Indexable_Repository $indexable_repository,
|
||||
Indexable_Hierarchy_Builder $indexable_hierarchy_builder,
|
||||
Indexable_Hierarchy_Repository $indexable_hierarchy_repository,
|
||||
wpdb $wpdb,
|
||||
Permalink_Helper $permalink_helper,
|
||||
Post_Type_Helper $post_type_helper
|
||||
) {
|
||||
$this->indexable_repository = $indexable_repository;
|
||||
$this->indexable_hierarchy_builder = $indexable_hierarchy_builder;
|
||||
$this->wpdb = $wpdb;
|
||||
$this->indexable_hierarchy_repository = $indexable_hierarchy_repository;
|
||||
$this->permalink_helper = $permalink_helper;
|
||||
$this->post_type_helper = $post_type_helper;
|
||||
@@ -99,7 +88,7 @@ class Indexable_Ancestor_Watcher implements Integration_Interface {
|
||||
/**
|
||||
* Returns the conditionals based on which this loadable should be active.
|
||||
*
|
||||
* @return array
|
||||
* @return array<Migrations_Conditional>
|
||||
*/
|
||||
public static function get_conditionals() {
|
||||
return [ Migrations_Conditional::class ];
|
||||
@@ -139,10 +128,10 @@ class Indexable_Ancestor_Watcher implements Integration_Interface {
|
||||
/**
|
||||
* Finds all child indexables for the given term.
|
||||
*
|
||||
* @param int $term_id Term to fetch the indexable for.
|
||||
* @param Indexable[] $child_indexables The already known child indexables.
|
||||
* @param int $term_id Term to fetch the indexable for.
|
||||
* @param array<Indexable> $child_indexables The already known child indexables.
|
||||
*
|
||||
* @return array The list of additional child indexables for a given term.
|
||||
* @return array<Indexable> The list of additional child indexables for a given term.
|
||||
*/
|
||||
public function get_children_for_term( $term_id, array $child_indexables ) {
|
||||
// Finds object_ids (posts) for the term.
|
||||
@@ -195,26 +184,29 @@ class Indexable_Ancestor_Watcher implements Integration_Interface {
|
||||
/**
|
||||
* Retrieves the object id's for a term based on the term-post relationship.
|
||||
*
|
||||
* @param int $term_id The term to get the object id's for.
|
||||
* @param Indexable[] $child_indexables The child indexables.
|
||||
* @param int $term_id The term to get the object id's for.
|
||||
* @param array<Indexable> $child_indexables The child indexables.
|
||||
*
|
||||
* @return array List with object ids for the term.
|
||||
* @return array<int> List with object ids for the term.
|
||||
*/
|
||||
protected function get_object_ids_for_term( $term_id, $child_indexables ) {
|
||||
global $wpdb;
|
||||
|
||||
$filter_terms = static function ( $child ) {
|
||||
return $child->object_type === 'term';
|
||||
};
|
||||
|
||||
$child_terms = \array_filter( $child_indexables, $filter_terms );
|
||||
$child_object_ids = \wp_list_pluck( $child_terms, 'object_id' );
|
||||
$child_object_ids = \array_merge( [ $term_id ], \wp_list_pluck( $child_terms, 'object_id' ) );
|
||||
|
||||
// Get the term-taxonomy id's for the term and its children.
|
||||
$term_taxonomy_ids = $this->wpdb->get_col(
|
||||
$this->wpdb->prepare(
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
$term_taxonomy_ids = $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
'SELECT term_taxonomy_id
|
||||
FROM ' . $this->wpdb->term_taxonomy . '
|
||||
WHERE term_id IN( ' . \implode( ', ', \array_fill( 0, ( \count( $child_object_ids ) + 1 ), '%s' ) ) . ' )',
|
||||
$term_id,
|
||||
FROM %i
|
||||
WHERE term_id IN( ' . \implode( ', ', \array_fill( 0, ( \count( $child_object_ids ) ), '%s' ) ) . ' )',
|
||||
$wpdb->term_taxonomy,
|
||||
...$child_object_ids
|
||||
)
|
||||
);
|
||||
@@ -225,11 +217,13 @@ class Indexable_Ancestor_Watcher implements Integration_Interface {
|
||||
}
|
||||
|
||||
// Get the (post) object id's that are attached to the term.
|
||||
return $this->wpdb->get_col(
|
||||
$this->wpdb->prepare(
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
return $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
'SELECT DISTINCT object_id
|
||||
FROM ' . $this->wpdb->term_relationships . '
|
||||
FROM %i
|
||||
WHERE term_taxonomy_id IN( ' . \implode( ', ', \array_fill( 0, \count( $term_taxonomy_ids ), '%s' ) ) . ' )',
|
||||
$wpdb->term_relationships,
|
||||
...$term_taxonomy_ids
|
||||
)
|
||||
);
|
||||
|
||||
@@ -28,7 +28,7 @@ class Option_Titles_Watcher implements Integration_Interface {
|
||||
/**
|
||||
* Returns the conditionals based on which this loadable should be active.
|
||||
*
|
||||
* @return array
|
||||
* @return array<Migrations_Conditional>
|
||||
*/
|
||||
public static function get_conditionals() {
|
||||
return [ Migrations_Conditional::class ];
|
||||
@@ -37,8 +37,8 @@ class Option_Titles_Watcher implements Integration_Interface {
|
||||
/**
|
||||
* Checks if one of the relevant options has been changed.
|
||||
*
|
||||
* @param array $old_value The old value of the option.
|
||||
* @param array $new_value The new value of the option.
|
||||
* @param array<string,int,bool> $old_value The old value of the option.
|
||||
* @param array<string,int,bool> $new_value The new value of the option.
|
||||
*
|
||||
* @return bool Whether or not the ancestors are removed.
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ class Option_Titles_Watcher implements Integration_Interface {
|
||||
/**
|
||||
* Retrieves the relevant keys.
|
||||
*
|
||||
* @return array Array with the relevant keys.
|
||||
* @return array<string> Array with the relevant keys.
|
||||
*/
|
||||
protected function get_relevant_keys() {
|
||||
$post_types = \get_post_types( [ 'public' => true ], 'names' );
|
||||
@@ -95,7 +95,7 @@ class Option_Titles_Watcher implements Integration_Interface {
|
||||
/**
|
||||
* Removes the ancestors for given post types.
|
||||
*
|
||||
* @param array $post_types The post types to remove hierarchy for.
|
||||
* @param array<string> $post_types The post types to remove hierarchy for.
|
||||
*
|
||||
* @return bool True when delete query was successful.
|
||||
*/
|
||||
@@ -105,21 +105,23 @@ class Option_Titles_Watcher implements Integration_Interface {
|
||||
}
|
||||
|
||||
$wpdb = Wrapper::get_wpdb();
|
||||
$total = \count( $post_types );
|
||||
$hierarchy_table = Model::get_table_name( 'Indexable_Hierarchy' );
|
||||
$indexable_table = Model::get_table_name( 'Indexable' );
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Delete query.
|
||||
$result = $wpdb->query(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
DELETE FROM `$hierarchy_table`
|
||||
DELETE FROM %i
|
||||
WHERE indexable_id IN(
|
||||
SELECT id
|
||||
FROM `$indexable_table`
|
||||
FROM %i
|
||||
WHERE object_type = 'post'
|
||||
AND object_sub_type IN( " . \implode( ', ', \array_fill( 0, $total, '%s' ) ) . ' )
|
||||
AND object_sub_type IN( " . \implode( ', ', \array_fill( 0, \count( $post_types ), '%s' ) ) . ' )
|
||||
)',
|
||||
$post_types
|
||||
$hierarchy_table,
|
||||
$indexable_table,
|
||||
...$post_types
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user