| @@ -103,9 +103,10 @@ | ||
| 103 | 103 | 'screen_size_condition' => array( |
| 104 | 104 | 'condition' => 'larger', |
| 105 | 105 | 'value' => 0, |
| 106 | 106 | ), |
| 107 | - 'closable' => true, | |
| 107 | + 'closable' => 1, | |
| 108 | + 'show_close_icon' => 1, | |
| 108 | 109 | ); |
| 109 | 110 | $box = $this; |
| 110 | 111 | |
| 111 | 112 | $options = get_post_meta( $this->ID, 'boxzilla_options', true ); |
| @@ -110,8 +111,9 @@ | ||
| 110 | 111 | |
| 111 | 112 | $options = get_post_meta( $this->ID, 'boxzilla_options', true ); |
| 112 | 113 | $options = is_array( $options ) ? $options : array(); |
| 113 | 114 | |
| 115 | + | |
| 114 | 116 | // merge options with default options |
| 115 | 117 | $options = array_replace_recursive( $defaults, $options ); |
| 116 | 118 | |
| 117 | 119 | // allow others to filter the final array of options |
| @@ -148,8 +150,12 @@ | ||
| 148 | 150 | * @return string |
| 149 | 151 | */ |
| 150 | 152 | public function get_close_icon() { |
| 151 | 153 | |
| 154 | + if( ! $this->options['show_close_icon'] ) { | |
| 155 | + return ''; | |
| 156 | + } | |
| 157 | + | |
| 152 | 158 | $box = $this; |
| 153 | 159 | $html = '×'; |
| 154 | 160 | |
| 155 | 161 | /** |
| @@ -171,9 +177,21 @@ | ||
| 171 | 177 | public function get_content() { |
| 172 | 178 | $content = $this->content; |
| 173 | 179 | $box = $this; |
| 174 | 180 | |
| 175 | - /** | |
| 181 | + // replace boxzilla specific shortcodes | |
| 182 | + $close_link = sprintf('<a href="javascript:Boxzilla.dismiss(%d);">', $this->ID ); | |
| 183 | + | |
| 184 | + $replacements = array( | |
| 185 | + '[boxzilla_close]' => $close_link, // accept underscore and dash here for consistency with other shortcode | |
| 186 | + '[boxzilla-close]' => $close_link, | |
| 187 | + '[/boxzilla_close]' => '</a>', | |
| 188 | + '[/boxzilla-close]' => '</a>', | |
| 189 | + ); | |
| 190 | + | |
| 191 | + $content = str_replace( array_keys( $replacements ), array_values( $replacements ), $content ); | |
| 192 | + | |
| 193 | + /** | |
| 176 | 194 | * Filters the HTML for the box content |
| 177 | 195 | * |
| 178 | 196 | * @param string $content |
| 179 | 197 | * @param Box $box |
| @@ -223,9 +241,9 @@ | ||
| 223 | 241 | ), |
| 224 | 242 | 'rehide' => (bool) $box->options['auto_hide'], |
| 225 | 243 | 'position' => $box->options['css']['position'], |
| 226 | 244 | 'screenWidthCondition' => $screen_width_condition, |
| 227 | - 'closable' => $box->options['closable'], | |
| 245 | + 'closable' => !!$box->options['closable'], | |
| 228 | 246 | 'post' => array( |
| 229 | 247 | 'id' => $this->post->ID, |
| 230 | 248 | 'title' => $this->post->post_title, |
| 231 | 249 | 'slug' => $this->post->post_name, |