Changeset 1827523
- Timestamp:
- 02/23/2018 09:02:02 AM (8 years ago)
- Location:
- custom-cookie-message/trunk
- Files:
-
- 6 edited
-
assets/css/custom-cookie-message-popup.css (modified) (8 diffs)
-
assets/js/custom-cookie-message-popup.js (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
src/Forms/class-adminstylingoptions.php (modified) (4 diffs)
-
src/class-main.php (modified) (6 diffs)
-
templates/cookie-notice.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
custom-cookie-message/trunk/assets/css/custom-cookie-message-popup.css
r1823342 r1827523 10 10 z-index: 99; 11 11 } 12 12 13 .custom-cookie-message-banner--bottom-fixed { 13 14 bottom: 0; 14 15 } 16 15 17 .custom-cookie-message-banner--top-fixed { 16 18 top: 0; 17 19 } 18 .custom-cookie-message-banner__button { 20 21 .custom-cookie-message-banner__button, 22 .custom-cookie-message-popup__button { 19 23 margin: 0; 24 display: inline-block; 25 font-size: 14px; 26 font-weight: normal; 27 line-height: 1.4; 28 text-align: center; 29 white-space: nowrap; 30 vertical-align: middle; 31 cursor: pointer; 32 border: 1px solid transparent; 33 border-radius: 4px; 34 -webkit-user-select: none; 35 -moz-user-select: none; 36 -ms-user-select: none; 37 -o-user-select: none; 38 user-select: none; 39 40 border-color: #ccc; 20 41 } 42 21 43 .custom-cookie-message-banner__close { 22 44 position: absolute; … … 30 52 background: white; 31 53 cursor: pointer; 32 font-size: 0 px;33 line-height: 0 px;54 font-size: 0; 55 line-height: 0; 34 56 justify-content: center; 35 57 align-items: center; 36 58 } 37 .custom-cookie-message-banner__close::after { 38 content: "\f057"; 39 font-family: "fontawesome"; 40 font-size: 2rem; 41 line-height: 2rem; 42 display: block; 43 } 59 60 44 61 .custom-cookie-message-modal { 45 62 position: sticky; … … 57 74 align-items: flex-start; 58 75 } 76 59 77 .custom-cookie-message-modal--off { 60 78 display: none; 61 79 } 80 62 81 .custom-cookie-message-modal--on { 63 82 display: flex; 64 83 } 84 65 85 .custom-cookie-message-modal__title { 66 86 width: 100%; 67 87 } 88 68 89 .custom-cookie-message-modal__box { 69 90 width: 50%; … … 77 98 margin-top: 15vh; 78 99 } 100 79 101 .custom-cookie-message-modal__close { 80 102 position: absolute; … … 88 110 background: white; 89 111 cursor: pointer; 90 font-size: 0 px;91 line-height: 0 px;112 font-size: 0; 113 line-height: 0; 92 114 justify-content: center; 93 115 align-items: center; 94 116 } 95 .custom-cookie-message-modal__close::after { 96 content: "\f057"; 97 font-family: "fontawesome"; 98 font-size: 2rem; 99 line-height: 2rem; 100 display: block; 101 } 117 102 118 .custom-cookie-message-modal__tabs { 103 119 width: 30%; 104 120 } 121 105 122 .custom-cookie-message-modal__content { 106 123 flex: 1; 107 124 padding-left: 20px; 108 125 } 126 109 127 .custom-cookie-message-modal__content div { 110 128 display: flex; … … 112 130 height: 100%; 113 131 } 132 114 133 .custom-cookie-message-modal__item { 115 134 display: block; … … 123 142 cursor: pointer; 124 143 } 144 125 145 .custom-cookie-message-modal__item:hover { 126 146 text-decoration: underline; 127 147 } 148 128 149 .custom-cookie-message-modal__item--active { 129 150 background: #555; 130 151 color: white; 131 152 } 153 132 154 .custom-cookie-message-modal__checkbox { 133 155 margin-left: auto; 134 156 margin-top: auto; 135 157 } 158 136 159 .custom-cookie-message-modal__actions { 137 160 flex: 1 0 100%; … … 139 162 } 140 163 141 142 164 .custom-cookie-message-modal__content div.hide { 143 165 display: none; -
custom-cookie-message/trunk/assets/js/custom-cookie-message-popup.js
r1822626 r1827523 18 18 .on( 'click', '.custom-cookie-message-modal__item', this.actionTab ) 19 19 .on( 'click', '#ccm_cookie_preferences', this.cookiePreferences ) 20 .on( 'click', '#c mm-save-preference,.custom-cookie-message-banner__close', this.savePreferences );20 .on( 'click', '#ccm-save-preference,.custom-cookie-message-banner__close', this.savePreferences ); 21 21 }, 22 22 -
custom-cookie-message/trunk/readme.txt
r1823366 r1827523 1 1 === Custom Cookie Message === 2 Contributors: johansylvan, angrycreative, kylegard, killua99 2 Contributors: johansylvan, angrycreative, kylegard, killua99, melindrea 3 3 Tags: custom, cookie, message, consent, cookie bar, cookie compliance, cookie law, cookie notice, cookie notification, cookie notification bar, cookie notify, cookies, eu, eu cookie, eu cookie law, notice, notification, notify, custom cookie message, WPML, Polylang, Multisite, multisites, local storage 4 4 Requires at least: 4.9 5 Tested up to: 4.9. 16 Stable tag: 2. 0.45 Tested up to: 4.9.4 6 Stable tag: 2.1.0 7 7 Requires PHP: 5.6+ 8 8 -
custom-cookie-message/trunk/src/Forms/class-adminstylingoptions.php
r1823342 r1827523 69 69 add_settings_field( 'text_font', esc_html__( 'Text font', 'custom-cookie-message' ), [ $this, 'cookies_text_font_callback' ], $this->section_page, 'styling' ); 70 70 71 add_settings_field( 'text_size', esc_html__( 'Text size', 'custom-cookie-message' ), [ $this, 'cookies_text_size_callback' ], $this->section_page, 'styling' ); 72 71 73 add_settings_field( 'text_color_picker', esc_html__( 'Text Color', 'custom-cookie-message' ), [ $this, 'cookies_text_color_picker_callback' ], $this->section_page, 'styling' ); 72 74 73 75 add_settings_field( 'link_color_picker', esc_html__( 'Link Color', 'custom-cookie-message' ), [ $this, 'cookies_link_color_picker_callback' ], $this->section_page, 'styling' ); 74 75 add_settings_field( 'add_button_class', esc_html__( 'Button classes', 'custom-cookie-message' ), [ $this, 'cookies_add_button_class_callback' ], $this->section_page, 'styling' );76 76 77 77 add_settings_field( 'button_color_picker', esc_html__( 'Button Color', 'custom-cookie-message' ), [ $this, 'cookies_button_color_picker_callback' ], $this->section_page, 'styling' ); … … 133 133 134 134 /** 135 * Text size family. 136 */ 137 public function cookies_text_size_callback() { 138 $val = isset( $this->options['styles']['text_size'] ) ? $this->options['styles']['text_font'] : ''; 139 echo '<input type="text" id="text_size" name="custom_cookie_message[styles][text_size]" value="' . $val . '" class="regular-text ltr" />'; // WPCS: XSS ok. 140 echo '<div><p>Size of the text in the banner and modal</p></div>'; 141 } 142 143 /** 135 144 * Color Text. 136 145 */ … … 146 155 $val = isset( $this->options['styles']['link_color_picker'] ) ? $this->options['styles']['link_color_picker'] : ''; 147 156 echo '<input type="text" id="link_color_picker" name="custom_cookie_message[styles][link_color_picker]" value="' . $val . '" class="cpa-color-picker" >'; // WPCS: XSS ok. 148 }149 150 /**151 * Button Class.152 */153 public function cookies_add_button_class_callback() {154 $val = isset( $this->options['styles']['add_button_class'] ) ? $this->options['styles']['add_button_class'] : '';155 echo '<input type="text" id="add_button_class" name="custom_cookie_message[styles][add_button_class]" value="' . $val . '" class="regular-text ltr" />'; // WPCS: XSS ok.156 echo '<div><p>Replace the standard styling of the button by specifying your own class. If several classes, separate with space. Leave empty to keep the standard styling.</p></div>';157 157 } 158 158 … … 200 200 201 201 /** 202 * Button hover color.202 * Modal background. 203 203 */ 204 204 public function cookies_modal_background_callback() { 205 205 $val = isset( $this->options['styles']['modal_bg'] ) ? $this->options['styles']['modal_bg'] : '#3d3d3d'; 206 echo '<input type="text" id=" button_hover_color_picker" name="custom_cookie_message[styles][modal_bg]" value="' . $val . '" class="cpa-color-picker" >'; // WPCS: XSS ok.207 } 208 209 /** 210 * Button width.206 echo '<input type="text" id="modal_bg" name="custom_cookie_message[styles][modal_bg]" value="' . $val . '" class="cpa-color-picker" >'; // WPCS: XSS ok. 207 } 208 209 /** 210 * Modal opacity. 211 211 */ 212 212 public function cookies_modal_background_opacity_callback() { -
custom-cookie-message/trunk/src/class-main.php
r1823366 r1827523 23 23 * @var string 24 24 */ 25 protected $version = '2. 0.4';25 protected $version = '2.1.0'; 26 26 27 27 /** … … 262 262 263 263 wp_enqueue_style( 'custom-cookie-message-popup-styles', CUSTOM_COOKIE_MESSAGE_PLUGIN_URL . '/assets/css/custom-cookie-message-popup.css', [], $this->version, 'screen' ); 264 264 wp_add_inline_style( 'custom-cookie-message-popup-styles', $this->custom_css() ); 265 265 wp_enqueue_script( 'custom-cookie-message-popup', CUSTOM_COOKIE_MESSAGE_PLUGIN_URL . '/assets/js/custom-cookie-message-popup.js', [ 'jquery' ], $this->version, true ); 266 wp_enqueue_script( 'custom-cookie-message-svg', CUSTOM_COOKIE_MESSAGE_PLUGIN_URL . '/assets/js/svgxuse.js', [], $this->version, true ); 266 267 wp_localize_script( 267 268 'custom-cookie-message-popup', 'customCookieMessageLocalize', [ … … 275 276 } 276 277 278 protected function parse_to_rgba( $colour, $opacity = 1) { 279 list( $r, $g, $b ) = sscanf( $colour, '#%02x%02x%02x' ); 280 281 $opacity = $opacity / 100; 282 $rgba = sprintf('rgba(%s, %s, %s, %s)', $r, $g, $b, $opacity); 283 284 return $rgba; 285 } 286 287 /** 288 * Create styles from the options 289 */ 290 protected function custom_css() { 291 $options = get_option( 'custom_cookie_message' ); 292 $styles = $options['styles']; 293 294 $banner_background = $this->parse_to_rgba( $styles['message_color_picker'], $styles['opacity_slider_amount'] ); 295 296 $modal_background = $this->parse_to_rgba( $styles['modal_bg'], $styles['modal_bg_opacity'] ); 297 298 $css = ''; 299 $css .= '.custom-cookie-message-banner {'; 300 $css .= sprintf('background-color: %s;', $banner_background ); 301 $css .= sprintf('padding: %spx 0;', $styles['message_height_slider_amount'] ); 302 $css .= '}'; 303 304 $css .= '.custom-cookie-message-banner__text,'; 305 $css .= '.custom-cookie-message-modal__box {'; 306 $css .= sprintf('color: %s;', $styles['text_color_picker'] ); 307 if (! empty( $styles['text_font'] ) ) { 308 $css .= sprintf('font-family: %s;', $styles['text_font']); 309 } 310 $css .= sprintf('font-size: %s;', $styles['text_size'] ); 311 $css .= '}'; 312 313 $css .= '.custom-cookie-message-banner a {'; 314 $css .= sprintf('color: %s;', $styles['link_color_picker']); 315 $css .= '}'; 316 317 $css .= '.custom-cookie-message-modal {'; 318 $css .= sprintf('background-color: %s;', $modal_background); 319 $css .= '}'; 320 321 $css .= '.custom-cookie-message-banner__button,'; 322 $css .= '.custom-cookie-message-popup__button {'; 323 $css .= sprintf('background-color: %s;', $styles['button_color_picker']); 324 $css .= sprintf('color: %s;', $styles['button_text_color_picker']); 325 $css .= sprintf( 326 'padding: %spx %spx;', $styles['button_height_slider_amount'], 327 $styles['button_width_slider_amount'] 328 ); 329 $css .= '}'; 330 331 return $css; 332 } 333 277 334 /** 278 335 * Include template if we could locate it. … … 320 377 321 378 /** 322 * TODO: Move this away f orm here.379 * TODO: Move this away from here. 323 380 */ 324 381 public function cookie_setcookie() { … … 343 400 'content' => [ 344 401 'input_button_text' => 'Change Settings', 402 'save_settings_button' => 'Save Settings', 345 403 'input_link_text' => 'Read more', 346 404 'textarea_warning_text' => 'This website uses cookies. By using our website you accept our use of cookies.', … … 348 406 ], 349 407 'styles' => [ 350 'messages_color_picker' => '#3E3E3B', 351 'button_color_picker' => '#EBECED', 352 'button_hover_color_picker' => '#CBC5C1', 353 'button_text_color_picker' => '#3E3E3B', 354 'text_color_picker' => '#EBECED', 355 'link_color_picker' => '#CBC5C1', 356 'add_button_class' => 'custom-cookie-message-banner__button', 408 'message_color_picker' => '#3E3E3B', 409 'message_height_slider_amount' => '10', 410 'opacity_slider_amount' => '100', 411 'button_color_picker' => '#EBECED', 412 'button_hover_color_picker' => '#CBC5C1', 413 'button_text_color_picker' => '#3E3E3B', 414 'button_height_slider_amount' => '15', 415 'button_width_slider_amount' => '10', 416 'text_color_picker' => '#c0c0c0', 417 'text_size' => '16px', 418 'text_font' => '', 419 'link_color_picker' => '#CBC5C1', 420 'modal_bg' => '#3d3d3d', 421 'modal_bg_opacity' => '50', 422 357 423 ], 358 424 'cookie_granularity_settings' => [ -
custom-cookie-message/trunk/templates/cookie-notice.php
r1823342 r1827523 21 21 } 22 22 23 list( $r, $g, $b ) = sscanf( $options['styles']['message_color_picker'], '#%02x%02x%02x' );24 25 $background_opacity = $options['styles']['opacity_slider_amount'] / 100;26 $style_notice_banner = "background-color: rgba({$r}, {$g}, {$b}, {$background_opacity});";27 $style_notice_banner .= ' padding: ' . $options['styles']['message_height_slider_amount'] . 'px 0;';28 29 $style_message = 'color: ' . $options['styles']['text_color_picker'] . ';';30 $style_message .= empty( $options['styles']['text_font'] ) ? '' : 'font-family: ' . $options['styles']['text_font'] . ';';31 32 $style_link = 'color: ' . $options['styles']['link_color_picker'] . ';';33 34 $style_button_class = $options['styles']['add_button_class'];35 36 list( $r, $g, $b ) = sscanf( $options['styles']['modal_bg'], '#%02x%02x%02x' );37 38 $modal_background_opacity = $options['styles']['modal_bg_opacity'] / 100;39 $modal_style = "background-color: rgba({$r}, {$g}, {$b}, {$modal_background_opacity});";40 41 23 $functional_check = 'checked'; 42 24 $advertising_check = 'checked'; … … 52 34 53 35 ?> 54 <div id="custom-cookie-message-banner" class="custom-cookie-message-banner custom-cookie-message-banner--<?php echo esc_attr( $options['general']['location_options'] ); ?>" style="<?php echo esc_attr( $style_notice_banner ); ?>"> 36 <svg aria-hidden="true" style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> 37 <defs> 38 <symbol id="icon-cancel-circle" viewBox="0 0 32 32"> 39 <title>cancel-circle</title> 40 <path d="M16 0c-8.837 0-16 7.163-16 16s7.163 16 16 16 16-7.163 16-16-7.163-16-16-16zM16 29c-7.18 0-13-5.82-13-13s5.82-13 13-13 13 5.82 13 13-5.82 13-13 13z"></path> 41 <path d="M21 8l-5 5-5-5-3 3 5 5-5 5 3 3 5-5 5 5 3-3-5-5 5-5z"></path> 42 </symbol> 43 </defs> 44 </svg> 45 <div id="custom-cookie-message-banner" class="custom-cookie-message-banner custom-cookie-message-banner--<?php echo esc_attr( $options['general']['location_options'] ); ?>"> 55 46 <div class="custom-cookie-message-banner__content"> 56 <div class=" warning-text" style="<?php echo esc_attr( $style_message ); ?>">47 <div class="custom-cookie-message-banner__text"> 57 48 <p><?php $esc_html( $options['content']['textarea_warning_text'], 'custom-cookie-message' ); ?> 58 49 <?php if ( $options['general']['cookies_page_link'] ) : ?> 59 <a style="<?php echo esc_attr( $style_link ); ?>"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>50 <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> 60 51 <?php endif; ?> 61 <button id="custom-cookie-message-preference" class=" btn btn-default <?php echo esc_attr( $style_button_class ); ?>">52 <button id="custom-cookie-message-preference" class=".custom-cookie-message-banner__button"> 62 53 <?php $esc_html( $options['content']['input_button_text'], 'custom-cookie-message' ); ?> 63 54 </button> 64 55 </p> 65 56 </div> 66 <div class="custom-cookie-message-banner__close"><?php esc_html_e( 'Close', 'custom-cookie-message' ); ?> </div>57 <div class="custom-cookie-message-banner__close"><?php esc_html_e( 'Close', 'custom-cookie-message' ); ?> <svg class="icon icon-cancel-circle"><use xlink:href="#icon-cancel-circle"></use></svg></div> 67 58 </div> 68 59 </div> 69 <div id="custom-cookie-message-modal" class="custom-cookie-message-modal custom-cookie-message-modal--off" style="<?php echo esc_attr( $modal_style ); ?>"> 60 61 <div id="custom-cookie-message-modal" class="custom-cookie-message-modal custom-cookie-message-modal--off"> 70 62 <div class="custom-cookie-message-modal__box"> 71 <div class="custom-cookie-message-modal__close"><?php esc_html_e( 'Close', 'custom-cookie-message' ); ?>< /div>63 <div class="custom-cookie-message-modal__close"><?php esc_html_e( 'Close', 'custom-cookie-message' ); ?><svg class="icon icon-cancel-circle"><use xlink:href="#icon-cancel-circle"></use></svg></div> 72 64 <h2 class="custom-cookie-message-modal__title"><?php $esc_html( $options['cookie_granularity_settings']['headline'], 'custom-cookie-message' ); ?></h2> 73 65 <div class="custom-cookie-message-modal__tabs"> … … 98 90 </div> 99 91 <div class="custom-cookie-message-modal__actions"> 100 < a id="cmm-save-preference" class="btn btn-default"><?php $esc_html( $options['content']['save_settings_button'], 'custom-cookie-message' ); ?></a>92 <button id="ccm-save-preference" class=".custom-cookie-message-popup__button"><?php $esc_html( $options['content']['save_settings_button'], 'custom-cookie-message' ); ?></button> 101 93 </div> 102 94 </div>
Note: See TracChangeset
for help on using the changeset viewer.