PluginProbe
Boxzilla – WordPress Popup Builder / 3.1.4
Boxzilla – WordPress Popup Builder v3.1.4
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-box.php +24 -51 3.1.173.1.4 View file →
@@ -30,13 +30,8 @@
30 30 * @var bool
31 31 */
32 32 public $enabled = false;
33 33
34 - /**
35 - * @var WP_Post
36 - */
37 - private $post;
38 -
39 34 /**
40 35 * @param WP_Post|int $post
41 36 */
42 37 public function __construct( $post ) {
@@ -45,11 +40,8 @@
45 40 if( ! $post instanceof WP_Post ) {
46 41 $post = get_post( $post );
47 42 }
48 43
49 - // store ref to post
50 - $this->post = $post;
51 -
52 44 // store ID in property for quick access
53 45 $this->ID = $post->ID;
54 46
55 47 // store title in property
@@ -99,14 +91,10 @@
99 91 'trigger_time_on_site' => 0,
100 92 'trigger_time_on_page' => 0,
101 93 'animation' => 'fade',
102 94 'auto_hide' => 0,
103 - 'screen_size_condition' => array(
104 - 'condition' => 'larger',
105 - 'value' => 0,
106 - ),
107 - 'closable' => 1,
108 - 'show_close_icon' => 1,
95 + 'hide_on_screen_size' => '',
96 + 'closable' => true,
109 97 );
110 98 $box = $this;
111 99
112 100 $options = get_post_meta( $this->ID, 'boxzilla_options', true );
@@ -111,9 +99,8 @@
111 99
112 100 $options = get_post_meta( $this->ID, 'boxzilla_options', true );
113 101 $options = is_array( $options ) ? $options : array();
114 102
115 -
116 103 // merge options with default options
117 104 $options = array_replace_recursive( $defaults, $options );
118 105
119 106 // allow others to filter the final array of options
@@ -150,12 +137,8 @@
150 137 * @return string
151 138 */
152 139 public function get_close_icon() {
153 140
154 - if( ! $this->options['show_close_icon'] ) {
155 - return '';
156 - }
157 -
158 141 $box = $this;
159 142 $html = '×';
160 143
161 144 /**
@@ -171,21 +154,15 @@
171 154
172 155 /**
173 156 * Get the content of this box
174 157 *
175 - * @return string
158 + * @return mixed|void
176 159 */
177 160 public function get_content() {
178 161 $content = $this->content;
179 162 $box = $this;
180 163
181 - // replace boxzilla specific shortcodes
182 - $close_link = sprintf('<a href="javascript:Boxzilla.dismiss(%d);">', $this->ID );
183 - $content = str_replace( '[boxzilla-close]', $close_link, $content );
184 - $content = str_replace( '[/boxzilla-close]', '</a>', $content );
185 -
186 -
187 - /**
164 + /**
188 165 * Filters the HTML for the box content
189 166 *
190 167 * @param string $content
191 168 * @param Box $box
@@ -193,36 +170,37 @@
193 170 $content = apply_filters( 'boxzilla_box_content', $content, $box );
194 171 return $content;
195 172 }
196 173
197 - /**
198 - * Get options object for JS script.
199 - *
200 - * @return array
201 - */
174 + /**
175 + * Get the minimum allowed screen size for this box
176 + *
177 + * @return int
178 + */
179 + public function get_minimum_screen_size() {
180 +
181 + if( $this->options['hide_on_screen_size'] > 0 ) {
182 + $minimum_screen_size = absint( $this->options['hide_on_screen_size'] );
183 + } else {
184 + $minimum_screen_size = 0;
185 + }
186 +
187 + return $minimum_screen_size;
188 + }
189 +
202 190 public function get_client_options() {
203 191 $box = $this;
204 192
205 193 $trigger = false;
206 194 if( $box->options['trigger'] ) {
207 - $trigger = array(
208 - 'method' => $this->options['trigger']
209 - );
210 195
196 + $trigger = array( 'method' => $this->options['trigger'] );
197 +
211 198 if( isset( $this->options[ 'trigger_' . $this->options['trigger'] ] ) ) {
212 199 $trigger['value'] = $this->options[ 'trigger_' . $this->options['trigger'] ];
213 200 }
214 201 }
215 202
216 - // build screenWidthCondition object (or null)
217 - $screen_width_condition = null;
218 - if( $box->options['screen_size_condition']['value'] > 0 ) {
219 - $screen_width_condition = array(
220 - 'condition' => $box->options['screen_size_condition']['condition'],
221 - 'value' => intval( $box->options['screen_size_condition']['value'] ),
222 - );
223 - }
224 -
225 203 $client_options = array(
226 204 'id' => $box->ID,
227 205 'icon' => $box->get_close_icon(),
228 206 'content' => $box->get_content(),
@@ -234,15 +212,10 @@
234 212 'dismissed' => absint( $box->options['cookie']['dismissed'] ),
235 213 ),
236 214 'rehide' => (bool) $box->options['auto_hide'],
237 215 'position' => $box->options['css']['position'],
238 - 'screenWidthCondition' => $screen_width_condition,
239 - 'closable' => !!$box->options['closable'],
240 - 'post' => array(
241 - 'id' => $this->post->ID,
242 - 'title' => $this->post->post_title,
243 - 'slug' => $this->post->post_name,
244 - ),
216 + 'minimumScreenWidth' => $box->get_minimum_screen_size(),
217 + 'closable' => $box->options['closable'],
245 218 );
246 219
247 220 /**
248 221 * Filter the final options for the JS Boxzilla client.