| @@ -126,8 +126,10 @@ | ||
| 126 | 126 | break; |
| 127 | 127 | |
| 128 | 128 | case 'is_single': |
| 129 | 129 | case 'is_post': |
| 130 | + // convert to empty string if array with just empty string in it | |
| 131 | + $value = ( $value === array( '' ) ) ? '' : $value; | |
| 130 | 132 | $matched = is_single( $value ); |
| 131 | 133 | break; |
| 132 | 134 | |
| 133 | 135 | case 'is_post_in_category': |
| @@ -138,10 +140,23 @@ | ||
| 138 | 140 | case 'is_page': |
| 139 | 141 | $matched = is_page( $value ); |
| 140 | 142 | break; |
| 141 | 143 | |
| 144 | + case 'is_post_with_tag': | |
| 145 | + $matched = is_singular( 'post' ) && has_tag( $value ); | |
| 146 | + break; | |
| 142 | 147 | } |
| 143 | 148 | |
| 149 | + /** | |
| 150 | + * Filters whether a given box rule matches the condition and expected value. | |
| 151 | + * | |
| 152 | + * The dynamic portion of the hook, `$condition`, refers to the condition being matched. | |
| 153 | + * | |
| 154 | + * @param boolean $matched | |
| 155 | + * @param array $value | |
| 156 | + */ | |
| 157 | + $matched = apply_filters( 'boxzilla_box_rule_matches_' . $condition, $matched, $value ); | |
| 158 | + | |
| 144 | 159 | // if qualifier is set to false, we need to reverse this value here. |
| 145 | 160 | if( ! $qualifier ) { |
| 146 | 161 | $matched = ! $matched; |
| 147 | 162 | } |
| @@ -162,9 +177,9 @@ | ||
| 162 | 177 | foreach( $rules as $box_id => $box_rules ) { |
| 163 | 178 | |
| 164 | 179 | $matched = false; |
| 165 | 180 | $comparision = isset( $box_rules['comparision'] ) ? $box_rules['comparision'] : 'any'; |
| 166 | - | |
| 181 | + | |
| 167 | 182 | // loop through all rules for all boxes |
| 168 | 183 | foreach ( $box_rules as $rule ) { |
| 169 | 184 | |
| 170 | 185 | // skip faulty values (and comparision rule) |
| @@ -220,19 +235,10 @@ | ||
| 220 | 235 | * Load plugin styles |
| 221 | 236 | */ |
| 222 | 237 | public function load_assets() { |
| 223 | 238 | $pre_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 239 | + wp_enqueue_script('boxzilla', $this->plugin->url('/assets/js/script' . $pre_suffix . '.js' ), array(), $this->plugin->version(), true ); | |
| 224 | 240 | |
| 225 | - // stylesheets | |
| 226 | - wp_register_style( 'boxzilla', $this->plugin->url( '/assets/css/styles' . $pre_suffix . '.css' ), array(), $this->plugin->version() ); | |
| 227 | - | |
| 228 | - // scripts | |
| 229 | - wp_register_script( 'boxzilla',$this->plugin->url( '/assets/js/script' . $pre_suffix . '.js' ), array( 'jquery' ), $this->plugin->version(), true ); | |
| 230 | - | |
| 231 | - // Finally, enqueue style. | |
| 232 | - wp_enqueue_style( 'boxzilla' ); | |
| 233 | - wp_enqueue_script( 'boxzilla' ); | |
| 234 | - | |
| 235 | 241 | $this->pass_box_options(); |
| 236 | 242 | |
| 237 | 243 | do_action( 'boxzilla_load_assets', $this ); |
| 238 | 244 | } |
| @@ -280,9 +286,9 @@ | ||
| 280 | 286 | $plugin_options = $this->options; |
| 281 | 287 | $boxes = $this->get_matched_boxes(); |
| 282 | 288 | |
| 283 | 289 | $data = array( |
| 284 | - 'testMode' => (boolean) $plugin_options['test_mode'], | |
| 290 | + 'testMode' => (bool) $plugin_options['test_mode'], | |
| 285 | 291 | 'boxes' => array_map( function(Box $box) { return $box->get_client_options(); }, $boxes ), |
| 286 | 292 | ); |
| 287 | 293 | |
| 288 | 294 | wp_localize_script( 'boxzilla', 'boxzilla_options', $data ); |