plugin updates
This commit is contained in:
@@ -51,7 +51,9 @@ class WPSEO_Post_Type {
|
||||
* @return array The filtered array.
|
||||
*/
|
||||
public static function filter_attachment_post_type( array $post_types ) {
|
||||
unset( $post_types['attachment'] );
|
||||
if ( WPSEO_Options::get( 'disable-attachment' ) === true ) {
|
||||
unset( $post_types['attachment'] );
|
||||
}
|
||||
|
||||
return $post_types;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class WPSEO_Rewrite {
|
||||
add_filter( 'query_vars', [ $this, 'query_vars' ] );
|
||||
add_filter( 'term_link', [ $this, 'no_category_base' ], 10, 3 );
|
||||
add_filter( 'request', [ $this, 'request' ] );
|
||||
add_filter( 'category_rewrite_rules', [ $this, 'category_rewrite_rules' ] );
|
||||
add_filter( 'category_rewrite_rules', [ $this, 'category_rewrite_rules_wrapper' ] );
|
||||
|
||||
add_action( 'created_category', [ $this, 'schedule_flush' ] );
|
||||
add_action( 'edited_category', [ $this, 'schedule_flush' ] );
|
||||
@@ -32,7 +32,9 @@ class WPSEO_Rewrite {
|
||||
* @return void
|
||||
*/
|
||||
public function schedule_flush() {
|
||||
add_action( 'shutdown', 'flush_rewrite_rules' );
|
||||
if ( WPSEO_Options::get( 'stripcategorybase' ) === true ) {
|
||||
add_action( 'shutdown', 'flush_rewrite_rules' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,6 +47,10 @@ class WPSEO_Rewrite {
|
||||
* @return string
|
||||
*/
|
||||
public function no_category_base( $link, $term, $taxonomy ) {
|
||||
if ( WPSEO_Options::get( 'stripcategorybase' ) !== true ) {
|
||||
return $link;
|
||||
}
|
||||
|
||||
if ( $taxonomy !== 'category' ) {
|
||||
return $link;
|
||||
}
|
||||
@@ -91,6 +97,10 @@ class WPSEO_Rewrite {
|
||||
* @return array<string> The query vars.
|
||||
*/
|
||||
public function request( $query_vars ) {
|
||||
if ( WPSEO_Options::get( 'stripcategorybase' ) !== true ) {
|
||||
return $query_vars;
|
||||
}
|
||||
|
||||
if ( ! isset( $query_vars['wpseo_category_redirect'] ) ) {
|
||||
return $query_vars;
|
||||
}
|
||||
@@ -99,6 +109,21 @@ class WPSEO_Rewrite {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for the category_rewrite_rules() below, so we can add the $rules param in a BC way.
|
||||
*
|
||||
* @param array<string> $rules Rewrite rules generated for the current permastruct, keyed by their regex pattern.
|
||||
*
|
||||
* @return array<string> The category rewrite rules.
|
||||
*/
|
||||
public function category_rewrite_rules_wrapper( $rules ) {
|
||||
if ( WPSEO_Options::get( 'stripcategorybase' ) !== true ) {
|
||||
return $rules;
|
||||
}
|
||||
|
||||
return $this->category_rewrite_rules();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function taken and only slightly adapted from WP No Category Base plugin by Saurabh Gupta.
|
||||
*
|
||||
|
||||
@@ -103,10 +103,6 @@ class WPSEO_Upgrade {
|
||||
add_action( 'init', [ $this, 'upgrade_125' ] );
|
||||
}
|
||||
|
||||
// Since 3.7.
|
||||
$upsell_notice = new WPSEO_Product_Upsell_Notice();
|
||||
$upsell_notice->set_upgrade_notice();
|
||||
|
||||
/**
|
||||
* Filter: 'wpseo_run_upgrade' - Runs the upgrade hook which are dependent on Yoast SEO.
|
||||
*
|
||||
@@ -154,9 +150,9 @@ class WPSEO_Upgrade {
|
||||
*/
|
||||
protected function finish_up( $previous_version = null ) {
|
||||
if ( $previous_version ) {
|
||||
WPSEO_Options::set( 'previous_version', $previous_version );
|
||||
WPSEO_Options::set( 'previous_version', $previous_version, 'wpseo' );
|
||||
}
|
||||
WPSEO_Options::set( 'version', WPSEO_VERSION );
|
||||
WPSEO_Options::set( 'version', WPSEO_VERSION, 'wpseo' );
|
||||
|
||||
// Just flush rewrites, always, to at least make them work after an upgrade.
|
||||
add_action( 'shutdown', 'flush_rewrite_rules' );
|
||||
|
||||
@@ -240,7 +240,7 @@ class WPSEO_Meta {
|
||||
*/
|
||||
public static function init() {
|
||||
foreach ( self::$social_networks as $option => $network ) {
|
||||
if ( WPSEO_Options::get( $option, false ) === true ) {
|
||||
if ( WPSEO_Options::get( $option, false, [ 'wpseo_social' ] ) === true ) {
|
||||
foreach ( self::$social_fields as $box => $type ) {
|
||||
self::$meta_fields['social'][ $network . '-' . $box ] = [
|
||||
'type' => $type,
|
||||
|
||||
@@ -107,7 +107,7 @@ class WPSEO_Option_Social extends WPSEO_Option {
|
||||
* @return void
|
||||
*/
|
||||
public function translate_defaults() {
|
||||
self::$twitter_card_types['summary_large_image'] = __( 'Summary with large image', 'wordpress-seo' );
|
||||
self::$twitter_card_types['summary_large_image'] = 'Summary with large image';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -212,10 +212,13 @@ class WPSEO_Options {
|
||||
/**
|
||||
* Retrieve all the options for the SEO plugin in one go.
|
||||
*
|
||||
* @param array<string> $specific_options The option groups of the option you want to get.
|
||||
*
|
||||
* @return array Array combining the values of all the options.
|
||||
*/
|
||||
public static function get_all() {
|
||||
static::$option_values = static::get_options( static::get_option_names() );
|
||||
public static function get_all( $specific_options = [] ) {
|
||||
$option_names = ( empty( $specific_options ) ) ? static::get_option_names() : $specific_options;
|
||||
static::$option_values = static::get_options( $option_names );
|
||||
|
||||
return static::$option_values;
|
||||
}
|
||||
@@ -269,14 +272,15 @@ class WPSEO_Options {
|
||||
/**
|
||||
* Retrieve a single field from any option for the SEO plugin. Keys are always unique.
|
||||
*
|
||||
* @param string $key The key it should return.
|
||||
* @param mixed $default_value The default value that should be returned if the key isn't set.
|
||||
* @param string $key The key it should return.
|
||||
* @param mixed $default_value The default value that should be returned if the key isn't set.
|
||||
* @param array<string> $option_groups The option groups to retrieve the option from.
|
||||
*
|
||||
* @return mixed Returns value if found, $default_value if not.
|
||||
*/
|
||||
public static function get( $key, $default_value = null ) {
|
||||
if ( static::$option_values === null ) {
|
||||
static::prime_cache();
|
||||
public static function get( $key, $default_value = null, $option_groups = [] ) {
|
||||
if ( ! isset( static::$option_values[ $key ] ) ) {
|
||||
static::prime_cache( $option_groups );
|
||||
}
|
||||
if ( isset( static::$option_values[ $key ] ) ) {
|
||||
return static::$option_values[ $key ];
|
||||
@@ -297,23 +301,26 @@ class WPSEO_Options {
|
||||
/**
|
||||
* Primes our cache.
|
||||
*
|
||||
* @param array<string> $option_groups The option groups to prime the cache with.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function prime_cache() {
|
||||
static::$option_values = static::get_all();
|
||||
private static function prime_cache( $option_groups = [] ) {
|
||||
static::$option_values = static::get_all( $option_groups );
|
||||
static::$option_values = static::add_ms_option( static::$option_values );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single field from an option for the SEO plugin.
|
||||
*
|
||||
* @param string $key The key to set.
|
||||
* @param mixed $value The value to set.
|
||||
* @param string $key The key to set.
|
||||
* @param mixed $value The value to set.
|
||||
* @param string $option_group The lookup table which represents the option_group where the key is stored.
|
||||
*
|
||||
* @return mixed|null Returns value if found, $default if not.
|
||||
*/
|
||||
public static function set( $key, $value ) {
|
||||
$lookup_table = static::get_lookup_table();
|
||||
public static function set( $key, $value, $option_group = '' ) {
|
||||
$lookup_table = static::get_lookup_table( $option_group );
|
||||
|
||||
if ( isset( $lookup_table[ $key ] ) ) {
|
||||
return static::save_option( $lookup_table[ $key ], $key, $value );
|
||||
@@ -562,12 +569,15 @@ class WPSEO_Options {
|
||||
/**
|
||||
* Retrieves a lookup table to find in which option_group a key is stored.
|
||||
*
|
||||
* @param string $option_group The option_group where the key is stored.
|
||||
*
|
||||
* @return array The lookup table.
|
||||
*/
|
||||
private static function get_lookup_table() {
|
||||
$lookup_table = [];
|
||||
private static function get_lookup_table( $option_group = '' ) {
|
||||
$lookup_table = [];
|
||||
$option_groups = ( $option_group === '' ) ? static::$options : [ $option_group => static::$options[ $option_group ] ];
|
||||
|
||||
foreach ( array_keys( static::$options ) as $option_name ) {
|
||||
foreach ( array_keys( $option_groups ) as $option_name ) {
|
||||
$full_option = static::get_option( $option_name );
|
||||
foreach ( $full_option as $key => $value ) {
|
||||
$lookup_table[ $key ] = $option_name;
|
||||
|
||||
Reference in New Issue
Block a user