PluginProbe
Boxzilla – WordPress Popup Builder / 3.2
Boxzilla – WordPress Popup Builder v3.2
3.4.11 3.4.10 3.4.9 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 trunk 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 All 72 releases
← All changes | src/class-loader.php +37 -21 3.1.113.2 View file →
@@ -38,8 +38,9 @@
38 38 $this->box_ids_to_load = $this->filter_boxes();
39 39
40 40 // Only add other hooks if necessary
41 41 if( count( $this->box_ids_to_load ) > 0 ) {
42 + add_action( 'wp_footer', array( $this, 'print_boxes_content' ) );
42 43 add_action( 'wp_enqueue_scripts', array( $this, 'load_assets' ), 90 );
43 44 }
44 45 }
45 46
@@ -160,8 +161,12 @@
160 161
161 162 case 'is_post_with_tag':
162 163 $matched = is_singular( 'post' ) && has_tag( $value );
163 164 break;
165 +
166 + case 'is_user_logged_in':
167 + $matched = is_user_logged_in();
168 + break;
164 169 }
165 170
166 171 /**
167 172 * Filters whether a given box rule matches the condition and expected value.
@@ -254,13 +259,35 @@
254 259 public function load_assets() {
255 260 $pre_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
256 261 wp_enqueue_script('boxzilla', $this->plugin->url('/assets/js/script' . $pre_suffix . '.js' ), array(), $this->plugin->version(), true );
257 262
258 - $this->pass_box_options();
263 + // create boxzilla_Global_Options object
264 + $plugin_options = $this->options;
265 + $boxes = $this->get_matched_boxes();
259 266
267 + $data = array(
268 + 'testMode' => (bool) $plugin_options['test_mode'],
269 + 'boxes' => array_map( function(Box $box) { return $box->get_client_options(); }, $boxes ),
270 + );
271 +
272 + wp_localize_script( 'boxzilla', 'boxzilla_options', $data );
273 +
260 274 do_action( 'boxzilla_load_assets', $this );
261 275 }
262 276
277 + public function print_boxes_content() {
278 + $boxes = $this->get_matched_boxes();
279 + if( empty( $boxes ) ) {
280 + return;
281 + }
282 +
283 + echo '<div style="display: none;">';
284 + foreach( $boxes as $box ) {
285 + echo sprintf( '<div id="boxzilla-box-%d-content">', $box->ID ) . $box->get_content() . '</div>';
286 + }
287 + echo '</div>';
288 + }
289 +
263 290 /**
264 291 * Get an array of Box objects. These are the boxes that will be loaded for the current request.
265 292 *
266 293 * @return Box[]
@@ -275,9 +302,9 @@
275 302 return $boxes;
276 303 }
277 304
278 305 // query Box posts
279 - $boxes = get_posts(
306 + $posts = get_posts(
280 307 array(
281 308 'post_type' => 'boxzilla-box',
282 309 'post_status' => 'publish',
283 310 'post__in' => $this->box_ids_to_load,
@@ -285,31 +312,20 @@
285 312 )
286 313 );
287 314
288 315 // create `Box` instances out of \WP_Post instances
289 - foreach ( $boxes as $key => $box ) {
290 - $boxes[ $key ] = new Box( $box );
316 + $boxes = array();
317 + foreach ( $posts as $key => $post ) {
318 + // skip posts with no content
319 + if( empty( trim( $post->post_content ) ) ) {
320 + continue;
321 + }
322 +
323 + $boxes[ $key ] = new Box( $post );
291 324 }
292 325 }
293 326
294 327 return $boxes;
295 - }
296 -
297 - /**
298 - * Create array of Box options and pass it to JavaScript script.
299 - */
300 - public function pass_box_options() {
301 -
302 - // create boxzilla_Global_Options object
303 - $plugin_options = $this->options;
304 - $boxes = $this->get_matched_boxes();
305 -
306 - $data = array(
307 - 'testMode' => (bool) $plugin_options['test_mode'],
308 - 'boxes' => array_map( function(Box $box) { return $box->get_client_options(); }, $boxes ),
309 - );
310 -
311 - wp_localize_script( 'boxzilla', 'boxzilla_options', $data );
312 328 }
313 329
314 330 }
315 331