diff --git a/assets/js/custom-cookie-message-popup.js b/assets/js/custom-cookie-message-popup.js index a943a8e..ce41947 100644 --- a/assets/js/custom-cookie-message-popup.js +++ b/assets/js/custom-cookie-message-popup.js @@ -113,39 +113,40 @@ jQuery( function ( $ ) { }, } ) .done( function ( response ) { - if ( null !== response.template && '' !== customCookieMessageLocalize.options ) { + if ( null !== response.template && typeof customCookieMessageLocalize.options.general != 'undefined' ) { if ( 'bottom-fixed' === customCookieMessageLocalize.options.general.location_options ) { $( 'body' ).append( response.template ); } else { $( 'body' ).prepend( response.template ); } - /* Get height of the banner before showing it */ - var get_height = $( '#custom-cookie-message-banner' ).clone().attr("id", false).css({display:"block", position:"absolute"}); - $( 'body' ).append(get_height); - var scroll_height = get_height.outerHeight(); - - get_height.remove(); - - /* banner animation */ - if ( 'scroll' === customCookieMessageLocalize.options.styles.banner_animation ) { - $( '#custom-cookie-message-banner' ).slideDown(); - } else - if ( 'fade' === customCookieMessageLocalize.options.styles.banner_animation ) { - $( '#custom-cookie-message-banner' ).fadeIn(); - } - else { - $( '#custom-cookie-message-banner' ).show(); - } - /* Scroll content container */ - if ( 'yes' === customCookieMessageLocalize.options.styles.scroll_body ) { - if ( 'bottom-fixed' === customCookieMessageLocalize.options.general.location_options ) { - $( 'body' ).animate({marginBottom: scroll_height}); - } - else { - $( 'body' ).animate({marginTop: scroll_height}); - } - } + /* Get height of the banner before showing it */ + var get_height = $( '#custom-cookie-message-banner' ).clone().attr("id", false).css({display:"block", position:"absolute"}); + $( 'body' ).append(get_height); + var scroll_height = get_height.outerHeight(); + + get_height.remove(); + + /* banner animation */ + if ( typeof customCookieMessageLocalize.options.styles != 'undefined' ) { + if ( typeof customCookieMessageLocalize.options.styles.banner_animation != 'undefined' && 'scroll' === customCookieMessageLocalize.options.styles.banner_animation ) { + $( '#custom-cookie-message-banner' ).slideDown(); + } else if ( typeof customCookieMessageLocalize.options.styles.banner_animation != 'undefined' && 'fade' === customCookieMessageLocalize.options.styles.banner_animation ) { + $( '#custom-cookie-message-banner' ).fadeIn(); + } + } else { + $( '#custom-cookie-message-banner' ).show(); + } + + /* Scroll content container */ + if ( typeof customCookieMessageLocalize.options.styles != 'undefined' && 'yes' === customCookieMessageLocalize.options.styles.scroll_body ) { + if ( typeof customCookieMessageLocalize.options.general.location_options != 'undefined' && 'bottom-fixed' === customCookieMessageLocalize.options.general.location_options ) { + $( 'body' ).animate({marginBottom: scroll_height}); + } + else { + $( 'body' ).animate({marginTop: scroll_height}); + } + } } else { console.warn( 'Custom Cookie Message options are not set' ); diff --git a/src/class-main.php b/src/class-main.php index 0a014a1..152da8a 100644 --- a/src/class-main.php +++ b/src/class-main.php @@ -122,7 +122,8 @@ public function init() { add_action( 'upgrader_process_complete', [ __CLASS__, 'update' ] ); - add_action( 'admin_notices', [ __CLASS__, 'admin_notices' ] ); + // NO! We do NOT spam users with update notices! - Jonathan + //add_action( 'admin_notices', [ __CLASS__, 'admin_notices' ] ); } add_action( 'wp_footer', [ $this, 'display_frontend_notice' ] ); @@ -185,7 +186,7 @@ public static function update() { } } - // Is empty, nani? + // Bail early if empty. if ( empty( $update_queue ) ) { return; } @@ -237,7 +238,8 @@ protected function ccm_patter_list( $pattern_array ) { } $pattern_array = array_filter( - $pattern_array, function ( $value ) { + $pattern_array, + function ( $value ) { return '' !== trim( $value ); } ); @@ -245,7 +247,8 @@ protected function ccm_patter_list( $pattern_array ) { $pattern_array = array_map( function ( $pattern ) { return '(' . trim( $pattern ) . ')'; - }, $pattern_array + }, + $pattern_array ); return implode( '|', $pattern_array ); @@ -288,7 +291,9 @@ public function display_frontend_notice() { wp_add_inline_style( 'custom-cookie-message-popup-styles', $this->custom_css() ); wp_enqueue_script( 'custom-cookie-message-popup', CUSTOM_COOKIE_MESSAGE_PLUGIN_URL . '/assets/js/custom-cookie-message-popup.js', [ 'jquery' ], $this->version, true ); wp_localize_script( - 'custom-cookie-message-popup', 'customCookieMessageLocalize', [ + 'custom-cookie-message-popup', + 'customCookieMessageLocalize', + [ 'options' => get_option( 'custom_cookie_message' ), 'wp_rest_nonce' => wp_create_nonce( 'wp_rest' ), 'rest_url_banner' => rest_url( 'custom-cm/banner' ), @@ -362,7 +367,8 @@ protected function custom_css() { $css .= sprintf( 'background-color: %s;', $styles['button_color_picker'] ); $css .= sprintf( 'color: %s;', $styles['button_text_color_picker'] ); $css .= sprintf( - 'padding: %spx %spx;', $styles['button_height_slider_amount'], + 'padding: %spx %spx;', + $styles['button_height_slider_amount'], $styles['button_width_slider_amount'] ); $css .= '}'; @@ -372,7 +378,7 @@ protected function custom_css() { $css .= sprintf( 'background-color: %s;', $styles['button_hover_color_picker'] ); $css .= sprintf( 'color: %s;', $styles['button_hover_text_color_picker'] ); $css .= '}'; - $css .= $styles['textarea_btn_custom_styling']; + $css .= ( isset( $styles['textarea_btn_custom_styling'] ) ) ? $styles['textarea_btn_custom_styling'] : ''; endif; return $css; diff --git a/templates/cookie-notice.php b/templates/cookie-notice.php index 42bb194..d6f0b1a 100644 --- a/templates/cookie-notice.php +++ b/templates/cookie-notice.php @@ -20,6 +20,8 @@ $esc_html = 'pll_e'; } +error_log( print_r( $esc_html, true ) ); + $functional_check = 'checked'; $advertising_check = 'checked'; @@ -46,19 +48,19 @@