show_bar(); // Only do all this if post isn't excluded if( ! empty( $exclude ) ) { $ctcc_options_settings = get_option ( 'ctcc_options_settings' ); $options = get_option ( 'ctcc_styles_settings' ); if ( isset ( $options['enqueue_styles'] ) ) { wp_enqueue_style ( 'cookie-consent-style', CTCC_PLUGIN_URL . 'assets/css/style.css', '2.3.0' ); } wp_enqueue_script ( 'cookie-consent', CTCC_PLUGIN_URL . 'assets/js/uk-cookie-consent-js.js', array ( 'jquery' ), '2.3.0', true ); wp_localize_script ( 'cookie-consent', 'ctcc_vars', array ( 'expiry' => $ctcc_options_settings['cookie_expiry'], 'method' => isset ( $ctcc_options_settings['first_page'] ), 'version' => $ctcc_options_settings['cookie_version'], ) ); } } /* * Check if post or page is excluded from displaying the bar * @since 2.2.0 */ public function show_bar() { global $post; $options = get_option( 'ctcc_options_settings' ); if( isset( $post->ID) ) { $post_id = $post->ID; $excluded = get_post_meta( $post_id, 'ctcc_exclude', true ); if( $excluded == 1 && ! empty( $options['enable_metafield'] ) ) { return false; } } return true; } /* * Add some CSS to the header * @since 2.0.0 */ public function add_css() { $exclude = $this->show_bar(); // Only do all this if post isn't excluded if( ! empty( $exclude ) ) { $options = get_option ( 'ctcc_options_settings' ); $ctcc_styles_settings = get_option ( 'ctcc_styles_settings' ); $position_css = 'position: fixed; left: 0; top: 0; width: 100%;'; // Figure out the bar position if ( $ctcc_styles_settings['position'] == 'top-bar' ) { $position_css = 'position: fixed; left: 0; top: 0; width: 100%;'; } else if ( $ctcc_styles_settings['position'] == 'bottom-bar' ) { $position_css = 'position: fixed; left: 0; bottom: 0; width: 100%;'; } else if ( $ctcc_styles_settings['position'] == 'top-right-block' ) { $position_css = 'position: fixed; right: 20px; top: 6%; width: 300px;'; } else if ( $ctcc_styles_settings['position'] == 'top-left-block' ) { $position_css = 'position: fixed; left: 20px; top: 6%; width: 300px;'; } else if ( $ctcc_styles_settings['position'] == 'bottom-left-block' ) { $position_css = 'position: fixed; left: 20px; bottom: 6%; width: 300px;'; } else if ( $ctcc_styles_settings['position'] == 'bottom-right-block' ) { $position_css = 'position: fixed; right: 20px; bottom: 6%; width: 300px;'; } // Get our styles $text_color = $ctcc_styles_settings['text_color']; $position = 'top'; $bg_color = $ctcc_styles_settings['bg_color']; $link_color = $ctcc_styles_settings['link_color']; $button_bg = $ctcc_styles_settings['button_bg_color']; $button_color = $ctcc_styles_settings['button_color']; if ( ! empty ( $ctcc_styles_settings['flat_button'] ) ){ $button_style = 'border: 0; padding: 6px 9px; border-radius: 3px;'; } else { $button_style = ''; } // Build our CSS $css = ''; echo $css; // Add it to the header } } /* * Add some JS to the footer * @since 2.0.0 */ public function add_js() { $exclude = $this->show_bar(); // Only do all this if post isn't excluded if( ! empty( $exclude ) ) { $options = get_option( 'ctcc_options_settings' ); $ctcc_styles_settings = get_option ( 'ctcc_styles_settings' ); if ( $ctcc_styles_settings['position'] == 'top-bar' || $ctcc_styles_settings['position'] == 'bottom-bar' ) { $type = 'bar'; } else { $type = 'block'; } ?> show_bar(); // Only do all this if post isn't excluded if( ! empty( $exclude ) ) { $ctcc_options_settings = get_option ( 'ctcc_options_settings' ); $ctcc_content_settings = get_option ( 'ctcc_content_settings' ); $ctcc_styles_settings = get_option ( 'ctcc_styles_settings' ); // Check if it's a block or a bar $is_block = true; if ( $ctcc_styles_settings['position'] == 'top-bar' || $ctcc_styles_settings['position'] == 'bottom-bar' ) { $is_block = false; // It's a bar } // Add some classes to the block $classes = ''; if ( $is_block ) { if ( ! empty ( $ctcc_styles_settings['rounded_corners'] ) ) { $classes .= ' rounded-corners'; } if ( ! empty ( $ctcc_styles_settings['drop_shadow'] ) ) { $classes .= ' drop-shadow'; } } if ( ! empty ( $ctcc_styles_settings['x_close'] ) ) { $classes .= ' use_x_close'; } if ( empty ( $ctcc_styles_settings['display_accept_with_text'] ) ) { $classes .= ' float-accept'; } // Allowed tags $allowed = array ( 'a' => array ( 'href' => array(), 'title' => array() ), 'br' => array(), 'em' => array(), 'strong' => array(), 'p' => array() ); $content = ''; $close_content = ''; // Print the notification bar $content = '
'; echo apply_filters ( 'catapult_cookie_content', $content, $ctcc_content_settings ); } } } }