From 409fd26e5e6407a8734c34c90ba22c574286a4a3 Mon Sep 17 00:00:00 2001 From: "Daniel L. Iser" Date: Sun, 20 Sep 2026 22:02:45 -0400 Subject: [PATCH 1/2] Fix: Use plugin text domain for requirement notices --- .phpcs.xml.dist | 4 ++-- classes/Plugin/Prerequisites.php | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index 0d92db56..fabb2c3a 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -21,7 +21,7 @@ https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties --> - + @@ -45,4 +45,4 @@ tests/* - \ No newline at end of file + diff --git a/classes/Plugin/Prerequisites.php b/classes/Plugin/Prerequisites.php index 3b4b5c28..dc0c6d82 100644 --- a/classes/Plugin/Prerequisites.php +++ b/classes/Plugin/Prerequisites.php @@ -311,8 +311,7 @@ public function get_php_message( $failed_check_args ) { $message = __( 'This plugin requires %1$s %2$s or higher in order to run.', 'content-control' ); return sprintf( $message, - // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch -- Reuse the WordPress Core translation. - __( 'PHP', 'default' ), + __( 'PHP', 'content-control' ), $failed_check_args['version'] ); } @@ -328,8 +327,7 @@ public function get_wp_message( $failed_check_args ) { $message = __( 'This plugin requires %1$s %2$s or higher in order to run.', 'content-control' ); return sprintf( $message, - // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch -- Reuse the WordPress Core translation. - __( 'WordPress', 'default' ), + __( 'WordPress', 'content-control' ), $failed_check_args['version'] ); } From 89bb5a765439eab7e020db8f71b7b702cef1fdb2 Mon Sep 17 00:00:00 2001 From: "Daniel L. Iser" Date: Sun, 20 Sep 2026 22:03:50 -0400 Subject: [PATCH 2/2] Remove: Retire obsolete legacy APIs --- bin/psalm-autoloader.php | 1 - content-control.php | 1 - inc/deprecated.php | 116 -------------------------- inc/deprecated/class.is.php | 49 ----------- inc/deprecated/class.restrictions.php | 36 -------- inc/functions/query.php | 39 +-------- inc/functions/rule-callbacks.php | 4 +- 7 files changed, 6 insertions(+), 240 deletions(-) delete mode 100644 inc/deprecated.php delete mode 100644 inc/deprecated/class.is.php delete mode 100644 inc/deprecated/class.restrictions.php diff --git a/bin/psalm-autoloader.php b/bin/psalm-autoloader.php index 96eba2ca..93fb4b6c 100644 --- a/bin/psalm-autoloader.php +++ b/bin/psalm-autoloader.php @@ -7,4 +7,3 @@ require_once __DIR__ . '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/vendor/autoload.php'; require_once __DIR__ . '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/inc/functions.php'; -require_once __DIR__ . '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/inc/deprecated.php'; diff --git a/content-control.php b/content-control.php index d4481230..d2d187b1 100644 --- a/content-control.php +++ b/content-control.php @@ -129,7 +129,6 @@ function plugin_instance() { if ( ! $plugin instanceof \ContentControl\Plugin\Core ) { require_once __DIR__ . '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/inc/functions.php'; - require_once __DIR__ . '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/inc/deprecated.php'; $plugin = new Plugin\Core( get_plugin_config() ); } diff --git a/inc/deprecated.php b/inc/deprecated.php deleted file mode 100644 index fea1de2e..00000000 --- a/inc/deprecated.php +++ /dev/null @@ -1,116 +0,0 @@ -log_deprecated_notice( 'filter:jp_cc_registered_conditions', '2.0.0', 'filter:content_control/rule_engine/deprecated_rules' ); - /** - * Filter the registered conditions. - * - * @deprecated 2.0.0 - * - * @param boolean $conditions Registered conditions. - */ - return apply_filters( 'jp_cc_registered_conditions', $conditions ); - } - - return $conditions; -}, 9 ); - -add_filter( 'content_control/user_roles', function ( $roles ) { - if ( has_filter( 'jp_cc_user_roles' ) ) { - plugin( 'logging' )->log_deprecated_notice( 'filter:jp_cc_user_roles', '2.0.0', 'filter:content_control/user_roles' ); - /** - * Filter the user roles that our plugin should consider. - * - * @deprecated 2.0.0 - * - * @param array $roles Roles that our plugin should consider. - */ - return apply_filters( 'jp_cc_user_roles', $roles ); - } - - return $roles; -}, 9 ); - -add_filter( 'content_control/restricted_post_content', function ( $message ) { - if ( has_filter( 'jp_cc_restricted_message' ) ) { - plugin( 'logging' )->log_deprecated_notice( 'filter:jp_cc_restricted_message', '2.0.0', 'filter:content_control/restricted_post_content' ); - /** - * Filter the restricted message. - * - * @deprecated 2.0.0 - * - * @param string $message - */ - return apply_filters( 'jp_cc_restricted_message', $message ); - } - - return $message; -}, 9 ); - -add_filter( 'content_control/should_exclude_widget', function ( $should_exclude ) { - if ( has_filter( 'jp_cc_should_exclude_widget' ) ) { - plugin( 'logging' )->log_deprecated_notice( 'filter:jp_cc_should_exclude_widget', '2.0.0', 'filter:content_control/should_exclude_widget' ); - /** - * Filter if the widget should be excluded. - * - * @deprecated 2.0.0 - * - * @param boolean $should_exclude - */ - return apply_filters( 'jp_cc_should_exclude_widget', $should_exclude ); - } - - return $should_exclude; -}, 9 ); - -add_filter( 'content_control/excerpt_length', function ( $length = 50 ) { - if ( has_filter( 'jp_cc_filter_excerpt_length' ) ) { - plugin( 'logging' )->log_deprecated_notice( 'filter:jp_cc_filter_excerpt_length', '2.0.0', 'filter:content_control/excerpt_length' ); - /** - * Filter the excerpt length. - * - * @deprecated 2.0.0 - * - * @param array $settings - */ - return apply_filters( 'jp_cc_filter_excerpt_length', $length ); - } - - return $length; -}, 9 ); diff --git a/inc/deprecated/class.is.php b/inc/deprecated/class.is.php deleted file mode 100644 index 86b469fa..00000000 --- a/inc/deprecated/class.is.php +++ /dev/null @@ -1,49 +0,0 @@ -|string $roles array of roles to check. - * - * @return bool - * - * @deprecated 2.0.0 - */ - public static function accessible( $who = '', $roles = [] ) { - return \ContentControl\user_meets_requirements( $who, $roles, 'match' ); - } - - /** - * Check if a content is blocked to current user. - * - * @param string $who logged_in or logged_out. - * @param string[]|array|string $roles array of roles to check. - * - * @return boolean - * - * @deprecated 2.0.0 - */ - public static function restricted( $who = '', $roles = [] ) { - return ! \ContentControl\user_meets_requirements( $who, $roles, 'match' ); - } -} diff --git a/inc/deprecated/class.restrictions.php b/inc/deprecated/class.restrictions.php deleted file mode 100644 index 39680488..00000000 --- a/inc/deprecated/class.restrictions.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ - public static $protected_posts = []; - - /** - * Method to get the protected post content. - * - * @return string - */ - public static function restricted_content() { - $restriction = get_applicable_restriction(); - return false !== $restriction ? $restriction->get_message() : false; - } -} diff --git a/inc/functions/query.php b/inc/functions/query.php index c965e5eb..e452a504 100644 --- a/inc/functions/query.php +++ b/inc/functions/query.php @@ -266,21 +266,7 @@ function setup_post_globals( $post_id = null ) { * @since 2.4.0 - Added support for `terms` context. */ function setup_term_globals( $term_id = null ) { - /** - * Legacy term context global retained for backward compatibility. - * - * `$cc_term` predates the managed term-context service. It remains - * synchronized so existing integrations do not break, but Content Control - * itself reads the managed `term` value and new integrations should do the - * same. - * - * @deprecated 2.7.1 Use get_global( 'term' ) instead. - * @var \WP_Term|\WP_Error|false|null $cc_term - */ - // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Deprecated compatibility global. - global $cc_term; - - $current_term = get_global( 'term' ); // Used instead of global $cc_term. + $current_term = get_global( 'term' ); // Return early if we don't have a term ID. if ( is_null( $term_id ) ) { @@ -302,9 +288,7 @@ function setup_term_globals( $term_id = null ) { push_to_global( 'overloaded_terms', $current_term_id ); // Overload the globals so conditionals work properly. - $cc_term = get_term( $term_id ); - // Set the global term object (forward compatibility). - set_global( 'term', $cc_term ); + set_global( 'term', get_term( $term_id ) ); } return $overload_term; @@ -366,24 +350,9 @@ function reset_term_globals() { return; } - /** - * Legacy term context global retained for backward compatibility. - * - * `$cc_term` predates the managed term-context service. It remains - * synchronized so existing integrations do not break, but Content Control - * itself reads the managed `term` value and new integrations should do the - * same. - * - * @deprecated 2.7.1 Use get_global( 'term' ) instead. - * @var \WP_Term|\WP_Error|false|null $cc_term - */ - // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Deprecated compatibility global. - global $cc_term; - $stored_term_id = pop_from_global( 'overloaded_terms' ); // Reset global post object. - $cc_term = get_term( $stored_term_id ); - set_global( 'term', $cc_term ); + set_global( 'term', get_term( $stored_term_id ) ); } /** @@ -397,7 +366,7 @@ function get_the_content_id() { switch ( $context ) { case 'terms': case 'restapi/terms': - $term = get_global( 'term' ); // Used instead of global $cc_term. + $term = get_global( 'term' ); return $term->term_id ?? null; default: diff --git a/inc/functions/rule-callbacks.php b/inc/functions/rule-callbacks.php index eb18a114..9b62ac62 100644 --- a/inc/functions/rule-callbacks.php +++ b/inc/functions/rule-callbacks.php @@ -744,7 +744,7 @@ function content_is_selected_term() { } case 'terms': - $term = get_global( 'term' ); // Used instead of global $cc_term. + $term = get_global( 'term' ); // Check if we have a term object from the term query. if ( $term && $term->term_id > 0 ) { @@ -756,7 +756,7 @@ function content_is_selected_term() { case 'restapi': case 'restapi/terms': $rest_intent = get_rest_api_intent(); - $term = get_global( 'term' ); // Used instead of global $cc_term. + $term = get_global( 'term' ); if ( 'unknown' === $rest_intent['type'] ) { return false;