Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions assets/js/custom-cookie-message-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
20 changes: 13 additions & 7 deletions src/class-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ] );
Expand Down Expand Up @@ -185,7 +186,7 @@ public static function update() {
}
}

// Is empty, nani?
// Bail early if empty.
if ( empty( $update_queue ) ) {
return;
}
Expand Down Expand Up @@ -237,15 +238,17 @@ protected function ccm_patter_list( $pattern_array ) {
}

$pattern_array = array_filter(
$pattern_array, function ( $value ) {
$pattern_array,
function ( $value ) {
return '' !== trim( $value );
}
);

$pattern_array = array_map(
function ( $pattern ) {
return '(' . trim( $pattern ) . ')';
}, $pattern_array
},
$pattern_array
);

return implode( '|', $pattern_array );
Expand Down Expand Up @@ -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' ),
Expand Down Expand Up @@ -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 .= '}';
Expand All @@ -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;
Expand Down
18 changes: 10 additions & 8 deletions templates/cookie-notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
$esc_html = 'pll_e';
}

error_log( print_r( $esc_html, true ) );

$functional_check = 'checked';
$advertising_check = 'checked';

Expand All @@ -46,19 +48,19 @@
<div id="custom-cookie-message-banner" class="custom-cookie-message-banner custom-cookie-message-banner--<?php echo esc_attr( $options['general']['location_options'] ); ?>">
<div class="custom-cookie-message-banner__content">
<p class="custom-cookie-message-banner__text">
<?php $esc_html( $options['content']['textarea_warning_text'], 'custom-cookie-message' ); ?>
<?php echo esc_html( $options['content']['textarea_warning_text'] ); ?>
<?php if ( $options['general']['cookies_page_link'] ) { ?>
<a href="<?php echo esc_url( $options['general']['cookies_page_link'] ); ?>" title="<?php $esc_html( $options['content']['input_link_text'], 'custom-cookie-message' ); ?>"><?php $esc_html( $options['content']['input_link_text'], 'custom-cookie-message' ); ?></a>
<a href="<?php echo esc_url( $options['general']['cookies_page_link'] ); ?>" title="<?php $esc_html( $options['content']['input_link_text'], 'custom-cookie-message' ); ?>"><?php echo esc_html( $options['content']['input_link_text'] ); ?></a>
<?php } else { ?>
<?php
if ( $options['general']['cookies_about_page'] ) {
if ( function_exists( 'icl_object_id' ) ) {
$page_id = icl_object_id( $options['general']['cookies_about_page'], 'page', true );
} else {
$page_id = $options['general']['cookies_about_page'];
}
if ( function_exists( 'icl_object_id' ) ) {
$page_id = icl_object_id( $options['general']['cookies_about_page'], 'page', true );
} else {
$page_id = $options['general']['cookies_about_page'];
}
?>
<a href="<?php echo get_permalink( $page_id ); ?>" title="<?php $esc_html( $options['content']['input_link_text'], 'custom-cookie-message' ); ?>"><?php $esc_html( $options['content']['input_link_text'], 'custom-cookie-message' ); ?></a>
<a href="<?php echo get_permalink( $page_id ); ?>" title="<?php echo esc_attr( $options['content']['input_link_text'] ); ?>"><?php echo esc_html( $options['content']['input_link_text'] ); ?></a>
<?php
}
}
Expand Down