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

@@ -71,9 +71,9 @@ class WPSEO_Rewrite {
/**
* Update the query vars with the redirect var when stripcategorybase is active.
*
* @param array $query_vars Main query vars to filter.
* @param array<string> $query_vars Main query vars to filter.
*
* @return array
* @return array<string> The query vars.
*/
public function query_vars( $query_vars ) {
if ( WPSEO_Options::get( 'stripcategorybase' ) === true ) {
@@ -86,9 +86,9 @@ class WPSEO_Rewrite {
/**
* Checks whether the redirect needs to be created.
*
* @param array $query_vars Query vars to check for existence of redirect var.
* @param array<string> $query_vars Query vars to check for existence of redirect var.
*
* @return array|void The query vars.
* @return array<string> The query vars.
*/
public function request( $query_vars ) {
if ( ! isset( $query_vars['wpseo_category_redirect'] ) ) {
@@ -96,12 +96,13 @@ class WPSEO_Rewrite {
}
$this->redirect( $query_vars['wpseo_category_redirect'] );
return [];
}
/**
* This function taken and only slightly adapted from WP No Category Base plugin by Saurabh Gupta.
*
* @return array
* @return array<string> The category rewrite rules.
*/
public function category_rewrite_rules() {
global $wp_rewrite;
@@ -112,8 +113,10 @@ class WPSEO_Rewrite {
$permalink_structure = get_option( 'permalink_structure' );
$blog_prefix = '';
if ( is_multisite() && ! is_subdomain_install() && is_main_site() && strpos( $permalink_structure, '/blog/' ) === 0 ) {
$blog_prefix = 'blog/';
if ( strpos( $permalink_structure, '/blog/' ) === 0 ) {
if ( ( is_multisite() && ! is_subdomain_install() ) || is_main_site() || is_main_network() ) {
$blog_prefix = 'blog/';
}
}
$categories = get_categories( [ 'hide_empty' => false ] );
@@ -156,12 +159,12 @@ class WPSEO_Rewrite {
/**
* Adds required category rewrites rules.
*
* @param array $rewrites The current set of rules.
* @param string $category_name Category nicename.
* @param string $blog_prefix Multisite blog prefix.
* @param string $pagination_base WP_Query pagination base.
* @param array<string> $rewrites The current set of rules.
* @param string $category_name Category nicename.
* @param string $blog_prefix Multisite blog prefix.
* @param string $pagination_base WP_Query pagination base.
*
* @return array The added set of rules.
* @return array<string> The added set of rules.
*/
protected function add_category_rewrites( $rewrites, $category_name, $blog_prefix, $pagination_base ) {
$rewrite_name = $blog_prefix . '(' . $category_name . ')';

View File

@@ -26,7 +26,7 @@ class WPSEO_Option_Titles extends WPSEO_Option {
*
* {@internal Note: Some of the default values are added via the translate_defaults() method.}}
*
* @var array
* @var string[]
*/
protected $defaults = [
// Form fields.
@@ -101,6 +101,20 @@ class WPSEO_Option_Titles extends WPSEO_Option {
'diversity_policy_id' => 0,
'diversity_staffing_report_id' => 0,
'org-description' => '',
'org-email' => '',
'org-phone' => '',
'org-legal-name' => '',
'org-founding-date' => '',
'org-number-employees' => '',
'org-vat-id' => '',
'org-tax-id' => '',
'org-iso' => '',
'org-duns' => '',
'org-leicode' => '',
'org-naics' => '',
/*
* Uses enrich_defaults to add more along the lines of:
* - 'title-' . $pt->name => ''; // Text field.
@@ -126,14 +140,14 @@ class WPSEO_Option_Titles extends WPSEO_Option {
/**
* Used for "caching" during pageload.
*
* @var array
* @var string[]
*/
protected $enriched_defaults = null;
/**
* Array of variable option name patterns for the option.
*
* @var array
* @var string[]
*/
protected $variable_array_key_patterns = [
'title-',
@@ -149,12 +163,13 @@ class WPSEO_Option_Titles extends WPSEO_Option {
'social-description-',
'social-image-url-',
'social-image-id-',
'org-',
];
/**
* Array of sub-options which should not be overloaded with multi-site defaults.
*
* @var array
* @var string[]
*/
public $ms_exclude = [
'forcerewritetitle',
@@ -205,7 +220,7 @@ class WPSEO_Option_Titles extends WPSEO_Option {
/**
* Get the available separator options.
*
* @return array
* @return string[]
*/
public function get_separator_options() {
$separators = wp_list_pluck( self::get_separator_option_list(), 'option' );
@@ -227,7 +242,7 @@ class WPSEO_Option_Titles extends WPSEO_Option {
/**
* Get the available separator options aria-labels.
*
* @return array Array with the separator options aria-labels.
* @return string[] Array with the separator options aria-labels.
*/
public function get_separator_options_for_display() {
$separators = $this->get_separator_options();
@@ -365,11 +380,11 @@ class WPSEO_Option_Titles extends WPSEO_Option {
/**
* Validate the option.
*
* @param array $dirty New value for the option.
* @param array $clean Clean value for the option, normally the defaults.
* @param array $old Old value of the option.
* @param string[] $dirty New value for the option.
* @param string[] $clean Clean value for the option, normally the defaults.
* @param string[] $old Old value of the option.
*
* @return array Validated clean value for the option to be saved to the database.
* @return string[] Validated clean value for the option to be saved to the database.
*/
protected function validate_option( $dirty, $clean, $old ) {
$allowed_post_types = $this->get_allowed_post_types();
@@ -415,6 +430,7 @@ class WPSEO_Option_Titles extends WPSEO_Option {
* 'social-title-author-wpseo', 'social-title-archive-wpseo'
* 'open_graph_frontpage_title'
*/
case 'org-':
case 'website_name':
case 'alternate_website_name':
case 'title-':
@@ -696,7 +712,7 @@ class WPSEO_Option_Titles extends WPSEO_Option {
*
* {@internal Don't make static as new types may still be registered.}}
*
* @return array
* @return string[]
*/
protected function get_allowed_post_types() {
$allowed_post_types = [];
@@ -724,14 +740,11 @@ class WPSEO_Option_Titles extends WPSEO_Option {
/**
* Clean a given option value.
*
* @param array $option_value Old (not merged with defaults or filtered) option value to
* clean according to the rules for this option.
* @param string|null $current_version Optional. Version from which to upgrade, if not set,
* version specific upgrades will be disregarded.
* @param array|null $all_old_option_values Optional. Only used when importing old options to have
* access to the real old values, in contrast to the saved ones.
* @param string[] $option_value Old (not merged with defaults or filtered) option value to clean according to the rules for this option.
* @param string[]|null $current_version Optional. Version from which to upgrade, if not set, version specific upgrades will be disregarded.
* @param string[]|null $all_old_option_values Optional. Only used when importing old options to have access to the real old values, in contrast to the saved ones.
*
* @return array Cleaned option.
* @return string[] Cleaned option.
*/
protected function clean_option( $option_value, $current_version = null, $all_old_option_values = null ) {
static $original = null;
@@ -912,12 +925,12 @@ class WPSEO_Option_Titles extends WPSEO_Option {
* variable key does not get removed. IMPORTANT: keep this method in line with
* the parent on which it is based!}}
*
* @param array $dirty Original option as retrieved from the database.
* @param array $clean Filtered option where any options which shouldn't be in our option
* @param string[] $dirty Original option as retrieved from the database.
* @param string[] $clean Filtered option where any options which shouldn't be in our option
* have already been removed and any options which weren't set
* have been set to their defaults.
*
* @return array
* @return string[]
*/
protected function retain_variable_keys( $dirty, $clean ) {
if ( ( is_array( $this->variable_array_key_patterns ) && $this->variable_array_key_patterns !== [] ) && ( is_array( $dirty ) && $dirty !== [] ) ) {
@@ -955,7 +968,7 @@ class WPSEO_Option_Titles extends WPSEO_Option {
/**
* Retrieves a list of separator options.
*
* @return array An array of the separator options.
* @return string[] An array of the separator options.
*/
protected static function get_separator_option_list() {
$separators = [

View File

@@ -53,52 +53,18 @@ class WPSEO_Sitemaps_Admin {
$post_type = get_post_type( $post );
wp_cache_delete( 'lastpostmodified:gmt:' . $post_type, 'timeinfo' ); // #17455.
// Not something we're interested in.
if ( $post_type === 'nav_menu_item' ) {
return;
}
// If the post type is excluded in options, we can stop.
if ( WPSEO_Options::get( 'noindex-' . $post_type, false ) ) {
return;
}
if ( ! YoastSEO()->helpers->environment->is_production_mode() ) {
return;
}
$this->ping_search_engines();
}
/**
* Notify Google of the updated sitemap.
*
* @deprecated 22.0
* @codeCoverageIgnore
*
* @return void
*/
public function ping_search_engines() {
if ( get_option( 'blog_public' ) === '0' ) { // Don't ping if blog is not public.
return;
}
/**
* Filter: 'wpseo_allow_xml_sitemap_ping' - Check if pinging is not allowed (allowed by default).
*
* @param bool $allow_ping The boolean that is set to true by default.
*/
if ( apply_filters( 'wpseo_allow_xml_sitemap_ping', true ) === false ) {
return;
}
$url = rawurlencode( WPSEO_Sitemaps_Router::get_base_url( 'sitemap_index.xml' ) );
// Ping Google about our sitemap change.
wp_remote_get( 'https://www.google.com/ping?sitemap=' . $url, [ 'blocking' => false ] );
if ( ! defined( 'WPSEO_PREMIUM_FILE' ) || WPSEO_Options::get( 'enable_index_now' ) === false ) {
wp_remote_get( 'https://www.bing.com/ping?sitemap=' . $url, [ 'blocking' => false ] );
}
_deprecated_function( __METHOD__, 'Yoast SEO 22.0' );
}
/**
@@ -155,7 +121,5 @@ class WPSEO_Sitemaps_Admin {
if ( WP_CACHE ) {
do_action( 'wpseo_hit_sitemap_index' );
}
$this->ping_search_engines();
}
}

View File

@@ -61,7 +61,7 @@ class WPSEO_Sitemaps_Renderer {
/**
* Builds the sitemap index.
*
* @param array $links Set of sitemaps index links.
* @param array<string> $links Set of sitemaps index links.
*
* @return string
*/
@@ -87,18 +87,25 @@ class WPSEO_Sitemaps_Renderer {
/**
* Builds the sitemap.
*
* @param array $links Set of sitemap links.
* @param string $type Sitemap type.
* @param int $current_page Current sitemap page number.
* @param array<string> $links Set of sitemap links.
* @param string $type Sitemap type.
* @param int $current_page Current sitemap page number.
*
* @return string
*/
public function get_sitemap( $links, $type, $current_page ) {
$urlset = '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" '
. 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd '
. 'http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" '
. 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
. 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd '
. 'http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" '
. 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
/**
* Filters the `urlset` for all sitemaps.
*
* @param string $urlset The output for the sitemap's `urlset`.
*/
$urlset = apply_filters( 'wpseo_sitemap_urlset', $urlset );
/**
* Filters the `urlset` for a sitemap by type.
@@ -176,7 +183,7 @@ class WPSEO_Sitemaps_Renderer {
/**
* Build the `<sitemap>` tag for a given URL.
*
* @param array $url Array of parts that make up this entry.
* @param array<string> $url Array of parts that make up this entry.
*
* @return string
*/
@@ -203,7 +210,7 @@ class WPSEO_Sitemaps_Renderer {
*
* Public access for backwards compatibility reasons.
*
* @param array $url Array of parts that make up this entry.
* @param array<string> $url Array of parts that make up this entry.
*
* @return string
*/