Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
<config name="minimum_supported_wp_version" value="6.1" />

<config name="text_domain" value="content-control, default" />
<config name="text_domain" value="content-control" />

<!-- Force short syntax arrays. -->
<rule ref="CodeAtlantic" />
Expand All @@ -45,4 +45,4 @@
<exclude-pattern>tests/*</exclude-pattern>
</rule>

</ruleset>
</ruleset>
1 change: 0 additions & 1 deletion bin/psalm-autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@

require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/inc/functions.php';
require_once __DIR__ . '/inc/deprecated.php';
6 changes: 2 additions & 4 deletions classes/Plugin/Prerequisites.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ public function get_php_message( $failed_check_args ) {
$message = __( 'This plugin requires <b>%1$s %2$s</b> 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'] );
}

Expand All @@ -328,8 +327,7 @@ public function get_wp_message( $failed_check_args ) {
$message = __( 'This plugin requires <b>%1$s %2$s</b> 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']
);
}
Expand Down
1 change: 0 additions & 1 deletion content-control.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ function plugin_instance() {

if ( ! $plugin instanceof \ContentControl\Plugin\Core ) {
require_once __DIR__ . '/inc/functions.php';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve legacy APIs until the next major release

On sites with extensions or custom snippets that still call jp_content_control(), JP\CC\Is, or the jp_cc_* hooks, omitting this loader causes fatal undefined-function/class errors or silently disables their restriction callbacks. These APIs were explicitly retained as compatibility shims, and the repository advertises SemVer while the plugin metadata remains at 2.7.3, so they should remain available until a major release.

Useful? React with 👍 / 👎.

require_once __DIR__ . '/inc/deprecated.php';
$plugin = new Plugin\Core( get_plugin_config() );
}

Expand Down
116 changes: 0 additions & 116 deletions inc/deprecated.php

This file was deleted.

49 changes: 0 additions & 49 deletions inc/deprecated/class.is.php

This file was deleted.

36 changes: 0 additions & 36 deletions inc/deprecated/class.restrictions.php

This file was deleted.

39 changes: 4 additions & 35 deletions inc/functions/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand All @@ -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 ) );
Comment on lines 290 to +291

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Continue synchronizing the deprecated term global

When a term restriction is evaluated, integrations that inspect the legacy $cc_term global now see it unset or stale because only the managed term value is updated. That compatibility global predates the managed service and was deprecated only in 2.7.1, so removing its synchronization in the still-2.7.x plugin can make existing term-related callbacks evaluate the wrong term; keep both values synchronized until a major release.

Useful? React with 👍 / 👎.

}

return $overload_term;
Expand Down Expand Up @@ -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 ) );
}

/**
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions inc/functions/rule-callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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;
Expand Down
Loading