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/Query.php +7 -6 2.0.22.6.1 View file →
@@ -7,10 +7,8 @@
7 7 */
8 8
9 9 namespace ContentControl\Models\RuleEngine;
10 10
11 -use function ContentControl\Rules\current_query;
12 -
13 11 /**
14 12 * Handler for condition queries.
15 13 *
16 14 * @package ContentControl
@@ -33,9 +31,9 @@
33 31
34 32 /**
35 33 * Build a query.
36 34 *
37 - * @param array $query Query data.
35 + * @param array{logicalOperator:string,items:array<mixed>} $query Query data.
38 36 */
39 37 public function __construct( $query ) {
40 38 $query = wp_parse_args( $query, [
41 39 'logicalOperator' => 'and',
@@ -95,8 +93,11 @@
95 93 return true;
96 94 }
97 95
98 96 foreach ( $this->items as $item ) {
97 + // Missing rules should result in restricted content.
98 + $result = false;
99 +
99 100 if ( $item instanceof Rule ) {
100 101 $result = $item->check_rule();
101 102 } elseif ( $item instanceof Group ) {
102 103 $result = $item->check_rules();
@@ -120,9 +121,9 @@
120 121 * if changed, null needs to be accounted for.
121 122 */
122 123 if ( 'or' === $this->logical_operator ) {
123 124 // If any values are true or null, return true.
124 - return in_array( true, $checks, true ) || in_array( null, $checks, true );
125 + return in_array( true, $checks, true );
125 126 } else {
126 127 // If any values are false, return false.
127 128 return ! in_array( false, $checks, true );
128 129 }
@@ -132,9 +133,9 @@
132 133 * Return the checks as an array.
133 134 *
134 135 * Useful for debugging or passing to JS.
135 136 *
136 - * @return (bool|null)[]
137 + * @return array<bool|null|array<bool|null>>
137 138 */
138 139 public function get_checks() {
139 140 $checks = [];
140 141
@@ -153,9 +154,9 @@
153 154 * Return the checks as an array of information.
154 155 *
155 156 * Useful for debugging.
156 157 *
157 - * @return array
158 + * @return array<mixed>
158 159 */
159 160 public function get_check_info() {
160 161 $checks = [];
161 162