Cookie Notice by dFactory - Version 1.2.38

Version Description

  • Tweak: Move frontend cookie js functions before the document ready call, thanks to fgreinus
  • Tweak: Adjust functional javascript code handling
  • Fix: Chhromium infinity expiration date not valid
  • Fix: Remove deprecated screen_icon() function
Download this release

Release Info

Developer dfactory
Plugin Icon 128x128 Cookie Notice by dFactory
Version 1.2.38
Comparing to
See all releases

Code changes from version 1.2.37 to 1.2.38

Files changed (4) hide show
  1. cookie-notice.php +69 -60
  2. js/front.js +69 -70
  3. languages/cookie-notice.pot +52 -57
  4. readme.txt +11 -5
cookie-notice.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Cookie Notice
4
  Description: Cookie Notice allows you to elegantly inform users that your site uses cookies and to comply with the EU cookie law regulations.
5
- Version: 1.2.37
6
  Author: dFactory
7
  Author URI: http://www.dfactory.eu/
8
  Plugin URI: http://www.dfactory.eu/plugins/cookie-notice/
@@ -12,7 +12,7 @@ Text Domain: cookie-notice
12
  Domain Path: /languages
13
 
14
  Cookie Notice
15
- Copyright (C) 2013-2016, Digital Factory - info@digitalfactory.pl
16
 
17
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
18
 
@@ -34,7 +34,7 @@ include_once( plugin_dir_path( __FILE__ ) . 'includes/upgrade.php' );
34
  * Cookie Notice class.
35
  *
36
  * @class Cookie_Notice
37
- * @version 1.2.37
38
  */
39
  class Cookie_Notice {
40
 
@@ -70,7 +70,7 @@ class Cookie_Notice {
70
  'translate' => true,
71
  'deactivation_delete' => 'no'
72
  ),
73
- 'version' => '1.2.37'
74
  );
75
  private $positions = array();
76
  private $styles = array();
@@ -108,14 +108,14 @@ class Cookie_Notice {
108
  add_action( 'admin_menu', array( $this, 'admin_menu_options' ) );
109
  add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
110
  add_action( 'after_setup_theme', array( $this, 'load_defaults' ) );
111
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_load_scripts_styles' ) );
112
- add_action( 'wp_enqueue_scripts', array( $this, 'front_load_scripts_styles' ) );
113
  add_action( 'wp_print_footer_scripts', array( $this, 'wp_print_footer_scripts' ) );
114
  add_action( 'wp_footer', array( $this, 'add_cookie_notice' ), 1000 );
115
 
116
  // filters
117
- add_filter( 'plugin_row_meta', array( $this, 'plugin_extend_links' ), 10, 2 );
118
- add_filter( 'plugin_action_links', array( $this, 'plugin_settings_link' ), 10, 2 );
119
  }
120
 
121
  /**
@@ -155,7 +155,7 @@ class Cookie_Notice {
155
  '3months' => array( __( '3 months', 'cookie-notice' ), 7862400 ),
156
  '6months' => array( __( '6 months', 'cookie-notice' ), 15811200 ),
157
  'year' => array( __( '1 year', 'cookie-notice' ), 31536000 ),
158
- 'infinity' => array( __( 'infinity', 'cookie-notice' ), 31337313373 )
159
  );
160
 
161
  $this->effects = array(
@@ -246,22 +246,22 @@ class Cookie_Notice {
246
  */
