| @@ -30,8 +30,13 @@ | ||
| 30 | 30 | * @var bool |
| 31 | 31 | */ |
| 32 | 32 | public $enabled = false; |
| 33 | 33 | |
| 34 | + /** | |
| 35 | + * @var WP_Post | |
| 36 | + */ | |
| 37 | + private $post; | |
| 38 | + | |
| 34 | 39 | /** |
| 35 | 40 | * @param WP_Post|int $post |
| 36 | 41 | */ |
| 37 | 42 | public function __construct( $post ) { |
| @@ -40,8 +45,11 @@ | ||
| 40 | 45 | if( ! $post instanceof WP_Post ) { |
| 41 | 46 | $post = get_post( $post ); |
| 42 | 47 | } |
| 43 | 48 | |
| 49 | + // store ref to post | |
| 50 | + $this->post = $post; | |
| 51 | + | |
| 44 | 52 | // store ID in property for quick access |
| 45 | 53 | $this->ID = $post->ID; |
| 46 | 54 | |
| 47 | 55 | // store title in property |
| @@ -186,16 +194,22 @@ | ||
| 186 | 194 | |
| 187 | 195 | return $minimum_screen_size; |
| 188 | 196 | } |
| 189 | 197 | |
| 198 | + /** | |
| 199 | + * Get options object for JS script. | |
| 200 | + * | |
| 201 | + * @return array | |
| 202 | + */ | |
| 190 | 203 | public function get_client_options() { |
| 191 | 204 | $box = $this; |
| 192 | 205 | |
| 193 | 206 | $trigger = false; |
| 194 | 207 | if( $box->options['trigger'] ) { |
| 208 | + $trigger = array( | |
| 209 | + 'method' => $this->options['trigger'] | |
| 210 | + ); | |
| 195 | 211 | |
| 196 | - $trigger = array( 'method' => $this->options['trigger'] ); | |
| 197 | - | |
| 198 | 212 | if( isset( $this->options[ 'trigger_' . $this->options['trigger'] ] ) ) { |
| 199 | 213 | $trigger['value'] = $this->options[ 'trigger_' . $this->options['trigger'] ]; |
| 200 | 214 | } |
| 201 | 215 | } |
| @@ -214,8 +228,13 @@ | ||
| 214 | 228 | 'rehide' => (bool) $box->options['auto_hide'], |
| 215 | 229 | 'position' => $box->options['css']['position'], |
| 216 | 230 | 'minimumScreenWidth' => $box->get_minimum_screen_size(), |
| 217 | 231 | 'closable' => $box->options['closable'], |
| 232 | + 'post' => array( | |
| 233 | + 'id' => $this->post->ID, | |
| 234 | + 'title' => $this->post->post_title, | |
| 235 | + 'slug' => $this->post->post_name, | |
| 236 | + ), | |
| 218 | 237 | ); |
| 219 | 238 | |
| 220 | 239 | /** |
| 221 | 240 | * Filter the final options for the JS Boxzilla client. |