get_ccpa_default_settings(); $ccpa_default_text = ( isset( $ccpa_settings['ccpa'] ) ? $ccpa_settings['ccpa'] : '' ); $ccpa_gdpr_default_text = ( isset( $ccpa_settings['ccpa_gdpr'] ) ? $ccpa_settings['ccpa_gdpr'] : '' ); $this->ccpa_enabled = Cookie_Law_Info::sanitise_settings('ccpa_enabled', ( isset( $cookie_options['ccpa_enabled'] ) ? $cookie_options['ccpa_enabled'] : false ) ); $this->ccpa_as_link = Cookie_Law_Info::sanitise_settings('button_6_as_link', ( isset( $cookie_options['button_6_as_link'] ) ? $cookie_options['button_6_as_link'] : true ) ); $this->ccpa_text = Cookie_Law_Info::sanitise_settings('button_6_text', ( isset( $cookie_options['button_6_text'] ) ? $cookie_options['button_6_text'] : 'Do not sell my personal information' ) ); $this->ccpa_link_colour = Cookie_Law_Info::sanitise_settings('button_6_link_colour', ( isset( $cookie_options['button_6_link_colour'] ) ? $cookie_options['button_6_link_colour'] : '#333333' ) ); $this->ccpa_region_based = Cookie_Law_Info::sanitise_settings('ccpa_region_based', ( isset( $cookie_options['ccpa_region_based'] ) ? $cookie_options['ccpa_region_based'] : false ) ); $this->consent_type = Cookie_Law_Info::sanitise_settings('consent_type', ( isset( $cookie_options['consent_type'] ) ? $cookie_options['consent_type'] : 'gdpr' ) ); $this->ccpa_gdpr_content = Cookie_Law_Info::sanitise_settings('ccpa_gdpr_content', ( isset( $cookie_options['ccpa_gdpr_content'] ) ? $cookie_options['ccpa_gdpr_content'] : $ccpa_gdpr_default_text ) ); $this->gdpr_content = Cookie_Law_Info::sanitise_settings('gdpr_content', ( isset( $cookie_options['gdpr_content'] ) ? $cookie_options['gdpr_content'] : $cookie_options['notify_message'] ) ); $this->ccpa_content = Cookie_Law_Info::sanitise_settings('ccpa_content', ( isset( $cookie_options['ccpa_content'] ) ? $cookie_options['ccpa_content'] : $ccpa_default_text) ); $this->ccpa_enable_bar = Cookie_Law_Info::sanitise_settings('ccpa_enable_bar', ( isset( $cookie_options['ccpa_enable_bar'] ) ? $cookie_options['ccpa_enable_bar'] : false ) ); add_action( 'wt_cli_ccpa_settings', array( $this, 'add_ccpa_settings')); add_action( 'wp_enqueue_scripts', array( $this, 'wt_cli_enqueue_script')); add_action( 'wt_cli_before_cookie_message',array($this, 'wt_cli_message_toggler')); add_filter( 'wt_cli_before_save_settings',array($this, 'wt_cli_modify_plugin_settings'),10,2); add_filter( 'wt_cli_plugin_settings', array( $this, 'wt_cli_add_options'),10); add_filter( 'admin_enqueue_scripts', array( $this, 'wt_cli_enqueue_admin_scripts'),10); add_shortcode( 'wt_cli_ccpa_optout', array( $this, 'wt_cli_ccpa_optout_callback')); } public function add_ccpa_settings() { $cookie_options = Cookie_Law_Info::get_settings(); $ccpa_settings_file = plugin_dir_path( __FILE__ ).'views/ccpa_settings.php'; if( file_exists($ccpa_settings_file) ) { include $ccpa_settings_file; echo $ccpa_settings; } } public function get_ccpa_default_settings() { $settings = array ( 'ccpa' => addslashes ( '
This website or its third-party tools process personal data.
In case of sale of your personal information, you may opt out by using the link [wt_cli_ccpa_optout].
[cookie_close]
'), 'ccpa_gdpr' => addslashes ( '
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
[wt_cli_ccpa_optout].
[cookie_settings margin="0px 10px 0px 5px"][cookie_button]
'), ); return $settings; } public function wt_cli_add_options( $options ) { $options = ( isset( $options ) && is_array( $options ) ) ? $options : array(); $options['ccpa_enabled'] = $this->ccpa_enabled; $options['button_6_as_link'] = $this->ccpa_as_link; $options['button_6_text'] = $this->ccpa_text; $options['ccpa_enable_bar'] = $this->ccpa_enable_bar; $options['ccpa_region_based'] = $this->ccpa_region_based; $options['consent_type'] = $this->consent_type; $options['ccpa_content'] = $this->ccpa_content; $options['ccpa_gdpr_content'] = $this->ccpa_gdpr_content; $options['gdpr_content'] = $this->gdpr_content; $options['button_6_link_colour'] = $this->ccpa_link_colour; return $options; } public function wt_cli_enqueue_admin_scripts() { if(isset($_GET['post_type']) && $_GET['post_type']==CLI_POST_TYPE && isset($_GET['page']) && $_GET['page']=='cookie-law-info') { wp_enqueue_script('cookie-law-info-ccpa-admin',plugin_dir_url( __FILE__ ).'assets/js/cookie-law-info-ccpa-admin.js', array( 'jquery'),CLI_VERSION,false); } } public function wt_cli_enqueue_script() { if( !is_admin() ) { $cookie_options = Cookie_Law_Info::get_settings(); $ccpa_enabled = ( wp_validate_boolean ( isset( $cookie_options['ccpa_enabled'] ) ? $cookie_options['ccpa_enabled'] : false ) ); $cli_ccpa_datas = array ( 'opt_out_prompt' => __('Do you really wish to opt out?','cookie-law-info'), 'opt_out_confirm' => __('Confirm','cookie-law-info'), 'opt_out_cancel' => __('Cancel','cookie-law-info'), ); if( $ccpa_enabled === true ) { wp_enqueue_script('cookie-law-info-ccpa',plugin_dir_url( __FILE__ ).'assets/js/cookie-law-info-ccpa.js', array( 'jquery','cookie-law-info'),CLI_VERSION,false); wp_localize_script('cookie-law-info-ccpa', 'ccpa_data', $cli_ccpa_datas ); } } } public function wt_cli_ccpa_optout_callback() { $ccpa_data = ''; $ccpa_enabled = $this->ccpa_enabled; $ccpa_as_link = $this->ccpa_as_link; $ccpa_text = $this->ccpa_text; $ccpa_colour = $this->ccpa_link_colour; if( $ccpa_enabled === false ) { return ''; } if( $ccpa_as_link === false ) { $ccpa_data = ''; } else { $ccpa_data = ''.$ccpa_text.''; } return $ccpa_data; } public function wt_cli_message_toggler() { $ccpa_enabled = $this->ccpa_enabled; $consent_type = $this->consent_type; $ccpa_only_content = $this->ccpa_content; $ccpa_gdpr_content = $this->ccpa_gdpr_content; $gdpr_content = $this->gdpr_content; echo '
'.__('Customize the buttons, notice, themes from the relevant tabs to setup your cookie notice accordingly.','cookie-law-info').'
'.__('Most of the customizations from the tabs for buttons, notice or themes are not relevant especially if you choose to not show the notice, except the Do not sell within the buttons.','cookie-law-info').'
'.__('Customize the buttons, notice, themes from the relevant tabs to setup your cookie notice accordingly.','cookie-law-info').'
'; } public function wt_cli_modify_plugin_settings($options, $post) { $ccpa_enabled = Cookie_Law_Info::sanitise_settings('ccpa_enabled',( isset( $post['ccpa_enabled_field'] ) ? $post['ccpa_enabled_field'] : false )); $ccpa_as_link = Cookie_Law_Info::sanitise_settings('button_6_as_link',( isset( $post['button_6_as_link_field'] ) ? $post['button_6_as_link_field'] : false ) ); $ccpa_enable_bar = Cookie_Law_Info::sanitise_settings('ccpa_enable_bar',( isset( $post['ccpa_enable_bar_field'] ) ? $post['ccpa_enable_bar_field'] : false ) ); $ccpa_text = Cookie_Law_Info::sanitise_settings('button_6_text',( isset( $post['button_6_text_field'] ) ? $post['button_6_text_field'] : 'Do not sell my personal information' )); $ccpa_region_based = Cookie_Law_Info::sanitise_settings('ccpa_region_based',( isset( $post['ccpa_region_based_field'] ) ? $post['ccpa_region_based_field'] : false ) ); $cookie_content = Cookie_Law_Info::sanitise_settings( 'notify_message',( isset( $options['notify_message'] ) ? $options['notify_message'] : '' )); $consent_type = Cookie_Law_Info::sanitise_settings('consent_type',( isset( $post['consent_type_field'] ) && in_array( $post['consent_type_field'], self::$consent_allowed_values) ? $post['consent_type_field'] : 'gdpr' )); $ccpa_colour = Cookie_Law_Info::sanitise_settings('button_6_link_colour',( isset( $post['button_6_link_colour_field'] ) ? $post['button_6_link_colour_field'] : '#000000' )); $this->ccpa_enabled = $options['ccpa_enabled'] = $ccpa_enabled; $this->ccpa_as_link = $options['button_6_as_link'] = $ccpa_as_link; $this->ccpa_link_colour = $options['button_6_link_colour'] = $ccpa_colour; $this->ccpa_text = $options['button_6_text'] = $ccpa_text; $this->ccpa_region_based = $options['ccpa_region_based'] = $ccpa_region_based; $this->consent_type = $options['consent_type'] = $consent_type; $this->ccpa_enable_bar = $options['ccpa_enable_bar'] = $ccpa_enable_bar; if( $consent_type === 'ccpa') { $this->ccpa_content = $options['ccpa_content'] = $cookie_content; } else if( $consent_type === 'ccpa_gdpr' ) { $this->ccpa_gdpr_content = $options['ccpa_gdpr_content'] = $cookie_content; } else { $this->gdpr_content = $options['gdpr_content'] = $cookie_content; } // if( $this->ccpa_enabled === false ) { // $options['notify_message'] = $this->gdpr_content; // } return $options; } } $CliCcpa = new Cookie_Law_Info_CCPA();