247
  public function options_page() {
248
  echo '
249
- <div class="wrap">' . screen_icon() . '
250
  <h2>' . __( 'Cookie Notice', 'cookie-notice' ) . '</h2>
251
  <div class="cookie-notice-settings">
252
  <div class="df-credits">
253
  <h3 class="hndle">' . __( 'Cookie Notice', 'cookie-notice' ) . ' ' . $this->defaults['version'] . '</h3>
254
  <div class="inside">
255
  <h4 class="inner">' . __( 'Need support?', 'cookie-notice' ) . '</h4>
256
- <p class="inner">' . __( 'If you are having problems with this plugin, please talk about them in the', 'cookie-notice' ) . ' <a href="http://dfactory.eu/support/" target="_blank" title="' . __( 'Support forum', 'cookie-notice' ) . '">' . __( 'Support forum', 'cookie-notice' ) . '</a></p>
257
  <hr />
258
  <h4 class="inner">' . __( 'Do you like this plugin?', 'cookie-notice' ) . '</h4>
259
- <p class="inner"><a href="http://wordpress.org/support/view/plugin-reviews/cookie-notice" target="_blank" title="' . __( 'Rate it 5', 'cookie-notice' ) . '">' . __( 'Rate it 5', 'cookie-notice' ) . '</a> ' . __( 'on WordPress.org', 'cookie-notice' ) . '<br />' .
260
- __( 'Blog about it & link to the', 'cookie-notice' ) . ' <a href="http://dfactory.eu/plugins/cookie-notice/" target="_blank" title="' . __( 'plugin page', 'cookie-notice' ) . '">' . __( 'plugin page', 'cookie-notice' ) . '</a><br />' .
261
- __( 'Check out our other', 'cookie-notice' ) . ' <a href="http://dfactory.eu/plugins/" target="_blank" title="' . __( 'WordPress plugins', 'cookie-notice' ) . '">' . __( 'WordPress plugins', 'cookie-notice' ) . '</a>
262
  </p>
263
  <hr />
264
- <p class="df-link inner">Created by <a href="http://www.dfactory.eu" target="_blank" title="dFactory - Quality plugins for WordPress"><img src="' . plugins_url( '/images/logo-dfactory.png', __FILE__ ) . '" title="dFactory - Quality plugins for WordPress" alt="dFactory - Quality plugins for WordPress" /></a></p>
265
  </div>
266
  </div>
267
  <form action="options.php" method="post">';
@@ -295,6 +295,7 @@ class Cookie_Notice {
295
  add_settings_field( 'cn_see_more', __( 'More info link', 'cookie-notice' ), array( $this, 'cn_see_more' ), 'cookie_notice_options', 'cookie_notice_configuration' );
296
  add_settings_field( 'cn_link_target', __( 'Link target', 'cookie-notice' ), array( $this, 'cn_link_target' ), 'cookie_notice_options', 'cookie_notice_configuration' );
297
  add_settings_field( 'cn_refuse_opt', __( 'Refuse button', 'cookie-notice' ), array( $this, 'cn_refuse_opt' ), 'cookie_notice_options', 'cookie_notice_configuration' );
 
298
  add_settings_field( 'cn_on_scroll', __( 'On scroll', 'cookie-notice' ), array( $this, 'cn_on_scroll' ), 'cookie_notice_options', 'cookie_notice_configuration' );
299
  add_settings_field( 'cn_time', __( 'Cookie expiry', 'cookie-notice' ), array( $this, 'cn_time' ), 'cookie_notice_options', 'cookie_notice_configuration' );
300
  add_settings_field( 'cn_script_placement', __( 'Script placement', 'cookie-notice' ), array( $this, 'cn_script_placement' ), 'cookie_notice_options', 'cookie_notice_configuration' );
@@ -355,17 +356,23 @@ class Cookie_Notice {
355
  echo '
356
  <div id="cn_refuse_text">
357
  <input type="text" class="regular-text" name="cookie_notice_options[refuse_text]" value="' . esc_attr( $this->options['general']['refuse_text'] ) . '" />
358
- <p class="description">' . __( 'The text of the option to refuse the usage of the cookies. To get the cookie notice status use <code>cn_cookies_accepted()</code> function.', 'cookie-notice' ) . '</p>
359
- </div>';
360
- echo '
361
- <div id="cn_refuse_code">
362
- <textarea name="cookie_notice_options[refuse_code]" class="large-text" cols="50" rows="5">' . esc_textarea( $this->options['general']['refuse_code'] ) . '</textarea>
363
- <p class="description">' . __( 'Enter non functional cookies Javascript code here (for e.g. Google Analitycs). It will be used after cookies are accepted.', 'cookie-notice' ) . '</p>
364
  </div>';
365
  echo '
366
  </div>
367
  </fieldset>';
368
  }
 
 
 
 
 
 
 
 
 
 
 
369
 
370
  /**
371
  * Read more link option.
@@ -602,7 +609,8 @@ class Cookie_Notice {
602
  $input['accept_text'] = sanitize_text_field( isset( $input['accept_text'] ) && $input['accept_text'] !== '' ? $input['accept_text'] : $this->defaults['general']['accept_text'] );
603
  $input['refuse_text'] = sanitize_text_field( isset( $input['refuse_text'] ) && $input['refuse_text'] !== '' ? $input['refuse_text'] : $this->defaults['general']['refuse_text'] );
604
  $input['refuse_opt'] = (bool) isset( $input['refuse_opt'] ) ? 'yes' : 'no';
605
- $input['refuse_code'] = wp_kses_post( isset( $input['refuse_code'] ) && $input['refuse_code'] !== '' ? $input['refuse_code'] : $this->defaults['general']['refuse_code'] );
 
606
 
607
  // css
608
  $input['css_style'] = sanitize_text_field( isset( $input['css_style'] ) && in_array( $input['css_style'], array_keys( $this->styles ) ) ? $input['css_style'] : $this->defaults['general']['css_style'] );
@@ -667,7 +675,7 @@ class Cookie_Notice {
667
  * @return mixed
668
  */
669
  public function add_cookie_notice() {
670
- if ( ! $this->cookie_setted() ) {
671
  // WPML >= 3.2
672
  if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
673
  $this->options['general']['message_text'] = apply_filters( 'wpml_translate_single_string', $this->options['general']['message_text'], 'Cookie Notice', 'Message in the notice' );
@@ -721,8 +729,8 @@ class Cookie_Notice {
721
  *
722
  * @return bool
723
  */
724
- public function cookie_setted() {
725
- return isset( $_COOKIE[self::$cookie['name']] );
726
  }
727
 
728
  /**
@@ -731,9 +739,9 @@ class Cookie_Notice {
731
  * @return bool
732
  */
733
  public static function cookies_accepted() {
734
- return ( isset( $_COOKIE[self::$cookie['name']] ) && strtoupper( $_COOKIE[self::$cookie['name']] ) === self::$cookie['value'] );
735
  }
736
-
737
  /**
738
  * Get default settings.
739
  */
@@ -742,13 +750,13 @@ class Cookie_Notice {
742
  }
743
 
744
  /**
745
- * Add links to Support Forum.
746
  *
747
  * @param array $links
748
  * @param string $file
749
  * @return array
750
  */
751
- public function plugin_extend_links( $links, $file ) {
752
  if ( ! current_user_can( apply_filters( 'cn_manage_cookie_notice_cap', 'manage_options' ) ) )
753
  return $links;
754
 
@@ -767,7 +775,7 @@ class Cookie_Notice {
767
  * @param string $file
768
  * @return array
769
  */
770
- public function plugin_settings_link( $links, $file ) {
771
  if ( ! current_user_can( apply_filters( 'cn_manage_cookie_notice_cap', 'manage_options' ) ) )
772
  return $links;
773
 
@@ -798,7 +806,7 @@ class Cookie_Notice {
798
  /**
799
  * Load scripts and styles - admin.
800
  */
801
- public function admin_load_scripts_styles( $page ) {
802
  if ( $page !== 'settings_page_cookie-notice' )
803
  return;
804
 
@@ -819,28 +827,26 @@ class Cookie_Notice {
819
  /**
820
  * Load scripts and styles - frontend.
821
  */
822
- public function front_load_scripts_styles() {
823
- if ( ! $this->cookie_setted() ) {
824
- wp_enqueue_script(
825
- 'cookie-notice-front', plugins_url( 'js/front.js', __FILE__ ), array( 'jquery' ), $this->defaults['version'], isset( $this->options['general']['script_placement'] ) && $this->options['general']['script_placement'] === 'footer' ? true : false
826
- );
827
-
828
- wp_localize_script(
829
- 'cookie-notice-front', 'cnArgs', array(
830
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
831
- 'hideEffect' => $this->options['general']['hide_effect'],
832
- 'onScroll' => $this->options['general']['on_scroll'],
833
- 'onScrollOffset' => $this->options['general']['on_scroll_offset'],
834
- 'cookieName' => self::$cookie['name'],
835
- 'cookieValue' => self::$cookie['value'],
836
- 'cookieTime' => $this->times[$this->options['general']['time']][1],
837
- 'cookiePath' => ( defined( 'COOKIEPATH' ) ? COOKIEPATH : '' ),
838
- 'cookieDomain' => ( defined( 'COOKIE_DOMAIN' ) ? COOKIE_DOMAIN : '' )
839
- )
840
- );
841
-
842
- wp_enqueue_style( 'cookie-notice-front', plugins_url( 'css/front.css', __FILE__ ) );
843
- }
844
  }
845
 
846
  /**
@@ -849,14 +855,17 @@ class Cookie_Notice {
849
  * @return mixed
850
  */
851
  public function wp_print_footer_scripts() {
852
- $scripts = html_entity_decode( trim( wp_kses_post( $this->options['general']['refuse_code'] ) ) );
 
 
 
 
 
 
 
853
 
854
- if ( $this->cookie_setted() && ! empty( $scripts ) ) {
855
- ?>
856
- <script type='text/javascript'>
857
- <?php echo $scripts; ?>
858
- </script>
859
- <?php
860
  }
861
  }
862
 
2
  /*
3
  Plugin Name: Cookie Notice
4
  Description: Cookie Notice allows you to elegantly inform users that your site uses cookies and to comply with the EU cookie law regulations.
5
+ Version: 1.2.38
6
  Author: dFactory
7
  Author URI: http://www.dfactory.eu/
8
  Plugin URI: http://www.dfactory.eu/plugins/cookie-notice/
12
  Domain Path: /languages
13
 
14
  Cookie Notice
15
+ Copyright (C) 2013-2017, Digital Factory - info@digitalfactory.pl
16
 
17
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
18
 
34
  * Cookie Notice class.
35
  *
36
  * @class Cookie_Notice
37
+ * @version 1.2.38
38
  */
39
  class Cookie_Notice {
40
 
70
  'translate' => true,
71
  'deactivation_delete' => 'no'
72
  ),
73
+ 'version' => '1.2.38'
74
  );
75
  private $positions = array();
76
  private $styles = array();
108
  add_action( 'admin_menu', array( $this, 'admin_menu_options' ) );
109
  add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
110
  add_action( 'after_setup_theme', array( $this, 'load_defaults' ) );
111
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
112
+ add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
113
  add_action( 'wp_print_footer_scripts', array( $this, 'wp_print_footer_scripts' ) );
114
  add_action( 'wp_footer', array( $this, 'add_cookie_notice' ), 1000 );
115
 
116
  // filters
117
+ add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
118
+ add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 );
119
  }
120
 
121
  /**
155
  '3months' => array( __( '3 months', 'cookie-notice' ), 7862400 ),
156
  '6months' => array( __( '6 months', 'cookie-notice' ), 15811200 ),
157
  'year' => array( __( '1 year', 'cookie-notice' ), 31536000 ),
158
+ 'infinity' => array( __( 'infinity', 'cookie-notice' ), PHP_INT_MAX )
159
  );
160
 
161
  $this->effects = array(
246
  */
247
  public function options_page() {
248
  echo '
249
+ <div class="wrap">
250
  <h2>' . __( 'Cookie Notice', 'cookie-notice' ) . '</h2>
251
  <div class="cookie-notice-settings">
252
  <div class="df-credits">
253
  <h3 class="hndle">' . __( 'Cookie Notice', 'cookie-notice' ) . ' ' . $this->defaults['version'] . '</h3>
254
  <div class="inside">
255
  <h4 class="inner">' . __( 'Need support?', 'cookie-notice' ) . '</h4>
256
+ <p class="inner">' . sprintf( __( 'If you are having problems with this plugin, please browse it\'s <a href="%s" target="_blank">Documentation</a> or talk about them in the <a href="%s" target="_blank">Support forum</a>', 'cookie-notice' ), 'https://www.dfactory.eu/docs/cookie-notice/?utm_source=cookie-notice-settings&utm_medium=link&utm_campaign=docs', 'https://dfactory.eu/support/?utm_source=cookie-notice-settings&utm_medium=link&utm_campaign=support' ) . '</p>
257
  <hr />
258
  <h4 class="inner">' . __( 'Do you like this plugin?', 'cookie-notice' ) . '</h4>
259
+ <p class="inner">' . sprintf( __( '<a href="%s" target="_blank">Rate it 5</a> on WordPress.org', 'cookie-notice' ), 'https://wordpress.org/support/plugin/cookie-notice/reviews/?filter=5' ) . '<br />' .
260
+ sprintf( __( 'Blog about it & link to the <a href="%s" target="_blank">plugin page</a>.', 'cookie-notice' ), 'https://dfactory.eu/plugins/cookie-notice?utm_source=cookie-notice-settings&utm_medium=link&utm_campaign=blog-about' ) . '<br />' .
261
+ sprintf( __( 'Check out our other <a href="%s" target="_blank">WordPress plugins</a>.', 'cookie-notice' ), 'https://dfactory.eu/plugins/?utm_source=cookie-notice-settings&utm_medium=link&utm_campaign=other-plugins' ) . '
262
  </p>
263
  <hr />
264
+ <p class="df-link inner">Created by <a href="https://dfactory.eu/?utm_source=cookie-notice-settings&utm_medium=link&utm_campaign=created-by" target="_blank" title="dFactory - Quality plugins for WordPress"><img src="' . plugins_url( '/images/logo-dfactory.png', __FILE__ ) . '" title="dFactory - Quality plugins for WordPress" alt="dFactory - Quality plugins for WordPress" /></a></p>
265
  </div>
266
  </div>
267
  <form action="options.php" method="post">';
295
  add_settings_field( 'cn_see_more', __( 'More info link', 'cookie-notice' ), array( $this, 'cn_see_more' ), 'cookie_notice_options', 'cookie_notice_configuration' );
296
  add_settings_field( 'cn_link_target', __( 'Link target', 'cookie-notice' ), array( $this, 'cn_link_target' ), 'cookie_notice_options', 'cookie_notice_configuration' );
297
  add_settings_field( 'cn_refuse_opt', __( 'Refuse button', 'cookie-notice' ), array( $this, 'cn_refuse_opt' ), 'cookie_notice_options', 'cookie_notice_configuration' );
298
+ add_settings_field( 'cn_refuse_code', __( 'Script blocking', 'cookie-notice' ), array( $this, 'cn_refuse_code' ), 'cookie_notice_options', 'cookie_notice_configuration' );
299
  add_settings_field( 'cn_on_scroll', __( 'On scroll', 'cookie-notice' ), array( $this, 'cn_on_scroll' ), 'cookie_notice_options', 'cookie_notice_configuration' );
300
  add_settings_field( 'cn_time', __( 'Cookie expiry', 'cookie-notice' ), array( $this, 'cn_time' ), 'cookie_notice_options', 'cookie_notice_configuration' );
301
  add_settings_field( 'cn_script_placement', __( 'Script placement', 'cookie-notice' ), array( $this, 'cn_script_placement' ), 'cookie_notice_options', 'cookie_notice_configuration' );
356
  echo '
357
  <div id="cn_refuse_text">
358
  <input type="text" class="regular-text" name="cookie_notice_options[refuse_text]" value="' . esc_attr( $this->options['general']['refuse_text'] ) . '" />
359
+ <p class="description">' . __( 'The text of the option to refuse the usage of the cookies.', 'cookie-notice' ) . '</p>
 
 
 
 
 
360
  </div>';
361
  echo '
362
  </div>
363
  </fieldset>';
364
  }
365
+
366
+ /**
367
+ * Non functional cookies code.
368
+ */
369
+ public function cn_refuse_code() {
370
+ echo '
371
+ <div id="cn_refuse_code">
372
+ <textarea name="cookie_notice_options[refuse_code]" class="large-text" cols="50" rows="8">' . html_entity_decode( trim( wp_kses( $this->options['general']['refuse_code'], apply_filters( 'cn_refuse_code_allowed_html', array( 'script' => array( 'type' => array(), 'src' => array(), 'charset' => array(), 'async' => array() ) ) ) ) ) ) . '</textarea>
373
+ <p class="description">' . __( 'Enter non functional cookies Javascript code here (for e.g. Google Analitycs) to be used after cookies are accepted.', 'cookie-notice' ) . '</br>' . __( 'To get the cookie notice status use <code>cn_cookies_accepted()</code> function.', 'cookie-notice' ) . '</p>
374
+ </div>';
375
+ }
376
 
377
  /**
378
  * Read more link option.
609
  $input['accept_text'] = sanitize_text_field( isset( $input['accept_text'] ) && $input['accept_text'] !== '' ? $input['accept_text'] : $this->defaults['general']['accept_text'] );
610
  $input['refuse_text'] = sanitize_text_field( isset( $input['refuse_text'] ) && $input['refuse_text'] !== '' ? $input['refuse_text'] : $this->defaults['general']['refuse_text'] );
611
  $input['refuse_opt'] = (bool) isset( $input['refuse_opt'] ) ? 'yes' : 'no';
612
+
613
+ $input['refuse_code'] = wp_kses( isset( $input['refuse_code'] ) && $input['refuse_code'] !== '' ? $input['refuse_code'] : $this->defaults['general']['refuse_code'], apply_filters( 'cn_refuse_code_allowed_html', array( 'script' => array( 'type' => array(), 'src' => array(), 'charset' => array(), 'async' => array() ) ) ) );
614
 
615
  // css
616
  $input['css_style'] = sanitize_text_field( isset( $input['css_style'] ) && in_array( $input['css_style'], array_keys( $this->styles ) ) ? $input['css_style'] : $this->defaults['general']['css_style'] );
675
  * @return mixed
676
  */
677
  public function add_cookie_notice() {
678
+ if ( ! $this->cookies_set() ) {
679
  // WPML >= 3.2
680
  if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
681
  $this->options['general']['message_text'] = apply_filters( 'wpml_translate_single_string', $this->options['general']['message_text'], 'Cookie Notice', 'Message in the notice' );
729
  *
730
  * @return bool
731
  */
732
+ public function cookies_set() {
733
+ return apply_filters( 'cn_is_cookie_set', isset( $_COOKIE[self::$cookie['name']] ) );
734
  }
735
 
736
  /**
739
  * @return bool
740
  */
741
  public static function cookies_accepted() {
742
+ return apply_filters( 'cn_is_cookie_accepted', isset( $_COOKIE[self::$cookie['name']] ) && strtoupper( $_COOKIE[self::$cookie['name']] ) === self::$cookie['value'] );
743
  }
744
+
745
  /**
746
  * Get default settings.
747
  */
750
  }
751
 
752
  /**
753
+ * Add links to support forum.
754
  *
755
  * @param array $links
756
  * @param string $file
757
  * @return array
758
  */
759
+ public function plugin_row_meta( $links, $file ) {
760
  if ( ! current_user_can( apply_filters( 'cn_manage_cookie_notice_cap', 'manage_options' ) ) )
761
  return $links;
762
 
775
  * @param string $file
776
  * @return array
777
  */
778
+ public function plugin_action_links( $links, $file ) {
779
  if ( ! current_user_can( apply_filters( 'cn_manage_cookie_notice_cap', 'manage_options' ) ) )
780
  return $links;
781
 
806
  /**
807
  * Load scripts and styles - admin.
808
  */
809
+ public function admin_enqueue_scripts( $page ) {
810
  if ( $page !== 'settings_page_cookie-notice' )
811
  return;
812
 
827
  /**
828
  * Load scripts and styles - frontend.
829
  */
830
+ public function wp_enqueue_scripts() {
831
+ wp_enqueue_script(
832
+ 'cookie-notice-front', plugins_url( 'js/front.js', __FILE__ ), array( 'jquery' ), $this->defaults['version'], isset( $this->options['general']['script_placement'] ) && $this->options['general']['script_placement'] === 'footer' ? true : false
833
+ );
834
+
835
+ wp_localize_script(
836
+ 'cookie-notice-front', 'cnArgs', array(
837
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
838
+ 'hideEffect' => $this->options['general']['hide_effect'],
839
+ 'onScroll' => $this->options['general']['on_scroll'],
840
+ 'onScrollOffset' => $this->options['general']['on_scroll_offset'],
841
+ 'cookieName' => self::$cookie['name'],
842
+ 'cookieValue' => self::$cookie['value'],
843
+ 'cookieTime' => $this->times[$this->options['general']['time']][1],
844
+ 'cookiePath' => ( defined( 'COOKIEPATH' ) ? COOKIEPATH : '' ),
845
+ 'cookieDomain' => ( defined( 'COOKIE_DOMAIN' ) ? COOKIE_DOMAIN : '' )
846
+ )
847
+ );
848
+
849
+ wp_enqueue_style( 'cookie-notice-front', plugins_url( 'css/front.css', __FILE__ ) );
 
 
850
  }
851
 
852
  /**
855
  * @return mixed
856
  */
857
  public function wp_print_footer_scripts() {
858
+ $allowed_html = apply_filters( 'cn_refuse_code_allowed_html', array( 'script' => array(
859
+ 'type' => array(),
860
+ 'src' => array(),
861
+ 'charset' => array(),
862
+ 'async' => array()
863
+ )
864
+ ) );
865
+ $scripts = apply_filters( 'cn_refuse_code_scripts_html', html_entity_decode( trim( wp_kses( $this->options['general']['refuse_code'], $allowed_html ) ) ) );
866
 
867
+ if ( $this->cookies_accepted() && ! empty( $scripts ) ) {
868
+ echo $scripts;
 
 
 
 
869
  }
870
  }
871
 
js/front.js CHANGED
@@ -1,86 +1,85 @@
1
  ( function ( $ ) {
2
 
3
- $( document ).ready( function () {
 
4
 
5
- var cnDomNode = $( '#cookie-notice' );
 
 
 
6
 
7
- // handle set-cookie button click
8
- $( document ).on( 'click', '.cn-set-cookie', function ( e ) {
9
- e.preventDefault();
10
- $( this ).setCookieNotice( $( this ).data( 'cookie-set' ) );
11
- } );
12
 
13
- // handle on scroll
14
- if ( cnArgs.onScroll == 'yes' ) {
15
- var cnHandleScroll = function () {
16
- var win = $( this );
17
- if ( win.scrollTop() > parseInt( cnArgs.onScrollOffset ) ) {
18
- // If user scrolls at least 100 pixels
19
- win.setCookieNotice( 'accept' );
20
- win.off( 'scroll', cnHandleScroll ); //remove itself after cookie accept
21
- }
22
- };
23
-
24
- $( window ).on( 'scroll', cnHandleScroll );
25
- }
26
 
27
- // display cookie notice
28
- if ( document.cookie.indexOf( 'cookie_notice_accepted' ) === -1 ) {
29
- if ( cnArgs.hideEffect === 'fade' ) {
30
- cnDomNode.fadeIn( 300 );
31
- } else if ( cnArgs.hideEffect === 'slide' ) {
32
- cnDomNode.slideDown( 300 );
33
- } else {
34
- cnDomNode.show();
35
- }
36
- $( 'body' ).addClass( 'cookies-not-accepted' );
37
- } else {
38
- cnDomNode.removeCookieNotice();
39
- }
40
 
41
- } );
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- // set Cookie Notice
44
- $.fn.setCookieNotice = function ( cookie_value ) {
 
 
 
45
 
46
- var cnTime = new Date(),
47
- cnLater = new Date(),
48
- cnDomNode = $( '#cookie-notice' ),
49
- cnSelf = this;
50
 
51
- // set expiry time in seconds
52
- cnLater.setTime( parseInt( cnTime.getTime() ) + parseInt( cnArgs.cookieTime ) * 1000 );
53
 
54
- // set cookie
55
- cookie_value = cookie_value === 'accept' ? true : false;
56
- document.cookie = cnArgs.cookieName + '=' + cookie_value + ';expires=' + cnLater.toGMTString() + ';' + ( cnArgs.cookieDomain !== undefined && cnArgs.cookieDomain !== '' ? 'domain=' + cnArgs.cookieDomain + ';' : '' ) + ( cnArgs.cookiePath !== undefined && cnArgs.cookiePath !== '' ? 'path=' + cnArgs.cookiePath + ';' : '' );
 
 
57
 
58
- // trigger custom event
59
- $.event.trigger( {
60
- type: "setCookieNotice",
61
- value: cookie_value,
62
- time: cnTime,
63
- expires: cnLater
64
- } );
 
 
 
65
 
66
- // hide message container
67
- if ( cnArgs.hideEffect === 'fade' ) {
68
- cnDomNode.fadeOut( 300, function () {
69
- cnSelf.removeCookieNotice();
70
- } );
71
- } else if ( cnArgs.hideEffect === 'slide' ) {
72
- cnDomNode.slideUp( 300, function () {
73
- cnSelf.removeCookieNotice();
74
- } );
75
- } else {
76
- cnSelf.removeCookieNotice();
77
- }
78
- };
79
 
80
- // remove Cookie Notice
81
- $.fn.removeCookieNotice = function ( cookie_value ) {
82
- $( '#cookie-notice' ).remove();
83
- $( 'body' ).removeClass( 'cookies-not-accepted' );
84
- }
 
 
 
 
 
 
 
 
85
 
 
86
  } )( jQuery );
1
  ( function ( $ ) {
2
 
3
+ // set Cookie Notice
4
+ $.fn.setCookieNotice = function ( cookie_value ) {
5
 
6
+ var cnTime = new Date(),
7
+ cnLater = new Date(),
8
+ cnDomNode = $( '#cookie-notice' ),
9
+ cnSelf = this;
10
 
11
+ // set expiry time in seconds
12
+ cnLater.setTime( parseInt( cnTime.getTime() ) + parseInt( cnArgs.cookieTime ) * 1000 );
 
 
 
13
 
14
+ // set cookie
15
+ cookie_value = cookie_value === 'accept' ? true : false;
16
+ document.cookie = cnArgs.cookieName + '=' + cookie_value + ';expires=' + cnLater.toGMTString() + ';' + ( cnArgs.cookieDomain !== undefined && cnArgs.cookieDomain !== '' ? 'domain=' + cnArgs.cookieDomain + ';' : '' ) + ( cnArgs.cookiePath !== undefined && cnArgs.cookiePath !== '' ? 'path=' + cnArgs.cookiePath + ';' : '' );
 
 
 
 
 
 
 
 
 
 
17
 
18
+ // trigger custom event
19
+ $.event.trigger( {
20
+ type: "setCookieNotice",
21
+ value: cookie_value,
22
+ time: cnTime,
23
+ expires: cnLater
24
+ } );
 
 
 
 
 
 
25
 
26
+ // hide message container
27
+ if ( cnArgs.hideEffect === 'fade' ) {
28
+ cnDomNode.fadeOut( 300, function () {
29
+ cnSelf.removeCookieNotice();
30
+ } );
31
+ } else if ( cnArgs.hideEffect === 'slide' ) {
32
+ cnDomNode.slideUp( 300, function () {
33
+ cnSelf.removeCookieNotice();
34
+ } );
35
+ } else {
36
+ cnSelf.removeCookieNotice();
37
+ }
38
+ };
39
 
40
+ // remove Cookie Notice
41
+ $.fn.removeCookieNotice = function ( cookie_value ) {
42
+ $( '#cookie-notice' ).remove();
43
+ $( 'body' ).removeClass( 'cookies-not-accepted' );
44
+ };
45
 
46
+ $( document ).ready( function () {
 
 
 
47
 
48
+ var cnDomNode = $( '#cookie-notice' );
 
49
 
50
+ // handle set-cookie button click
51
+ $( document ).on( 'click', '.cn-set-cookie', function ( e ) {
52
+ e.preventDefault();
53
+ $( this ).setCookieNotice( $( this ).data( 'cookie-set' ) );
54
+ } );
55
 
56
+ // handle on scroll
57
+ if ( cnArgs.onScroll == 'yes' ) {
58
+ var cnHandleScroll = function () {
59
+ var win = $( this );
60
+ if ( win.scrollTop() > parseInt( cnArgs.onScrollOffset ) ) {
61
+ // If user scrolls at least 100 pixels
62
+ win.setCookieNotice( 'accept' );
63
+ win.off( 'scroll', cnHandleScroll ); //remove itself after cookie accept
64
+ }
65
+ };
66
 
67
+ $( window ).on( 'scroll', cnHandleScroll );
68
+ }
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ // display cookie notice
71
+ if ( document.cookie.indexOf( 'cookie_notice_accepted' ) === -1 ) {
72
+ if ( cnArgs.hideEffect === 'fade' ) {
73
+ cnDomNode.fadeIn( 300 );
74
+ } else if ( cnArgs.hideEffect === 'slide' ) {
75
+ cnDomNode.slideDown( 300 );
76
+ } else {
77
+ cnDomNode.show();
78
+ }
79
+ $( 'body' ).addClass( 'cookies-not-accepted' );
80
+ } else {
81
+ cnDomNode.removeCookieNotice();
82
+ }
83
 
84
+ } )
85
  } )( jQuery );
languages/cookie-notice.pot CHANGED
@@ -2,7 +2,7 @@
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: Cookie Notice\n"
5
- "POT-Creation-Date: 2016-12-07 10:49+0100\n"
6
  "PO-Revision-Date: 2015-03-24 11:30+0100\n"
7
  "Last-Translator: Bartosz Arendt <info@dfactory.eu>\n"
8
  "Language-Team: dFactory <info@dfactory.eu>\n"
@@ -121,11 +121,8 @@ msgid "Need support?"
121
  msgstr ""
122
 
123
  #: ../cookie-notice.php:256
124
- msgid "If you are having problems with this plugin, please talk about them in the"
125
- msgstr ""
126
-
127
- #: ../cookie-notice.php:256
128
- msgid "Support forum"
129
  msgstr ""
130
 
131
  #: ../cookie-notice.php:258
@@ -133,27 +130,18 @@ msgid "Do you like this plugin?"
133
  msgstr ""
134
 
135
  #: ../cookie-notice.php:259
136
- msgid "Rate it 5"
137
- msgstr ""
138
-
139
- #: ../cookie-notice.php:259
140
- msgid "on WordPress.org"
141
- msgstr ""
142
-
143
- #: ../cookie-notice.php:260
144
- msgid "Blog about it & link to the"
145
  msgstr ""
146
 
147
  #: ../cookie-notice.php:260
148
- msgid "plugin page"
149
- msgstr ""
150
-
151
- #: ../cookie-notice.php:261
152
- msgid "Check out our other"
153
  msgstr ""
154
 
155
  #: ../cookie-notice.php:261
156
- msgid "WordPress plugins"
 
157
  msgstr ""
158
 
159
  #: ../cookie-notice.php:276
@@ -185,139 +173,146 @@ msgid "Refuse button"
185
  msgstr ""
186
 
187
  #: ../cookie-notice.php:298
188
- msgid "On scroll"
189
  msgstr ""
190
 
191
  #: ../cookie-notice.php:299
192
- msgid "Cookie expiry"
193
  msgstr ""
194
 
195
  #: ../cookie-notice.php:300
196
- msgid "Script placement"
197
  msgstr ""
198
 
199
  #: ../cookie-notice.php:301
 
 
 
 
200
  msgid "Deactivation"
201
  msgstr ""
202
 
203
- #: ../cookie-notice.php:304
204
  msgid "Design"
205
  msgstr ""
206
 
207
- #: ../cookie-notice.php:305
208
  msgid "Position"
209
  msgstr ""
210
 
211
- #: ../cookie-notice.php:306
212
  msgid "Animation"
213
  msgstr ""
214
 
215
- #: ../cookie-notice.php:307
216
  msgid "Button style"
217
  msgstr ""
218
 
219
- #: ../cookie-notice.php:308
220
  msgid "Colors"
221
  msgstr ""
222
 
223
- #: ../cookie-notice.php:322
224
  msgid "Enable if you want all plugin data to be deleted on deactivation."
225
  msgstr ""
226
 
227
- #: ../cookie-notice.php:332
228
  msgid "Enter the cookie notice message."
229
  msgstr ""
230
 
231
- #: ../cookie-notice.php:343
232
  msgid "The text of the option to accept the usage of the cookies and make the notification disappear."
233
  msgstr ""
234
 
235
- #: ../cookie-notice.php:353
236
  msgid "Give to the user the possibility to refuse third party non functional cookies."
237
  msgstr ""
238
 
239
- #: ../cookie-notice.php:358
240
- msgid "The text of the option to refuse the usage of the cookies. To get the cookie notice status use <code>cn_cookies_accepted()</code> function."
241
  msgstr ""
242
 
243
- #: ../cookie-notice.php:363
244
- msgid "Enter non functional cookies Javascript code here (for e.g. Google Analitycs). It will be used after cookies are accepted."
245
  msgstr ""
246
 
247
- #: ../cookie-notice.php:389
 
 
 
 
248
  msgid "Enable Read more link."
249
  msgstr ""
250
 
251
- #: ../cookie-notice.php:390
252
  #, php-format
253
  msgid "Need a Cookie Policy? Generate one with <a href=\"%s\" target=\"_blank\" title=\"iubenda\">iubenda</a>"
254
  msgstr ""
255
 
256
- #: ../cookie-notice.php:396
257
  msgid "The text of the more info button."
258
  msgstr ""
259
 
260
- #: ../cookie-notice.php:410
261
  msgid "Select where to redirect user for more information about cookies."
262
  msgstr ""
263
 
264
- #: ../cookie-notice.php:413
265
  msgid "-- select page --"
266
  msgstr ""
267
 
268
- #: ../cookie-notice.php:424
269
  msgid "Select from one of your site's pages"
270
  msgstr ""
271
 
272
- #: ../cookie-notice.php:428
273
  msgid "Enter the full URL starting with http://"
274
  msgstr ""
275
 
276
- #: ../cookie-notice.php:448
277
  msgid "Select the link target for more info page."
278
  msgstr ""
279
 
280
- #: ../cookie-notice.php:468
281
  msgid "The ammount of time that cookie should be stored for."
282
  msgstr ""
283
 
284
- #: ../cookie-notice.php:482
285
  msgid "Select where all the plugin scripts should be placed."
286
  msgstr ""
287
 
288
- #: ../cookie-notice.php:500
289
  msgid "Select location for your cookie notice."
290
  msgstr ""
291
 
292
- #: ../cookie-notice.php:519
293
  msgid "Cookie notice acceptance animation."
294
  msgstr ""
295
 
296
- #: ../cookie-notice.php:529
297
  msgid "Enable cookie notice acceptance when users scroll."
298
  msgstr ""
299
 
300
- #: ../cookie-notice.php:533
301
  msgid "Number of pixels user has to scroll to accept the usage of the cookies and make the notification disappear."
302
  msgstr ""
303
 
304
- #: ../cookie-notice.php:553
305
  msgid "Choose buttons style."
306
  msgstr ""
307
 
308
- #: ../cookie-notice.php:657
309
  msgid "Settings restored to defaults."
310
  msgstr ""
311
 
312
- #: ../cookie-notice.php:758
313
  msgid "Support"
314
  msgstr ""
315
 
316
- #: ../cookie-notice.php:777
317
  msgid "Settings"
318
  msgstr ""
319
 
320
- #: ../cookie-notice.php:811
321
  msgid "Are you sure you want to reset these settings to defaults?"
322
  msgstr ""
323
-
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: Cookie Notice\n"
5
+ "POT-Creation-Date: 2017-02-02 14:21+0100\n"
6
  "PO-Revision-Date: 2015-03-24 11:30+0100\n"
7
  "Last-Translator: Bartosz Arendt <info@dfactory.eu>\n"
8
  "Language-Team: dFactory <info@dfactory.eu>\n"
121
  msgstr ""
122
 
123
  #: ../cookie-notice.php:256
124
+ #, php-format
125
+ msgid "If you are having problems with this plugin, please browse it's <a href=\"%s\" target=\"_blank\">Documentation</a> or talk about them in the <a href=\"%s\" target=\"_blank\">Support forum</a>"
 
 
 
126
  msgstr ""
127
 
128
  #: ../cookie-notice.php:258
130
  msgstr ""
131
 
132
  #: ../cookie-notice.php:259
133
+ #, php-format
134
+ msgid "<a href=\"%s\" target=\"_blank\">Rate it 5</a> on WordPress.org"
 
 
 
 
 
 
 
135
  msgstr ""
136
 
137
  #: ../cookie-notice.php:260
138
+ #, php-format
139
+ msgid "Blog about it & link to the <a href=\"%s\" target=\"_blank\">plugin page</a>."
 
 
 
140
  msgstr ""
141
 
142
  #: ../cookie-notice.php:261
143
+ #, php-format
144
+ msgid "Check out our other <a href=\"%s\" target=\"_blank\">WordPress plugins</a>."
145
  msgstr ""
146
 
147
  #: ../cookie-notice.php:276
173
  msgstr ""
174
 
175
  #: ../cookie-notice.php:298
176
+ msgid "Script blocking"
177
  msgstr ""
178
 
179
  #: ../cookie-notice.php:299
180
+ msgid "On scroll"
181
  msgstr ""
182
 
183
  #: ../cookie-notice.php:300
184
+ msgid "Cookie expiry"
185
  msgstr ""
186
 
187
  #: ../cookie-notice.php:301
188
+ msgid "Script placement"
189
+ msgstr ""
190
+
191
+ #: ../cookie-notice.php:302
192
  msgid "Deactivation"
193
  msgstr ""
194
 
195
+ #: ../cookie-notice.php:305
196
  msgid "Design"
197
  msgstr ""
198
 
199
+ #: ../cookie-notice.php:306
200
  msgid "Position"
201
  msgstr ""
202
 
203
+ #: ../cookie-notice.php:307
204
  msgid "Animation"
205
  msgstr ""
206
 
207
+ #: ../cookie-notice.php:308
208
  msgid "Button style"
209
  msgstr ""
210
 
211
+ #: ../cookie-notice.php:309
212
  msgid "Colors"
213
  msgstr ""
214
 
215
+ #: ../cookie-notice.php:323
216
  msgid "Enable if you want all plugin data to be deleted on deactivation."
217
  msgstr ""
218
 
219
+ #: ../cookie-notice.php:333
220
  msgid "Enter the cookie notice message."
221
  msgstr ""
222
 
223
+ #: ../cookie-notice.php:344
224
  msgid "The text of the option to accept the usage of the cookies and make the notification disappear."
225
  msgstr ""
226
 
227
+ #: ../cookie-notice.php:354
228
  msgid "Give to the user the possibility to refuse third party non functional cookies."
229
  msgstr ""
230
 
231
+ #: ../cookie-notice.php:359
232
+ msgid "The text of the option to refuse the usage of the cookies."
233
  msgstr ""
234
 
235
+ #: ../cookie-notice.php:373
236
+ msgid "Enter non functional cookies Javascript code here (for e.g. Google Analitycs) to be used after cookies are accepted."
237
  msgstr ""
238
 
239
+ #: ../cookie-notice.php:373
240
+ msgid "To get the cookie notice status use <code>cn_cookies_accepted()</code> function."
241
+ msgstr ""
242
+
243
+ #: ../cookie-notice.php:396
244
  msgid "Enable Read more link."
245
  msgstr ""
246
 
247
+ #: ../cookie-notice.php:397
248
  #, php-format
249
  msgid "Need a Cookie Policy? Generate one with <a href=\"%s\" target=\"_blank\" title=\"iubenda\">iubenda</a>"
250
  msgstr ""
251
 
252
+ #: ../cookie-notice.php:403
253
  msgid "The text of the more info button."
254
  msgstr ""
255
 
256
+ #: ../cookie-notice.php:417
257
  msgid "Select where to redirect user for more information about cookies."
258
  msgstr ""
259
 
260
+ #: ../cookie-notice.php:420
261
  msgid "-- select page --"
262
  msgstr ""
263
 
264
+ #: ../cookie-notice.php:431
265
  msgid "Select from one of your site's pages"
266
  msgstr ""
267
 
268
+ #: ../cookie-notice.php:435
269
  msgid "Enter the full URL starting with http://"
270
  msgstr ""
271
 
272
+ #: ../cookie-notice.php:455
273
  msgid "Select the link target for more info page."
274
  msgstr ""
275
 
276
+ #: ../cookie-notice.php:475
277
  msgid "The ammount of time that cookie should be stored for."
278
  msgstr ""
279
 
280
+ #: ../cookie-notice.php:489
281
  msgid "Select where all the plugin scripts should be placed."
282
  msgstr ""
283
 
284
+ #: ../cookie-notice.php:507
285
  msgid "Select location for your cookie notice."
286
  msgstr ""
287
 
288
+ #: ../cookie-notice.php:526
289
  msgid "Cookie notice acceptance animation."
290
  msgstr ""
291
 
292
+ #: ../cookie-notice.php:536
293
  msgid "Enable cookie notice acceptance when users scroll."
294
  msgstr ""
295
 
296
+ #: ../cookie-notice.php:540
297
  msgid "Number of pixels user has to scroll to accept the usage of the cookies and make the notification disappear."
298
  msgstr ""
299
 
300
+ #: ../cookie-notice.php:560
301
  msgid "Choose buttons style."
302
  msgstr ""
303
 
304
+ #: ../cookie-notice.php:665
305
  msgid "Settings restored to defaults."
306
  msgstr ""
307
 
308
+ #: ../cookie-notice.php:766
309
  msgid "Support"
310
  msgstr ""
311
 
312
+ #: ../cookie-notice.php:785
313
  msgid "Settings"
314
  msgstr ""
315
 
316
+ #: ../cookie-notice.php:819
317
  msgid "Are you sure you want to reset these settings to defaults?"
318
  msgstr ""
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dfactory
3
  Donate link: http://www.dfactory.eu/
4
  Tags: cookie, cookies, notice, notification, notify, cookie, cookie compliance, cookie law, eu cookie, privacy, privacy directive, consent, Bootstrap
5
  Requires at least: 3.3
6
- Tested up to: 4.7
7
- Stable tag: 1.2.37
8
  License: MIT License
9
  License URI: http://opensource.org/licenses/MIT
10
 
@@ -60,6 +60,12 @@ No questions yet.
60
 
61
  == Changelog ==
62
 
 
 
 
 
 
 
63
  = 1.2.37 =
64
  * Tweak: Add aria landmark role="banner"
65
  * Tweak: Extend cn_cookie_notice_args with button class
@@ -215,6 +221,6 @@ Initial release
215
 
216
  == Upgrade Notice ==
217
 
218
- = 1.2.37 =
219
- * Tweak: Add aria landmark role="banner"
220
- * Tweak: Extend cn_cookie_notice_args with button class
3
  Donate link: http://www.dfactory.eu/
4
  Tags: cookie, cookies, notice, notification, notify, cookie, cookie compliance, cookie law, eu cookie, privacy, privacy directive, consent, Bootstrap
5
  Requires at least: 3.3
6
+ Tested up to: 4.7.2
7
+ Stable tag: 1.2.38
8
  License: MIT License
9
  License URI: http://opensource.org/licenses/MIT
10
 
60
 
61
  == Changelog ==
62
 
63
+ = 1.2.38 =
64
+ * Tweak: Move frontend cookie js functions before the document ready call, thanks to [fgreinus](https://github.com/fgreinus)
65
+ * Tweak: Adjust functional javascript code handling
66
+ * Fix: Chhromium infinity expiration date not valid
67
+ * Fix: Remove deprecated screen_icon() function
68
+
69
  = 1.2.37 =
70
  * Tweak: Add aria landmark role="banner"
71
  * Tweak: Extend cn_cookie_notice_args with button class
221
 
222
  == Upgrade Notice ==
223
 
224
+ = 1.2.38 =
225
+ * Tweak: Move frontend cookie js functions before the document ready call
226
+ * Tweak: Adjust functional javascript code handling