GDPR Cookie Compliance - Version 4.1.0

Version Description

Download this release

Release Info

Developer MooveAgency
Plugin Icon 128x128 GDPR Cookie Compliance
Version 4.1.0
Comparing to
See all releases

Code changes from version 4.0.3 to 4.1.0

class-moove-gdpr-actions.php CHANGED
@@ -48,6 +48,8 @@ class Moove_GDPR_Actions {
48
  $gdpr_default_content = new Moove_GDPR_Content();
49
  $option_key = $gdpr_default_content->moove_gdpr_get_key_name();
50
  $gdpr_key = function_exists( 'get_site_option' ) ? get_site_option( $option_key ) : get_option( $option_key );
 
 
51
  if ( $gdpr_key && ! isset( $gdpr_key['deactivation'] ) ) :
52
  do_action( 'gdpr_plugin_loaded' );
53
  endif;
@@ -69,6 +71,19 @@ class Moove_GDPR_Actions {
69
 
70
  }
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  /**
73
  * Using custom database instead default WordPress options
74
  * @param array $option_data Option data.
48
  $gdpr_default_content = new Moove_GDPR_Content();
49
  $option_key = $gdpr_default_content->moove_gdpr_get_key_name();
50
  $gdpr_key = function_exists( 'get_site_option' ) ? get_site_option( $option_key ) : get_option( $option_key );
51
+
52
+ add_action( 'admin_enqueue_scripts', array( &$this, 'gdpr_thirdparty_admin_scripts' ) );
53
  if ( $gdpr_key && ! isset( $gdpr_key['deactivation'] ) ) :
54
  do_action( 'gdpr_plugin_loaded' );
55
  endif;
71
 
72
  }
73
 
74
+ /**
75
+ * Enqueue a script in the WordPress admin, excluding GDPR Settings page.
76
+ *
77
+ * @param int $hook Hook suffix for the current admin page.
78
+ */
79
+ function gdpr_thirdparty_admin_scripts( $hook ) {
80
+ if ( 'toplevel_page_moove-gdpr' !== $hook ) :
81
+ return;
82
+ endif;
83
+ wp_enqueue_script( 'gdpr_colorpicker_script', esc_url( moove_gdpr_get_plugin_directory_url() ) . 'dist/scripts/colorpicker.js', array(), MOOVE_GDPR_VERSION );
84
+ wp_enqueue_script( 'gdpr_codemirror_script', esc_url( moove_gdpr_get_plugin_directory_url() ) . 'dist/scripts/codemirror.js', array(), MOOVE_GDPR_VERSION );
85
+ }
86
+
87
  /**
88
  * Using custom database instead default WordPress options
89
  * @param array $option_data Option data.
controllers/class-moove-gdpr-updater.php DELETED
@@ -1,287 +0,0 @@
1
- <?php
2
- /**
3
- * Moove_GDPR_Updater File Doc Comment
4
- *
5
- * @category Moove_GDPR_Updater
6
- * @package gdpr-cookie-compliance
7
- * @author Gaspar Nemes
8
- */
9
-
10
- if ( ! defined( 'ABSPATH' ) ) {
11
- exit;
12
- } // Exit if accessed directly
13
-
14
- if ( ! class_exists( 'Moove_GDPR_Updater' ) ) {
15
- /**
16
- * Moove_GDPR_Updater Class Doc Comment
17
- *
18
- * @category Class
19
- * @package Moove_GDPR_Updater
20
- * @author Gaspar Nemes
21
- */
22
- class Moove_GDPR_Updater {
23
- /**
24
- * Update data
25
- *
26
- * @var array $update_data Update array
27
- */
28
- public $update_data = array();
29
-
30
- /**
31
- * Active plugins
32
- *
33
- * @var array $active_plugins Active plugins.
34
- */
35
- public $active_plugins = array();
36
-
37
- /**
38
- * Construct
39
- */
40
- public function __construct() {
41
- add_action( 'gdpr_plugin_updater_notice', array( &$this, 'gdpr_plugin_updater_notice' ) );
42
- global $pagenow;
43
- $allowed_pages = array( 'update-core.php', 'plugins.php' );
44
- $plugin_slug = false;
45
- $lm = new Moove_GDPR_License_Manager();
46
- $plugin_slug = $lm->get_add_on_plugin_slug();
47
- wp_verify_nonce( 'gdpr_nonce', 'gdpr_cookie_compliance_nonce' );
48
- if ( in_array( $pagenow, $allowed_pages ) ) :
49
- $this->gdpr_plugin_updater_notice();
50
- $this->gdpr_check_for_updates();
51
- elseif ( ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'moove-gdpr' === sanitize_text_field( wp_unslash( $_GET['page'] ) ) ) ) :
52
- $this->gdpr_check_for_updates();
53
- endif;
54
- add_filter( 'plugins_api', array( &$this, 'plugins_api' ), 10, 3 );
55
- add_filter( 'pre_set_site_transient_update_plugins', array( &$this, 'set_update_data' ) );
56
- add_filter( 'upgrader_source_selection', array( &$this, 'upgrader_source_selection' ), 10, 4 );
57
- if ( $plugin_slug ) :
58
- add_action( "in_plugin_update_message-{$plugin_slug}", array( &$this, 'gdpr_update_message_content' ), 10, 2 );
59
- endif;
60
- }
61
-
62
- /**
63
- * Update message
64
- *
65
- * @param array $plugin_data Plugin data.
66
- * @param object $response Response.
67
- */
68
- public function gdpr_update_message_content( $plugin_data, $response ) {
69
- if ( isset( $plugin_data['package'] ) && ! $plugin_data['package'] ) :
70
- $gdpr_default_content = new Moove_GDPR_Content();
71
- $option_key = $gdpr_default_content->moove_gdpr_get_key_name();
72
- $gdpr_key = function_exists( 'get_site_option' ) ? get_site_option( $option_key ) : get_option( $option_key );
73
- $license_key = isset( $gdpr_key['key'] ) ? sanitize_text_field( $gdpr_key['key'] ) : false;
74
- $renew_link = MOOVE_SHOP_URL . '?renew=' . $license_key;
75
- $license_manager = admin_url( 'admin.php' ) . '?page=moove-gdpr&amp;tab=licence';
76
- $purchase_link = 'https://www.mooveagency.com/wordpress-plugins/gdpr-cookie-compliance/';
77
- if ( $license_key && isset( $gdpr_key['activation'] ) ) :
78
- // Expired.
79
- echo ' Update is not available until you <a href="' . esc_url( $renew_link ) . '" target="_blank">renew your licence</a>. You can also update your licence key in the <a href="' . esc_url( $license_manager ) . '" target="_blank">Licence Manager</a>.';
80
- elseif ( $license_key && isset( $gdpr_key['deactivation'] ) ) :
81
- // Deactivated.
82
- echo ' Update is not available until you <a href="' . esc_url( $purchase_link ) . '" target="_blank">purchase a licence</a>. You can also update your licence key in the <a href="' . esc_url( $license_manager ) . '" target="_blank">Licence Manager</a>.';
83
- elseif ( ! $license_key ) :
84
- // No license key installed.
85
- echo ' Update is not available until you <a href="' . esc_url( $purchase_link ) . '" target="_blank">purchase a licence</a>. You can also update your licence key in the <a href="' . esc_url( $license_manager ) . '" target="_blank">Licence Manager</a>.';
86
- endif;
87
- endif;
88
- return array();
89
- }
90
-
91
- /**
92
- * Updater notice
93
- */
94
- public function gdpr_plugin_updater_notice() {
95
- update_option( 'gpdr_last_checked', strtotime( 'yesterday' ) );
96
- delete_site_transient( 'update_plugins' );
97
- }
98
-
99
- /**
100
- * Update checker
101
- */
102
- public function gdpr_check_for_updates() {
103
- $this->update_data = get_option( 'gdpr_update_data' );
104
- $active = get_option( 'active_plugins' );
105
- $last_checked = get_option( 'gpdr_last_checked' );
106
- $now = strtotime( 'now' );
107
- $check_interval = 6 * HOUR_IN_SECONDS;
108
-
109
- foreach ( $active as $slug ) :
110
- $this->active_plugins[ $slug ] = true;
111
- endforeach;
112
-
113
- // transient expiration.
114
- if ( ( $now - $last_checked ) > $check_interval ) :
115
- $this->update_data = $this->get_addon_updates();
116
- update_option( 'gdpr_update_data', $this->update_data );
117
- update_option( 'gpdr_last_checked', $now );
118
- $plugins = get_site_transient( 'update_plugins' );
119
- $lm = new Moove_GDPR_License_Manager();
120
- $plugin_slug = $lm->get_add_on_plugin_slug();
121
-
122
- $gdpr_default_content = new Moove_GDPR_Content();
123
- $option_key = $gdpr_default_content->moove_gdpr_get_key_name();
124
- $gdpr_key = function_exists( 'get_site_option' ) ? get_site_option( $option_key ) : get_option( $option_key );
125
- $license_key = sanitize_text_field( $gdpr_key['key'] );
126
- if ( $plugin_slug ) :
127
- if ( $license_key && ! isset( $gdpr_key['deactivation'] ) ) :
128
- if ( isset( $plugins->response[ $plugin_slug ] ) ) :
129
- $plugins->response[ $plugin_slug ]->new_version = $this->update_data[ $plugin_slug ]['new_version'];
130
- $plugins->response[ $plugin_slug ]->package = $this->update_data[ $plugin_slug ]['package'];
131
- set_site_transient( 'update_plugins', $plugins );
132
- endif;
133
- else :
134
- if ( isset( $plugins->response[ $plugin_slug ] ) ) :
135
- $plugins->response[ $plugin_slug ]->new_version = $this->update_data[ $plugin_slug ]['new_version'];
136
- $plugins->response[ $plugin_slug ]->package = '';
137
- set_site_transient( 'update_plugins', $plugins );
138
- endif;
139
- endif;
140
- endif;
141
- endif;
142
- }
143
-
144
-
145
- /**
146
- * Fetch the latest GitHub tags and build the plugin data array
147
- */
148
- public function get_addon_updates() {
149
- $plugin_data = array();
150
- $gdpr_default_content = new Moove_GDPR_Content();
151
- $option_key = $gdpr_default_content->moove_gdpr_get_key_name();
152
- $gdpr_key = function_exists( 'get_site_option' ) ? get_site_option( $option_key ) : get_option( $option_key );
153
- $license_key = sanitize_text_field( $gdpr_key['key'] );
154
- if ( $license_key ) :
155
-
156
- $plugins = function_exists( 'get_plugins' ) ? get_plugins() : array();
157
- foreach ( $plugins as $slug => $info ) :
158
- if ( isset( $info['TextDomain'] ) && 'gdpr-cookie-compliance-addon' === $info['TextDomain'] ) :
159
- $license_manager = new Moove_GDPR_License_Manager();
160
- $is_valid_license = $license_manager->get_premium_add_on( $license_key, 'update' );
161
- $temp = array(
162
- 'plugin' => $slug,
163
- 'slug' => trim( dirname( $slug ), '/' ),
164
- 'name' => $info['Name'],
165
- 'description' => $info['Description'],
166
- 'new_version' => false,
167
- 'package' => false,
168
- );
169
- if ( $is_valid_license && isset( $is_valid_license['valid'] ) ) :
170
-
171
- $plugin_token = isset( $is_valid_license['data'] ) && isset( $is_valid_license['data']['download_token'] ) && $is_valid_license['data']['download_token'] ? $is_valid_license['data']['download_token'] : false;
172
- $plugin_version = isset( $is_valid_license['data'] ) && isset( $is_valid_license['data']['version'] ) && $is_valid_license['data']['version'] ? $is_valid_license['data']['version'] : 0;
173
-
174
- $temp['new_version'] = $plugin_version;
175
- $temp['package'] = ! isset( $gdpr_key['deactivation'] ) ? $plugin_token : '';
176
-
177
- endif;
178
- $plugin_data[ $slug ] = $temp;
179
- endif;
180
- endforeach;
181
- endif;
182
- return $plugin_data;
183
- }
184
-
185
-
186
- /**
187
- * Get plugin info for the "View Details" popup
188
- *
189
- * @param bool $default Default.
190
- * @param string $action Action.
191
- * @param array $args Args.
192
- */
193
- public function plugins_api( $default = false, $action, $args ) {
194
- if ( 'plugin_information' === $action ) {
195
- $plugin_data = array();
196
- $this->update_data = get_option( 'uat_update_data' );
197
- if ( is_array( $this->update_data ) && ! empty( $this->update_data ) ) :
198
- foreach ( $this->update_data as $slug => $data ) :
199
- if ( $data['slug'] === $args->slug ) :
200
- if ( class_exists( 'Moove_GDPR_Controller' ) ) :
201
- $gdpr_controller = new Moove_GDPR_Controller();
202
- $plugin_details = $gdpr_controller->get_gdpr_plugin_details( 'gdpr-cookie-compliance' );
203
- unset( $plugin_details->sections['screenshot'] );
204
- unset( $plugin_details->sections['changelog'] );
205
- unset( $plugin_details->sections['installation'] );
206
- $plugin_details->name = $data['name'];
207
- $plugin_details->slug = $data['plugin'];
208
- $plugin_details->version = $data['new_version'];
209
- $plugin_details->last_updated = '';
210
- $plugin_details->banners = array(
211
- 'high' => 'https://ps.w.org/gdpr-cookie-compliance/assets/banner-772x250.png',
212
- );
213
- return (object) $plugin_details;
214
- endif;
215
- endif;
216
- endforeach;
217
- endif;
218
- }
219
- return $default;
220
- }
221
-
222
- /**
223
- * Set update data
224
- *
225
- * @param string $transient Transient key.
226
- */
227
- public function set_update_data( $transient ) {
228
- if ( empty( $transient->checked ) ) {
229
- return $transient;
230
- }
231
- foreach ( $this->update_data as $plugin => $info ) {
232
- if ( isset( $this->active_plugins[ $plugin ] ) ) {
233
- $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
234
- $version = $plugin_data['Version'];
235
-
236
- if ( version_compare( $version, $info['new_version'], '<' ) ) {
237
- $transient->response[ $plugin ] = (object) $info;
238
- }
239
- }
240
- }
241
- return $transient;
242
- }
243
-
244
- /**
245
- * Rename the plugin folder
246
- *
247
- * @param string $source Source.
248
- * @param string $remote_source Remote source.
249
- * @param object $upgrader Upgrader.
250
- * @param bool $hook_extra Hook extra.
251
- */
252
- public function upgrader_source_selection( $source, $remote_source, $upgrader, $hook_extra = null ) {
253
- global $wp_filesystem;
254
- $plugin = isset( $hook_extra['plugin'] ) ? $hook_extra['plugin'] : false;
255
- if ( isset( $this->update_data[ $plugin ] ) && $plugin ) :
256
- $lm = new Moove_GDPR_License_Manager();
257
- $plugin_slug = $lm->get_add_on_plugin_slug();
258
- $temp_slug = basename( trailingslashit( $source ) );
259
- $plugin_slug = explode( '/', $plugin_slug );
260
- $plugin_slug = isset( $plugin_slug[0] ) && $plugin_slug[0] ? $plugin_slug[0] : 'gdpr-cookie-compliance-addon';
261
-
262
- if ( $temp_slug !== $plugin_slug ) :
263
- $new_source = trailingslashit( $remote_source );
264
- $new_source = str_replace( $temp_slug, $plugin_slug, $new_source );
265
- $wp_filesystem->move( $source, $new_source );
266
- return trailingslashit( $new_source );
267
- endif;
268
- endif;
269
- return $source;
270
- }
271
-
272
- /**
273
- * Hide update notice
274
- */
275
- public function moove_hide_update_notice() {
276
- wp_verify_nonce( 'gdpr_nonce', 'gdpr_cookie_compliance_nonce' );
277
- $version = isset( $_POST['version'] ) ? sanitize_text_field( wp_unslash( $_POST['version'] ) ) : false;
278
- if ( $version ) :
279
- $current_user = wp_get_current_user();
280
- $user_id = isset( $current_user->ID ) ? $current_user->ID : false;
281
- update_option( 'gdpr_hide_update_notice_' . $user_id, $version );
282
- endif;
283
- }
284
-
285
- }
286
- new Moove_GDPR_Updater();
287
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
moove-gdpr.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: GDPR Cookie Compliance
5
  * Plugin URI: https://wordpress.org/plugins/gdpr-cookie-compliance/
6
  * Description: Our plugin is useful in preparing your site for the following data protection and privacy regulations: GDPR, PIPEDA, CCPA, AAP, LGPD and others.
7
- * Version: 4.0.3
8
  * Author: Moove Agency
9
  * Domain Path: /languages
10
  * Author URI: https://www.mooveagency.com
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
18
  exit;
19
  } // Exit if accessed directly
