| 1 |
<?php |
| 2 |
/** |
| 3 |
* Deprecated filters & functions. |
| 4 |
* |
| 5 |
* @package ContentControl |
| 6 |
* @subpackage Deprecated |
| 7 |
* @since 2.0.0 |
| 8 |
* @copyright (c) 2023 Code Atlantic LLC |
| 9 |
*/ |
| 10 |
|
| 11 |
// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed |
| 12 |
|
| 13 |
use function ContentControl\plugin; |
| 14 |
|
| 15 |
defined( 'ABSPATH' ) || exit; |
| 16 |
|
| 17 |
require_once 'deprecated/class.is.php'; |
| 18 |
require_once 'deprecated/class.restrictions.php'; |
| 19 |
|
| 20 |
/** |
| 21 |
* Class JP_Content_Control |
| 22 |
* |
| 23 |
* @deprecated 2.0.0 Use \ContentControl\Plugin instead. |
| 24 |
*/ |
| 25 |
class JP_Content_Control {} |
| 26 |
|
| 27 |
/** |
| 28 |
* Get the Content Control plugin instance. |
| 29 |
* |
| 30 |
* @deprecated 2.0.0 Use \ContentControl\plugin() instead. |
| 31 |
* |
| 32 |
* @return \ContentControl\Plugin\Core |
| 33 |
*/ |
| 34 |
function jp_content_control() { |
| 35 |
return \ContentControl\plugin(); |
| 36 |
} |
| 37 |
|
| 38 |
add_filter( 'content_control/rule_engine/deprecated_rules', function ( $conditions ) { |
| 39 |
if ( has_filter( 'jp_cc_registered_conditions' ) ) { |
| 40 |
plugin( 'logging' )->log_deprecated_notice( 'filter:jp_cc_registered_conditions', '2.0.0', 'filter:content_control/rule_engine/deprecated_rules' ); |
| 41 |
/** |
| 42 |
* Filter the registered conditions. |
| 43 |
* |
| 44 |
* @deprecated 2.0.0 |
| 45 |
* |
| 46 |
* @param boolean $conditions Registered conditions. |
| 47 |
*/ |
| 48 |
return apply_filters( 'jp_cc_registered_conditions', $conditions ); |
| 49 |
} |
| 50 |
|
| 51 |
return $conditions; |
| 52 |
}, 9 ); |
| 53 |
|
| 54 |
add_filter( 'content_control/user_roles', function ( $roles ) { |
| 55 |
if ( has_filter( 'jp_cc_user_roles' ) ) { |
| 56 |
plugin( 'logging' )->log_deprecated_notice( 'filter:jp_cc_user_roles', '2.0.0', 'filter:content_control/user_roles' ); |
| 57 |
/** |
| 58 |
* Filter the user roles that our plugin should consider. |
| 59 |
* |
| 60 |
* @deprecated 2.0.0 |
| 61 |
* |
| 62 |
* @param array $roles Roles that our plugin should consider. |
| 63 |
*/ |
| 64 |
return apply_filters( 'jp_cc_user_roles', $roles ); |
| 65 |
} |
| 66 |
|
| 67 |
return $roles; |
| 68 |
}, 9 ); |
| 69 |
|
| 70 |
add_filter( 'content_control/restricted_post_content', function ( $message ) { |
| 71 |
if ( has_filter( 'jp_cc_restricted_message' ) ) { |
| 72 |
plugin( 'logging' )->log_deprecated_notice( 'filter:jp_cc_restricted_message', '2.0.0', 'filter:content_control/restricted_post_content' ); |
| 73 |
/** |
| 74 |
* Filter the restricted message. |
| 75 |
* |
| 76 |
* @deprecated 2.0.0 |
| 77 |
* |
| 78 |
* @param string $message |
| 79 |
*/ |
| 80 |
return apply_filters( 'jp_cc_restricted_message', $message ); |
| 81 |
} |
| 82 |
|
| 83 |
return $message; |
| 84 |
}, 9 ); |
| 85 |
|
| 86 |
add_filter( 'content_control/should_exclude_widget', function ( $should_exclude ) { |
| 87 |
if ( has_filter( 'jp_cc_should_exclude_widget' ) ) { |
| 88 |
plugin( 'logging' )->log_deprecated_notice( 'filter:jp_cc_should_exclude_widget', '2.0.0', 'filter:content_control/should_exclude_widget' ); |
| 89 |
/** |
| 90 |
* Filter if the widget should be excluded. |
| 91 |
* |
| 92 |
* @deprecated 2.0.0 |
| 93 |
* |
| 94 |
* @param boolean $should_exclude |
| 95 |
*/ |
| 96 |
return apply_filters( 'jp_cc_should_exclude_widget', $should_exclude ); |
| 97 |
} |
| 98 |
|
| 99 |
return $should_exclude; |
| 100 |
}, 9 ); |
| 101 |
|
| 102 |
add_filter( 'content_control/excerpt_length', function ( $length = 50 ) { |
| 103 |
if ( has_filter( 'jp_cc_filter_excerpt_length' ) ) { |
| 104 |
plugin( 'logging' )->log_deprecated_notice( 'filter:jp_cc_filter_excerpt_length', '2.0.0', 'filter:content_control/excerpt_length' ); |
| 105 |
/** |
| 106 |
* Filter the excerpt length. |
| 107 |
* |
| 108 |
* @deprecated 2.0.0 |
| 109 |
* |
| 110 |
* @param array $settings |
| 111 |
*/ |
| 112 |
return apply_filters( 'jp_cc_filter_excerpt_length', $length ); |
| 113 |
} |
| 114 |
|
| 115 |
return $length; |
| 116 |
}, 9 ); |
| 117 |
|