PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / 2.6.1
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More v2.6.1
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.10 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 47 releases
← All changes | classes/Models/RuleEngine/Rule.php +12 -12 2.0.22.6.1 View file →
@@ -34,9 +34,9 @@
34 34
35 35 /**
36 36 * Rule options.
37 37 *
38 - * @var array
38 + * @var array<string,mixed>
39 39 */
40 40 public $options;
41 41
42 42 /**
@@ -50,9 +50,9 @@
50 50 * Rule extras.
51 51 *
52 52 * Such as post type or taxnomy like meta.
53 53 *
54 - * @var array
54 + * @var array<string,mixed>
55 55 */
56 56 public $extras = [];
57 57
58 58 /**
@@ -64,9 +64,9 @@
64 64
65 65 /**
66 66 * Rule definition.
67 67 *
68 - * @var array
68 + * @var array<string,mixed>|null
69 69 */
70 70 public $definition;
71 71
72 72 /**
@@ -78,9 +78,9 @@
78 78
79 79 /**
80 80 * Build a rule.
81 81 *
82 - * @param array $rule Rule data.
82 + * @param array{id:string,name:string,notOperand:bool,options:array<string,mixed>,extras:array<string,mixed>} $rule Rule data.
83 83 */
84 84 public function __construct( $rule ) {
85 85 $rule = wp_parse_args( $rule, [
86 86 'id' => '',
@@ -99,9 +99,9 @@
99 99 $this->definition = plugin( 'rules' )->get_rule( $name );
100 100
101 101 if ( ! $this->definition ) {
102 102 /* translators: 1. Rule name. */
103 - plugin( 'logging' )->log( 'ERROR: ' . sprintf( __( 'Rule `%s` not found.', 'content-control' ), $name ) );
103 + plugin( 'logging' )->log_unique( 'ERROR: ' . sprintf( __( 'Rule `%s` not found.', 'content-control' ), $name ) );
104 104 }
105 105
106 106 $extras = isset( $this->definition['extras'] ) ? $this->definition['extras'] : [];
107 107
@@ -115,10 +115,10 @@
115 115
116 116 /**
117 117 * Parse rule options based on rule definitions.
118 118 *
119 - * @param array $options Array of rule opions.
120 - * @return array
119 + * @param array<string,mixed> $options Array of rule opions.
120 + * @return array<string,mixed>
121 121 */
122 122 public function parse_options( $options = [] ) {
123 123 return $options;
124 124 }
@@ -141,10 +141,8 @@
141 141 /**
142 142 * Check the results of this rule.
143 143 *
144 144 * @return bool True if rule passes, false if not.
145 - *
146 - * @throws \Exception If rule callback is not callable.
147 145 */
148 146 private function run_check() {
149 147 $callback = isset( $this->definition['callback'] ) ? $this->definition['callback'] : null;
150 148
@@ -149,14 +147,16 @@
149 147 $callback = isset( $this->definition['callback'] ) ? $this->definition['callback'] : null;
150 148
151 149 if ( ! $callback ) {
152 150 /* translators: 1. Rule name. */
153 - throw new \Exception( esc_html( sprintf( __( 'Rule `%s` has no callback.', 'content-control' ), $this->name ) ) );
151 + plugin( 'logging' )->log_unique( 'ERROR: ' . esc_html( sprintf( __( 'Rule `%s` has no callback.', 'content-control' ), $this->name ) ) );
152 + return false;
154 153 }
155 154
156 155 if ( ! is_callable( $callback ) ) {
157 156 /* translators: 1. Rule name. 2. Callback name. */
158 - throw new \Exception( esc_html( sprintf( __( 'Rule `%1$s` callback is not callable (%2$s).', 'content-control' ), $this->name, $callback ) ) );
157 + plugin( 'logging' )->log_unique( 'ERROR: ' . esc_html( sprintf( __( 'Rule `%1$s` callback is not callable (%2$s).', 'content-control' ), $this->name, $callback ) ) );
158 + return false;
159 159 }
160 160
161 161 // Set global current rule so it can be easily accessed.
162 162 current_rule( $this );
@@ -210,9 +210,9 @@
210 210 * Return the rule check as an array of information.
211 211 *
212 212 * Useful for debugging.
213 213 *
214 - * @return array|null
214 + * @return array<string,mixed>|null
215 215 */
216 216 public function get_check_info() {
217 217 if ( $this->is_js_rule() ) {
218 218 return null;