Merged in feature/314-dev-dev01 (pull request #24)

auto-patch  314-dev-dev01-2024-01-25T04_09_02

* auto-patch  314-dev-dev01-2024-01-25T04_09_02
This commit is contained in:
Tony Volpe
2024-01-25 04:11:47 +00:00
parent 6b67473553
commit 68dbe860e9
540 changed files with 3445 additions and 2131 deletions

View File

@@ -63,6 +63,8 @@ class WPSEO_Replace_Vars {
/**
* Setup the help texts and external replacements as statics so they will be available to all instances.
*
* @return void
*/
public static function setup_statics_once() {
if ( self::$help_texts === [] ) {
@@ -107,7 +109,7 @@ class WPSEO_Replace_Vars {
elseif ( strpos( $var_to_replace, 'cf_' ) === 0 || strpos( $var_to_replace, 'ct_' ) === 0 ) {
trigger_error( esc_html__( 'A replacement variable can not start with "%%cf_" or "%%ct_" as these are reserved for the WPSEO standard variable variables for custom fields and custom taxonomies. Try making your variable name unique.', 'wordpress-seo' ), E_USER_WARNING );
}
elseif ( ! method_exists( __CLASS__, 'retrieve_' . $var_to_replace ) ) {
elseif ( ! method_exists( self::class, 'retrieve_' . $var_to_replace ) ) {
if ( $var_to_replace !== '' && ! isset( self::$external_replacements[ $var_to_replace ] ) ) {
self::$external_replacements[ $var_to_replace ] = $replace_function;
$replacement_variable = new WPSEO_Replacement_Variable( $var_to_replace, $var_to_replace, $help_text );
@@ -156,7 +158,7 @@ class WPSEO_Replace_Vars {
// Clean $omit array.
if ( is_array( $omit ) && $omit !== [] ) {
$omit = array_map( [ __CLASS__, 'remove_var_delimiter' ], $omit );
$omit = array_map( [ self::class, 'remove_var_delimiter' ], $omit );
}
$replacements = [];
@@ -167,10 +169,9 @@ class WPSEO_Replace_Vars {
/**
* Filter: 'wpseo_replacements' - Allow customization of the replacements before they are applied.
*
* @api array $replacements The replacements.
*
* @param array $args The object some of the replacement values might come from,
* could be a post, taxonomy or term.
* @param array $replacements The replacements.
* @param array $args The object some of the replacement values might come from,
* could be a post, taxonomy or term.
*/
$replacements = apply_filters( 'wpseo_replacements', $replacements, $this->args );
@@ -190,12 +191,12 @@ class WPSEO_Replace_Vars {
*
* @example <code>add_filter( 'wpseo_replacements_final', '__return_false' );</code>
*
* @api bool $final
* @param bool $final
*/
if ( apply_filters( 'wpseo_replacements_final', true ) === true && ( isset( $matches[1] ) && is_array( $matches[1] ) ) ) {
// Remove non-replaced variables.
$remove = array_diff( $matches[1], $omit ); // Make sure the $omit variables do not get removed.
$remove = array_map( [ __CLASS__, 'add_var_delimiter' ], $remove );
$remove = array_map( [ self::class, 'add_var_delimiter' ], $remove );
$text = str_replace( $remove, '', $text );
}
@@ -366,21 +367,17 @@ class WPSEO_Replace_Vars {
// Returns a string.
$replacement = YoastSEO()->helpers->date->format_translated( $this->args->post_date, get_option( 'date_format' ) );
}
else {
if ( get_query_var( 'day' ) && get_query_var( 'day' ) !== '' ) {
// Returns a string.
$replacement = get_the_date();
}
else {
if ( single_month_title( ' ', false ) && single_month_title( ' ', false ) !== '' ) {
// Returns a string.
$replacement = single_month_title( ' ', false );
}
elseif ( get_query_var( 'year' ) !== '' ) {
// Returns an integer, let's cast to string.
$replacement = (string) get_query_var( 'year' );
}
}
elseif ( get_query_var( 'day' ) && get_query_var( 'day' ) !== '' ) {
// Returns a string.
$replacement = get_the_date();
}
elseif ( single_month_title( ' ', false ) && single_month_title( ' ', false ) !== '' ) {
// Returns a string.
$replacement = single_month_title( ' ', false );
}
elseif ( get_query_var( 'year' ) !== '' ) {
// Returns an integer, let's cast to string.
$replacement = (string) get_query_var( 'year' );
}
return $replacement;
@@ -394,7 +391,7 @@ class WPSEO_Replace_Vars {
*/
private function retrieve_excerpt() {
$replacement = null;
$locale = \get_locale();
$locale = get_locale();
// Japanese doesn't have a jp_JP variant in WP.
$limit = ( $locale === 'ja' ) ? 80 : 156;
@@ -1148,7 +1145,7 @@ class WPSEO_Replace_Vars {
return null;
}
return \get_the_date( 'Y', $this->args->ID );
return get_the_date( 'Y', $this->args->ID );
}
/**
@@ -1161,7 +1158,7 @@ class WPSEO_Replace_Vars {
return null;
}
return \get_the_date( 'F', $this->args->ID );
return get_the_date( 'F', $this->args->ID );
}
/**
@@ -1174,7 +1171,7 @@ class WPSEO_Replace_Vars {
return null;
}
return \get_the_date( 'd', $this->args->ID );
return get_the_date( 'd', $this->args->ID );
}
/**
@@ -1221,7 +1218,7 @@ class WPSEO_Replace_Vars {
return null;
}
return \get_permalink( $this->args->ID );
return get_permalink( $this->args->ID );
}
/**
@@ -1280,6 +1277,8 @@ class WPSEO_Replace_Vars {
*
* @param string $type Type of variable: 'basic' or 'advanced'.
* @param WPSEO_Replacement_Variable $replacement_variable The replacement variable to register.
*
* @return void
*/
private static function register_help_text( $type, WPSEO_Replacement_Variable $replacement_variable ) {
$identifier = $replacement_variable->get_variable();
@@ -1455,6 +1454,8 @@ class WPSEO_Replace_Vars {
/**
* Set/translate the help texts for the WPSEO standard basic variables.
*
* @return void
*/
private static function set_basic_help_texts() {
/* translators: %s: wp_title() function. */
@@ -1505,6 +1506,8 @@ class WPSEO_Replace_Vars {
/**
* Set/translate the help texts for the WPSEO standard advanced variables.
*
* @return void
*/
private static function set_advanced_help_texts() {
$replacement_variables = [
@@ -1591,8 +1594,8 @@ class WPSEO_Replace_Vars {
* Allows filtering of the terms list used to replace %%category%%, %%tag%%
* and %%ct_<custom-tax-name>%% variables.
*
* @api string $output Comma-delimited string containing the terms.
* @api string $taxonomy The taxonomy of the terms.
* @param string $output Comma-delimited string containing the terms.
* @param string $taxonomy The taxonomy of the terms.
*/
return apply_filters( 'wpseo_terms', $output, $taxonomy );
}