| 1 |
<?php |
| 2 |
|
| 3 |
// Do not allow the file to be called directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Class used for the cookie notice that can be enabled by the user. |
| 10 |
* This is turned off by default. |
| 11 |
*/ |
| 12 |
class P_Cookie_Notice extends P_Core { |
| 13 |
|
| 14 |
/** |
| 15 |
* Add the actions required for the cookie notice. |
| 16 |
* |
| 17 |
* @param Patchstack $core |
| 18 |
* @return void |
| 19 |
*/ |
| 20 |
public function __construct( $core ) { |
| 21 |
parent::__construct( $core ); |
| 22 |
|
| 23 |
// The cookie notice feature can only be used on an activated license. |
| 24 |
if ( ! $this->license_is_active() || $this->get_option( 'patchstack_license_free', 0 ) == 1 ) { |
| 25 |
return; |
| 26 |
} |
| 27 |
|
| 28 |
// Register the actions if the cookie notice message is turned on. |
| 29 |
if ( $this->get_option( 'patchstack_enable_cookie_notice_message', false ) == true ) { |
| 30 |
add_action( 'wp_footer', array( $this, 'add_cookie_notice' ), 1000 ); |
| 31 |
add_action( 'wp_enqueue_scripts', array( $this, 'public_styles' ) ); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Cookie notice output. |
| 37 |
* |
| 38 |
* @return void |
| 39 |
*/ |
| 40 |
public function add_cookie_notice() { |
| 41 |
require_once dirname( __FILE__ ) . '/views/cookie-notice.php'; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Register CSS and JavaScript file for the cookie notice. |
| 46 |
* |
| 47 |
* @return void |
| 48 |
*/ |
| 49 |
public function public_styles() { |
| 50 |
wp_enqueue_style( 'patchstack', $this->plugin->url . 'assets/css/public.min.css', array(), $this->plugin->version ); |
| 51 |
wp_enqueue_script( 'patchstack', $this->plugin->url . 'assets/js/public.min.js', array(), $this->plugin->version ); |
| 52 |
} |
| 53 |
} |
| 54 |
|