20
 
21
- define( 'MOOVE_GDPR_VERSION', '4.0.3' );
22
  if ( ! defined( 'MOOVE_SHOP_URL' ) ) :
23
  define( 'MOOVE_SHOP_URL', 'https://shop.mooveagency.com' );
24
  endif;
@@ -123,7 +123,6 @@ function gdpr_cookie_compliance_load_libs() {
123
  */
124
  include_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'class-moove-gdpr-controller.php';
125
  include_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'class-moove-gdpr-license-manager.php';
126
- include_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'class-moove-gdpr-updater.php';
127
 
128
  /**
129
  * Actions
4
  * Plugin Name: GDPR Cookie Compliance
5
  * Plugin URI: https://wordpress.org/plugins/gdpr-cookie-compliance/
6
  * Description: Our plugin is useful in preparing your site for the following data protection and privacy regulations: GDPR, PIPEDA, CCPA, AAP, LGPD and others.
7
+ * Version: 4.1.0
8
  * Author: Moove Agency
9
  * Domain Path: /languages
10
  * Author URI: https://www.mooveagency.com
18
  exit;
19
  } // Exit if accessed directly
20
 
21
+ define( 'MOOVE_GDPR_VERSION', '4.1.0' );
22
  if ( ! defined( 'MOOVE_SHOP_URL' ) ) :
23
  define( 'MOOVE_SHOP_URL', 'https://shop.mooveagency.com' );
24
  endif;
123
  */
124
  include_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'class-moove-gdpr-controller.php';
125
  include_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'class-moove-gdpr-license-manager.php';
 
126
 
127
  /**
128
  * Actions
readme.txt CHANGED
@@ -203,7 +203,11 @@ The Brazilian General Data Protection Law (“Lei Geral de Proteção de Dados
203
  32. GDPR Cookie Compliance - Admin - Language Specific Scripts [Premium]
204
 
205
  == Changelog ==
206
- = 4.0.3: December 25th, 2019
 
 
 
 
207
  * Fixed settings reset function
208
 
209
  = 4.0.2: December 16th, 2019
203
  32. GDPR Cookie Compliance - Admin - Language Specific Scripts [Premium]
204
 
205
  == Changelog ==
206
+ = 4.1.0: December 23th, 2019
207
+ * Plugin updater removed
208
+ * Improved admin enqueue scripts
209
+
210
+ = 4.0.3: December 23th, 2019
211
  * Fixed settings reset function
212
 
213
  = 4.0.2: December 16th, 2019
views/moove/admin/settings/advanced-cookies.php CHANGED
@@ -227,7 +227,6 @@ endif;
227
  <?php esc_html_e( 'Save changes', 'gdpr-cookie-compliance' ); ?>
228
  </button>
229
 
230
- <script type="text/javascript" src="<?php echo esc_url( moove_gdpr_get_plugin_directory_url() ); ?>/dist/scripts/codemirror.js"></script>
231
  <script type="text/javascript">
232
  window.onload = function() {
233
  jQuery('.gdpr-tab-section-cnt textarea.code').each(function(){
227
  <?php esc_html_e( 'Save changes', 'gdpr-cookie-compliance' ); ?>
228
  </button>
229
 
 
230
  <script type="text/javascript">
231
  window.onload = function() {
232
  jQuery('.gdpr-tab-section-cnt textarea.code').each(function(){
views/moove/admin/settings/help.php CHANGED
@@ -552,85 +552,84 @@
552
  </div>
553
  <!-- .gdpr-help-content-cnt -->
554
 
555
-
556
-
557
- <script type="text/javascript" src="<?php echo esc_url( moove_gdpr_get_plugin_directory_url() ); ?>/dist/scripts/codemirror.js"></script>
558
  <script type="text/javascript">
559
- if (typeof CodeMirror !== "undefined") {
560
- CodeMirror.defineExtension("autoFormatRange", function (from, to) {
561
- var cm = this;
562
- var outer = cm.getMode(), text = cm.getRange(from, to).split("\n");
563
- var state = CodeMirror.copyState(outer, cm.getTokenAt(from).state);
564
- var tabSize = cm.getOption("tabSize");
565
-
566
- var out = "", lines = 0, atSol = from.ch == 0;
567
- function newline() {
568
- out += "\n";
569
- atSol = true;
570
- ++lines;
571
- }
 
572
 
573
- for (var i = 0; i < text.length; ++i) {
574
- var stream = new CodeMirror.StringStream(text[i], tabSize);
575
- while (!stream.eol()) {
576
- var inner = CodeMirror.innerMode(outer, state);
577
- var style = outer.token(stream, state), cur = stream.current();
578
- stream.start = stream.pos;
579
- if (!atSol || /\S/.test(cur)) {
580
- out += cur;
581
- atSol = false;
 
 
 
 
582
  }
583
- if (!atSol && inner.mode.newlineAfterToken &&
584
- inner.mode.newlineAfterToken(style, cur, stream.string.slice(stream.pos) || text[i+1] || "", inner.state))
585
- newline();
586
  }
587
- if (!stream.pos && outer.blankLine) outer.blankLine(state);
588
- if (!atSol) newline();
589
- }
590
 
591
- cm.operation(function () {
592
- cm.replaceRange(out, from, to);
593
- for (var cur = from.line + 1, end = from.line + lines; cur <= end; ++cur)
594
- cm.indentLine(cur, "smart");
595
- });
596
- });
597
-
598
- // Applies automatic mode-aware indentation to the specified range
599
- CodeMirror.defineExtension("autoIndentRange", function (from, to) {
600
- var cmInstance = this;
601
- this.operation(function () {
602
- for (var i = from.line; i <= to.line; i++) {
603
- cmInstance.indentLine(i, "smart");
604
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
605
  });
606
- });
607
- function GDPR_CodeMirror() {
608
- jQuery('.gdpr-faq-accordion-content textarea').each(function(){
609
- var element = jQuery(this).closest('.gdpr-faq-accordion-content').find('.gdpr-code')[0];
610
- var id = jQuery(this).attr('id');
611
- console.log(element);
612
- jQuery(this).css({
613
- 'opacity' : '0',
614
- 'height' : '0',
615
- });
616
- var editor = CodeMirror( element, {
617
- mode: "javascript",
618
- lineWrapping: true,
619
- lineNumbers: false,
620
- readOnly: true,
621
- value: document.getElementById(id).value
622
- });
623
- var totalLines = editor.lineCount();
624
- editor.autoFormatRange({line:0, ch:0}, {line:totalLines});
625
- });
626
  }
627
- jQuery(document).ready(function(){
628
- GDPR_CodeMirror();
629
-
630
- jQuery('.gdpr-faq-toggle:not(.gdpr-faq-open)').find('.gdpr-faq-accordion-content').hide();
631
- jQuery('.gdpr-help-content-block:not(.help-block-open)').hide();
632
- });
633
- }
634
  </script>
635
  <style>
636
  .CodeMirror {
552
  </div>
553
  <!-- .gdpr-help-content-cnt -->
554
 
 
 
 
555
  <script type="text/javascript">
556
+ window.onload = function() {
557
+ if (typeof CodeMirror !== "undefined") {
558
+ CodeMirror.defineExtension("autoFormatRange", function (from, to) {
559
+ var cm = this;
560
+ var outer = cm.getMode(), text = cm.getRange(from, to).split("\n");
561
+ var state = CodeMirror.copyState(outer, cm.getTokenAt(from).state);
562
+ var tabSize = cm.getOption("tabSize");
563
+
564
+ var out = "", lines = 0, atSol = from.ch == 0;
565
+ function newline() {
566
+ out += "\n";
567
+ atSol = true;
568
+ ++lines;
569
+ }
570
 
571
+ for (var i = 0; i < text.length; ++i) {
572
+ var stream = new CodeMirror.StringStream(text[i], tabSize);
573
+ while (!stream.eol()) {
574
+ var inner = CodeMirror.innerMode(outer, state);
575
+ var style = outer.token(stream, state), cur = stream.current();
576
+ stream.start = stream.pos;
577
+ if (!atSol || /\S/.test(cur)) {
578
+ out += cur;
579
+ atSol = false;
580
+ }
581
+ if (!atSol && inner.mode.newlineAfterToken &&
582
+ inner.mode.newlineAfterToken(style, cur, stream.string.slice(stream.pos) || text[i+1] || "", inner.state))
583
+ newline();
584
  }
585
+ if (!stream.pos && outer.blankLine) outer.blankLine(state);
586
+ if (!atSol) newline();
 
587
  }
 
 
 
588
 
589
+ cm.operation(function () {
590
+ cm.replaceRange(out, from, to);
591
+ for (var cur = from.line + 1, end = from.line + lines; cur <= end; ++cur)
592
+ cm.indentLine(cur, "smart");
593
+ });
594
+ });
595
+
596
+ // Applies automatic mode-aware indentation to the specified range
597
+ CodeMirror.defineExtension("autoIndentRange", function (from, to) {
598
+ var cmInstance = this;
599
+ this.operation(function () {
600
+ for (var i = from.line; i <= to.line; i++) {
601
+ cmInstance.indentLine(i, "smart");
602
+ }
603
+ });
604
+ });
605
+ function GDPR_CodeMirror() {
606
+ jQuery('.gdpr-faq-accordion-content textarea').each(function(){
607
+ var element = jQuery(this).closest('.gdpr-faq-accordion-content').find('.gdpr-code')[0];
608
+ var id = jQuery(this).attr('id');
609
+
610
+ jQuery(this).css({
611
+ 'opacity' : '0',
612
+ 'height' : '0',
613
+ });
614
+ var editor = CodeMirror( element, {
615
+ mode: "javascript",
616
+ lineWrapping: true,
617
+ lineNumbers: false,
618
+ readOnly: true,
619
+ value: document.getElementById(id).value
620
+ });
621
+ var totalLines = editor.lineCount();
622
+ editor.autoFormatRange({line:0, ch:0}, {line:totalLines});
623
+ });
624
+ }
625
+ jQuery(document).ready(function(){
626
+ GDPR_CodeMirror();
627
+
628
+ jQuery('.gdpr-faq-toggle:not(.gdpr-faq-open)').find('.gdpr-faq-accordion-content').hide();
629
+ jQuery('.gdpr-help-content-block:not(.help-block-open)').hide();
630
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
631
  }
632
+ };
 
 
 
 
 
 
633
  </script>
634
  <style>
635
  .CodeMirror {
views/moove/admin/settings/settings-page.php CHANGED
@@ -19,7 +19,6 @@
19
  </h4>
20
  </div>
21
  <!-- .gdpr-header-section -->
22
- <script type="text/javascript" src="<?php echo esc_url( moove_gdpr_get_plugin_directory_url() ); ?>/dist/scripts/colorpicker.js"></script>
23
  <div class="wrap moove-clearfix" id="moove_form_checker_wrap">
24
  <h1></h1>
25
  <div id="moove-gdpr-setting-error-settings_updated" class="updated settings-error notice is-dismissible" style="display:none;">
19
  </h4>
20
  </div>
21
  <!-- .gdpr-header-section -->
 
22
  <div class="wrap moove-clearfix" id="moove_form_checker_wrap">
23
  <h1></h1>
24
  <div id="moove-gdpr-setting-error-settings_updated" class="updated settings-error notice is-dismissible" style="display:none;">
views/moove/admin/settings/third-party-cookies.php CHANGED
@@ -252,7 +252,6 @@ $nav_label = isset( $gdpr_options[ 'moove_gdpr_performance_cookies_tab_title' .
252
  <button type="submit" class="button button-primary">
253
  <?php esc_html_e( 'Save changes', 'gdpr-cookie-compliance' ); ?>
254
  </button>
255
- <script type="text/javascript" src="<?php echo esc_url( moove_gdpr_get_plugin_directory_url() ); ?>/dist/scripts/codemirror.js"></script>
256
  <script type="text/javascript">
257
  window.onload = function() {
258
  jQuery('.gdpr-tab-section-cnt textarea.code').each(function(){
252
  <button type="submit" class="button button-primary">
253
  <?php esc_html_e( 'Save changes', 'gdpr-cookie-compliance' ); ?>
254
  </button>
 
255
  <script type="text/javascript">
256
  window.onload = function() {
257
  jQuery('.gdpr-tab-section-cnt textarea.code').each(function(){