plugin updates

This commit is contained in:
Tony Volpe
2024-11-20 22:40:39 -05:00
parent 0238f0c4ca
commit 3362947c6e
434 changed files with 13405 additions and 9202 deletions

View File

@@ -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.
*