plugin updates

This commit is contained in:
Tony Volpe
2024-02-21 16:19:46 +00:00
parent c72f206574
commit 21d4c85c00
1214 changed files with 102269 additions and 179257 deletions

View File

@@ -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;
}