Clearfy – WordPress optimization plugin and disable ultimate tweaker - Version 1.5.0

Version Description

  • Fixed: Bug when disabling embeds, in Wordpress 5.0 did not work editor gutenberg
Download this release

Release Info

Developer webcraftic
Plugin Icon 128x128 Clearfy – WordPress optimization plugin and disable ultimate tweaker
Version 1.5.0
Comparing to
See all releases

Code changes from version 1.4.6 to 1.5.0

Files changed (80) hide show
  1. admin/ajax/check-license.php +68 -65
  2. admin/ajax/index.php +2 -0
  3. admin/ajax/install-addons.php +127 -135
  4. admin/assets/css/general.css +28 -0
  5. admin/assets/css/index.php +2 -0
  6. admin/assets/css/install-addons.css +31 -31
  7. admin/assets/css/install-addons.less +0 -1
  8. admin/assets/img/index.php +2 -0
  9. admin/assets/index.php +2 -0
  10. admin/assets/js/index.php +2 -0
  11. admin/boot.php +323 -342
  12. admin/includes/index.php +2 -0
  13. admin/includes/sidebar-widgets.php +81 -0
  14. admin/index.php +2 -0
  15. admin/pages/clearfy-settings.php +232 -242
  16. admin/pages/components.php +33 -32
  17. admin/pages/defence.php +197 -172
  18. admin/pages/index.php +2 -0
  19. admin/pages/license.php +243 -268
  20. admin/pages/performance.php +27 -0
  21. assets/css/admin-bar.css +47 -39
  22. assets/css/admin-bar.less +12 -0
  23. assets/css/index.php +2 -0
  24. assets/img/index.php +2 -0
  25. assets/index.php +2 -0
  26. assets/js/index.php +2 -0
  27. clearfy.php +81 -80
  28. components/assets-manager/admin/boot.php +218 -128
  29. components/assets-manager/includes/class.configurate-assets.php +1482 -1526
  30. components/comments-plus/admin/boot.php +0 -5
  31. components/cyrlitera/admin/assets/js/cyrlitera-for-acf.js +41 -0
  32. components/cyrlitera/includes/class.helpers.php +295 -2
  33. components/cyrlitera/includes/class.plugin.php +1 -1
  34. components/cyrlitera/includes/classes/class.configurate-cyrlitera.php +243 -205
  35. components/disable-admin-notices/includes/classes/class.configurate-notices.php +376 -389
  36. components/index.php +2 -0
  37. components/minify-and-combine/admin/pages/settings.php +419 -340
  38. components/updates-manager/admin/assets/css/general.css +155 -153
  39. components/updates-manager/admin/assets/css/general.css.map +1 -1
  40. components/updates-manager/admin/assets/css/plugins.css +32 -32
  41. components/updates-manager/admin/assets/css/themes.css +19 -19
  42. components/updates-manager/admin/assets/css/themes.css.map +1 -1
  43. components/updates-manager/admin/assets/css/themes.less +2 -2
  44. components/updates-manager/admin/assets/js/ajax-components.js +33 -7
  45. components/updates-manager/admin/boot.php +2 -2
  46. components/updates-manager/admin/includes/class.plugin-filters.php +5 -0
  47. components/updates-manager/admin/pages/plugins.php +30 -24
  48. components/updates-manager/admin/pages/themes.php +8 -6
  49. components/updates-manager/includes/classes/class.configurate-updates.php +6 -3
  50. components/updates-manager/languages/webcraftic-updates-manager-ru_RU.po +501 -501
  51. includes/boot.php +6 -0
  52. includes/class.plugin.php +376 -381
  53. includes/classes/class.configurate-performance.php +422 -449
  54. includes/classes/class.configurate-privacy.php +70 -58
  55. includes/classes/class.licensing.php +555 -586
  56. includes/classes/class.package.php +274 -292
  57. includes/classes/exceptions/class.license-exception.php +21 -0
  58. includes/classes/exceptions/index.php +2 -0
  59. includes/classes/index.php +2 -0
  60. includes/freemius/class.storage.php +173 -71
  61. includes/freemius/entities/class.wcl-fs-entity.php +142 -144
  62. includes/freemius/entities/class.wcl-fs-plugin-license.php +325 -289
  63. includes/freemius/entities/class.wcl-fs-scope-entity.php +26 -25
  64. includes/freemius/entities/class.wcl-fs-site.php +148 -237
  65. includes/freemius/entities/class.wcl-fs-user.php +78 -64
  66. includes/freemius/entities/index.php +2 -0
  67. includes/freemius/index.php +2 -0
  68. includes/freemius/sdk/Exceptions/index.php +2 -0
  69. includes/freemius/sdk/FreemiusBase.php +187 -195
  70. includes/freemius/sdk/FreemiusWordPress.php +605 -650
  71. includes/freemius/sdk/index.php +2 -0
  72. includes/index.php +2 -0
  73. index.php +2 -0
  74. languages/index.php +2 -0
  75. libs/index.php +2 -0
  76. readme.txt +22 -1
  77. templates/index.php +2 -0
  78. uninstall.php +67 -57
  79. updates/010409.php +31 -0
  80. updates/index.php +2 -0
admin/ajax/check-license.php CHANGED
@@ -1,87 +1,90 @@
1
  <?php
2
- /**
3
- * Ajax plugin check licensing
4
- * @author Webcraftic <wordpress.webraftic@gmail.com>
5
- * @copyright (c) 2017 Webraftic Ltd
6
- * @version 1.0
7
- */
8
-
9
- // Exit if accessed directly
10
- if( !defined('ABSPATH') ) {
11
- exit;
12
- }
13
-
14
- /**
15
- * Обработчик ajax запросов для проверки, активации, деактивации лицензионного ключа
16
- *
17
- * @since 1.4.0
18
- */
19
- function wbcr_clearfy_check_license()
20
- {
21
- check_admin_referer('license');
22
 
23
- $action = WCL_Plugin::app()->request->post('license_action', false, true);
24
- $license_key = WCL_Plugin::app()->request->post('licensekey', null);
25
-
26
- if( empty($action) || !in_array($action, array('activate', 'deactivate', 'sync', 'unsubscribe')) ) {
27
- wp_send_json_error(array('error_message' => __('Licensing action not passed or this action is prohibited!', 'clearfy')));
28
- die();
29
- }
30
 
31
- $licensing = WCL_Licensing::instance();
32
-
33
- $result = null;
34
- $success_message = '';
35
-
36
- switch( $action ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  case 'activate':
38
- if( empty($license_key) || strlen($license_key) > 32 ) {
39
- wp_send_json_error(array('error_message' => __('License key is empty or license key too long (license key is 32 characters long)', 'clearfy')));
40
  } else {
41
- $result = $licensing->activate($license_key);
42
- $success_message = __('Your license has been successfully activated', 'clearfy');
 
43
  }
44
  break;
45
  case 'deactivate':
46
- $result = $licensing->uninstall();
47
- $success_message = __('The license is deactivated', 'clearfy');
48
  break;
49
  case 'sync':
50
- $result = $licensing->sync();
51
- $success_message = __('The license has been updated', 'clearfy');
52
  break;
53
  case 'unsubscribe':
54
- $result = $licensing->unsubscribe();
55
- $success_message = __('Subscription success cancelled', 'clearfy');
56
  break;
57
  }
58
-
59
- if( is_wp_error($result) ) {
60
-
61
- /**
62
- * Экшен выполняет, когда проверка лицензии вернула ошибку
63
- * @param string $action
64
- * @param string $license_key
65
- * @since 1.4.0
66
- */
67
- add_action('wbcr/clearfy/check_license_error', $action, $license_key);
68
-
69
- wp_send_json_error(array('error_message' => $result->get_error_message()));
70
- die();
71
- }
72
-
73
  /**
74
- * Экшен выполняет, когда проверка лицензии успешно завершена
 
75
  * @param string $action
76
  * @param string $license_key
 
77
  * @since 1.4.0
78
  */
79
- add_action('wbcr/clearfy/check_license_success', $action, $license_key);
80
-
81
- wp_send_json_success(array('message' => $success_message));
82
-
83
- die();
84
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
- add_action('wp_ajax_wbcr-clearfy-check-license', 'wbcr_clearfy_check_license');
87
 
1
  <?php
2
+ /**
3
+ * Ajax plugin check licensing
4
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
5
+ * @copyright (c) 2017 Webraftic Ltd
6
+ * @version 1.0
7
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
 
 
 
13
 
14
+ /**
15
+ * Обработчик ajax запросов для проверки, активации, деактивации лицензионного ключа
16
+ *
17
+ * @since 1.4.0
18
+ */
19
+ function wbcr_clearfy_check_license() {
20
+
21
+ check_admin_referer( 'license' );
22
+
23
+ $action = WCL_Plugin::app()->request->post( 'license_action', false, true );
24
+ $license_key = WCL_Plugin::app()->request->post( 'licensekey', null );
25
+
26
+ if ( empty( $action ) || ! in_array( $action, array( 'activate', 'deactivate', 'sync', 'unsubscribe' ) ) ) {
27
+ wp_send_json_error( array( 'error_message' => __( 'Licensing action not passed or this action is prohibited!', 'clearfy' ) ) );
28
+ die();
29
+ }
30
+
31
+ $licensing = WCL_Licensing::instance();
32
+
33
+ $result = null;
34
+ $success_message = '';
35
+
36
+ try {
37
+ switch ( $action ) {
38
  case 'activate':
39
+ if ( empty( $license_key ) || strlen( $license_key ) > 32 ) {
40
+ wp_send_json_error( array( 'error_message' => __( 'License key is empty or license key too long (license key is 32 characters long)', 'clearfy' ) ) );
41
  } else {
42
+ $licensing->activate( $license_key );
43
+
44
+ $success_message = __( 'Your license has been successfully activated', 'clearfy' );
45
  }
46
  break;
47
  case 'deactivate':
48
+ $licensing->uninstall();
49
+ $success_message = __( 'The license is deactivated', 'clearfy' );
50
  break;
51
  case 'sync':
52
+ $licensing->sync();
53
+ $success_message = __( 'The license has been updated', 'clearfy' );
54
  break;
55
  case 'unsubscribe':
56
+ $licensing->unsubscribe();
57
+ $success_message = __( 'Subscription success cancelled', 'clearfy' );
58
  break;
59
  }
60
+ } catch( WCL\LicenseException $e ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  /**
62
+ * Экшен выполняет, когда проверка лицензии вернула ошибку
63
+ *
64
  * @param string $action
65
  * @param string $license_key
66
+ *
67
  * @since 1.4.0
68
  */
69
+ add_action( 'wbcr/clearfy/check_license_error', $action, $license_key );
70
+
71
+ wp_send_json_error( array( 'error_message' => $e->getMessage(), 'code' => $e->getCode() ) );
 
 
72
  }
73
+
74
+ /**
75
+ * Экшен выполняет, когда проверка лицензии успешно завершена
76
+ *
77
+ * @param string $action
78
+ * @param string $license_key
79
+ *
80
+ * @since 1.4.0
81
+ */
82
+ add_action( 'wbcr/clearfy/check_license_success', $action, $license_key );
83
+
84
+ wp_send_json_success( array( 'message' => $success_message ) );
85
+
86
+ die();
87
+ }
88
 
89
+ add_action( 'wp_ajax_wbcr-clearfy-check-license', 'wbcr_clearfy_check_license' );
90
 
admin/ajax/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
admin/ajax/install-addons.php CHANGED
@@ -1,151 +1,143 @@
1
  <?php
2
- /**
3
- * Ajax plugin configuration
4
- * @author Webcraftic <wordpress.webraftic@gmail.com>
5
- * @copyright (c) 2017 Webraftic Ltd
6
- * @version 1.0
7
- */
8
-
9
- // Exit if accessed directly
10
- if( !defined('ABSPATH') ) {
11
- exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  }
13
-
14
- /**
15
- * This action allows you to process Ajax requests to activate external components Clearfy
16
- */
17
- function wbcr_clearfy_update_component()
18
- {
19
- check_ajax_referer('updates');
20
-
21
- $slug = WCL_Plugin::app()->request->post('plugin', null, true);
22
- $action = WCL_Plugin::app()->request->post('plugin_action', null, true);
23
- $storage = WCL_Plugin::app()->request->post('storage', null, true);
24
-
25
- if( !WCL_Plugin::app()->currentUserCan() ) {
26
- wp_die(__('You don\'t have enough capability to edit this information.', 'clearfy'), __('Something went wrong.'), 403);
 
 
 
 
 
 
 
27
  }
28
-
29
- if( empty($slug) || empty($action) ) {
30
- wp_send_json_error(array('error_message' => __('Required attributes are not passed or empty.', 'clearfy')));
 
 
 
 
31
  }
32
- $success = false;
33
- $send_data = array();
34
-
35
- if( $storage == 'freemius' ) {
36
- $licensing = WCL_Licensing::instance();
37
- $result = false;
38
-
39
- switch( $action ) {
40
- /*case 'install':
41
- $result = $licensing->installAddon($slug);
42
- break;
43
- case 'delete':
44
- $result = $licensing->deleteAddon($slug);
45
- break;*/
46
- case 'deactivate':
47
- $result = $licensing->deactivateAddon($slug);
48
- break;
49
- case 'activate':
50
- $result = $licensing->activateAddon($slug);
51
- break;
52
- default:
53
- wp_send_json_error(array('error_message' => __('You are trying to perform an invalid action.', 'clearfy')));
54
- break;
55
- }
56
-
57
- if( is_wp_error($result) ) {
58
- wp_send_json_error(array('error_message' => $result->get_error_message()));
59
- } else {
60
  $success = true;
61
- $package_plugin = WCL_Package::instance();
62
- $send_data['update_notice'] = $package_plugin->getUpdateNotice();
63
  }
64
- } else if( $storage == 'internal' ) {
65
-
66
- if( $action == 'activate' ) {
67
- if( WCL_Plugin::app()->activateComponent($slug) ) {
68
- $success = true;
69
- }
70
- } else if( $action == 'deactivate' ) {
71
-
72
- if( WCL_Plugin::app()->deactivateComponent($slug) ) {
73
- $success = true;
74
- }
75
- } else {
76
- wp_send_json_error(array('error_message' => __('You are trying to perform an invalid action.', 'clearfy')));
77
- }
78
- } else if( $storage == 'wordpress' ) {
79
- if( !empty($slug) ) {
80
- $network_wide = WCL_Plugin::app()->isNetworkActive();
81
-
82
- if( $action == 'activate' ) {
83
- $result = activate_plugin($slug, '', $network_wide);
84
-
85
- if( is_wp_error($result) ) {
86
- wp_send_json_error(array('error_message' => $result->get_error_message()));
87
- }
88
- } elseif( $action == 'deactivate' ) {
89
- deactivate_plugins($slug, false, $network_wide);
90
- }
91
-
92
  $success = true;
93
  }
 
 
94
  }
95
-
96
- if( $action == 'install' || $action == 'deactivate' ) {
97
- try {
98
- // Delete button
99
- $delete_button = WCL_Plugin::app()->getDeleteComponentsButton($storage, $slug);
100
- $send_data['delete_button'] = $delete_button->getButton();
101
- } catch( Exception $e ) {
102
- wp_send_json_error(array('error_message' => $e->getMessage()));
103
- }
104
- }
105
-
106
- // Если требуется обновить постоянные ссылки, даем сигнал, что пользователю, нужно показать
107
- // всплывающее уведомление.
108
- // todo: сделать более красивое решение с передачей текстовых сообщений
109
- if( $action == 'deactivate' ) {
110
- $is_need_rewrite_rules = WCL_Plugin::app()->getPopulateOption('need_rewrite_rules');
111
- if( $is_need_rewrite_rules ) {
112
- $send_data['need_rewrite_rules'] = sprintf('<span class="wbcr-clr-need-rewrite-rules-message">'.__('When you deactivate some components, permanent links may work incorrectly. If this happens, please, <a href="%s">update the permalinks</a>, so you could complete the deactivation.', 'clearfy'), admin_url('options-permalink.php') .'</span>');
113
  }
 
 
114
  }
115
-
116
- if( $success ) {
117
- do_action('wbcr_clearfy_update_component', $slug, $action, $storage);
118
-
119
- wp_send_json_success($send_data);
120
- }
121
-
122
- wp_send_json_error(array('error_message' => __('An unknown error occurred during the activation of the component.', 'clearfy')));
123
  }
124
-
125
- add_action('wp_ajax_wbcr-clearfy-update-component', 'wbcr_clearfy_update_component');
126
-
127
- /**
128
- * Ajax event that calls the wbcr/clearfy/activated_component action,
129
- * to get the component to work. Usually this is a call to the installation functions,
130
- * but in some cases, overwriting permanent references or compatibility checks.
131
- */
132
- function wbcr_clearfy_prepare_component()
133
- {
134
- check_ajax_referer('updates');
135
-
136
- $component_name = WCL_Plugin::app()->request->post('plugin', null, true);
137
-
138
- if( !WCL_Plugin::app()->currentUserCan() ) {
139
- wp_send_json_error(array('error_message' => __('You don\'t have enough capability to edit this information.', 'clearfy')), 403);
140
  }
141
-
142
- if( empty($component_name) ) {
143
- wp_send_json_error(array('error_message' => __('Required attribute [component_name] is empty.', 'clearfy')));
 
 
 
 
 
 
144
  }
145
-
146
- do_action('wbcr/clearfy/activated_component', $component_name);
147
-
148
- wp_send_json_success();
149
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
- add_action('wp_ajax_wbcr-clearfy-prepare-component', 'wbcr_clearfy_prepare_component');
1
  <?php
2
+ /**
3
+ * Ajax plugin configuration
4
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
5
+ * @copyright (c) 2017 Webraftic Ltd
6
+ * @version 1.0
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ /**
15
+ * This action allows you to process Ajax requests to activate external components Clearfy
16
+ */
17
+ function wbcr_clearfy_update_component() {
18
+ check_ajax_referer( 'updates' );
19
+
20
+ $slug = WCL_Plugin::app()->request->post( 'plugin', null, true );
21
+ $action = WCL_Plugin::app()->request->post( 'plugin_action', null, true );
22
+ $storage = WCL_Plugin::app()->request->post( 'storage', null, true );
23
+
24
+ if ( ! WCL_Plugin::app()->currentUserCan() ) {
25
+ wp_die( __( 'You don\'t have enough capability to edit this information.', 'clearfy' ), __( 'Something went wrong.' ), 403 );
26
  }
27
+
28
+ if ( empty( $slug ) || empty( $action ) ) {
29
+ wp_send_json_error( array( 'error_message' => __( 'Required attributes are not passed or empty.', 'clearfy' ) ) );
30
+ }
31
+ $success = false;
32
+ $send_data = array();
33
+
34
+ if ( $storage == 'freemius' ) {
35
+ $licensing = WCL_Licensing::instance();
36
+ $result = false;
37
+
38
+ switch ( $action ) {
39
+ case 'deactivate':
40
+ $result = $licensing->deactivateAddon( $slug );
41
+ break;
42
+ case 'activate':
43
+ $result = $licensing->activateAddon( $slug );
44
+ break;
45
+ default:
46
+ wp_send_json_error( array( 'error_message' => __( 'You are trying to perform an invalid action.', 'clearfy' ) ) );
47
+ break;
48
  }
49
+
50
+ if ( is_wp_error( $result ) ) {
51
+ wp_send_json_error( array( 'error_message' => $result->get_error_message() ) );
52
+ } else {
53
+ $success = true;
54
+ $package_plugin = WCL_Package::instance();
55
+ $send_data['update_notice'] = $package_plugin->getUpdateNotice();
56
  }
57
+ } else if ( $storage == 'internal' ) {
58
+
59
+ if ( $action == 'activate' ) {
60
+ if ( WCL_Plugin::app()->activateComponent( $slug ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  $success = true;
 
 
62
  }
63
+ } else if ( $action == 'deactivate' ) {
64
+
65
+ if ( WCL_Plugin::app()->deactivateComponent( $slug ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  $success = true;
67
  }
68
+ } else {
69
+ wp_send_json_error( array( 'error_message' => __( 'You are trying to perform an invalid action.', 'clearfy' ) ) );
70
  }
71
+ } else if ( $storage == 'wordpress' ) {
72
+ if ( ! empty( $slug ) ) {
73
+ $network_wide = WCL_Plugin::app()->isNetworkActive();
74
+
75
+ if ( $action == 'activate' ) {
76
+ $result = activate_plugin( $slug, '', $network_wide );
77
+
78
+ if ( is_wp_error( $result ) ) {
79
+ wp_send_json_error( array( 'error_message' => $result->get_error_message() ) );
80
+ }
81
+ } else if ( $action == 'deactivate' ) {
82
+ deactivate_plugins( $slug, false, $network_wide );
 
 
 
 
 
 
83
  }
84
+
85
+ $success = true;
86
  }
 
 
 
 
 
 
 
 
87
  }
88
+
89
+ if ( $action == 'install' || $action == 'deactivate' ) {
90
+ try {
91
+ // Delete button
92
+ $delete_button = WCL_Plugin::app()->getDeleteComponentsButton( $storage, $slug );
93
+ $send_data['delete_button'] = $delete_button->getButton();
94
+ } catch( Exception $e ) {
95
+ wp_send_json_error( array( 'error_message' => $e->getMessage() ) );
 
 
 
 
 
 
 
 
96
  }
97
+ }
98
+
99
+ // Если требуется обновить постоянные ссылки, даем сигнал, что пользователю, нужно показать
100
+ // всплывающее уведомление.
101
+ // todo: сделать более красивое решение с передачей текстовых сообщений
102
+ if ( $action == 'deactivate' ) {
103
+ $is_need_rewrite_rules = WCL_Plugin::app()->getPopulateOption( 'need_rewrite_rules' );
104
+ if ( $is_need_rewrite_rules ) {
105
+ $send_data['need_rewrite_rules'] = sprintf( '<span class="wbcr-clr-need-rewrite-rules-message">' . __( 'When you deactivate some components, permanent links may work incorrectly. If this happens, please, <a href="%s">update the permalinks</a>, so you could complete the deactivation.', 'clearfy' ), admin_url( 'options-permalink.php' ) . '</span>' );
106
  }
 
 
 
 
107
  }
108
+
109
+ if ( $success ) {
110
+ do_action( 'wbcr_clearfy_update_component', $slug, $action, $storage );
111
+
112
+ wp_send_json_success( $send_data );
113
+ }
114
+
115
+ wp_send_json_error( array( 'error_message' => __( 'An unknown error occurred during the activation of the component.', 'clearfy' ) ) );
116
+ }
117
+
118
+ add_action( 'wp_ajax_wbcr-clearfy-update-component', 'wbcr_clearfy_update_component' );
119
+
120
+ /**
121
+ * Ajax event that calls the wbcr/clearfy/activated_component action,
122
+ * to get the component to work. Usually this is a call to the installation functions,
123
+ * but in some cases, overwriting permanent references or compatibility checks.
124
+ */
125
+ function wbcr_clearfy_prepare_component() {
126
+ check_ajax_referer( 'updates' );
127
+
128
+ $component_name = WCL_Plugin::app()->request->post( 'plugin', null, true );
129
+
130
+ if ( ! WCL_Plugin::app()->currentUserCan() ) {
131
+ wp_send_json_error( array( 'error_message' => __( 'You don\'t have enough capability to edit this information.', 'clearfy' ) ), 403 );
132
+ }
133
+
134
+ if ( empty( $component_name ) ) {
135
+ wp_send_json_error( array( 'error_message' => __( 'Required attribute [component_name] is empty.', 'clearfy' ) ) );
136
+ }
137
+
138
+ do_action( 'wbcr/clearfy/activated_component', $component_name );
139
+
140
+ wp_send_json_success();
141
+ }
142
 
143
+ add_action( 'wp_ajax_wbcr-clearfy-prepare-component', 'wbcr_clearfy_prepare_component' );
admin/assets/css/general.css CHANGED
@@ -95,6 +95,34 @@
95
  #WBCR .wbcr-factory-left-navigation-bar .wbcr-factory-active-tab #license-wbcr_clearfy-tab .dashicons-admin-network {
96
  color: #222;
97
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  #WBCR .wbcr-clearfy-group-header {
99
  background: #efefef;
100
  padding: 20px 0 10px 20px;
95
  #WBCR .wbcr-factory-left-navigation-bar .wbcr-factory-active-tab #license-wbcr_clearfy-tab .dashicons-admin-network {
96
  color: #222;
97
  }
98
+ #WBCR .wbcr-clearfy-danger-message {
99
+ position: relative;
100
+ padding: 15px;
101
+ background: #ffe0de;
102
+ color: #9c6e6e;
103
+ border-radius: 3px;
104
+ }
105
+ #WBCR .wbcr-clearfy-danger-message:after,
106
+ #WBCR .wbcr-clearfy-danger-message:before {
107
+ bottom: 100%;
108
+ left: 20px;
109
+ border: solid transparent;
110
+ content: " ";
111
+ height: 0;
112
+ width: 0;
113
+ position: absolute;
114
+ pointer-events: none;
115
+ }
116
+ #WBCR .wbcr-clearfy-danger-message:after {
117
+ border-color: rgba(136, 183, 213, 0);
118
+ border-bottom-color: #ffe0de;
119
+ border-width: 10px;
120
+ }
121
+ #WBCR .wbcr-clearfy-danger-message:before {
122
+ border-color: rgba(194, 225, 245, 0);
123
+ border-bottom-color: #ffe0de;
124
+ border-width: 10px;
125
+ }
126
  #WBCR .wbcr-clearfy-group-header {
127
  background: #efefef;
128
  padding: 20px 0 10px 20px;
admin/assets/css/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
admin/assets/css/install-addons.css CHANGED
@@ -1,31 +1,31 @@
1
- /**
2
- * Install addons global styles
3
- * @author Webcraftic <wordpress.webraftic@gmail.com>
4
- * @copyright Webcraftic 11.07.2018
5
- */
6
- .wbcr-clr-new-component {
7
- background: #f7f7f7;
8
- border: 1px solid #eaeaea;
9
- padding: 5px 20px;
10
- margin-bottom: 10px;
11
- }
12
- .wbcr-clr-new-component h4 {
13
- margin: 5px 0;
14
- display: inline-block;
15
- }
16
- .wbcr-clr-new-component .wbcr-clr-proccess-button {
17
- display: inline-block;
18
- margin: 5px 0;
19
- }
20
- .wbcr-clr-new-component.wbcr-clr-premium {
21
- background: #fff6db;
22
- border: 1px solid #e4dea9;
23
- }
24
- .wbcr-clr-new-component.wbcr-clr-premium h4 {
25
- color: #88690c;
26
- }
27
- .wbcr-clr-proccess-button.button-link,
28
- .wbcr-clr-proccess-button.button-link:focus {
29
- outline: none !important;
30
- box-shadow: none !important;
31
- }
1
+ /**
2
+ * Install addons global styles
3
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
4
+ * @copyright Webcraftic 11.07.2018
5
+ */
6
+ .wbcr-clr-new-component {
7
+ background: #f7f7f7;
8
+ border: 1px solid #eaeaea;
9
+ padding: 5px 20px;
10
+ margin-bottom: 10px;
11
+ }
12
+ .wbcr-clr-new-component h4 {
13
+ margin: 5px 0;
14
+ display: inline-block;
15
+ }
16
+ .wbcr-clr-new-component .wbcr-clr-proccess-button {
17
+ display: inline-block;
18
+ margin: 5px 0;
19
+ }
20
+ .wbcr-clr-new-component.wbcr-clr-premium {
21
+ background: #fff6db;
22
+ border: 1px solid #e4dea9;
23
+ }
24
+ .wbcr-clr-new-component.wbcr-clr-premium h4 {
25
+ color: #88690c;
26
+ }
27
+ .wbcr-clr-proccess-button.button-link,
28
+ .wbcr-clr-proccess-button.button-link:focus {
29
+ outline: none !important;
30
+ box-shadow: none !important;
31
+ }
admin/assets/css/install-addons.less CHANGED
@@ -3,7 +3,6 @@
3
  * @author Webcraftic <wordpress.webraftic@gmail.com>
4
  * @copyright Webcraftic 11.07.2018
5
  */
6
-
7
  .wbcr-clr-new-component {
8
  background: #f7f7f7;
9
  border: 1px solid #eaeaea;
3
  * @author Webcraftic <wordpress.webraftic@gmail.com>
4
  * @copyright Webcraftic 11.07.2018
5
  */
 
6
  .wbcr-clr-new-component {
7
  background: #f7f7f7;
8
  border: 1px solid #eaeaea;
admin/assets/img/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
admin/assets/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
admin/assets/js/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
admin/boot.php CHANGED
@@ -1,365 +1,346 @@
1
  <?php
2
- /**
3
- * Admin boot
4
- * @author Webcraftic <alex.kovalevv@gmail.com>
5
- * @copyright Webcraftic 25.05.2017
6
- * @version 1.0
7
- */
8
-
9
- // Exit if accessed directly
10
- if( !defined('ABSPATH') ) {
11
- exit;
 
 
 
 
 
 
 
 
12
  }
13
-
14
- /**
15
- * Выводит кнопку настроек Clearfy в шапке интерфейса плагина
16
- */
17
- add_action('wbcr/factory/pages/impressive/header', function ($plugin_name) {
18
- if( $plugin_name != WCL_Plugin::app()->getPluginName() ) {
19
- return;
20
- }
21
- ?>
22
- <a href="<?= WCL_Plugin::app()->getPluginPageUrl('clearfy_settings') ?>" class="wbcr-factory-button wbcr-factory-type-settings">
23
- <?= apply_filters('wbcr/clearfy/settings_button_title', __('Clearfy settings', 'clearfy')); ?>
24
- </a>
25
  <?php
26
- });
27
-
28
- /**
29
- * Этот код обманывает Wordpress, убеждая его, что плагин имеет новую версию,
30
- * из-за чего Wordpress создает уведомление об обновлении плагина. Все это необходимо
31
- * для обновления пакета компонентов
32
- * @param mixed $transient - value of site transient.
33
- */
34
- add_filter('site_transient_update_plugins', function ($transient) {
35
- if( empty($transient->checked) ) {
36
- return $transient;
37
- }
38
-
39
- $package_plugin = WCL_Package::instance();
40
-
41
- if( !$package_plugin->isActive() ) {
42
- return $transient;
43
- }
44
-
45
- $need_update_package = $package_plugin->isNeedUpdate();
46
- $need_update_addons = $package_plugin->isNeedUpdateAddons();
47
- $info = $package_plugin->info();
48
-
49
- if( $need_update_package and $need_update_addons ) {
50
- $update_data = new stdClass();
51
- $update_data->slug = $info['plugin_slug'];
52
- $update_data->plugin = $info['plugin_basename'];
53
- $update_data->new_version = '1.1';
54
- $update_data->package = $package_plugin->downloadUrl();
55
- $transient->response[$update_data->plugin] = $update_data;
56
- }
57
-
58
  return $transient;
59
- });
60
-
61
- /**
62
- * Выводит уведомление внутри интерфейса Clearfy, на всех страницах плагина.
63
- * Это необходимо, чтоб напомнить пользователю обновить конфигурацию компонентов плагина,
64
- * иначе вновь активированные компоненты не будет зайдествованы в работе плагина.
65
- *
66
- * @param Wbcr_Factory409_Plugin $plugin
67
- * @param Wbcr_FactoryPages410_ImpressiveThemplate $obj
68
- * @return bool
69
- */
70
- add_action('wbcr/factory/pages/impressive/print_all_notices', function ($plugin, $obj) {
71
- // выводим уведомление везде, кроме страницы компонентов. Там выводится отдельно.
72
- if( (WCL_Plugin::app()->getPluginName() != $plugin->getPluginName()) || ($obj->id == 'components') ) {
73
- return false;
74
- }
75
- $package_plugin = WCL_Package::instance();
76
- $package_update_notice = $package_plugin->getUpdateNotice();
77
-
78
- if( $package_update_notice ) {
79
- $obj->printWarningNotice($package_update_notice);
80
- }
81
- }, 10, 2);
82
-
83
- /**
84
- * Выводит уведомление в строке плагина Clearfy (на странице плагинов),
85
- * что нужно обновить пакет компонентов.
86
- *
87
- * @see WP_Plugins_List_Table
88
- * @param string $plugin_file
89
- * @param array $plugin_data
90
- * @param string $status
91
- * @return bool
92
- */
93
- add_action('after_plugin_row_clearfy/clearfy.php', function ($plugin_file, $plugin_data, $status) {
94
- $package_plugin = WCL_Package::instance();
95
- $need_update_package = $package_plugin->isNeedUpdate();
96
-
97
- if( $need_update_package ) {
98
- if( $package_plugin->isNeedUpdateAddons() ) {
99
- $update_link = ' <a href="#" data-wpnonce="' . wp_create_nonce('package') . '" data-loading="' . __('Update in progress...', 'clearfy') . '" data-ok="' . __('Components have been successfully updated!', 'clearfy') . '" class="wbcr-clr-plugin-update-link">' . __('update now', 'clearfy') . '</a>';
100
- ?>
101
- <tr class="plugin-update-tr active update">
102
- <td colspan="3" class="plugin-update colspanchange">
103
- <div class="update-message notice inline notice-warning notice-alt" style="background-color:#f5e9f5;border-color: #dab9da;">
104
- <p><?= __('Updates are available for one of the components.', 'clearfy') . $update_link; ?></p>
105
- </div>
106
- </td>
107
- </tr>
108
- <?php
109
- }
110
- }
111
- }, 100, 3);
112
-
113
- /**
114
- * @param $form
115
- * @param Wbcr_Factory409_Plugin $plugin
116
- * @param Wbcr_FactoryPages410_ImpressiveThemplate $obj
117
- */
118
- function wbcr_clearfy_multisite_before_save($form, $plugin, $obj)
119
- {
120
-
121
- if( $plugin->isNetworkActive() ) {
122
- $licensing = WCL_Licensing::instance();
123
- if( !$licensing->isLicenseValid() && WCL_Plugin::app()->isNetworkActive() && $plugin->getPluginName() == WCL_Plugin::app()->getPluginName() ) {
124
- $obj->redirectToAction('multisite-pro');
125
- }
126
- }
127
  }
128
-
129
- add_action('wbcr_factory_409_imppage_before_form_save', 'wbcr_clearfy_multisite_before_save', 10, 3);
130
-
131
- /**
132
- * Устанавливает логотип Webcraftic и сборку плагина для Clearfy и всех его компонентов
133
- *
134
- * @param string $title
135
- * @since 1.4.0
136
- */
137
- function wbcr_clearfy_branding($title)
138
- {
139
- $licensing = WCL_Licensing::instance();
140
-
141
- return 'Webcraftic Clearfy ' . ($licensing->isLicenseValid() ? '<span class="wbcr-clr-logo-label wbcr-clr-premium-label-logo">' . __('Business', 'clearfy') . '</span>' : '<span class="wbcr-clr-logo-label wbcr-clr-free-label-logo">Free</span>') . ' ver';
142
  }
143
-
144
- add_action('wbcr/factory/pages/impressive/plugin_title', 'wbcr_clearfy_branding');
145
-
146
- /**
147
- * Подключаем скрипты отвественные за обновления пакетов для Clearfy
148
- * Скрипты подключа.тся на каждой странице Clearfy и его компонентов
149
- *
150
- * @param string $page_id
151
- * @param Wbcr_Factory409_ScriptList $scripts
152
- * @param Wbcr_Factory409_StyleList $styles
153
- * @since 1.4.0
154
- */
155
- function wbcr_clearfy_enqueue_global_scripts($page_id, $scripts, $styles)
156
- {
157
- $scripts->add(WCL_PLUGIN_URL . '/admin/assets/js/update-package.js', array(
158
- 'jquery',
159
- 'wbcr-factory-clearfy-206-global'
160
- ));
161
  }
162
-
163
- add_action('wbcr/clearfy/page_assets', 'wbcr_clearfy_enqueue_global_scripts', 10, 3);
164
-
165
- /**
166
- * Подключаем скрипты для установки компонентов Clearfy
167
- * на все страницы админпанели
168
- */
169
- add_action('admin_enqueue_scripts', function () {
170
- wp_enqueue_style('wbcr-clearfy-install-components', WCL_PLUGIN_URL . '/admin/assets/css/install-addons.css', array(), WCL_Plugin::app()->getPluginVersion());
171
- wp_enqueue_script('wbcr-clearfy-install-components', WCL_PLUGIN_URL . '/admin/assets/js/install-addons.js', array(
172
- 'jquery',
173
- 'wbcr-factory-clearfy-206-global'
174
- ), WCL_Plugin::app()->getPluginVersion());
175
- });
176
-
177
- /**
178
- * Выводит уведомление, что нужно сбросить постоянные ссылки.
179
- * Уведомление будет показано на всех страницах Clearfy и его компонентах.
180
- *
181
- * @param WCL_Plugin $plugin
182
- * @param Wbcr_FactoryPages410_ImpressiveThemplate $obj
183
- * @return bool
184
- */
185
- function wbcr_clearfy_print_notice_rewrite_rules($plugin, $obj)
186
- {
187
- if( WCL_Plugin::app()->getPopulateOption('need_rewrite_rules') ) {
188
- $obj->printWarningNotice(sprintf('<span class="wbcr-clr-need-rewrite-rules-message">' . __('When you deactivate some components, permanent links may work incorrectly. If this happens, please, <a href="%s">update the permalinks</a>, so you could complete the deactivation.', 'clearfy'), admin_url('options-permalink.php')) . '</span>');
189
- }
190
  }
191
-
192
- add_action('wbcr/factory/pages/impressive/print_all_notices', 'wbcr_clearfy_print_notice_rewrite_rules', 10, 2);
193
-
194
- /**
195
- * Удалем уведомление Clearfy о том, что нужно перезаписать постоянные ссылоки.s
196
- */
197
- function wbcr_clearfy_flush_rewrite_rules()
198
- {
199
- WCL_Plugin::app()->deletePopulateOption('need_rewrite_rules', 1);
200
  }
201
-
202
- add_action('flush_rewrite_rules_hard', 'wbcr_clearfy_flush_rewrite_rules');
203
-
204
- /**
205
- * Обновить постоынные ссылки, после выполнения быстрых настроек
206
- *
207
- * @param WHM_Plugin $plugin
208
- * @param Wbcr_FactoryPages410_ImpressiveThemplate $obj
209
- */
210
- function wbcr_clearfy_after_form_save($plugin, $obj)
211
- {
212
- if( !WCL_Plugin::app()->currentUserCan() ) {
213
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  }
215
- $is_clearfy = WCL_Plugin::app()->getPluginName() == $plugin->getPluginName();
216
-
217
- if( $is_clearfy && $obj->id == 'quick_start' && isset($_GET['action']) && $_GET['action'] == 'flush-cache-and-rules' ) {
218
- require_once ABSPATH . 'wp-admin/includes/file.php';
219
- require_once ABSPATH . 'wp-admin/includes/misc.php';
220
- flush_rewrite_rules(true);
 
 
 
 
 
 
 
 
221
  }
222
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
 
224
- add_action('wbcr_factory_409_imppage_after_form_save', 'wbcr_clearfy_after_form_save', 10, 2);
225
-
226
-
227
-
228
- /**
229
- * Fake stubs for the Clearfy plugin board
230
- */
231
- function wbcr_clearfy_fake_boards()
232
- {
233
- if( !defined('WIO_PLUGIN_ACTIVE') ) {
234
- ?>
235
-
236
- <div class="wio-image-optimize-board wbcr-clearfy-board">
237
- <h4 class="wio-text-left"><?php _e('Images optimization', 'clearfy'); ?></h4>
238
-
239
- <div class="wio-columns wio-widget">
240
- <div class="wio-col col-chart">
241
- <div class="wio-chart-container wio-overview-chart-container">
242
- <canvas id="wio-main-chart" width="110" height="110" data-unoptimized="1400" data-optimized="0" data-errors="0" style="display: block;"></canvas>
243
- <div id="wio-overview-chart-percent" class="wio-chart-percent">0<span>%</span></div>
244
- </div>
245
- <div id="wio-overview-chart-legend">
246
- <ul class="wio-doughnut-legend">
247
- <li>
248
- <span style="background-color:#d6d6d6"></span><?php _e('Unoptimized', 'clearfy'); ?>
249
- -
250
- <span class="wio-num" id="wio-unoptimized-num">1400</span>
251
- </li>
252
- <li>
253
- <span style="background-color:#8bc34a"></span><?php _e('Optimized', 'clearfy'); ?>
254
- -
255
- <span class="wio-num" id="wio-optimized-num">0</span>
256
- </li>
257
- <li>
258
- <span style="background-color:#f1b1b6"></span><?php _e('Error', 'clearfy'); ?>
259
- -
260
- <span class="wio-num" id="wio-error-num">0</span>
261
- </li>
262
- </ul>
263
- </div>
264
- <div class="wio-bars">
265
- <p><?php _e('Original size', 'clearfy'); ?></p>
266
-
267
- <div class="wio-bar-negative base-transparent wio-right-outside-number">
268
- <div id="wio-original-bar" class="wio-progress" style="width: 100%">
269
- <span class="wio-barnb" id="wio-original-size">75 MB</span>
270
- </div>
271
- </div>
272
- <p><?php _e('Optimized size', 'clearfy'); ?></p>
273
 
274
- <div class="wio-bar-primary base-transparent wio-right-outside-number">
275
- <div id="wio-optimized-bar" class="wio-progress" style="width: 100%;">
276
- <span class="wio-barnb" id="wio-optimized-size">75 MB</span>
277
- </div>
278
- </div>
279
- </div>
280
- </div>
281
- <ul class="wio-widget-bottom">
282
- <li>
283
- <p>
284
- <a type="button" id="wio-start-optimization" href="<?= WCL_Plugin::app()->getPluginPageUrl('clrf_image_optimization') ?>" class="wio-optimize-button"><?php echo __('Bulk optimize', 'clearfy'); ?></a>
285
- </p>
286
- </li>
287
- <li>
288
- <div class="factory-dropdown factory-from-control-dropdown factory-buttons-way" data-way="buttons">
289
- <div id="wio-level-buttons" class="btn-group factory-buttons-group">
290
- <button type="button" data-level="normal" class="btn btn-default btn-small active"><?php _e('Normal', 'clearfy'); ?></button>
291
- <button type="button" data-level="aggresive" class="btn btn-default btn-small"><?php _e('Medium', 'clearfy'); ?></button>
292
- <button type="button" data-level="ultra" class="btn btn-default btn-small"><?php _e('High', 'clearfy'); ?></button>
293
- </div>
294
- </div>
295
- </li>
296
- </ul>
297
- </div>
298
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  <?php
300
- }
301
  }
302
-
303
- add_action('wbcr_clearfy_quick_boards', 'wbcr_clearfy_fake_boards');
304
-
305
- /**
306
- * Widget with the offer to buy Clearfy Business
307
- *
308
- * @param array $widgets
309
- * @param string $position
310
- * @param Wbcr_Factory409_Plugin $plugin
311
- */
312
- function wbcr_clearfy_donate_widget($widgets, $position, $plugin)
313
- {
314
- if( $plugin->getPluginName() == WCL_Plugin::app()->getPluginName() ) {
315
-
316
- $licensing = WCL_Licensing::instance();
317
-
318
- if( $licensing->isLicenseValid() ) {
319
- unset($widgets['donate_widget']);
320
- unset($widgets['businnes_suggetion']);
321
-
322
- return $widgets;
323
- } else {
324
- if( $position == 'right' ) {
325
- unset($widgets['info_widget']);
326
- }
 
327
  }
328
-
329
- if( $position == 'bottom' ) {
330
- $buy_premium_url = WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl(WCL_Plugin::app()->getPluginName(), 'pricing', 'license_page');
331
- $upgrade_price = WbcrFactoryClearfy206_Helpers::getClearfyBusinessPrice();
332
-
333
- ob_start();
334
- ?>
335
- <div id="wbcr-clr-go-to-premium-widget" class="wbcr-factory-sidebar-widget">
336
- <p>
337
- <strong><?php _e('Activation Clearfy Business', 'clearfy'); ?></strong>
338
- </p>
339
-
340
- <div class="wbcr-clr-go-to-premium-widget-body">
341
- <p><?php _e('<b>Clearfy Business</b> is a paid package of components for the popular free WordPress plugin named Clearfy. You get access to all paid components at one price.', 'clearfy') ?></p>
342
-
343
- <p><?php _e('Paid license guarantees that you can download and update existing and future paid components of the plugin.', 'clearfy') ?></p>
344
- <a href="<?= $buy_premium_url ?>" class="wbcr-clr-purchase-premium" target="_blank" rel="noopener">
345
- <span class="btn btn-gold btn-inner-wrap">
346
- <i class="fa fa-star"></i> <?php printf(__('Upgrade to Clearfy Business for $%s', 'clearfy'), $upgrade_price) ?>
347
- <i class="fa fa-star"></i>
348
- </span>
349
- </a>
350
- </div>
351
- </div>
352
- <?php
353
-
354
- $widgets['donate_widget'] = ob_get_contents();
355
-
356
- ob_end_clean();
357
  }
358
  }
359
-
360
- return $widgets;
 
 
361
  }
 
 
 
 
362
 
363
- add_filter('wbcr/factory/pages/impressive/widgets', 'wbcr_clearfy_donate_widget', 10, 3);
364
 
365
 
1
  <?php
2
+ /**
3
+ * Admin boot
4
+ * @author Webcraftic <alex.kovalevv@gmail.com>
5
+ * @copyright Webcraftic 25.05.2017
6
+ * @version 1.0
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ /**
15
+ * Выводит кнопку настроек Clearfy в шапке интерфейса плагина
16
+ */
17
+ add_action( 'wbcr/factory/pages/impressive/header', function ( $plugin_name ) {
18
+ if ( $plugin_name != WCL_Plugin::app()->getPluginName() ) {
19
+ return;
20
  }
21
+ ?>
22
+ <a href="<?= WCL_Plugin::app()->getPluginPageUrl( 'clearfy_settings' ) ?>" class="wbcr-factory-button wbcr-factory-type-settings">
23
+ <?= apply_filters( 'wbcr/clearfy/settings_button_title', __( 'Clearfy settings', 'clearfy' ) ); ?>
24
+ </a>
 
 
 
 
 
 
 
 
25
  <?php
26
+ } );
27
+
28
+ /**
29
+ * Этот код обманывает Wordpress, убеждая его, что плагин имеет новую версию,
30
+ * из-за чего Wordpress создает уведомление об обновлении плагина. Все это необходимо
31
+ * для обновления пакета компонентов
32
+ *
33
+ * @param mixed $transient - value of site transient.
34
+ */
35
+ add_filter( 'site_transient_update_plugins', function ( $transient ) {
36
+ if ( empty( $transient->checked ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  return $transient;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
+
40
+ $package_plugin = WCL_Package::instance();
41
+
42
+ if ( ! $package_plugin->isActive() ) {
43
+ return $transient;
 
 
 
 
 
 
 
 
 
44
  }
45
+
46
+ $need_update_package = $package_plugin->isNeedUpdate();
47
+ $need_update_addons = $package_plugin->isNeedUpdateAddons();
48
+ $info = $package_plugin->info();
49
+
50
+ if ( $need_update_package and $need_update_addons ) {
51
+ $update_data = new stdClass();
52
+ $update_data->slug = $info['plugin_slug'];
53
+ $update_data->plugin = $info['plugin_basename'];
54
+ $update_data->new_version = '1.1';
55
+ $update_data->package = $package_plugin->downloadUrl();
56
+ $transient->response[ $update_data->plugin ] = $update_data;
 
 
 
 
 
 
57
  }
58
+
59
+ return $transient;
60
+ } );
61
+
62
+ /**
63
+ * Выводит уведомление внутри интерфейса Clearfy, на всех страницах плагина.
64
+ * Это необходимо, чтоб напомнить пользователю обновить конфигурацию компонентов плагина,
65
+ * иначе вновь активированные компоненты не будет зайдествованы в работе плагина.
66
+ *
67
+ * @param Wbcr_Factory409_Plugin $plugin
68
+ * @param Wbcr_FactoryPages410_ImpressiveThemplate $obj
69
+ *
70
+ * @return bool
71
+ */
72
+ add_action( 'wbcr/factory/pages/impressive/print_all_notices', function ( $plugin, $obj ) {
73
+ // выводим уведомление везде, кроме страницы компонентов. Там выводится отдельно.
74
+ if ( ( WCL_Plugin::app()->getPluginName() != $plugin->getPluginName() ) || ( $obj->id == 'components' ) ) {
75
+ return false;
 
 
 
 
 
 
 
 
 
 
76
  }
77
+ $package_plugin = WCL_Package::instance();
78
+ $package_update_notice = $package_plugin->getUpdateNotice();
79
+
80
+ if ( $package_update_notice ) {
81
+ $obj->printWarningNotice( $package_update_notice );
 
 
 
 
82
  }
83
+ }, 10, 2 );
84
+
85
+ /**
86
+ * Выводит уведомление в строке плагина Clearfy (на странице плагинов),
87
+ * что нужно обновить пакет компонентов.
88
+ *
89
+ * @see WP_Plugins_List_Table
90
+ *
91
+ * @param string $plugin_file
92
+ * @param array $plugin_data
93
+ * @param string $status
94
+ *
95
+ * @return bool
96
+ */
97
+ add_action( 'after_plugin_row_clearfy/clearfy.php', function ( $plugin_file, $plugin_data, $status ) {
98
+ $package_plugin = WCL_Package::instance();
99
+ $need_update_package = $package_plugin->isNeedUpdate();
100
+
101
+ if ( $need_update_package ) {
102
+ if ( $package_plugin->isNeedUpdateAddons() ) {
103
+ $update_link = ' <a href="#" data-wpnonce="' . wp_create_nonce( 'package' ) . '" data-loading="' . __( 'Update in progress...', 'clearfy' ) . '" data-ok="' . __( 'Components have been successfully updated!', 'clearfy' ) . '" class="wbcr-clr-plugin-update-link">' . __( 'update now', 'clearfy' ) . '</a>';
104
+ ?>
105
+ <tr class="plugin-update-tr active update">
106
+ <td colspan="3" class="plugin-update colspanchange">
107
+ <div class="update-message notice inline notice-warning notice-alt" style="background-color:#f5e9f5;border-color: #dab9da;">
108
+ <p><?= __( 'Updates are available for one of the components.', 'clearfy' ) . $update_link; ?></p>
109
+ </div>
110
+ </td>
111
+ </tr>
112
+ <?php
113
  }
114
+ }
115
+ }, 100, 3 );
116
+
117
+ /**
118
+ * @param $form
119
+ * @param Wbcr_Factory409_Plugin $plugin
120
+ * @param Wbcr_FactoryPages410_ImpressiveThemplate $obj
121
+ */
122
+ function wbcr_clearfy_multisite_before_save( $form, $plugin, $obj ) {
123
+
124
+ if ( $plugin->isNetworkActive() ) {
125
+ $licensing = WCL_Licensing::instance();
126
+ if ( ! $licensing->isLicenseValid() && WCL_Plugin::app()->isNetworkActive() && $plugin->getPluginName() == WCL_Plugin::app()->getPluginName() ) {
127
+ $obj->redirectToAction( 'multisite-pro' );
128
  }
129
  }
130
+ }
131
+
132
+ add_action( 'wbcr/factory/pages/impressive/before_form_save', 'wbcr_clearfy_multisite_before_save', 10, 3 );
133
+
134
+ /**
135
+ * Устанавливает логотип Webcraftic и сборку плагина для Clearfy и всех его компонентов
136
+ *
137
+ * @param string $title
138
+ *
139
+ * @since 1.4.0
140
+ */
141
+ function wbcr_clearfy_branding( $title ) {
142
+ $licensing = WCL_Licensing::instance();
143
+
144
+ return 'Webcraftic Clearfy ' . ( $licensing->isLicenseValid() ? '<span class="wbcr-clr-logo-label wbcr-clr-premium-label-logo">' . __( 'Business', 'clearfy' ) . '</span>' : '<span class="wbcr-clr-logo-label wbcr-clr-free-label-logo">Free</span>' ) . ' ver';
145
+ }
146
+
147
+ add_action( 'wbcr/factory/pages/impressive/plugin_title', 'wbcr_clearfy_branding' );
148
+
149
+ /**
150
+ * Подключаем скрипты отвественные за обновления пакетов для Clearfy
151
+ * Скрипты подключа.тся на каждой странице Clearfy и его компонентов
152
+ *
153
+ * @param string $page_id
154
+ * @param Wbcr_Factory409_ScriptList $scripts
155
+ * @param Wbcr_Factory409_StyleList $styles
156
+ *
157
+ * @since 1.4.0
158
+ */
159
+ function wbcr_clearfy_enqueue_global_scripts( $page_id, $scripts, $styles ) {
160
+ $scripts->add( WCL_PLUGIN_URL . '/admin/assets/js/update-package.js', array(
161
+ 'jquery',
162
+ 'wbcr-factory-clearfy-206-global'
163
+ ) );
164
+ }
165
+
166
+ add_action( 'wbcr/clearfy/page_assets', 'wbcr_clearfy_enqueue_global_scripts', 10, 3 );
167
+
168
+ /**
169
+ * Подключаем скрипты для установки компонентов Clearfy
170
+ * на все страницы админпанели
171
+ */
172
+ add_action( 'admin_enqueue_scripts', function () {
173
+ wp_enqueue_style( 'wbcr-clearfy-install-components', WCL_PLUGIN_URL . '/admin/assets/css/install-addons.css', array(), WCL_Plugin::app()->getPluginVersion() );
174
+ wp_enqueue_script( 'wbcr-clearfy-install-components', WCL_PLUGIN_URL . '/admin/assets/js/install-addons.js', array(
175
+ 'jquery',
176
+ 'wbcr-factory-clearfy-206-global'
177
+ ), WCL_Plugin::app()->getPluginVersion() );
178
+ } );
179
+
180
+ /**
181
+ * Выводит уведомление, что нужно сбросить постоянные ссылки.
182
+ * Уведомление будет показано на всех страницах Clearfy и его компонентах.
183
+ *
184
+ * @param WCL_Plugin $plugin
185
+ * @param Wbcr_FactoryPages410_ImpressiveThemplate $obj
186
+ *
187
+ * @return bool
188
+ */
189
+ function wbcr_clearfy_print_notice_rewrite_rules( $plugin, $obj ) {
190
+ if ( WCL_Plugin::app()->getPopulateOption( 'need_rewrite_rules' ) ) {
191
+ $obj->printWarningNotice( sprintf( '<span class="wbcr-clr-need-rewrite-rules-message">' . __( 'When you deactivate some components, permanent links may work incorrectly. If this happens, please, <a href="%s">update the permalinks</a>, so you could complete the deactivation.', 'clearfy' ), admin_url( 'options-permalink.php' ) ) . '</span>' );
192
+ }
193
+ }
194
+
195
+ add_action( 'wbcr/factory/pages/impressive/print_all_notices', 'wbcr_clearfy_print_notice_rewrite_rules', 10, 2 );
196
+
197
+ /**
198
+ * Удалем уведомление Clearfy о том, что нужно перезаписать постоянные ссылоки.s
199
+ */
200
+ function wbcr_clearfy_flush_rewrite_rules() {
201
+ WCL_Plugin::app()->deletePopulateOption( 'need_rewrite_rules', 1 );
202
+ }
203
+
204
+ add_action( 'flush_rewrite_rules_hard', 'wbcr_clearfy_flush_rewrite_rules' );
205
+
206
+ /**
207
+ * Обновить постоынные ссылки, после выполнения быстрых настроек
208
+ *
209
+ * @param WHM_Plugin $plugin
210
+ * @param Wbcr_FactoryPages410_ImpressiveThemplate $obj
211
+ */
212
+ function wbcr_clearfy_after_form_save( $plugin, $obj ) {
213
+ if ( ! WCL_Plugin::app()->currentUserCan() ) {
214
+ return;
215
+ }
216
+ $is_clearfy = WCL_Plugin::app()->getPluginName() == $plugin->getPluginName();
217
+
218
+ if ( $is_clearfy && $obj->id == 'quick_start' && isset( $_GET['action'] ) && $_GET['action'] == 'flush-cache-and-rules' ) {
219
+ require_once ABSPATH . 'wp-admin/includes/file.php';
220
+ require_once ABSPATH . 'wp-admin/includes/misc.php';
221
+ flush_rewrite_rules( true );
222
+ }
223
+ }
224
 
225
+ add_action( 'wbcr/factory/pages/impressive/after_form_save', 'wbcr_clearfy_after_form_save', 10, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
 
227
+ /**
228
+ * Fake stubs for the Clearfy plugin board
229
+ */
230
+ function wbcr_clearfy_fake_boards() {
231
+ if ( ! defined( 'WIO_PLUGIN_ACTIVE' ) ) {
232
+ ?>
233
+ <div class="wio-image-optimize-board wbcr-clearfy-board">
234
+ <h4 class="wio-text-left"><?php _e( 'Images optimization', 'clearfy' ); ?></h4>
235
+ <div class="wio-columns wio-widget">
236
+ <div class="wio-col col-chart">
237
+ <div class="wio-chart-container wio-overview-chart-container">
238
+ <canvas id="wio-main-chart" width="110" height="110" data-unoptimized="1400" data-optimized="0" data-errors="0" style="display: block;"></canvas>
239
+ <div id="wio-overview-chart-percent" class="wio-chart-percent">0<span>%</span></div>
240
+ </div>
241
+ <div id="wio-overview-chart-legend">
242
+ <ul class="wio-doughnut-legend">
243
+ <li>
244
+ <span style="background-color:#d6d6d6"></span><?php _e( 'Unoptimized', 'clearfy' ); ?>
245
+ -
246
+ <span class="wio-num" id="wio-unoptimized-num">1400</span>
247
+ </li>
248
+ <li>
249
+ <span style="background-color:#8bc34a"></span><?php _e( 'Optimized', 'clearfy' ); ?>
250
+ -
251
+ <span class="wio-num" id="wio-optimized-num">0</span>
252
+ </li>
253
+ <li>
254
+ <span style="background-color:#f1b1b6"></span><?php _e( 'Error', 'clearfy' ); ?>
255
+ -
256
+ <span class="wio-num" id="wio-error-num">0</span>
257
+ </li>
258
+ </ul>
259
+ </div>
260
+ <div class="wio-bars">
261
+ <p><?php _e( 'Original size', 'clearfy' ); ?></p>
262
+ <div class="wio-bar-negative base-transparent wio-right-outside-number">
263
+ <div id="wio-original-bar" class="wio-progress" style="width: 100%">
264
+ <span class="wio-barnb" id="wio-original-size">75 MB</span>
265
+ </div>
266
+ </div>
267
+ <p><?php _e( 'Optimized size', 'clearfy' ); ?></p>
268
+ <div class="wio-bar-primary base-transparent wio-right-outside-number">
269
+ <div id="wio-optimized-bar" class="wio-progress" style="width: 100%;">
270
+ <span class="wio-barnb" id="wio-optimized-size">75 MB</span>
271
+ </div>
272
+ </div>
273
+ </div>
274
+ </div>
275
+ <ul class="wio-widget-bottom">
276
+ <li>
277
+ <p>
278
+ <a type="button" id="wio-start-optimization" href="<?= WCL_Plugin::app()->getPluginPageUrl( 'clrf_image_optimization' ) ?>" class="wio-optimize-button"><?php echo __( 'Bulk optimize', 'clearfy' ); ?></a>
279
+ </p>
280
+ </li>
281
+ <li>
282
+ <div class="factory-dropdown factory-from-control-dropdown factory-buttons-way" data-way="buttons">
283
+ <div id="wio-level-buttons" class="btn-group factory-buttons-group">
284
+ <button type="button" data-level="normal" class="btn btn-default btn-small active"><?php _e( 'Normal', 'clearfy' ); ?></button>
285
+ <button type="button" data-level="aggresive" class="btn btn-default btn-small"><?php _e( 'Medium', 'clearfy' ); ?></button>
286
+ <button type="button" data-level="ultra" class="btn btn-default btn-small"><?php _e( 'High', 'clearfy' ); ?></button>
287
+ </div>
288
+ </div>
289
+ </li>
290
+ </ul>
291
+ </div>
292
+ </div>
293
  <?php
 
294
  }
295
+ }
296
+
297
+ add_action( 'wbcr_clearfy_quick_boards', 'wbcr_clearfy_fake_boards' );
298
+
299
+ /**
300
+ * Widget with the offer to buy Clearfy Business
301
+ *
302
+ * @param array $widgets
303
+ * @param string $position
304
+ * @param Wbcr_Factory409_Plugin $plugin
305
+ */
306
+
307
+ add_filter( 'wbcr/factory/pages/impressive/widgets', function ( $widgets, $position, $plugin ) {
308
+ if ( $plugin->getPluginName() == WCL_Plugin::app()->getPluginName() ) {
309
+
310
+ require_once WCL_PLUGIN_DIR . '/admin/includes/sidebar-widgets.php';
311
+
312
+ $licensing = WCL_Licensing::instance();
313
+
314
+ if ( $licensing->isLicenseValid() ) {
315
+ unset( $widgets['donate_widget'] );
316
+
317
+ if ( $position == 'right' ) {
318
+ unset( $widgets['businnes_suggetion'] );
319
+ unset( $widgets['rating_widget'] );
320
+ unset( $widgets['info_widget'] );
321
  }
322
+
323
+ if ( $position == 'bottom' ) {
324
+ $widgets['support'] = wbcr_clearfy_get_sidebar_support_widget();
325
+ }
326
+
327
+ return $widgets;
328
+ } else {
329
+ if ( $position == 'right' ) {
330
+ unset( $widgets['info_widget'] );
331
+ unset( $widgets['rating_widget'] );
332
+ $widgets['support'] = wbcr_clearfy_get_sidebar_support_widget();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  }
334
  }
335
+
336
+ if ( $position == 'bottom' ) {
337
+ $widgets['donate_widget'] = wbcr_clearfy_get_sidebar_premium_widget();
338
+ }
339
  }
340
+
341
+ return $widgets;
342
+ }, 10, 3 );
343
+
344
 
 
345
 
346
 
admin/includes/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
admin/includes/sidebar-widgets.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sidebar widgets
4
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
5
+ * @copyright (c) 01.12.2018, Webcraftic
6
+ * @version 1.0
7
+ */
8
+
9
+ /**
10
+ * Return premium widget markup
11
+ * @return string
12
+ */
13
+ function wbcr_clearfy_get_sidebar_premium_widget() {
14
+
15
+ $buy_premium_url = WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl( WCL_Plugin::app()->getPluginName(), 'pricing', 'license_page' );
16
+ $upgrade_price = WbcrFactoryClearfy206_Helpers::getClearfyBusinessPrice();
17
+
18
+ ob_start();
19
+ ?>
20
+ <div id="wbcr-clr-go-to-premium-widget" class="wbcr-factory-sidebar-widget">
21
+ <p>
22
+ <strong><?php _e( 'Activation Clearfy Business', 'clearfy' ); ?></strong>
23
+ </p>
24
+ <div class="wbcr-clr-go-to-premium-widget-body">
25
+ <p><?php _e( '<b>Clearfy Business</b> is a paid package of components for the popular free WordPress plugin named Clearfy. You get access to all paid components at one price.', 'clearfy' ) ?></p>
26
+ <p><?php _e( 'Paid license guarantees that you can download and update existing and future paid components of the plugin.', 'clearfy' ) ?></p>
27
+ <a href="<?= $buy_premium_url ?>" class="wbcr-clr-purchase-premium" target="_blank" rel="noopener">
28
+ <span class="btn btn-gold btn-inner-wrap">
29
+ <i class="fa fa-star"></i> <?php printf( __( 'Upgrade to Clearfy Business for $%s', 'clearfy' ), $upgrade_price ) ?>
30
+ <i class="fa fa-star"></i>
31
+ </span>
32
+ </a>
33
+ </div>
34
+ </div>
35
+ <?php
36
+
37
+ $output = ob_get_contents();
38
+
39
+ ob_end_clean();
40
+
41
+ return $output;
42
+ }
43
+
44
+ /**
45
+ * Return support widget markup
46
+ * @return string
47
+ */
48
+ function wbcr_clearfy_get_sidebar_support_widget() {
49
+
50
+ $output = '';
51
+
52
+ $free_support_url = WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl( WCL_Plugin::app()->getPluginName(), 'support', 'support_widget' );
53
+ $page_hot_support_url = WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl( WCL_Plugin::app()->getPluginName(), 'hot-support', 'support_widget' );
54
+
55
+ ob_start();
56
+ ?>
57
+ <div id="wbcr-clr-support-widget" class="wbcr-factory-sidebar-widget">
58
+ <p><strong><?php _e( 'Having Issues?', 'clearfy' ); ?></strong></p>
59
+ <div class="wbcr-clr-support-widget-body">
60
+ <p>
61
+ <?php _e( 'We provide free support for this plugin. If you are pushed with a problem, just create a new ticket. We will definitely help you!', 'clearfy' ); ?>
62
+ </p>
63
+ <ul>
64
+ <li><span class="dashicons dashicons-sos"></span>
65
+ <a href="<?= $free_support_url ?>" target="_blank" rel="noopener"><?php _e( 'Get starting free support', 'clearfy' ); ?></a>
66
+ </li>
67
+ <li style="margin-top: 15px;background: #fff4f1;padding: 10px;color: #a58074;">
68
+ <span class="dashicons dashicons-warning"></span>
69
+ <?php printf( __( 'If you find a php error or a vulnerability in plugin, you can <a href="%s" target="_blank" rel="noopener">create ticket</a> in hot support that we responded instantly.', 'clearfy' ), $page_hot_support_url ); ?>
70
+ </li>
71
+ </ul>
72
+ </div>
73
+ </div>
74
+ <?php
75
+
76
+ $output = ob_get_contents();
77
+
78
+ ob_end_clean();
79
+
80
+ return $output;
81
+ }
admin/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
admin/pages/clearfy-settings.php CHANGED
@@ -1,257 +1,247 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  /**
4
- * The page Settings.
 
 
 
5
  *
6
  * @since 1.0.0
 
7
  */
8
-
9
- // Exit if accessed directly
10
- if( !defined('ABSPATH') ) {
11
- exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  }
13
 
14
- class WCL_ClearfySettingsPage extends Wbcr_FactoryClearfy206_PageBase {
15
-
16
- /**
17
- * The id of the page in the admin menu.
18
- *
19
- * Mainly used to navigate between pages.
20
- * @see FactoryPages410_AdminPage
21
- *
22
- * @since 1.0.0
23
- * @var string
24
- */
25
- public $id = "clearfy_settings";
26
-
27
- /**
28
- * @var string
29
- */
30
- public $page_parent_page = 'none';
31
-
32
- /**
33
- * @var string
34
- */
35
- public $page_menu_dashicon = 'dashicons-list-view';
36
-
37
- /**
38
- * @var bool
39
- */
40
- public $available_for_multisite = true;
41
-
42
- /**
43
- * @param WCL_Plugin $plugin
44
- */
45
- public function __construct(WCL_Plugin $plugin)
46
- {
47
- $this->menu_title = __('Clearfy Settings', 'clearfy');
48
- $this->page_menu_short_description = __('Useful tweaks', 'clearfy');
49
-
50
- parent::__construct($plugin);
51
-
52
- $this->plugin = $plugin;
53
- }
54
-
55
-
56
- /**
57
- * Requests assets (js and css) for the page.
58
- *
59
- * @see FactoryPages410_AdminPage
60
- *
61
- * @since 1.0.0
62
- * @return void
63
- */
64
- public function assets($scripts, $styles)
65
- {
66
- parent::assets($scripts, $styles);
67
-
68
- $this->scripts->add(WCL_PLUGIN_URL . '/admin/assets/js/general.js');
69
-
70
- $params = array(
71
- 'import_options_nonce' => wp_create_nonce('wbcr_clearfy_import_options'),
72
- 'i18n' => array(
73
- 'success_update_settings' => __('Settings successfully updated!', 'clearfy'),
74
- 'unknown_error' => __('During the setup, an unknown error occurred, please try again or contact the plugin support.', 'clearfy'),
75
- )
76
- );
77
-
78
- wp_localize_script('jquery', 'wbcr_clearfy_ajax', $params);
79
- }
80
-
81
- /**
82
- * Permalinks options.
83
- *
84
- * @since 1.0.0
85
- * @return mixed[]
86
- */
87
- public function getPageOptions()
88
- {
89
-
90
- $options = array();
91
-
92
- $options[] = array(
93
- 'type' => 'html',
94
- 'html' => '<div class="wbcr-clearfy-group-header">' . '<strong>' . __('Advanced settings', 'clearfy') . '</strong>' . '<p>' . __('This group of settings allows you to configure the work of the Clearfy plugin.', 'clearfy') . '</p>' . '</div>'
95
- );
96
-
97
- $options[] = array(
98
- 'type' => 'checkbox',
99
- 'way' => 'buttons',
100
- 'name' => 'disable_clearfy_extra_menu',
101
- 'title' => __('Disable menu in adminbar', 'clearfy'),
102
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'red'),
103
- 'hint' => __('This setting allows you to disable the additional menu of the Clearfy plugin, in the admin bar. This menu is required to work with the Minify and Combine and Assets Manager components.', 'clearfy'),
104
- 'default' => false
105
- );
106
-
107
- $options[] = array(
108
- 'type' => 'checkbox',
109
- 'way' => 'buttons',
110
- 'name' => 'save_all_settings_after_uninstall',
111
- 'title' => __('Save all settings', 'clearfy'),
112
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'green'),
113
- 'hint' => __("If On, the plugin's settings will be stored in the database, even if you delete the plugin. This is useful if you have a problem with the plugins and you decide to return to the previous version. Disable this option if you want the plugins to clean all settings after removal.", 'clearfy'),
114
- 'default' => false
115
- );
116
-
117
-
118
-
119
- $options[] = array(
120
- 'type' => 'html',
121
- 'html' => '<div class="wbcr-clearfy-group-header">' . '<strong>' . __('Import/Export', 'clearfy') . '</strong>' . '<p>' . __('This group of settings allows you to configure the work of the Clearfy plugin.', 'clearfy') . '</p>' . '</div>'
122
- );
123
-
124
- $options[] = array(
125
- 'type' => 'html',
126
- 'html' => array($this, 'export')
127
- );
128
-
129
- $options[] = array(
130
- 'type' => 'html',
131
- 'html' => '<div class="wbcr-clearfy-group-header">' . '<strong>' . __('Support', 'clearfy') . '</strong>' . '<p>' . __('This group of settings allows you to configure the work of the Clearfy plugin.', 'clearfy') . '</p>' . '</div>'
132
- );
133
-
134
- $options[] = array(
135
- 'type' => 'html',
136
- 'html' => array($this, 'supports')
137
- );
138
-
139
- $formOptions = array();
140
-
141
- $formOptions[] = array(
142
- 'type' => 'form-group',
143
- 'items' => $options,
144
- //'cssClass' => 'postbox'
145
- );
146
-
147
- return apply_filters('wbcr/clearfy/settings_form_options', $formOptions, $this);
148
- }
149
-
150
- public function export()
151
- {
152
- ?>
153
- <div class="wbcr-clearfy-export-import">
154
- <p>
155
- <label for="wbcr-clearfy-import-export">
156
- <strong><?php _e('Import/Export settings', 'clearfy') ?></strong>
157
- </label>
158
- <textarea id="wbcr-clearfy-import-export"><?= WCL_Helper::getExportOptions(); ?></textarea>
159
- <button class="button wbcr-clearfy-import-options-button"><?php _e('Import options', 'clearfy') ?></button>
160
- </p>
161
- </div>
162
  <?php
163
- }
164
-
165
- public function supports()
166
- {
167
- ?>
168
- <div class="wbcr-clearfy-troubleshooting">
169
- <p><?php _e('If you faced with any issues, please follow the steps below to get quickly quality support:', 'clearfy') ?></p>
170
- <ol>
171
- <li>
172
- <p><?php _e('Generate a debug report which will contains inforamtion about your configuratin and installed plugins', 'clearfy') ?></p>
173
-
174
- <p>
175
- <a href="<?= $this->getActionUrl('gererate_report'); ?>" class="button"><?php _e('Generate Debug Report', 'clearfy') ?></a>
176
- </p>
177
- </li>
178
- <li>
179
- <p><?php _e('Send a message to <b>wordpress.webraftic@gmail.com</b> include the debug report into the message body.', 'clearfy'); ?></p>
180
- </li>
181
- </ol>
182
- <p style="margin-bottom: 0px;"><?php _e('We guarantee to respond you within 7 business day.', 'clearfy') ?></p>
183
- </div>
184
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  }
186
-
187
- /**
188
- * Collects error and system error data
189
- * @return string
190
- */
191
- public function getDebugReport()
192
- {
193
- $run_time = number_format(microtime(true), 3);
194
- $pps = number_format(1 / $run_time, 0);
195
- $memory_avail = ini_get('memory_limit');
196
- $memory_used = number_format(memory_get_usage(true) / (1024 * 1024), 2);
197
- $memory_peak = number_format(memory_get_peak_usage(true) / (1024 * 1024), 2);
198
-
199
- $debug = '';
200
- if( PHP_SAPI == 'cli' ) {
201
- // if run for command line, display some info
202
- $debug = PHP_EOL . "======================================================================================" . PHP_EOL . " Config: php " . phpversion() . " " . php_sapi_name() . " / zend engine " . zend_version() . PHP_EOL . " Load: {$memory_avail} (avail) / {$memory_used}M (used) / {$memory_peak}M (peak)" . " | Time: {$run_time}s | {$pps} req/sec" . PHP_EOL . " | Server Timezone: " . date_default_timezone_get() . " | Agent: CLI" . PHP_EOL . "======================================================================================" . PHP_EOL;
203
- } else {
204
- // if not run from command line, only display if debug is enabled
205
- $debug = "" //<hr />"
206
- . "<div style=\"text-align: left;\">" . "<hr />" . " Config: " . "<br />" . " &nbsp;&nbsp; | php " . phpversion() . " " . php_sapi_name() . " / zend engine " . zend_version() . "<br />" . " &nbsp;&nbsp; | Server Timezone: " . date_default_timezone_get() . "<br />" . " Load: " . "<br />" . " &nbsp;&nbsp; | Memory: {$memory_avail} (avail) / {$memory_used}M (used) / {$memory_peak}M (peak)" . "<br />" . " &nbsp;&nbsp; | Time: {$run_time}s &nbsp;&nbsp; | {$pps} req/sec" . "<br />" . "Url: " . "<br />" . " &nbsp;&nbsp; |" . "<br />" . " &nbsp;&nbsp; | Agent: " . (@$_SERVER["HTTP_USER_AGENT"]) . "<br />" . "Version Control: " . "<br />" . " &nbsp;&nbsp; </div>" . "<br />";
207
- }
208
-
209
- $debug .= "Plugins<br>";
210
- $debug .= "=====================<br>";
211
-
212
- $plugins = get_plugins();
213
-
214
- require_once ABSPATH . '/wp-admin/includes/plugin.php';
215
- foreach($plugins as $path => $plugin) {
216
- if( is_plugin_active($path) ) {
217
- $debug .= $plugin['Name'] . '<br>';
218
- }
219
  }
220
-
221
- return $debug;
222
  }
223
-
224
- /**
225
- * Generates a report about the system and plug-in error
226
- * @return string
227
- */
228
- public function gererateReportAction()
229
- {
230
- require_once(WCL_PLUGIN_DIR . '/includes/classes/class.zip-archive.php');
231
-
232
- $reposts_dir = WCL_PLUGIN_DIR . '/reports';
233
- $reports_temp = $reposts_dir . '/temp';
234
-
235
- if( !file_exists($reposts_dir) ) {
236
- mkdir($reposts_dir, 0777, true);
237
- }
238
-
239
- if( !file_exists($reports_temp) ) {
240
- mkdir($reports_temp, 0777, true);
241
- }
242
-
243
- $file = fopen($reports_temp . '/site-info.html', 'w+');
244
- fputs($file, $this->getDebugReport());
245
- fclose($file);
246
-
247
- $download_file_name = 'webcraftic-clearfy-report-' . date('Y.m.d-H.i.s') . '.zip';
248
- $download_file_path = WCL_PLUGIN_DIR . '/reports/' . $download_file_name;
249
-
250
- Wbcr_ExtendedZip::zipTree(WCL_PLUGIN_DIR . '/reports/temp', $download_file_path, ZipArchive::CREATE);
251
-
252
- array_map('unlink', glob(WCL_PLUGIN_DIR . "/reports/temp/*"));
253
-
254
- wp_redirect(WCL_PLUGIN_URL . '/reports/' . $download_file_name);
255
- exit;
256
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  }
 
1
  <?php
2
 
3
+ /**
4
+ * The page Settings.
5
+ *
6
+ * @since 1.0.0
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ class WCL_ClearfySettingsPage extends Wbcr_FactoryClearfy206_PageBase {
15
+
16
  /**
17
+ * The id of the page in the admin menu.
18
+ *
19
+ * Mainly used to navigate between pages.
20
+ * @see FactoryPages410_AdminPage
21
  *
22
  * @since 1.0.0
23
+ * @var string
24
  */
25
+ public $id = "clearfy_settings";
26
+
27
+ /**
28
+ * @var string
29
+ */
30
+ public $page_parent_page = 'none';
31
+
32
+ /**
33
+ * @var string
34
+ */
35
+ public $page_menu_dashicon = 'dashicons-list-view';
36
+
37
+ /**
38
+ * @var bool
39
+ */
40
+ public $available_for_multisite = true;
41
+
42
+ /**
43
+ * @param WCL_Plugin $plugin
44
+ */
45
+ public function __construct( WCL_Plugin $plugin ) {
46
+ $this->menu_title = __( 'Clearfy Settings', 'clearfy' );
47
+ $this->page_menu_short_description = __( 'Useful tweaks', 'clearfy' );
48
+
49
+ parent::__construct( $plugin );
50
+
51
+ $this->plugin = $plugin;
52
  }
53
 
54
+
55
+ /**
56
+ * Requests assets (js and css) for the page.
57
+ *
58
+ * @see FactoryPages410_AdminPage
59
+ *
60
+ * @since 1.0.0
61
+ * @return void
62
+ */
63
+ public function assets( $scripts, $styles ) {
64
+ parent::assets( $scripts, $styles );
65
+
66
+ $this->scripts->add( WCL_PLUGIN_URL . '/admin/assets/js/general.js' );
67
+
68
+ $params = array(
69
+ 'import_options_nonce' => wp_create_nonce( 'wbcr_clearfy_import_options' ),
70
+ 'i18n' => array(
71
+ 'success_update_settings' => __( 'Settings successfully updated!', 'clearfy' ),
72
+ 'unknown_error' => __( 'During the setup, an unknown error occurred, please try again or contact the plugin support.', 'clearfy' ),
73
+ )
74
+ );
75
+
76
+ wp_localize_script( 'jquery', 'wbcr_clearfy_ajax', $params );
77
+ }
78
+
79
+ /**
80
+ * Permalinks options.
81
+ *
82
+ * @since 1.0.0
83
+ * @return mixed[]
84
+ */
85
+ public function getPageOptions() {
86
+
87
+ $options = array();
88
+
89
+ $options[] = array(
90
+ 'type' => 'html',
91
+ 'html' => '<div class="wbcr-clearfy-group-header">' . '<strong>' . __( 'Advanced settings', 'clearfy' ) . '</strong>' . '<p>' . __( 'This group of settings allows you to configure the work of the Clearfy plugin.', 'clearfy' ) . '</p>' . '</div>'
92
+ );
93
+
94
+ $options[] = array(
95
+ 'type' => 'checkbox',
96
+ 'way' => 'buttons',
97
+ 'name' => 'disable_clearfy_extra_menu',
98
+ 'title' => __( 'Disable menu in adminbar', 'clearfy' ),
99
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'red' ),
100
+ 'hint' => __( 'This setting allows you to disable the additional menu of the Clearfy plugin, in the admin bar. This menu is required to work with the Minify and Combine and Assets Manager components.', 'clearfy' ),
101
+ 'default' => false
102
+ );
103
+
104
+ $options[] = array(
105
+ 'type' => 'checkbox',
106
+ 'way' => 'buttons',
107
+ 'name' => 'complete_uninstall',
108
+ 'title' => __( 'Complete Uninstall', 'clearfy' ),
109
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
110
+ 'hint' => __( "When the plugin is deleted from the Plugins menu, also delete all plugin settings.", 'clearfy' ),
111
+ 'default' => false
112
+ );
113
+
114
+ $options[] = array(
115
+ 'type' => 'html',
116
+ 'html' => '<div class="wbcr-clearfy-group-header">' . '<strong>' . __( 'Import/Export', 'clearfy' ) . '</strong>' . '<p>' . __( 'This group of settings allows you to configure the work of the Clearfy plugin.', 'clearfy' ) . '</p>' . '</div>'
117
+ );
118
+
119
+ $options[] = array(
120
+ 'type' => 'html',
121
+ 'html' => array( $this, 'export' )
122
+ );
123
+
124
+ $options[] = array(
125
+ 'type' => 'html',
126
+ 'html' => '<div class="wbcr-clearfy-group-header">' . '<strong>' . __( 'Support', 'clearfy' ) . '</strong>' . '<p>' . __( 'This group of settings allows you to configure the work of the Clearfy plugin.', 'clearfy' ) . '</p>' . '</div>'
127
+ );
128
+
129
+ $options[] = array(
130
+ 'type' => 'html',
131
+ 'html' => array( $this, 'supports' )
132
+ );
133
+
134
+ $formOptions = array();
135
+
136
+ $formOptions[] = array(
137
+ 'type' => 'form-group',
138
+ 'items' => $options,
139
+ //'cssClass' => 'postbox'
140
+ );
141
+
142
+ return apply_filters( 'wbcr/clearfy/settings_form_options', $formOptions, $this );
143
+ }
144
+
145
+ public function export() {
146
+ ?>
147
+ <div class="wbcr-clearfy-export-import">
148
+ <p>
149
+ <label for="wbcr-clearfy-import-export">
150
+ <strong><?php _e( 'Import/Export settings', 'clearfy' ) ?></strong>
151
+ </label>
152
+ <textarea id="wbcr-clearfy-import-export"><?= WCL_Helper::getExportOptions(); ?></textarea>
153
+ <button class="button wbcr-clearfy-import-options-button"><?php _e( 'Import options', 'clearfy' ) ?></button>
154
+ </p>
155
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  <?php
157
+ }
158
+
159
+ public function supports() {
160
+ ?>
161
+ <div class="wbcr-clearfy-troubleshooting">
162
+ <p><?php _e( 'If you faced with any issues, please follow the steps below to get quickly quality support:', 'clearfy' ) ?></p>
163
+ <ol>
164
+ <li>
165
+ <p><?php _e( 'Generate a debug report which will contains inforamtion about your configuratin and installed plugins', 'clearfy' ) ?></p>
166
+ <p>
167
+ <a href="<?= $this->getActionUrl( 'gererate_report' ); ?>" class="button"><?php _e( 'Generate Debug Report', 'clearfy' ) ?></a>
168
+ </p>
169
+ </li>
170
+ <li>
171
+ <p><?php printf( __( 'Create a new ticket in our <a href="%s" target="_blank">support forum</a>, include the debug report into the message body.', 'clearfy' ), "https://forum.webcraftic.com" ); ?></p>
172
+ </li>
173
+ </ol>
174
+ <p style="margin-bottom: 0px;"><?php _e( 'We guarantee to respond you within 7 business day.', 'clearfy' ) ?></p>
175
+ </div>
 
 
176
  <?php
177
+ }
178
+
179
+ /**
180
+ * Collects error and system error data
181
+ * @return string
182
+ */
183
+ public function getDebugReport() {
184
+ $run_time = number_format( microtime( true ), 3 );
185
+ $pps = number_format( 1 / $run_time, 0 );
186
+ $memory_avail = ini_get( 'memory_limit' );
187
+ $memory_used = number_format( memory_get_usage( true ) / ( 1024 * 1024 ), 2 );
188
+ $memory_peak = number_format( memory_get_peak_usage( true ) / ( 1024 * 1024 ), 2 );
189
+
190
+ $debug = '';
191
+ if ( PHP_SAPI == 'cli' ) {
192
+ // if run for command line, display some info
193
+ $debug = PHP_EOL . "======================================================================================" . PHP_EOL . " Config: php " . phpversion() . " " . php_sapi_name() . " / zend engine " . zend_version() . PHP_EOL . " Load: {$memory_avail} (avail) / {$memory_used}M (used) / {$memory_peak}M (peak)" . " | Time: {$run_time}s | {$pps} req/sec" . PHP_EOL . " | Server Timezone: " . date_default_timezone_get() . " | Agent: CLI" . PHP_EOL . "======================================================================================" . PHP_EOL;
194
+ } else {
195
+ // if not run from command line, only display if debug is enabled
196
+ $debug = "" //<hr />"
197
+ . "<div style=\"text-align: left;\">" . "<hr />" . " Config: " . "<br />" . " &nbsp;&nbsp; | php " . phpversion() . " " . php_sapi_name() . " / zend engine " . zend_version() . "<br />" . " &nbsp;&nbsp; | Server Timezone: " . date_default_timezone_get() . "<br />" . " Load: " . "<br />" . " &nbsp;&nbsp; | Memory: {$memory_avail} (avail) / {$memory_used}M (used) / {$memory_peak}M (peak)" . "<br />" . " &nbsp;&nbsp; | Time: {$run_time}s &nbsp;&nbsp; | {$pps} req/sec" . "<br />" . "Url: " . "<br />" . " &nbsp;&nbsp; |" . "<br />" . " &nbsp;&nbsp; | Agent: " . ( @$_SERVER["HTTP_USER_AGENT"] ) . "<br />" . "Version Control: " . "<br />" . " &nbsp;&nbsp; </div>" . "<br />";
198
  }
199
+
200
+ $debug .= "Plugins<br>";
201
+ $debug .= "=====================<br>";
202
+
203
+ $plugins = get_plugins();
204
+
205
+ require_once ABSPATH . '/wp-admin/includes/plugin.php';
206
+ foreach ( $plugins as $path => $plugin ) {
207
+ if ( is_plugin_active( $path ) ) {
208
+ $debug .= $plugin['Name'] . '<br>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  }
 
 
210
  }
211
+
212
+ return $debug;
213
+ }
214
+
215
+ /**
216
+ * Generates a report about the system and plug-in error
217
+ * @return string
218
+ */
219
+ public function gererateReportAction() {
220
+ require_once( WCL_PLUGIN_DIR . '/includes/classes/class.zip-archive.php' );
221
+
222
+ $reposts_dir = WCL_PLUGIN_DIR . '/reports';
223
+ $reports_temp = $reposts_dir . '/temp';
224
+
225
+ if ( ! file_exists( $reposts_dir ) ) {
226
+ mkdir( $reposts_dir, 0777, true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  }
228
+
229
+ if ( ! file_exists( $reports_temp ) ) {
230
+ mkdir( $reports_temp, 0777, true );
231
+ }
232
+
233
+ $file = fopen( $reports_temp . '/site-info.html', 'w+' );
234
+ fputs( $file, $this->getDebugReport() );
235
+ fclose( $file );
236
+
237
+ $download_file_name = 'webcraftic-clearfy-report-' . date( 'Y.m.d-H.i.s' ) . '.zip';
238
+ $download_file_path = WCL_PLUGIN_DIR . '/reports/' . $download_file_name;
239
+
240
+ Wbcr_ExtendedZip::zipTree( WCL_PLUGIN_DIR . '/reports/temp', $download_file_path, ZipArchive::CREATE );
241
+
242
+ array_map( 'unlink', glob( WCL_PLUGIN_DIR . "/reports/temp/*" ) );
243
+
244
+ wp_redirect( WCL_PLUGIN_URL . '/reports/' . $download_file_name );
245
+ exit;
246
  }
247
+ }
admin/pages/components.php CHANGED
@@ -331,42 +331,43 @@
331
  'icon' => WCL_PLUGIN_URL . '/admin/assets/img/ctr-icon-128x128.png',
332
  'description' => __('Converts Cyrillic permalinks of post, pages, taxonomies and media files to the Latin alphabet. Supports Russian, Ukrainian, Georgian, Bulgarian languages.', 'clearfy')
333
  );
334
-
335
- $licensing = WCL_Licensing::instance();
336
- $freemius_addons_data = $licensing->getAddons(); // получаем все аддоны
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
 
338
- if( isset($freemius_addons_data->plugins) ) {
339
- foreach($freemius_addons_data->plugins as $freemius_addon) {
340
- $is_free_addon = false;
341
- if( $freemius_addon->free_releases_count ) {
342
- $is_free_addon = true;
343
- }
344
- $actual_version = isset($freemius_addon->info) ? $freemius_addon->info->selling_point_0 : '';
345
- if( !$actual_version ) {
346
- $actual_version = $licensing->getAddonCurrentVersion($freemius_addon->slug);
347
  }
348
- $component = array(
349
- 'name' => $freemius_addon->slug,
350
- 'slug' => $freemius_addon->slug,
351
- 'title' => __($freemius_addon->title, 'clearfy'),
352
- 'type' => 'freemius',
353
- 'installed' => false,
354
- 'is_free' => $is_free_addon,
355
- 'actived' => false,
356
- 'version' => $actual_version,
357
- 'url' => isset($freemius_addon->info) ? $freemius_addon->info->url : '#',
358
- 'icon' => isset($freemius_addon->icon) ? $freemius_addon->icon : WCL_PLUGIN_URL . '/admin/assets/img/ctr-icon-128x128.png',
359
- 'description' => isset($freemius_addon->info) ? __($freemius_addon->info->short_description, 'clearfy') : '',
360
- );
361
-
362
- if( in_array($component['name'], $freemius_activated_addons) ) {
363
- $component['actived'] = true;
364
- }
365
-
366
- array_unshift($response, $component);
367
  }
368
- }
369
 
 
 
370
  $components = $this->order($response);
371
 
372
  /**
331
  'icon' => WCL_PLUGIN_URL . '/admin/assets/img/ctr-icon-128x128.png',
332
  'description' => __('Converts Cyrillic permalinks of post, pages, taxonomies and media files to the Latin alphabet. Supports Russian, Ukrainian, Georgian, Bulgarian languages.', 'clearfy')
333
  );
334
+ $licensing = WCL_Licensing::instance();
335
+ $freemius_addons_data = $licensing->getAddons(); // получаем все аддоны
336
+
337
+ if( isset($freemius_addons_data->plugins) ) {
338
+ foreach($freemius_addons_data->plugins as $freemius_addon) {
339
+ $is_free_addon = false;
340
+ if( $freemius_addon->free_releases_count ) {
341
+ $is_free_addon = true;
342
+ }
343
+ $actual_version = isset($freemius_addon->info) ? $freemius_addon->info->selling_point_0 : '';
344
+ if( !$actual_version ) {
345
+ $actual_version = $licensing->getAddonCurrentVersion($freemius_addon->slug);
346
+ }
347
+ $component = array(
348
+ 'name' => $freemius_addon->slug,
349
+ 'slug' => $freemius_addon->slug,
350
+ 'title' => __($freemius_addon->title, 'clearfy'),
351
+ 'type' => 'freemius',
352
+ 'installed' => false,
353
+ 'is_free' => $is_free_addon,
354
+ 'actived' => false,
355
+ 'version' => $actual_version,
356
+ 'url' => isset($freemius_addon->info) ? $freemius_addon->info->url : '#',
357
+ 'icon' => isset($freemius_addon->icon) ? $freemius_addon->icon : WCL_PLUGIN_URL . '/admin/assets/img/ctr-icon-128x128.png',
358
+ 'description' => isset($freemius_addon->info) ? __($freemius_addon->info->short_description, 'clearfy') : '',
359
+ );
360
+
361
+ if( in_array($component['name'], $freemius_activated_addons) ) {
362
+ $component['actived'] = true;
363
+ }
364
 
365
+ array_unshift($response, $component);
 
 
 
 
 
 
 
 
366
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  }
 
368
 
369
+
370
+
371
  $components = $this->order($response);
372
 
373
  /**
admin/pages/defence.php CHANGED
@@ -1,182 +1,207 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  /**
4
- * The page Settings.
 
 
 
5
  *
6
  * @since 1.0.0
 
7
  */
 
8
 
9
- // Exit if accessed directly
10
- if( !defined('ABSPATH') ) {
11
- exit;
 
 
 
 
 
 
 
 
 
 
 
12
  }
13
 
14
- class WCL_DefencePage extends Wbcr_FactoryClearfy206_PageBase {
15
-
16
- /**
17
- * The id of the page in the admin menu.
18
- *
19
- * Mainly used to navigate between pages.
20
- * @see FactoryPages410_AdminPage
21
- *
22
- * @since 1.0.0
23
- * @var string
24
- */
25
- public $id = "defence";
26
-
27
- public $page_menu_dashicon = 'dashicons-shield-alt';
28
-
29
- public $available_for_multisite = true;
30
-
31
- /**
32
- * @param WCL_Plugin $plugin
33
- */
34
- public function __construct(WCL_Plugin $plugin)
35
- {
36
- $this->menu_title = __('Defence', 'clearfy');
37
- $this->page_menu_short_description = __('Protective hacks, privacy', 'clearfy');
38
-
39
- parent::__construct($plugin);
40
-
41
- $this->plugin = $plugin;
42
- }
43
-
44
- /**
45
- * Permalinks options.
46
- *
47
- * @since 1.0.0
48
- * @return mixed[]
49
- */
50
- public function getPageOptions()
51
- {
52
- $options = array();
53
-
54
- $options[] = array(
55
- 'type' => 'html',
56
- 'html' => '<div class="wbcr-factory-page-group-header">' . __('<strong>Base settings</strong>.', 'clearfy') . '<p>' . __('Basic recommended security settings.', 'clearfy') . '</p></div>'
57
- );
58
-
59
- $options[] = array(
60
- 'type' => 'checkbox',
61
- 'way' => 'buttons',
62
- 'name' => 'protect_author_get',
63
- 'title' => __('Hide author login', 'clearfy'),
64
- 'layout' => array('hint-type' => 'icon'),
65
- 'hint' => __('An attacker can find out the author\'s login, using a similar request to get your site. mysite.com/?author=1', 'clearfy') . '<br><b>Clearfy: </b>' . __('Sets the redirect to exclude the possibility of obtaining a login.', 'clearfy'),
66
- 'default' => false
67
- );
68
-
69
- $options[] = array(
70
- 'type' => 'checkbox',
71
- 'way' => 'buttons',
72
- 'name' => 'change_login_errors',
73
- 'title' => __('Hide errors when logging into the site', 'clearfy'),
74
- 'layout' => array('hint-type' => 'icon'),
75
- 'hint' => __('WP by default shows whether you entered a wrong login or incorrect password, which allows attackers to understand if there is a certain user on the site, and then start searching through the passwords.', 'clearfy') . '<br><b>Clearfy: </b>' . __('Changes in the text of the error so that attackers could not find the login.', 'clearfy'),
76
- 'default' => false
77
- );
78
-
79
- $options[] = array(
80
- 'type' => 'checkbox',
81
- 'way' => 'buttons',
82
- 'name' => 'remove_x_pingback',
83
- 'title' => __('Disable XML-RPC', 'clearfy'),
84
- 'layout' => array('hint-type' => 'icon'),
85
- 'hint' => __('A pingback is basically an automated comment that gets created when another blog links to you. A self-pingback is created when you link to an article within your own blog. Pingbacks are essentially nothing more than spam and simply waste resources.', 'clearfy') . '<br><b>Clearfy: </b>' . __('Removes the server responses a reference to the xmlrpc file.', 'clearfy'),
86
- 'default' => false
87
- );
88
-
89
- //block_xml_rpc
90
- //disable_xml_rpc_auth
91
- //remove_xml_rpc_tag
92
-
93
- $options[] = array(
94
- 'type' => 'html',
95
- 'html' => '<div class="wbcr-factory-page-group-header">' . __('<strong>Hide WordPress versions</strong>', 'clearfy') . '<p>' . __('WordPress itself and many plugins shows their version at the public areas of your site. An attacker received this information may be aware of the vulnerabilities found in the version of the WordPress core or plugins.', 'clearfy') . '</p></div>'
96
- );
97
-
98
- $options[] = array(
99
- 'type' => 'checkbox',
100
- 'way' => 'buttons',
101
- 'name' => 'remove_html_comments',
102
- 'title' => __('Remove html comments', 'clearfy'),
103
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
104
- 'hint' => __('This function will remove all html comments in the source code, except for special and hidden comments. This is necessary to hide the version of installed plugins.', 'clearfy') . '<br><br><b>Clearfy: </b>' . __('Remove html comments in source code.', 'clearfy'),
105
- 'default' => false
106
- );
107
-
108
- $options[] = array(
109
- 'type' => 'checkbox',
110
- 'way' => 'buttons',
111
- 'name' => 'remove_meta_generator',
112
- 'title' => __('Remove meta generator', 'clearfy') . ' <span class="wbcr-clearfy-recomended-text">(' . __('Recommended', 'clearfy') . ')</span>',
113
- 'layout' => array('hint-type' => 'icon'),
114
- 'hint' => __('Allows attacker to learn the version of WP installed on the site. This meta tag has no useful function.', 'clearfy') . '<br><b>Clearfy: </b>' . sprintf(__('Removes the meta tag from the %s section', 'clearfy'), '&lt;head&gt;'),
115
- 'default' => false
116
- );
117
-
118
- $options[] = array(
119
- 'type' => 'html',
120
- 'html' => '<div class="wbcr-clearfy-group-header">' . '<strong>' . __('Remove query strings from static resources', 'clearfy') . '</strong>' . '<p>' . __('This funcitons will remove query strings from static resources like CSS & JS files inside the HTML <head> element to improve your speed scores in services like Pingdom, GTmetrix, PageSpeed and YSlow.', 'clearfy') . '</p>' . '</div>'
121
- );
122
-
123
- $options[] = array(
124
- 'type' => 'checkbox',
125
- 'way' => 'buttons',
126
- 'name' => 'remove_js_version',
127
- 'title' => __('Remove Version from Script', 'clearfy') . ' <span class="wbcr-clearfy-recomended-text">(' . __('Recommended', 'clearfy') . ')</span>',
128
- 'layout' => array('hint-type' => 'icon'),
129
- 'hint' => __('To make it more difficult for others to hack your website you can remove the WordPress version number from your site, your css and js. Without that number it\'s not possible to see if you run not the current version to exploit bugs from the older versions. <br><br>
130
- Additionally it can improve the loading speed of your site, because without query strings in the URL the css and js files can be cached.', 'clearfy') . '<br><br><b>Clearfy: </b>' . __('Removes wordpress version number from scripts (not logged in user only).', 'clearfy'),
131
- 'default' => false
132
- );
133
-
134
- $options[] = array(
135
- 'type' => 'checkbox',
136
- 'way' => 'buttons',
137
- 'name' => 'remove_style_version',
138
- 'title' => __('Remove Version from Stylesheet', 'clearfy') . ' <span class="wbcr-clearfy-recomended-text">(' . __('Recommended', 'clearfy') . ')</span>',
139
- 'layout' => array('hint-type' => 'icon'),
140
- 'hint' => __('To make it more difficult for others to hack your website you can remove the WordPress version number from your site, your css and js. Without that number it\'s not possible to see if you run not the current version to exploit bugs from the older versions. <br><br>
141
- Additionally it can improve the loading speed of your site, because without query strings in the URL the css and js files can be cached.', 'clearfy') . '<br><br><b>Clearfy: </b>' . __('Removes the wordpress version number from stylesheets (not logged in user only).', 'clearfy'),
142
- 'default' => false
143
- /*'eventsOn' => array(
144
- 'show' => '.factory-control-disable_remove_style_version_for_auth_users'
145
- ),
146
- 'eventsOff' => array(
147
- 'hide' => '.factory-control-disable_remove_style_version_for_auth_users'
148
- )*/
149
- );
150
-
151
- $options[] = array(
152
- 'type' => 'checkbox',
153
- 'way' => 'buttons',
154
- 'name' => 'disable_remove_style_version_for_auth_users',
155
- 'title' => __('Disable remove versions for auth users', 'clearfy') . ' <span class="wbcr-clearfy-recomended-text">(' . __('Recommended', 'clearfy') . ')</span>',
156
- 'layout' => array('hint-type' => 'icon'),
157
- 'default' => false
158
- );
159
-
160
- $options[] = array(
161
- 'type' => 'textarea',
162
- 'name' => 'remove_version_exclude',
163
- 'height' => '120',
164
- 'title' => __('Exclude stylesheet/script file names', 'clearfy'),
165
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
166
- 'hint' => __('Enter Stylesheet/Script file names to exclude from version removal (each exclude file starts with a new line)', 'clearfy') . '<br><br><b>' . __('Example', 'clearfy') . ':</b>' . ' http://testwp.dev/wp-includes/js/jquery/jquery.js',
167
- );
168
-
169
- $form_options = array();
170
-
171
- $form_options[] = array(
172
- 'type' => 'form-group',
173
- 'items' => apply_filters('wbcr_clearfy_defence_form_options', $options, $this),
174
- //'cssClass' => 'postbox'
175
- );
176
-
177
- return wbcr_factory_409_apply_filters_deprecated('wbcr_clr_defence_form_options', array(
178
- $form_options,
179
- $this
180
- ), '1.3.1', 'wbcr_clearfy_defence_form_options');
181
- }
182
  }
 
1
  <?php
2
+
3
+ /**
4
+ * The page Settings.
5
+ *
6
+ * @since 1.0.0
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ class WCL_DefencePage extends Wbcr_FactoryClearfy206_PageBase {
15
 
16
  /**
17
+ * The id of the page in the admin menu.
18
+ *
19
+ * Mainly used to navigate between pages.
20
+ * @see FactoryPages410_AdminPage
21
  *
22
  * @since 1.0.0
23
+ * @var string
24
  */
25
+ public $id = "defence";
26
 
27
+ public $page_menu_dashicon = 'dashicons-shield-alt';
28
+
29
+ public $available_for_multisite = true;
30
+
31
+ /**
32
+ * @param WCL_Plugin $plugin
33
+ */
34
+ public function __construct( WCL_Plugin $plugin ) {
35
+ $this->menu_title = __( 'Defence', 'clearfy' );
36
+ $this->page_menu_short_description = __( 'Protective hacks, privacy', 'clearfy' );
37
+
38
+ parent::__construct( $plugin );
39
+
40
+ $this->plugin = $plugin;
41
  }
42
 
43
+ /**
44
+ * Permalinks options.
45
+ *
46
+ * @since 1.0.0
47
+ * @return mixed[]
48
+ */
49
+ public function getPageOptions() {
50
+ $options = array();
51
+
52
+ $options[] = array(
53
+ 'type' => 'html',
54
+ 'html' => '<div class="wbcr-factory-page-group-header">' . __( '<strong>Base settings</strong>.', 'clearfy' ) . '<p>' . __( 'Basic recommended security settings.', 'clearfy' ) . '</p></div>'
55
+ );
56
+
57
+ $options[] = array(
58
+ 'type' => 'checkbox',
59
+ 'way' => 'buttons',
60
+ 'name' => 'protect_author_get',
61
+ 'title' => __( 'Hide author login', 'clearfy' ),
62
+ 'layout' => array( 'hint-type' => 'icon' ),
63
+ 'hint' => __( 'An attacker can find out the author\'s login, using a similar request to get your site. mysite.com/?author=1', 'clearfy' ) . '<br><b>Clearfy: </b>' . __( 'Sets the redirect to exclude the possibility of obtaining a login.', 'clearfy' ),
64
+ 'default' => false
65
+ );
66
+
67
+ $options[] = array(
68
+ 'type' => 'checkbox',
69
+ 'way' => 'buttons',
70
+ 'name' => 'change_login_errors',
71
+ 'title' => __( 'Hide errors when logging into the site', 'clearfy' ),
72
+ 'layout' => array( 'hint-type' => 'icon' ),
73
+ 'hint' => __( 'WP by default shows whether you entered a wrong login or incorrect password, which allows attackers to understand if there is a certain user on the site, and then start searching through the passwords.', 'clearfy' ) . '<br><b>Clearfy: </b>' . __( 'Changes in the text of the error so that attackers could not find the login.', 'clearfy' ),
74
+ 'default' => false
75
+ );
76
+
77
+ $options[] = array(
78
+ 'type' => 'checkbox',
79
+ 'way' => 'buttons',
80
+ 'name' => 'remove_x_pingback',
81
+ 'title' => __( 'Disable XML-RPC', 'clearfy' ),
82
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
83
+ 'hint' => __( 'A pingback is basically an automated comment that gets created when another blog links to you. A self-pingback is created when you link to an article within your own blog. Pingbacks are essentially nothing more than spam and simply waste resources.', 'clearfy' ) . '<br><b>Clearfy: </b>' . __( 'Removes the server responses a reference to the xmlrpc file.', 'clearfy' ),
84
+ 'default' => false,
85
+ 'eventsOn' => array(
86
+ 'show' => '#wbcr-clearfy-xml-rpc-danger-message'
87
+ ),
88
+ 'eventsOff' => array(
89
+ 'hide' => '#wbcr-clearfy-xml-rpc-danger-message'
90
+ )
91
+ );
92
+
93
+ $options[] = array(
94
+ 'type' => 'html',
95
+ 'html' => array( $this, 'xmlRpcDangerMessage' )
96
+ );
97
+
98
+ //block_xml_rpc
99
+ //disable_xml_rpc_auth
100
+ //remove_xml_rpc_tag
101
+
102
+ $options[] = array(
103
+ 'type' => 'html',
104
+ 'html' => '<div class="wbcr-factory-page-group-header">' . __( '<strong>Hide WordPress versions</strong>', 'clearfy' ) . '<p>' . __( 'WordPress itself and many plugins shows their version at the public areas of your site. An attacker received this information may be aware of the vulnerabilities found in the version of the WordPress core or plugins.', 'clearfy' ) . '</p></div>'
105
+ );
106
+
107
+ $options[] = array(
108
+ 'type' => 'checkbox',
109
+ 'way' => 'buttons',
110
+ 'name' => 'remove_html_comments',
111
+ 'title' => __( 'Remove html comments', 'clearfy' ),
112
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
113
+ 'hint' => __( 'This function will remove all html comments in the source code, except for special and hidden comments. This is necessary to hide the version of installed plugins.', 'clearfy' ) . '<br><br><b>Clearfy: </b>' . __( 'Remove html comments in source code.', 'clearfy' ),
114
+ 'default' => false
115
+ );
116
+
117
+ $options[] = array(
118
+ 'type' => 'checkbox',
119
+ 'way' => 'buttons',
120
+ 'name' => 'remove_meta_generator',
121
+ 'title' => __( 'Remove meta generator', 'clearfy' ) . ' <span class="wbcr-clearfy-recomended-text">(' . __( 'Recommended', 'clearfy' ) . ')</span>',
122
+ 'layout' => array( 'hint-type' => 'icon' ),
123
+ 'hint' => __( 'Allows attacker to learn the version of WP installed on the site. This meta tag has no useful function.', 'clearfy' ) . '<br><b>Clearfy: </b>' . sprintf( __( 'Removes the meta tag from the %s section', 'clearfy' ), '&lt;head&gt;' ),
124
+ 'default' => false
125
+ );
126
+
127
+ $options[] = array(
128
+ 'type' => 'html',
129
+ 'html' => '<div class="wbcr-clearfy-group-header">' . '<strong>' . __( 'Remove query strings from static resources', 'clearfy' ) . '</strong>' . '<p>' . __( 'This funcitons will remove query strings from static resources like CSS & JS files inside the HTML <head> element to improve your speed scores in services like Pingdom, GTmetrix, PageSpeed and YSlow.', 'clearfy' ) . '</p>' . '</div>'
130
+ );
131
+
132
+ $options[] = array(
133
+ 'type' => 'checkbox',
134
+ 'way' => 'buttons',
135
+ 'name' => 'remove_js_version',
136
+ 'title' => __( 'Remove Version from Script', 'clearfy' ) . ' <span class="wbcr-clearfy-recomended-text">(' . __( 'Recommended', 'clearfy' ) . ')</span>',
137
+ 'layout' => array( 'hint-type' => 'icon' ),
138
+ 'hint' => __( 'To make it more difficult for others to hack your website you can remove the WordPress version number from your site, your css and js. Without that number it\'s not possible to see if you run not the current version to exploit bugs from the older versions. <br><br>
139
+ Additionally it can improve the loading speed of your site, because without query strings in the URL the css and js files can be cached.', 'clearfy' ) . '<br><br><b>Clearfy: </b>' . __( 'Removes wordpress version number from scripts (not logged in user only).', 'clearfy' ),
140
+ 'default' => false
141
+ );
142
+
143
+ $options[] = array(
144
+ 'type' => 'checkbox',
145
+ 'way' => 'buttons',
146
+ 'name' => 'remove_style_version',
147
+ 'title' => __( 'Remove Version from Stylesheet', 'clearfy' ) . ' <span class="wbcr-clearfy-recomended-text">(' . __( 'Recommended', 'clearfy' ) . ')</span>',
148
+ 'layout' => array( 'hint-type' => 'icon' ),
149
+ 'hint' => __( 'To make it more difficult for others to hack your website you can remove the WordPress version number from your site, your css and js. Without that number it\'s not possible to see if you run not the current version to exploit bugs from the older versions. <br><br>
150
+ Additionally it can improve the loading speed of your site, because without query strings in the URL the css and js files can be cached.', 'clearfy' ) . '<br><br><b>Clearfy: </b>' . __( 'Removes the wordpress version number from stylesheets (not logged in user only).', 'clearfy' ),
151
+ 'default' => false
152
+ /*'eventsOn' => array(
153
+ 'show' => '.factory-control-disable_remove_style_version_for_auth_users'
154
+ ),
155
+ 'eventsOff' => array(
156
+ 'hide' => '.factory-control-disable_remove_style_version_for_auth_users'
157
+ )*/
158
+ );
159
+
160
+ $options[] = array(
161
+ 'type' => 'checkbox',
162
+ 'way' => 'buttons',
163
+ 'name' => 'disable_remove_style_version_for_auth_users',
164
+ 'title' => __( 'Disable remove versions for auth users', 'clearfy' ) . ' <span class="wbcr-clearfy-recomended-text">(' . __( 'Recommended', 'clearfy' ) . ')</span>',
165
+ 'layout' => array( 'hint-type' => 'icon' ),
166
+ 'default' => false
167
+ );
168
+
169
+ $options[] = array(
170
+ 'type' => 'textarea',
171
+ 'name' => 'remove_version_exclude',
172
+ 'height' => '120',
173
+ 'title' => __( 'Exclude stylesheet/script file names', 'clearfy' ),
174
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
175
+ 'hint' => __( 'Enter Stylesheet/Script file names to exclude from version removal (each exclude file starts with a new line)', 'clearfy' ) . '<br><br><b>' . __( 'Example', 'clearfy' ) . ':</b>' . ' http://testwp.dev/wp-includes/js/jquery/jquery.js',
176
+ );
177
+
178
+ $form_options = array();
179
+
180
+ $form_options[] = array(
181
+ 'type' => 'form-group',
182
+ 'items' => apply_filters( 'wbcr_clearfy_defence_form_options', $options, $this ),
183
+ //'cssClass' => 'postbox'
184
+ );
185
+
186
+ return wbcr_factory_409_apply_filters_deprecated( 'wbcr_clr_defence_form_options', array(
187
+ $form_options,
188
+ $this
189
+ ), '1.3.1', 'wbcr_clearfy_defence_form_options' );
190
+ }
191
+
192
+ /**
193
+ * Adds an html warning notification html markup.
194
+ */
195
+ public function xmlRpcDangerMessage() {
196
+ ?>
197
+ <div class="form-group">
198
+ <label class="col-sm-4 control-label"></label>
199
+ <div class="control-group col-sm-8">
200
+ <div id="wbcr-clearfy-xml-rpc-danger-message" class="wbcr-clearfy-danger-message">
201
+ <?php _e( '<b>Use this option carefully!</b><br> Plugins like jetpack may have problems using this option.', 'clearfy' ) ?>
202
+ </div>
203
+ </div>
204
+ </div>
205
+ <?php
 
 
 
 
 
206
  }
207
+ }
admin/pages/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
admin/pages/license.php CHANGED
@@ -1,295 +1,270 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /**
3
- * The page License page class.
 
 
 
4
  *
5
  * @since 1.0.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  */
 
 
 
 
 
 
 
 
7
 
8
- // Exit if accessed directly
9
- if( !defined('ABSPATH') ) {
10
- exit;
 
 
 
 
 
11
  }
12
 
13
- class WCL_LicensePage extends Wbcr_FactoryClearfy206_PageBase {
14
-
15
- /**
16
- * The id of the page in the admin menu.
17
- *
18
- * Mainly used to navigate between pages.
19
- * @see Wbcr_FactoryPages410_AdminPage
20
- *
21
- * @since 1.0.0
22
- * @var string
23
- */
24
- public $id = "license";
25
-
26
- /**
27
- * Тип страницы - произвольный контент
28
- * @var string
29
- */
30
- public $type = "page";
31
-
32
- /**
33
- * Иконка страницы
34
- * Полный список иконок смотреть тут:
35
- * https://developer.wordpress.org/resource/dashicons/#admin-network
36
- * @var string
37
- */
38
- public $page_menu_dashicon = 'dashicons-admin-network';
39
-
40
- /**
41
- * Показывать правый сайдбар?
42
- * Сайдбар будет показан на внутренних страницах шаблона.
43
- *
44
- * @var bool
45
- */
46
- public $show_right_sidebar_in_options = false;
47
-
48
- /**
49
- * Позиция закладки в меню плагина.
50
- * 0 - в самом конце, 100 - в самом начале
51
- * @var int
52
- */
53
- public $page_menu_position = 0;
54
-
55
- public $available_for_multisite = true;
56
-
57
- /**
58
- * @param WCL_Plugin $plugin
59
- */
60
- public function __construct(WCL_Plugin $plugin)
61
- {
62
- $this->menu_title = __('License', 'clearfy');
63
- $this->page_menu_short_description = __('Product activation', 'clearfy');
64
-
65
- parent::__construct($plugin);
66
-
67
- $this->plugin = $plugin;
68
- }
69
-
70
- /**
71
- * [MAGIC] Magic method that configures assets for a page.
72
- */
73
- public function assets($scripts, $styles)
74
- {
75
- parent::assets($scripts, $styles);
76
-
77
- $this->styles->add(WCL_PLUGIN_URL . '/admin/assets/css/license-manager.css');
78
- $this->scripts->add(WCL_PLUGIN_URL . '/admin/assets/js/license-manager.js');
79
- }
80
-
81
- /**
82
- * Метод печатает html содержимое страницы
83
- * @return void
84
- */
85
- public function showPageContent()
86
- {
87
- ?>
88
- <?php wp_nonce_field('license'); ?>
89
- <div id="wcl-license-wrapper" data-loader="<?php echo WCL_PLUGIN_URL . '/admin/assets/img/loader.gif'; ?>">
90
- <?php $this->showLicenseForm(); ?>
91
- </div>
92
-
93
  <?php
94
- }
 
 
 
 
 
 
95
 
96
- public function showLicenseForm($notice = false)
97
- {
98
- $licensing = WCL_Licensing::instance();
99
- $storage = $licensing->getStorage();
100
- $license = $storage->get('license');
101
- // Тип лицензии, цветовое оформление для формы лицензирования
102
- // free - бесплатная
103
- // gift - пожизненная лицензия, лицензия на особых условиях
104
- // trial - красный цвет, применяется для триалов, если лиценизия истекла или заблокирована
105
- // paid - обычная оплаченная лицензия, в данный момент активна.
106
- $license_type = 'free';
107
- // Лицензионный ключ
108
- $license_key = '';
109
- // Тарифный план
110
- $plan = 'free';
111
- $premium = false;
112
- $has_key = false;
113
- // Сколько осталось дней до истечения лицензии
114
- $remained = 999;
115
- $subscribe = false;
116
- if( isset($license->id) ) {
117
- $subscribe = true;
118
- $license_type = 'paid';
119
- $activated = $license->activated;
120
- $quota = $license->quota;
121
- // Лицензионный ключ
122
- $license_key = substr_replace($license->secret_key, '******', 15, 6);
123
- // Тарифный план
124
- $plan = $license->plan_title;
125
- $premium = true;
126
- $has_key = true;
127
- // Сколько осталось дней до истечения лицензии
128
- $remained = $license->remainingDays();
129
- if( 1 == $license->billing_cycle ) {
130
- $billing = 'month';
131
- }
132
- if( 12 == $license->billing_cycle ) {
133
- $billing = 'year';
134
- }
135
- if( 0 == $license->billing_cycle ) {
136
- $billing = 'lifetime';
137
- }
138
- if( $license->is_lifetime() ) {
139
- $billing = 'lifetime';
140
- $license_type = 'gift';
141
- $quota = 999;
142
- }
143
- if( is_null($license->billing_cycle) ) {
144
- $billing = 'month';
145
- $subscribe = false;
146
- }
147
  }
148
 
149
- if( $remained < 1 ) {
150
- $license_type = 'trial';
151
  }
152
-
153
- ?>
154
- <div class="factory-bootstrap-409 onp-page-wrap <?= $license_type ?>-license-manager-content" id="license-manager">
155
- <div>
156
- <h3><?php _e('Activation Clearfy Business', 'clearfy') ?></h3>
157
-
158
- <p style="font-size: 16px;"><?php _e('<b>Clearfy Business</b> is a paid package of components for the popular free WordPress plugin named Clearfy. You get access to all paid components at one price.', 'clearfy')?></p>
159
-
160
- <p style="font-size: 16px;"><?php _e('Paid license guarantees that you can download and update existing and future paid components of the plugin.', 'clearfy')?></p>
161
- </div>
162
- <br>
163
- <?php if( is_wp_error($notice) ) : ?>
164
- <div class="license-message <?= $license_type ?>-license-message">
165
- <div class="alert <?php echo esc_attr($notice->get_error_code()); ?>">
166
- <h4 class="alert-heading"><?php _e($notice->get_error_message(), 'clearfy') ?></h4>
167
- </div>
168
- </div>
169
- <?php endif; ?>
170
-
171
- <div class="onp-container">
172
- <div class="license-details">
173
- <?php if( $license_type == 'free' ): ?>
174
- <a href="<?= WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl(WCL_Plugin::app()->getPluginName(), 'pricing', 'license_page') ?>" class="purchase-premium" target="_blank" rel="noopener">
 
 
 
 
 
 
 
 
 
 
175
  <span class="btn btn-gold btn-inner-wrap">
176
- <i class="fa fa-star"></i> <?php printf(__('Upgrade to Premium for $%s', 'clearfy'), WbcrFactoryClearfy206_Helpers::getClearfyBusinessPrice()) ?>
177
  <i class="fa fa-star"></i>
178
  </span>
179
- </a>
180
-
181
- <p><?php printf(__('Your current license for %1$s:', 'clearfy'), $this->plugin->getPluginTitle()) ?></p>
182
- <?php endif; ?>
183
-
184
- <div class="license-details-block <?= $license_type ?>-details-block">
185
- <?php if( $has_key ) { ?>
186
- <a data-action="deactivate" href="#" class="btn btn-default btn-small license-delete-button wcl-control-btn"><i class="icon-remove-sign"></i> <?php _e('Delete Key', 'clearfy') ?>
187
- </a>
188
- <a data-action="sync" href="#" class="btn btn-default btn-small license-synchronization-button wcl-control-btn"><i class="icon-remove-sign"></i> <?php _e('Synchronization', 'clearfy') ?>
189
- </a>
190
- <?php } ?>
191
-
192
- <h3>
193
- <?= ucfirst($plan); ?>
194
- <?php if( $premium and $subscribe ) { ?>
195
- <span style="font-size: 15px;"><?php printf(__('(Automatic renewal, every %s', ''), esc_attr($billing)); ?>
196
  )</span>
197
- <?php } ?>
198
- </h3>
199
-
200
- <?php if( $has_key ) { ?>
201
- <div class="license-key-identity"><code><?= esc_attr($license_key) ?></code></div>
202
  <?php } ?>
203
-
204
- <div class="license-key-description">
205
- <p><?php _e('Public License is a GPLv2 compatible license allowing you to change and use this version of the plugin for free. Please keep in mind this license covers only free edition of the plugin. Premium versions are distributed with other type of a license.', 'clearfy') ?>
206
- </p>
207
- <?php if( $premium and $subscribe and $license->billing_cycle ) { ?>
208
- <p class="activate-trial-hint">
209
- <?php _e('You use a paid subscription for the plugin updates. In case you don’t want to receive paid updates, please, click <a data-action="unsubscribe" class="wcl-control-btn" href="#">cancel subscription</a>', 'clearfy') ?>
210
- </p>
211
- <?php } ?>
212
- <?php if( $remained < 1 ) { ?>
213
- <p class="activate-error-hint">
214
- <?php printf(__('Your license has expired, please extend the license to get updates and support.', 'clearfy'), '') ?>
215
- </p>
216
- <?php } ?>
217
- </div>
218
- <table class="license-params" colspacing="0" colpadding="0">
219
- <tr>
220
- <!--<td class="license-param license-param-domain">
221
- <span class="license-value"><?php echo esc_attr($_SERVER['SERVER_NAME']); ?></span>
222
- <span class="license-value-name"><?php _e('domain', 'clearfy') ?></span>
 
 
 
223
  </td>-->
224
- <td class="license-param license-param-days">
225
- <span class="license-value"><?= $plan ?></span>
226
- <span class="license-value-name"><?php _e('plan', 'clearfy') ?></span>
227
- </td>
228
- <?php if( $premium ) : ?>
229
- <td class="license-param license-param-sites">
230
- <span class="license-value"><?php echo esc_attr($activated); ?> <?php _e('of', 'clearfy') ?> <?php echo esc_attr($quota); ?></span>
231
- <span class="license-value-name"><?php _e('active sites', 'clearfy') ?></span>
232
- </td>
233
- <?php endif; ?>
234
- <td class="license-param license-param-version">
235
  <span class="license-value"><?= $this->plugin->getPluginVersion() ?>
236
- <small><?php _e('version', 'clearfy') ?></small></span>
237
- <span class="license-value-name"><span><?php _e('up-to-date', 'clearfy') ?></span></span>
238
- </td>
239
- <?php if( $premium ) { ?>
240
- <td class="license-param license-param-days">
241
- <?php if( $remained < 1 ) { ?>
242
- <span class="license-value"><?php _e('EXPIRED!', 'clearfy') ?></span>
243
- <span class="license-value-name"><?php _e('please update the key', 'clearfy') ?></span>
244
- <?php } else { ?>
245
- <span class="license-value">
246
  <?php
247
- if( $billing == 'lifetime' ) {
248
- $remained = 'infiniate';
249
- }
250
  ?>
251
- <?= $remained ?>
252
- <small> <?php _e('day(s)', 'clearfy') ?></small>
253
  </span>
254
- <span class="license-value-name"><?php _e('remained', 'clearfy') ?></span>
255
- <?php } ?>
256
- </td>
257
- <?php } ?>
258
- </tr>
259
- </table>
260
- </div>
261
- </div>
262
- <div class="license-input">
263
- <form action="" method="post">
264
- <?php if ($premium) { ?>
265
- <p><?php _e('Have a key to activate the premium version? Paste it here:', 'clearfy') ?><p>
266
- <?php } else { ?>
267
- <p><?php _e('Have a key to activate the plugin? Paste it here:', 'clearfy') ?>
268
-
269
- <p>
270
  <?php } ?>
271
-
272
- <button data-action="activate" class="btn btn-default wcl-control-btn" type="button" id="license-submit">
273
- <?php _e('Submit Key', 'clearfy') ?>
274
- </button>
275
- <div class="license-key-wrap">
276
- <input type="text" id="license-key" name="licensekey" value="" class="form-control"/>
277
- </div>
278
-
279
- <?php if( $premium ) { ?>
280
- <p style="margin-top: 10px;">
281
- <?php printf(__('<a href="%s" target="_blank" rel="noopener">Lean more</a> about the premium version and get the license key to activate it now!', 'clearfy'), WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl(WCL_Plugin::app()->getPluginName(), 'pricing', 'license_page')) ?>
282
- </p>
283
- <?php } else { ?>
284
- <p style="margin-top: 10px;">
285
- <?php printf(__('Can’t find your key? Go to <a href="%s" target="_blank" rel="noopener">this page</a> and login using the e-mail address associated with your purchase.', 'clearfy'), WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl(WCL_Plugin::app()->getPluginName(), 'contact-us', 'license_page')) ?>
286
- </p>
287
  <?php } ?>
288
- </form>
289
- </div>
290
- </div>
291
- </div>
292
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  <?php
294
- }
295
  }
 
1
  <?php
2
+ /**
3
+ * The page License page class.
4
+ *
5
+ * @since 1.0.0
6
+ */
7
+
8
+ // Exit if accessed directly
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class WCL_LicensePage extends Wbcr_FactoryClearfy206_PageBase {
14
+
15
  /**
16
+ * The id of the page in the admin menu.
17
+ *
18
+ * Mainly used to navigate between pages.
19
+ * @see Wbcr_FactoryPages410_AdminPage
20
  *
21
  * @since 1.0.0
22
+ * @var string
23
+ */
24
+ public $id = "license";
25
+
26
+ /**
27
+ * Тип страницы - произвольный контент
28
+ * @var string
29
+ */
30
+ public $type = "page";
31
+
32
+ /**
33
+ * Иконка страницы
34
+ * Полный список иконок смотреть тут:
35
+ * https://developer.wordpress.org/resource/dashicons/#admin-network
36
+ * @var string
37
+ */
38
+ public $page_menu_dashicon = 'dashicons-admin-network';
39
+
40
+ /**
41
+ * Показывать правый сайдбар?
42
+ * Сайдбар будет показан на внутренних страницах шаблона.
43
+ *
44
+ * @var bool
45
+ */
46
+ public $show_right_sidebar_in_options = false;
47
+
48
+ /**
49
+ * Позиция закладки в меню плагина.
50
+ * 0 - в самом конце, 100 - в самом начале
51
+ * @var int
52
+ */
53
+ public $page_menu_position = 0;
54
+
55
+ public $available_for_multisite = true;
56
+
57
+ /**
58
+ * @param WCL_Plugin $plugin
59
  */
60
+ public function __construct( WCL_Plugin $plugin ) {
61
+ $this->menu_title = __( 'License', 'clearfy' );
62
+ $this->page_menu_short_description = __( 'Product activation', 'clearfy' );
63
+
64
+ parent::__construct( $plugin );
65
+
66
+ $this->plugin = $plugin;
67
+ }
68
 
69
+ /**
70
+ * [MAGIC] Magic method that configures assets for a page.
71
+ */
72
+ public function assets( $scripts, $styles ) {
73
+ parent::assets( $scripts, $styles );
74
+
75
+ $this->styles->add( WCL_PLUGIN_URL . '/admin/assets/css/license-manager.css' );
76
+ $this->scripts->add( WCL_PLUGIN_URL . '/admin/assets/js/license-manager.js' );
77
  }
78
 
79
+ /**
80
+ * Метод печатает html содержимое страницы
81
+ * @return void
82
+ */
83
+ public function showPageContent() {
84
+ ?>
85
+ <?php wp_nonce_field( 'license' ); ?>
86
+ <div id="wcl-license-wrapper" data-loader="<?php echo WCL_PLUGIN_URL . '/admin/assets/img/loader.gif'; ?>">
87
+ <?php $this->showLicenseForm(); ?>
88
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  <?php
90
+ }
91
+
92
+ public function showLicenseForm() {
93
+
94
+ $licensing = WCL_Licensing::instance();
95
+ $storage = $licensing->getStorage();
96
+ $license = $storage->getLicense();
97
 
98
+ $license_type = 'free';
99
+ $license_key = '';
100
+ $plan = 'free';
101
+ $premium = false;
102
+ $has_key = false;
103
+
104
+ $remained = 999;
105
+ $subscribe = false;
106
+
107
+ if ( isset( $license->id ) ) {
108
+ $subscribe = true;
109
+ $license_type = 'paid';
110
+ $activated = $license->activated;
111
+ $quota = $license->quota;
112
+ $license_key = substr_replace( $license->secret_key, '******', 15, 6 );
113
+ $plan = $license->plan_title;
114
+ $premium = true;
115
+ $has_key = true;
116
+
117
+ $remained = $license->remainingDays();
118
+
119
+ if ( 1 == $license->billing_cycle ) {
120
+ $billing = 'month';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  }
122
 
123
+ if ( 12 == $license->billing_cycle ) {
124
+ $billing = 'year';
125
  }
126
+
127
+ if ( 0 == $license->billing_cycle ) {
128
+ $billing = 'lifetime';
129
+ }
130
+
131
+ if ( $license->is_lifetime() ) {
132
+ $billing = 'lifetime';
133
+ $license_type = 'gift';
134
+ $quota = 999;
135
+ }
136
+
137
+ if ( is_null( $license->billing_cycle ) ) {
138
+ $billing = 'month';
139
+ $subscribe = false;
140
+ }
141
+ }
142
+
143
+ if ( $remained < 1 ) {
144
+ $license_type = 'trial';
145
+ }
146
+
147
+ ?>
148
+ <div class="factory-bootstrap-409 onp-page-wrap <?= $license_type ?>-license-manager-content" id="license-manager">
149
+ <div>
150
+ <h3><?php _e( 'Activation Clearfy Business', 'clearfy' ) ?></h3>
151
+ <p style="font-size: 16px;"><?php _e( '<b>Clearfy Business</b> is a paid package of components for the popular free WordPress plugin named Clearfy. You get access to all paid components at one price.', 'clearfy' ) ?></p>
152
+ <p style="font-size: 16px;"><?php _e( 'Paid license guarantees that you can download and update existing and future paid components of the plugin.', 'clearfy' ) ?></p>
153
+ </div>
154
+ <br>
155
+ <div class="onp-container">
156
+ <div class="license-details">
157
+ <?php if ( $license_type == 'free' ): ?>
158
+ <a href="<?= WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl( WCL_Plugin::app()->getPluginName(), 'pricing', 'license_page' ) ?>" class="purchase-premium" target="_blank" rel="noopener">
159
  <span class="btn btn-gold btn-inner-wrap">
160
+ <i class="fa fa-star"></i> <?php printf( __( 'Upgrade to Premium for $%s', 'clearfy' ), WbcrFactoryClearfy206_Helpers::getClearfyBusinessPrice() ) ?>
161
  <i class="fa fa-star"></i>
162
  </span>
163
+ </a>
164
+ <p><?php printf( __( 'Your current license for %1$s:', 'clearfy' ), $this->plugin->getPluginTitle() ) ?></p>
165
+ <?php endif; ?>
166
+ <div class="license-details-block <?= $license_type ?>-details-block">
167
+ <?php if ( $has_key ) { ?>
168
+ <a data-action="deactivate" href="#" class="btn btn-default btn-small license-delete-button wcl-control-btn"><i class="icon-remove-sign"></i> <?php _e( 'Delete Key', 'clearfy' ) ?>
169
+ </a>
170
+ <a data-action="sync" href="#" class="btn btn-default btn-small license-synchronization-button wcl-control-btn"><i class="icon-remove-sign"></i> <?php _e( 'Synchronization', 'clearfy' ) ?>
171
+ </a>
172
+ <?php } ?>
173
+ <h3>
174
+ <?= ucfirst( $plan ); ?>
175
+ <?php if ( $premium and $subscribe ) { ?>
176
+ <span style="font-size: 15px;"><?php printf( __( '(Automatic renewal, every %s', '' ), esc_attr( $billing ) ); ?>
 
 
 
177
  )</span>
 
 
 
 
 
178
  <?php } ?>
179
+ </h3>
180
+ <?php if ( $has_key ) { ?>
181
+ <div class="license-key-identity"><code><?= esc_attr( $license_key ) ?></code></div>
182
+ <?php } ?>
183
+ <div class="license-key-description">
184
+ <p><?php _e( 'Public License is a GPLv2 compatible license allowing you to change and use this version of the plugin for free. Please keep in mind this license covers only free edition of the plugin. Premium versions are distributed with other type of a license.', 'clearfy' ) ?>
185
+ </p>
186
+ <?php if ( $premium and $subscribe and $license->billing_cycle ) { ?>
187
+ <p class="activate-trial-hint">
188
+ <?php _e( 'You use a paid subscription for the plugin updates. In case you don’t want to receive paid updates, please, click <a data-action="unsubscribe" class="wcl-control-btn" href="#">cancel subscription</a>', 'clearfy' ) ?>
189
+ </p>
190
+ <?php } ?>
191
+ <?php if ( $remained < 1 ) { ?>
192
+ <p class="activate-error-hint">
193
+ <?php printf( __( 'Your license has expired, please extend the license to get updates and support.', 'clearfy' ), '' ) ?>
194
+ </p>
195
+ <?php } ?>
196
+ </div>
197
+ <table class="license-params" colspacing="0" colpadding="0">
198
+ <tr>
199
+ <!--<td class="license-param license-param-domain">
200
+ <span class="license-value"><?php echo esc_attr( $_SERVER['SERVER_NAME'] ); ?></span>
201
+ <span class="license-value-name"><?php _e( 'domain', 'clearfy' ) ?></span>
202
  </td>-->
203
+ <td class="license-param license-param-days">
204
+ <span class="license-value"><?= $plan ?></span>
205
+ <span class="license-value-name"><?php _e( 'plan', 'clearfy' ) ?></span>
206
+ </td>
207
+ <?php if ( $premium ) : ?>
208
+ <td class="license-param license-param-sites">
209
+ <span class="license-value"><?php echo esc_attr( $activated ); ?>&nbsp;<?php _e( 'of', 'clearfy' ) ?>&nbsp;<?php echo esc_attr( $quota ); ?></span>
210
+ <span class="license-value-name"><?php _e( 'active sites', 'clearfy' ) ?></span>
211
+ </td>
212
+ <?php endif; ?>
213
+ <td class="license-param license-param-version">
214
  <span class="license-value"><?= $this->plugin->getPluginVersion() ?>
215
+ <small><?php _e( 'version', 'clearfy' ) ?></small></span>
216
+ <span class="license-value-name"><span><?php _e( 'up-to-date', 'clearfy' ) ?></span></span>
217
+ </td>
218
+ <?php if ( $premium ) { ?>
219
+ <td class="license-param license-param-days">
220
+ <?php if ( $remained < 1 ) { ?>
221
+ <span class="license-value"><?php _e( 'EXPIRED!', 'clearfy' ) ?></span>
222
+ <span class="license-value-name"><?php _e( 'please update the key', 'clearfy' ) ?></span>
223
+ <?php } else { ?>
224
+ <span class="license-value">
225
  <?php
226
+ if ( $billing == 'lifetime' ) {
227
+ $remained = 'infiniate';
228
+ }
229
  ?>
230
+ <?= $remained ?>
231
+ <small> <?php _e( 'day(s)', 'clearfy' ) ?></small>
232
  </span>
233
+ <span class="license-value-name"><?php _e( 'remained', 'clearfy' ) ?></span>
234
+ <?php } ?>
235
+ </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  <?php } ?>
237
+ </tr>
238
+ </table>
239
+ </div>
240
+ </div>
241
+ <div class="license-input">
242
+ <form action="" method="post">
243
+ <?php if ( $premium ) { ?>
244
+ <p><?php _e( 'Have a key to activate the premium version? Paste it here:', 'clearfy' ) ?><p>
245
+ <?php } else { ?>
246
+ <p><?php _e( 'Have a key to activate the plugin? Paste it here:', 'clearfy' ) ?>
247
+ <p>
 
 
 
 
 
248
  <?php } ?>
249
+ <button data-action="activate" class="btn btn-default wcl-control-btn" type="button" id="license-submit">
250
+ <?php _e( 'Submit Key', 'clearfy' ) ?>
251
+ </button>
252
+ <div class="license-key-wrap">
253
+ <input type="text" id="license-key" name="licensekey" value="" class="form-control"/>
254
+ </div>
255
+ <?php if ( $premium ) { ?>
256
+ <p style="margin-top: 10px;">
257
+ <?php printf( __( '<a href="%s" target="_blank" rel="noopener">Lean more</a> about the premium version and get the license key to activate it now!', 'clearfy' ), WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl( WCL_Plugin::app()->getPluginName(), 'pricing', 'license_page' ) ) ?>
258
+ </p>
259
+ <?php } else { ?>
260
+ <p style="margin-top: 10px;">
261
+ <?php printf( __( 'Can’t find your key? Go to <a href="%s" target="_blank" rel="noopener">this page</a> and login using the e-mail address associated with your purchase.', 'clearfy' ), WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl( WCL_Plugin::app()->getPluginName(), 'contact-us', 'license_page' ) ) ?>
262
+ </p>
263
+ <?php } ?>
264
+ </form>
265
+ </div>
266
+ </div>
267
+ </div>
268
  <?php
 
269
  }
270
+ }
admin/pages/performance.php CHANGED
@@ -110,6 +110,17 @@
110
  'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'red'),
111
  'hint' => __('The WordPress REST API provides API endpoints for WordPress data types that allow developers to interact with sites remotely by sending and receiving JSON (JavaScript Object Notation) objects. However, a lot of sites don’t use this, and therefore in most cases, it is just unnecessary code.', 'clearfy') . '<br><br><b>Clearfy: </b>' . __('Removes REST API link tag from the front end and the REST API header link from page requests.', 'clearfy'),
112
  'default' => false,
 
 
 
 
 
 
 
 
 
 
 
113
  );
114
 
115
  $options[] = array(
@@ -254,4 +265,20 @@ In particular, the profile is used for the XFN microformat (XHTML Friends Networ
254
 
255
  return apply_filters('wbcr_clr_code_clean_form_options', $form_options, $this);
256
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  }
110
  'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'red'),
111
  'hint' => __('The WordPress REST API provides API endpoints for WordPress data types that allow developers to interact with sites remotely by sending and receiving JSON (JavaScript Object Notation) objects. However, a lot of sites don’t use this, and therefore in most cases, it is just unnecessary code.', 'clearfy') . '<br><br><b>Clearfy: </b>' . __('Removes REST API link tag from the front end and the REST API header link from page requests.', 'clearfy'),
112
  'default' => false,
113
+ 'eventsOn' => array(
114
+ 'show' => '#wbcr-clearfy-rest-api-danger-message'
115
+ ),
116
+ 'eventsOff' => array(
117
+ 'hide' => '#wbcr-clearfy-rest-api-danger-message'
118
+ )
119
+ );
120
+
121
+ $options[] = array(
122
+ 'type' => 'html',
123
+ 'html' => array( $this, 'restApiDangerMessage' )
124
  );
125
 
126
  $options[] = array(
265
 
266
  return apply_filters('wbcr_clr_code_clean_form_options', $form_options, $this);
267
  }
268
+
269
+ /**
270
+ * Adds an html warning notification html markup.
271
+ */
272
+ public function restApiDangerMessage() {
273
+ ?>
274
+ <div class="form-group">
275
+ <label class="col-sm-4 control-label"></label>
276
+ <div class="control-group col-sm-8">
277
+ <div id="wbcr-clearfy-rest-api-danger-message" class="wbcr-clearfy-danger-message">
278
+ <?php _e( '<b>Use this option carefully!</b><br> Plugins like Contact form 7 may have problems using this option.', 'clearfy' ) ?>
279
+ </div>
280
+ </div>
281
+ </div>
282
+ <?php
283
+ }
284
  }
assets/css/admin-bar.css CHANGED
@@ -1,39 +1,47 @@
1
- /**
2
- * Admin bar menu
3
- * @author Webcraftic <wordpress.webraftic@gmail.com>
4
- * @copyright Webcraftic 01.07.2018
5
- */
6
- #wp-admin-bar-clearfy-menu {
7
- background: #443a54 !important;
8
- }
9
- #wp-admin-bar-clearfy-menu .dashicons {
10
- font: 400 20px/1 dashicons;
11
- }
12
- #wp-admin-bar-clearfy-menu #wp-admin-bar-clearfy-menu-default {
13
- background: #565656 !important;
14
- }
15
- #wp-admin-bar-clearfy-menu .wbcr-clearfy-admin-bar-menu-icon {
16
- display: inline-block !important;
17
- width: 20px;
18
- height: 25px;
19
- margin-right: 5px;
20
- background: url(../img/webcraftic-plugin-icon.png) 0 0 no-repeat;
21
- }
22
- #wp-admin-bar-clearfy-menu .wbcr-clearfy-admin-bar-menu-title {
23
- display: inline-block !important;
24
- overflow: hidden;
25
- }
26
- #wp-admin-bar-clearfy-menu .wbcr-clearfy-admin-bar-menu-title .dashicons {
27
- font-size: 20px !important;
28
- padding: 6px 0 !important;
29
- }
30
- #wp-admin-bar-clearfy-menu .ab-item .dashicons {
31
- font-size: 14px;
32
- padding: 6px 0;
33
- }
34
- #wp-admin-bar-clearfy-menu .ab-item .dashicons.dashicons-heart {
35
- color: #fb7976;
36
- }
37
- #wp-admin-bar-clearfy-menu .ab-item .dashicons.dashicons-star-filled {
38
- color: #ffbe00;
39
- }
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Admin bar menu
3
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
4
+ * @copyright Webcraftic 01.07.2018
5
+ */
6
+ #wp-admin-bar-clearfy-menu {
7
+ background: #443a54 !important;
8
+ }
9
+ #wp-admin-bar-clearfy-menu::after {
10
+ clear: both;
11
+ }
12
+ #wp-admin-bar-clearfy-menu .dashicons {
13
+ font: 400 20px/1 dashicons;
14
+ }
15
+ #wp-admin-bar-clearfy-menu #wp-admin-bar-clearfy-menu-default {
16
+ background: #565656 !important;
17
+ }
18
+ #wp-admin-bar-clearfy-menu .wbcr-clearfy-admin-bar-menu-icon {
19
+ display: inline-block !important;
20
+ width: 20px;
21
+ height: 25px;
22
+ margin-top: 6px;
23
+ margin-right: 5px;
24
+ float: left;
25
+ background: url(../img/webcraftic-plugin-icon.png) 0 0 no-repeat;
26
+ }
27
+ #wp-admin-bar-clearfy-menu .wbcr-clearfy-admin-bar-menu-title {
28
+ display: inline-block !important;
29
+ overflow: hidden;
30
+ }
31
+ #wp-admin-bar-clearfy-menu .wbcr-clearfy-admin-bar-menu-title .dashicons {
32
+ font-size: 20px !important;
33
+ padding: 6px 0 !important;
34
+ }
35
+ #wp-admin-bar-clearfy-menu .ab-item .dashicons {
36
+ font-size: 14px;
37
+ padding: 6px 0;
38
+ }
39
+ #wp-admin-bar-clearfy-menu .ab-item .dashicons.dashicons-heart {
40
+ color: #fb7976;
41
+ }
42
+ #wp-admin-bar-clearfy-menu .ab-item .dashicons.dashicons-sos {
43
+ color: #c6e9f9;
44
+ }
45
+ #wp-admin-bar-clearfy-menu .ab-item .dashicons.dashicons-star-filled {
46
+ color: #ffbe00;
47
+ }
assets/css/admin-bar.less CHANGED
@@ -5,6 +5,10 @@
5
  */
6
 
7
  #wp-admin-bar-clearfy-menu {
 
 
 
 
8
  .dashicons {
9
  font: 400 20px/1 dashicons;
10
  }
@@ -14,13 +18,17 @@
14
  #wp-admin-bar-clearfy-menu-default {
15
  background: #565656 !important;
16
  }
 
17
  .wbcr-clearfy-admin-bar-menu-icon {
18
  display: inline-block !important;
19
  width: 20px;
20
  height: 25px;
 
21
  margin-right: 5px;
 
22
  background: url(../img/webcraftic-plugin-icon.png) 0 0 no-repeat;
23
  }
 
24
  .wbcr-clearfy-admin-bar-menu-title {
25
  display: inline-block !important;
26
  overflow: hidden;
@@ -40,6 +48,10 @@
40
  color: #fb7976;
41
  }
42
 
 
 
 
 
43
  &.dashicons-star-filled {
44
  color: #ffbe00;
45
  }
5
  */
6
 
7
  #wp-admin-bar-clearfy-menu {
8
+ &::after {
9
+ clear: both;
10
+ }
11
+
12
  .dashicons {
13
  font: 400 20px/1 dashicons;
14
  }
18
  #wp-admin-bar-clearfy-menu-default {
19
  background: #565656 !important;
20
  }
21
+
22
  .wbcr-clearfy-admin-bar-menu-icon {
23
  display: inline-block !important;
24
  width: 20px;
25
  height: 25px;
26
+ margin-top: 6px;
27
  margin-right: 5px;
28
+ float: left;
29
  background: url(../img/webcraftic-plugin-icon.png) 0 0 no-repeat;
30
  }
31
+
32
  .wbcr-clearfy-admin-bar-menu-title {
33
  display: inline-block !important;
34
  overflow: hidden;
48
  color: #fb7976;
49
  }
50
 
51
+ &.dashicons-sos {
52
+ color: #c6e9f9;
53
+ }
54
+
55
  &.dashicons-star-filled {
56
  color: #ffbe00;
57
  }
assets/css/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
assets/img/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
assets/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
assets/js/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
clearfy.php CHANGED
@@ -1,83 +1,84 @@
1
  <?php
2
- /**
3
- * Plugin Name: Webcraftic Clearfy – WordPress optimization plugin
4
- * Plugin URI: https://wordpress.org/plugins/clearfy/
5
- * Description: Disables unused Wordpress features, improves performance and increases SEO rankings, using Clearfy, which makes WordPress very easy.
6
- * Author: Webcraftic <wordpress.webraftic@gmail.com>
7
- * Version: 1.4.6
8
- * Text Domain: clearfy
9
- * Domain Path: /languages/
10
- * Author URI: http://clearfy.pro
11
- * Framework Version: FACTORY_409_VERSION
12
- */
13
-
14
- // Exit if accessed directly
15
- if( !defined('ABSPATH') ) {
16
- exit;
17
- }
18
-
19
- if( defined('WBCR_CLEARFY_PLUGIN_ACTIVE') ) {
20
- return;
21
- }
22
-
23
- define('WBCR_CLEARFY_PLUGIN_VERSION', '1.4.6');
24
-
25
- define('WBCR_CLEARFY_PLUGIN_ACTIVE', true);
26
-
27
- define('WBCR_CLEARFY_FRAMEWORK_VER', 'FACTORY_409_VERSION');
28
-
29
- define('WCL_PLUGIN_DIR', dirname(__FILE__));
30
- define('WCL_PLUGIN_BASE', plugin_basename(__FILE__));
31
- define('WCL_PLUGIN_URL', plugins_url(null, __FILE__));
32
-
33
- // Fix for ithemes sync. When the ithemes sync plugin accepts the request, set the WP_ADMIN constant,
34
- // after which the plugin Clearfy begins to create errors, and how the logic of its work is broken.
35
- // Solution to simply terminate the plugin if there is a request from ithemes sync
36
- // --------------------------------------
37
- if( defined('DOING_AJAX') && DOING_AJAX && isset($_REQUEST['action']) && $_REQUEST['action'] == 'ithemes_sync_request' ) {
38
- return;
39
- }
40
-
41
- if( isset($_GET['ithemes-sync-request']) && !empty($_GET['ithemes-sync-request']) ) {
42
- return;
43
- }
44
- // ----------------------------------------
45
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
 
48
- require_once(WCL_PLUGIN_DIR . '/libs/factory/core/includes/check-compatibility.php');
49
- require_once(WCL_PLUGIN_DIR . '/libs/factory/clearfy/includes/check-clearfy-compatibility.php');
50
-
51
- $plugin_info = array(
52
- 'prefix' => 'wbcr_clearfy_',
53
- 'plugin_name' => 'wbcr_clearfy',
54
- 'plugin_title' => __('Clearfy', 'clearfy'),
55
- 'plugin_version' => WBCR_CLEARFY_PLUGIN_VERSION,
56
- 'required_php_version' => '5.3',
57
- 'required_wp_version' => '4.2',
58
- 'freemius_plugin_id' => 2315,
59
- 'freemius_plugin_slug' => 'clearfy',
60
- 'freemius_public_key' => 'pk_70e226af07d37d2b9a69720e0952c',
61
- 'plugin_build' => 'free',
62
- 'updates' => WCL_PLUGIN_DIR . '/updates/',
63
- //'author_site_url' => 'https://clearfy.pro',
64
- //'author_ru_site_url' => 'https://ru.clearfy.pro'
65
- );
66
-
67
- /**
68
- * Проверяет совместимость с Wordpress, php и другими плагинами.
69
- */
70
- $compatibility = new Wbcr_FactoryClearfy_Compatibility($plugin_info);
71
-
72
- if( !$compatibility->check() ) {
73
- return;
74
- }
75
-
76
- require_once(WCL_PLUGIN_DIR . '/includes/helpers.php');
77
-
78
- // creating a plugin via the factory
79
- require_once(WCL_PLUGIN_DIR . '/libs/factory/core/boot.php');
80
- require_once(WCL_PLUGIN_DIR . '/includes/class.plugin.php');
81
-
82
- new WCL_Plugin(__FILE__, $plugin_info);
83
-
1
  <?php
2
+ /**
3
+ * Plugin Name: Webcraftic Clearfy – WordPress optimization plugin
4
+ * Plugin URI: https://wordpress.org/plugins/clearfy/
5
+ * Description: Disables unused Wordpress features, improves performance and increases SEO rankings, using Clearfy, which makes WordPress very easy.
6
+ * Author: Webcraftic <wordpress.webraftic@gmail.com>
7
+ * Version: 1.5.0
8
+ * Text Domain: clearfy
9
+ * Domain Path: /languages/
10
+ * Author URI: http://clearfy.pro
11
+ * Framework Version: FACTORY_409_VERSION
12
+ */
13
+
14
+ // Exit if accessed directly
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit;
17
+ }
18
+
19
+ if ( defined( 'WBCR_CLEARFY_PLUGIN_ACTIVE' ) ) {
20
+ return;
21
+ }
22
+
23
+ define( 'WBCR_CLEARFY_PLUGIN_VERSION', '1.5.0' );
24
+
25
+ define( 'WBCR_CLEARFY_PLUGIN_ACTIVE', true );
26
+
27
+ define( 'WBCR_CLEARFY_FRAMEWORK_VER', 'FACTORY_409_VERSION' );
28
+
29
+ define( 'WCL_PLUGIN_DIR', dirname( __FILE__ ) );
30
+ define( 'WCL_PLUGIN_BASE', plugin_basename( __FILE__ ) );
31
+ define( 'WCL_PLUGIN_URL', plugins_url( null, __FILE__ ) );
32
+
33
+ // Fix for ithemes sync. When the ithemes sync plugin accepts the request, set the WP_ADMIN constant,
34
+ // after which the plugin Clearfy begins to create errors, and how the logic of its work is broken.
35
+ // Solution to simply terminate the plugin if there is a request from ithemes sync
36
+ // --------------------------------------
37
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'ithemes_sync_request' ) {
38
+ return;
39
+ }
40
+
41
+ if ( isset( $_GET['ithemes-sync-request'] ) && ! empty( $_GET['ithemes-sync-request'] ) ) {
42
+ return;
43
+ }
44
+ // ----------------------------------------
45
+
46
+
47
+
48
+ require_once( WCL_PLUGIN_DIR . '/libs/factory/core/includes/check-compatibility.php' );
49
+ require_once( WCL_PLUGIN_DIR . '/libs/factory/clearfy/includes/check-clearfy-compatibility.php' );
50
+
51
+ $plugin_info = array(
52
+ 'prefix' => 'wbcr_clearfy_',
53
+ 'plugin_name' => 'wbcr_clearfy',
54
+ 'plugin_title' => __( 'Clearfy', 'clearfy' ),
55
+ 'plugin_version' => WBCR_CLEARFY_PLUGIN_VERSION,
56
+ 'required_php_version' => '5.3',
57
+ 'required_wp_version' => '4.2',
58
+ 'freemius_plugin_id' => 2315,
59
+ 'freemius_plugin_slug' => 'clearfy',
60
+ 'freemius_public_key' => 'pk_70e226af07d37d2b9a69720e0952c',
61
+ 'plugin_build' => 'free',
62
+ 'updates' => WCL_PLUGIN_DIR . '/updates/',
63
+ //'author_site_url' => 'https://clearfy.pro',
64
+ //'author_ru_site_url' => 'https://ru.clearfy.pro'
65
+ );
66
+
67
+ /**
68
+ * Проверяет совместимость с Wordpress, php и другими плагинами.
69
+ */
70
+ $compatibility = new Wbcr_FactoryClearfy_Compatibility( $plugin_info );
71
+
72
+ if ( ! $compatibility->check() ) {
73
+ return;
74
+ }
75
+
76
+ require_once( WCL_PLUGIN_DIR . '/includes/helpers.php' );
77
+
78
+ // creating a plugin via the factory
79
+ require_once( WCL_PLUGIN_DIR . '/libs/factory/core/boot.php' );
80
+ require_once( WCL_PLUGIN_DIR . '/includes/class.plugin.php' );
81
+
82
+ new WCL_Plugin( __FILE__, $plugin_info );
83
 
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/assets-manager/admin/boot.php CHANGED
@@ -1,38 +1,177 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /**
3
- * Admin boot
4
- * @author Webcraftic <wordpress.webraftic@gmail.com>
5
- * @copyright Webcraftic 25.05.2017
6
- * @version 1.0
7
  */
8
-
9
- // Exit if accessed directly
10
- if( !defined('ABSPATH') ) {
11
- exit;
12
- }
13
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  /**
15
- * Заменяем премиум возможности в бизнес виджете
16
- * @param array $features
17
- * @param string $page_id
18
- * @param string $plugin
19
  */
20
- add_filter('wbcr/clearfy/page_bussines_suggetion_features', function ($features, $plugin_name, $page_id) {
21
-
22
- if( !empty($plugin_name) && ($plugin_name == WGZ_Plugin::app()->getPluginName()) ) {
23
- $upgrade_feature = array();
24
- $upgrade_feature[] = __('Disable plugins (groups of scripts)', 'gonzales');
25
- $upgrade_feature[] = __('Conditions by the link template', 'gonzales');
26
- $upgrade_feature[] = __('Conditions by the regular expression', 'gonzales');
27
- $upgrade_feature[] = __('Safe mode', 'gonzales');
28
- $upgrade_feature[] = __('Statistics and optimization results', 'gonzales');
29
-
30
- return $upgrade_feature;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
-
33
- return $features;
34
- }, 20, 3);
35
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  /**
37
  * Удаляем лишние виджеты в левом сайдбаре
38
  *
@@ -40,108 +179,59 @@
40
  * @param string $position
41
  * @param Wbcr_Factory409_Plugin $plugin
42
  */
43
- add_filter('wbcr/factory/pages/impressive/widgets', function ($widgets, $position, $plugin) {
44
- if( $plugin->getPluginName() == WGZ_Plugin::app()->getPluginName() ) {
45
- if( $position == 'right' ) {
46
- unset($widgets['donate_widget']);
47
- unset($widgets['rating_widget']);
48
- unset($widgets['info_widget']);
49
  }
50
  }
51
-
52
  return $widgets;
53
- }, 20, 3);
54
-
55
- if( defined('LOADING_ASSETS_MANAGER_AS_ADDON') ) {
56
-
57
- /**
58
- * This action is executed when the component of the Clearfy plugin is activate and if this component is name ga_cache
59
- * @param string $component_name
60
- */
61
- add_action('wbcr/clearfy/activated_component', function ($component_name) {
62
- if( $component_name == 'assets_manager' ) {
63
- if( class_exists('WCL_Plugin') ) {
64
- $license = WCL_Plugin::app()->getLicense();
65
- if( ($license->isLicenseValid() || (defined('WCL_PLUGIN_DEBUG') && WCL_PLUGIN_DEBUG)) && !WCL_Plugin::app()->isActivateComponent('assets-manager-premium') ) {
66
- WCL_Plugin::app()->activateComponent('assets-manager-premium');
67
- }
68
- }
69
- }
70
- });
71
-
72
- /**
73
- * This action is executed when the component of the Clearfy plugin is activate and if this component is name ga_cache
74
- * @param string $component_name
75
- */
76
- add_action('wbcr_clearfy_deactivated_component', function ($component_name) {
77
- if( $component_name == 'assets_manager' ) {
78
- if( class_exists('WCL_Plugin') ) {
79
- $license = WCL_Plugin::app()->getLicense();
80
- if( ($license->isLicenseValid() || (defined('WCL_PLUGIN_DEBUG') && WCL_PLUGIN_DEBUG)) && WCL_Plugin::app()->isActivateComponent('assets-manager-premium') ) {
81
- WCL_Plugin::app()->deactivateComponent('assets-manager-premium');
82
- }
83
- }
84
- }
85
- });
86
-
87
- function wbcr_gnz_group_options($options)
88
- {
89
- $options[] = array(
90
- 'name' => 'disable_assets_manager',
91
- 'title' => __('Disable assets manager', 'gonzales'),
92
- 'tags' => array(),
93
- 'values' => array()
94
- );
95
-
96
- $options[] = array(
97
- 'name' => 'disable_assets_manager_panel',
98
- 'title' => __('Disable assets manager panel', 'gonzales'),
99
- 'tags' => array()
100
- );
101
-
102
- $options[] = array(
103
- 'name' => 'disable_assets_manager_on_front',
104
- 'title' => __('Disable assets manager on front', 'gonzales'),
105
- 'tags' => array()
106
- );
107
-
108
- $options[] = array(
109
- 'name' => 'disable_assets_manager_on_backend',
110
- 'title' => __('Disable assets manager on back-end', 'gonzales'),
111
- 'tags' => array()
112
- );
113
-
114
- $options[] = array(
115
- 'name' => 'manager_options',
116
- 'title' => __('Assets manager options', 'gonzales'),
117
- 'tags' => array()
118
- );
119
-
120
- return $options;
121
  }
122
-
123
- add_filter("wbcr_clearfy_group_options", 'wbcr_gnz_group_options');
124
- } else {
125
- function wbcr_gnz_set_plugin_meta($links, $file)
126
- {
127
- if( $file == WGZ_PLUGIN_BASE ) {
128
- $url = WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl(WGZ_Plugin::app()->getPluginName(), 'assets-manager', 'plugin_row');
129
- $links[] = '<a href="' . $url . '" style="color: #FF5722;font-weight: bold;" target="_blank">' . __('Get premium', 'gonzales') . '</a>';
130
- }
131
-
132
- return $links;
133
  }
134
-
135
- add_filter('plugin_row_meta', 'wbcr_gnz_set_plugin_meta', 10, 2);
136
-
137
- function wbcr_gnz_rating_widget_url($page_url, $plugin_name)
138
- {
139
- if( !defined('LOADING_ASSETS_MANAGER_AS_ADDON') && ($plugin_name == WGZ_Plugin::app()->getPluginName()) ) {
140
- return 'https://goo.gl/zyNV6z';
141
- }
142
-
143
- return $page_url;
144
  }
145
-
146
- add_filter('wbcr_factory_pages_410_imppage_rating_widget_url', 'wbcr_gnz_rating_widget_url', 10, 2);
147
- }
 
 
 
1
  <?php
2
+ /**
3
+ * Admin boot
4
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
5
+ * @copyright Webcraftic 25.05.2017
6
+ * @version 1.0
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ if ( defined( 'LOADING_ASSETS_MANAGER_AS_ADDON' ) ) {
15
+
16
  /**
17
+ * Уведомление, которое сообщает о возможности импорта опций из плагина Assets manager в Clearfy
18
+ *
19
+ * @param array $notices
 
20
  */
21
+ add_filter( 'wbcr_factory_notices_407_list', function ( $notices ) {
22
+
23
+ if ( is_multisite() && is_network_admin() ) {
24
+ $am_options = get_site_option( 'wbcr_gnz_assets_manager_options' );
25
+ } else {
26
+ $am_options = get_option( 'wbcr_gnz_assets_manager_options' );
27
+ }
28
+
29
+ if ( $am_options ) {
30
+ $notice_text = '<p><b>Clearfy:</b> ' . __( 'We detected that you used the Assets manager plugin. Do you want to import settings from this plugin to the Clearfy plugin?', 'gonzales' ) . '</p>';
31
+ $notice_text .= '<p><a href="' . admin_url( '?wbcr_assets_manager_transfer' ) . '" class="button button-default">' . __( 'Import options', 'gonzales' ) . '</a></p>';
32
+
33
+ $notices[] = array(
34
+ 'id' => 'gnz_plugin_import_options',
35
+ 'type' => 'warning',
36
+ 'dismissible' => true,
37
+ 'dismiss_expires' => 0,
38
+ 'text' => $notice_text
39
+ );
40
+ }
41
+
42
+ if ( isset( $_GET['wbcr_assets_manager_transfer_completed'] ) ) {
43
+ $notices[] = array(
44
+ 'id' => 'gnz_plugin_transfer_options_completed',
45
+ 'type' => 'success',
46
+ 'dismissible' => false,
47
+ 'dismiss_expires' => 0,
48
+ 'text' => '<p><b>Clearfy:</b> ' . __( 'Settings has been successfully imported!', 'gonzales' )
49
+ );
50
+ }
51
+
52
+ return $notices;
53
+ }, 10, 2 );
54
+
55
  /**
56
+ * Импорт опций из плагина Assets manager в плагин Clearfy.
57
+ * При попытке использовать премиум версию, у многих пользователей уже настроен бесплатный плагин и
58
+ * на ручной перенос настроек уходит очень много времени. Этот кусок кода решает проблему переноса настроек между плагинами.
 
59
  */
60
+ add_action( 'admin_init', function () {
61
+ if ( isset( $_GET['wbcr_assets_manager_transfer'] ) ) {
62
+ global $wpdb;
63
+
64
+ if ( is_multisite() && is_network_admin() ) {
65
+ $am_options = get_site_option( 'wbcr_gnz_assets_manager_options' );
66
+ } else {
67
+ $am_options = get_option( 'wbcr_gnz_assets_manager_options' );
68
+ }
69
+
70
+ if ( ! $am_options || ! class_exists( 'WCL_Plugin' ) ) {
71
+ return;
72
+ }
73
+
74
+ $am_prefix = 'wbcr_gnz_';
75
+
76
+ if ( is_multisite() && is_network_admin() ) {
77
+ $request = $wpdb->get_results( "SELECT meta_key, meta_value
78
+ FROM {$wpdb->sitemeta}
79
+ WHERE option_name LIKE '{$am_prefix}_%'" );
80
+ } else {
81
+ $request = $wpdb->get_results( "SELECT option_name, option_value
82
+ FROM {$wpdb->options}
83
+ WHERE option_name LIKE '{$am_prefix}_%'" );
84
+ }
85
+
86
+ if ( $request ) {
87
+ foreach ( (array) $request as $option ) {
88
+ if ( is_multisite() && is_network_admin() ) {
89
+ $new_option_name = str_replace( $am_prefix, WCL_Plugin::app()->getPrefix(), $option->meta_key );
90
+ update_site_option( $new_option_name, $option->meta_value );
91
+ delete_site_option( $option->meta_key );
92
+ } else {
93
+ $new_option_name = str_replace( $am_prefix, WCL_Plugin::app()->getPrefix(), $option->option_name );
94
+ update_option( $new_option_name, $option->option_value );
95
+ delete_option( $option->option_name );
96
+ }
97
+ }
98
+
99
+ wp_redirect( admin_url( '?wbcr_assets_manager_transfer_completed' ) );
100
+ die();
101
+ }
102
  }
103
+ } );
104
+
105
+ /**
106
+ * This action is executed when the component of the Clearfy plugin is activate and if this component is name ga_cache
107
+ *
108
+ * @param string $component_name
109
+ */
110
+ add_action( 'wbcr/clearfy/activated_component', function ( $component_name ) {
111
+ if ( $component_name == 'assets_manager' ) {
112
+ if ( class_exists( 'WCL_Plugin' ) ) {
113
+ $license = WCL_Plugin::app()->getLicense();
114
+ if ( ( $license->isLicenseValid() || ( defined( 'WCL_PLUGIN_DEBUG' ) && WCL_PLUGIN_DEBUG ) ) && ! WCL_Plugin::app()->isActivateComponent( 'assets-manager-premium' ) ) {
115
+ WCL_Plugin::app()->activateComponent( 'assets-manager-premium' );
116
+ }
117
+ }
118
+ }
119
+ } );
120
+
121
+ /**
122
+ * This action is executed when the component of the Clearfy plugin is activate and if this component is name ga_cache
123
+ *
124
+ * @param string $component_name
125
+ */
126
+ add_action( 'wbcr_clearfy_deactivated_component', function ( $component_name ) {
127
+ if ( $component_name == 'assets_manager' ) {
128
+ if ( class_exists( 'WCL_Plugin' ) ) {
129
+ $license = WCL_Plugin::app()->getLicense();
130
+ if ( ( $license->isLicenseValid() || ( defined( 'WCL_PLUGIN_DEBUG' ) && WCL_PLUGIN_DEBUG ) ) && WCL_Plugin::app()->isActivateComponent( 'assets-manager-premium' ) ) {
131
+ WCL_Plugin::app()->deactivateComponent( 'assets-manager-premium' );
132
+ }
133
+ }
134
+ }
135
+ } );
136
+
137
+ function wbcr_gnz_group_options( $options ) {
138
+ $options[] = array(
139
+ 'name' => 'disable_assets_manager',
140
+ 'title' => __( 'Disable assets manager', 'gonzales' ),
141
+ 'tags' => array(),
142
+ 'values' => array()
143
+ );
144
+
145
+ $options[] = array(
146
+ 'name' => 'disable_assets_manager_panel',
147
+ 'title' => __( 'Disable assets manager panel', 'gonzales' ),
148
+ 'tags' => array()
149
+ );
150
+
151
+ $options[] = array(
152
+ 'name' => 'disable_assets_manager_on_front',
153
+ 'title' => __( 'Disable assets manager on front', 'gonzales' ),
154
+ 'tags' => array()
155
+ );
156
+
157
+ $options[] = array(
158
+ 'name' => 'disable_assets_manager_on_backend',
159
+ 'title' => __( 'Disable assets manager on back-end', 'gonzales' ),
160
+ 'tags' => array()
161
+ );
162
+
163
+ $options[] = array(
164
+ 'name' => 'manager_options',
165
+ 'title' => __( 'Assets manager options', 'gonzales' ),
166
+ 'tags' => array()
167
+ );
168
+
169
+ return $options;
170
+ }
171
+
172
+ add_filter( "wbcr_clearfy_group_options", 'wbcr_gnz_group_options' );
173
+ } else {
174
+
175
  /**
176
  * Удаляем лишние виджеты в левом сайдбаре
177
  *
179
  * @param string $position
180
  * @param Wbcr_Factory409_Plugin $plugin
181
  */
182
+ add_filter( 'wbcr/factory/pages/impressive/widgets', function ( $widgets, $position, $plugin ) {
183
+ if ( $plugin->getPluginName() == WGZ_Plugin::app()->getPluginName() ) {
184
+ if ( $position == 'right' ) {
185
+ unset( $widgets['donate_widget'] );
186
+ unset( $widgets['rating_widget'] );
187
+ unset( $widgets['info_widget'] );
188
  }
189
  }
190
+
191
  return $widgets;
192
+ }, 20, 3 );
193
+
194
+ /**
195
+ * Заменяем премиум возможности в бизнес виджете
196
+ *
197
+ * @param array $features
198
+ * @param string $page_id
199
+ * @param string $plugin
200
+ */
201
+ add_filter( 'wbcr/clearfy/page_bussines_suggetion_features', function ( $features, $plugin_name, $page_id ) {
202
+
203
+ if ( ! empty( $plugin_name ) && ( $plugin_name == WGZ_Plugin::app()->getPluginName() ) ) {
204
+ $upgrade_feature = array();
205
+ $upgrade_feature[] = __( 'Disable plugins (groups of scripts)', 'gonzales' );
206
+ $upgrade_feature[] = __( 'Conditions by the link template', 'gonzales' );
207
+ $upgrade_feature[] = __( 'Conditions by the regular expression', 'gonzales' );
208
+ $upgrade_feature[] = __( 'Safe mode', 'gonzales' );
209
+ $upgrade_feature[] = __( 'Statistics and optimization results', 'gonzales' );
210
+
211
+ return $upgrade_feature;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  }
213
+
214
+ return $features;
215
+ }, 20, 3 );
216
+
217
+ function wbcr_gnz_set_plugin_meta( $links, $file ) {
218
+ if ( $file == WGZ_PLUGIN_BASE ) {
219
+ $url = WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl( WGZ_Plugin::app()->getPluginName(), 'assets-manager', 'plugin_row' );
220
+ $links[] = '<a href="' . $url . '" style="color: #FF5722;font-weight: bold;" target="_blank">' . __( 'Get premium', 'gonzales' ) . '</a>';
 
 
 
221
  }
222
+
223
+ return $links;
224
+ }
225
+
226
+ add_filter( 'plugin_row_meta', 'wbcr_gnz_set_plugin_meta', 10, 2 );
227
+
228
+ function wbcr_gnz_rating_widget_url( $page_url, $plugin_name ) {
229
+ if ( ! defined( 'LOADING_ASSETS_MANAGER_AS_ADDON' ) && ( $plugin_name == WGZ_Plugin::app()->getPluginName() ) ) {
230
+ return 'https://goo.gl/zyNV6z';
 
231
  }
232
+
233
+ return $page_url;
234
+ }
235
+
236
+ add_filter( 'wbcr_factory_pages_410_imppage_rating_widget_url', 'wbcr_gnz_rating_widget_url', 10, 2 );
237
+ }
components/assets-manager/includes/class.configurate-assets.php CHANGED
@@ -1,1362 +1,1332 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  /**
4
- * Assets manager base class
5
- * @author Webcraftic <wordpress.webraftic@gmail.com>
6
- * @copyright (c) 05.11.2017, Webcraftic
7
- * @version 1.0
8
  */
9
-
10
- // Exit if accessed directly
11
- if( !defined('ABSPATH') ) {
12
- exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
-
15
- class WbcrGnz_ConfigAssetsManager extends Wbcr_FactoryClearfy206_Configurate {
16
-
17
- /**
18
- * Stores list of all available assets (used in rendering panel)
19
- *
20
- * @var array
21
- */
22
- public $collection = array();
23
-
24
- /**
25
- * Plugins for additional columns
26
- *
27
- * @var array
28
- */
29
- private $sided_plugins = array();
30
-
31
- /**
32
- * Css and js files excluded in sided plugins
33
- *
34
- * @var array
35
- */
36
- private $sided_plugin_files = array();
37
-
38
- /**
39
- * @var bool
40
- */
41
- private $is_user_can;
42
-
43
- /**
44
- * @param Wbcr_Factory409_Plugin $plugin
45
- */
46
- public function __construct(Wbcr_Factory409_Plugin $plugin)
47
- {
48
- parent::__construct($plugin);
49
- $this->plugin = $plugin;
50
  }
51
 
52
- protected function isUserCan()
53
- {
54
- return current_user_can('manage_options') || current_user_can('manage_network');
 
 
 
 
55
  }
56
-
57
- /**
58
- * Initilize entire machine
59
- */
60
- protected function registerActionsAndFilters()
61
- {
62
- if( $this->getPopulateOption('disable_assets_manager', false) ) {
63
- return;
64
- }
65
-
66
- $on_frontend = $this->getPopulateOption('disable_assets_manager_on_front');
67
- $on_backend = $this->getPopulateOption('disable_assets_manager_on_backend', true);
68
- $is_panel = $this->getPopulateOption('disable_assets_manager_panel');
69
-
70
- if( (!is_admin() && !$on_frontend) || (is_admin() && !$on_backend) ) {
71
- add_filter('script_loader_src', array($this, 'unloadAssets'), 10, 2);
72
- add_filter('style_loader_src', array($this, 'unloadAssets'), 10, 2);
73
- }
74
-
75
- if( !$is_panel && ((is_admin() && !$on_backend) || (!is_admin() && !$on_frontend)) ) {
76
- if( !is_admin() ) {
77
- add_action('wp_enqueue_scripts', array($this, 'appendAsset'), -100001);
78
- add_action('wp_footer', array($this, 'assetsManager'), 100001);
79
- } else {
80
- add_action('admin_enqueue_scripts', array($this, 'appendAsset'), -100001);
81
- add_action('admin_footer', array($this, 'assetsManager'), 100001);
82
- }
83
- }
84
-
85
- if( !is_admin() && !$on_frontend ) {
86
- add_action('wp_head', array($this, 'collectAssets'), 10000);
87
- add_action('wp_footer', array($this, 'collectAssets'), 10000);
88
- }
89
-
90
- if( is_admin() && !$on_backend ) {
91
- add_action('admin_head', array($this, 'collectAssets'), 10000);
92
- add_action('admin_footer', array($this, 'collectAssets'), 10000);
93
- }
94
-
95
- if( !$is_panel && ((is_admin() && !$on_backend) || (!is_admin() && !$on_frontend)) ) {
96
- if( defined('LOADING_ASSETS_MANAGER_AS_ADDON') ) {
97
- add_action('wbcr/clearfy/adminbar_menu_items', array($this, 'clearfyAdminBarMenu'));
98
- } else {
99
- add_action('admin_bar_menu', array($this, 'assetsManagerAdminBar'), 1000);
100
- }
101
- }
102
-
103
- if( !is_admin() && !$on_frontend ) {
104
- add_action('init', array($this, 'formSave'));
105
- }
106
-
107
- if( is_admin() && !$on_backend ) {
108
- add_action('admin_init', array($this, 'formSave'));
109
  }
110
-
111
- add_action('plugins_loaded', array($this, 'pluginsLoaded'));
112
- add_action('wbcr_gnz_form_save', array($this, 'actionFormSave'));
113
-
114
- add_filter('wbcr_gnz_unset_disabled', array($this, 'unsetDisabled'), 10, 2);
115
- add_filter('wbcr_gnz_get_additional_head_columns', array($this, 'getAdditionalHeadColumns'));
116
- add_filter('wbcr_gnz_get_additional_controls_columns', array($this, 'getAdditionalControlsColumns'), 10, 4);
117
-
118
- add_filter('autoptimize_filter_js_exclude', array($this, 'aoptFilterJsExclude'), 10, 2);
119
- add_filter('autoptimize_filter_css_exclude', array($this, 'aoptFilterCssExclude'), 10, 2);
120
- add_filter('wmac_filter_js_exclude', array($this, 'wmacFilterJsExclude'), 10, 2);
121
- add_filter('wmac_filter_css_exclude', array($this, 'wmacFilterCssExclude'), 10, 2);
122
- add_filter('wmac_filter_js_minify_excluded', array($this, 'wmacFilterJsMinifyExclude'), 10, 2);
123
- add_filter('wmac_filter_css_minify_excluded', array($this, 'wmacFilterCssMinifyExclude'), 10, 2);
124
  }
125
-
126
- function clearfyAdminBarMenu($menu_items)
127
- {
128
- $current_url = add_query_arg(array('wbcr_assets_manager' => 1));
129
-
130
- $menu_items['assetsManager'] = array(
131
- 'title' => '<span class="dashicons dashicons-list-view"></span> ' . __('Script Manager', 'gonzales'),
132
- 'href' => $current_url
133
- );
134
-
135
- return $menu_items;
136
  }
137
-
138
- /**
139
- * @param WP_Admin_Bar $wp_admin_bar
140
- */
141
- function assetsManagerAdminBar($wp_admin_bar)
142
- {
143
- if( !$this->isUserCan() ) {
144
- return;
 
 
 
145
  }
146
-
147
- $current_url = add_query_arg(array('wbcr_assets_manager' => 1));
148
-
149
- $args = array(
150
- 'id' => 'assetsManager',
151
- 'title' => __('Script Manager', 'gonzales'),
152
- 'href' => $current_url
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  );
154
- $wp_admin_bar->add_node($args);
155
  }
156
-
157
- /**
158
- * Action plugins loaded
159
- */
160
- public function pluginsLoaded()
161
- {
162
- if ( ! is_admin() ) {
163
- $this->sided_plugins = array(
164
- 'aopt' => 'autoptimize/autoptimize.php',
165
- 'wmac' => 'minify-and-combine/minify-and-combine.php'
166
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  }
168
-
169
- if( class_exists('WCL_Plugin') && (WCL_Plugin::app()->getPopulateOption('remove_js_version', false) || WCL_Plugin::app()->getPopulateOption('remove_css_version', false)) ) {
170
- $this->sided_plugins['wclp'] = 'clearfy/clearfy.php';
171
  }
172
-
173
 
174
-
175
- $this->sided_plugins = apply_filters('wbcr_gnz_sided_plugins', $this->sided_plugins);
 
 
 
 
 
 
 
176
  }
177
-
178
- function assetsManager()
179
- {
180
- if( !$this->isUserCan() || !isset($_GET['wbcr_assets_manager']) ) {
181
- return;
182
- }
183
-
184
- $current_url = esc_url($this->getCurrentUrl());
185
-
186
- // todo: вынести в метод
187
- if( is_multisite() && is_network_admin() ) {
188
- $options = $this->getNetworkOption('assets_manager_options', array());
189
- } else {
190
- $options = $this->getOption('assets_manager_options', array());
191
- }
192
-
193
- echo '<div id="WBCR" class="wbcr-gnz-wrapper"';
194
- if( isset($_GET['wbcr_assets_manager']) ) {
195
- echo 'style="display: block;"';
196
- }
197
- echo '>';
198
-
199
- //Form
200
- echo '<form method="POST">';
201
- wp_nonce_field('wbcr_assets_manager_nonce', 'wbcr_assets_manager_save');
202
-
203
- //Header
204
- echo '<header class="wbcr-gnz-panel">';
205
- echo '<div class="wbcr-gnz-panel__left">';
206
- echo '<div class="wbcr-gnz-panel__logo"></div>';
207
- echo '<ul class="wbcr-gnz-panel__data panel__data-main">';
208
- echo '<li class="wbcr-gnz-panel__data-item __info-query">' . __('Total requests', 'gonzales') . ': <b class="wbcr-gnz-panel__item_value">--</b></li>';
209
- echo '<li class="wbcr-gnz-panel__data-item __info-all-weight">' . __('Total size', 'gonzales') . ': <b class="wbcr-gnz-panel__item_value"><span class="wbcr-gnz-panel__color-1">--</span></b></li>';
210
- echo '<li class="wbcr-gnz-panel__data-item __info-opt-weight">' . __('Optimized size', 'gonzales') . ': <b class="wbcr-gnz-panel__item_value"><span class="wbcr-gnz-panel__color-2">--</span></b></li>';
211
- echo '<li class="wbcr-gnz-panel__data-item __info-off-js">' . __('Disabled js', 'gonzales') . ': <b class="wbcr-gnz-panel__item_value">--</li></b>';
212
- echo '<li class="wbcr-gnz-panel__data-item __info-off-css">' . __('Disabled css', 'gonzales') . ': <b class="wbcr-gnz-panel__item_value">--</li></b>';
213
- echo '</ul>';
214
- $panel_to_premium_info = '<div class="wbcr-gnz-panel__premium"><div class="wbcr-gnz-tooltip wbcr-gnz-tooltip-bottom" data-tooltip="' . __('This is the general statistics to see the optimization result. Available in the paid version only.', 'gonzales') . '.">PRO</div></div>';
215
- echo apply_filters('wbcr_gnz_panel_premium', $panel_to_premium_info);
216
- echo '</div>';
217
- echo '<div class="wbcr-gnz-panel__right">';
218
- echo '<button class="wbcr-gnz-panel__reset wbcr-reset-button" type="button">' . __('Reset', 'gonzales') . '</button>';
219
- echo '<input class="wbcr-gnz-panel__save" type="submit" value="' . __('Save', 'gonzales') . '">';
220
- echo '<label class="wbcr-gnz-panel__checkbox wbcr-gnz-tooltip wbcr-gnz-tooltip-bottom" data-tooltip="' . __('In test mode, you can experiment with disabling unused scripts safely for your site. The resources that you disabled will be visible only to you (the administrator), and all other users will receive an unoptimized version of the site, until you remove this tick', 'gonzales') . '.">';
221
- echo apply_filters('wbcr_gnz_test_mode_checkbox', '<input class="wbcr-gnz-panel__checkbox-input visually-hidden" type="checkbox" disabled="disabled" checked/><span class="wbcr-gnz-panel__checkbox-text-premium">' . __('Safe mode <b>PRO</b>', 'gonzales') . '</span>');
222
- echo '</label>';
223
- echo '<button class="wbcr-gnz-panel__close wbcr-close-button" type="button" aria-label="' . __('Close', 'gonzales') . '" data-href="' . remove_query_arg('wbcr_assets_manager') . '"></button>';
224
- echo '</div>';
225
- echo '</header>';
226
-
227
- // Main content
228
- echo '<main class="wbcr-gnz-content">';
229
-
230
- uksort($this->collection, function ($a, $b) {
231
- if( 'plugins' == $a ) {
232
- return -1;
233
- }
234
-
235
- if( 'plugins' == $b ) {
236
- return 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  }
238
-
239
- return strcasecmp($a, $b);
240
- });
241
-
242
- // Tabs
243
- echo '<ul class="wbcr-gnz-tabs">';
244
- foreach($this->collection as $resource_type => $resources) {
245
- echo '<li class="wbcr-gnz-tabs__item">';
246
- echo '<div class="wbcr-gnz-tabs__button wbcr-gnz-tabs__button--' . $resource_type . '" data-hash="' . $resource_type . '" aria-label="' . $resource_type . '"></div>';
247
- echo '</li>';
248
- }
249
- echo '</ul>';
250
-
251
- // Info
252
- echo '<div class="wbcr-gnz-info"><div class="wbcr-gnz-info__warning">';
253
- echo '<p><b>' . __('Important! Each page of your website has different sets of scripts and styles files.', 'gonzales') . '</b></p>';
254
- echo '<p>' . __('Use this feature to disable unwanted scripts and styles by setting up the logic for different types of pages. We recommend working in "Safe mode" because disabling any necessary system script file can corrupt the website. All changes done in Safe mode are available for administrator only. This way only you, as the administrator, can see the result of optimization. To enable the changes for other users, uncheck Safe mode.', 'gonzales') . '</p>';
255
- echo '<p>' . sprintf(__('For more details and user guides, check the plugin’s <a href="%s" target="_blank" rel="noreferrer noopener">documentation</a>.', 'gonzales'), WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl(WGZ_Plugin::app()->getPluginName(), 'docs')) . '</p>';
256
- echo '</div>';
257
-
258
- $premium_button = '<a class="wbcr-gnz-button__pro" href="' . WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl(WGZ_Plugin::app()->getPluginName(), 'assets-manager') . '" target="_blank" rel="noreferrer noopener">' . __('Upgrade to Premium', 'gonzales') . '</a>';
259
-
260
- $upgrade_to_premium_info = '<div class="wbcr-gnz-info__go-to-premium"><ul>';
261
- $upgrade_to_premium_info .= '<h3><span>' . __('MORE IN CLEARFY BUSINESS', 'gonzales') . '</span>' . $premium_button . '</h3><ul>';
262
- $upgrade_to_premium_info .= '<li>' . __('Disable plugins (groups of scripts)', 'gonzales') . '</li>';
263
- $upgrade_to_premium_info .= '<li>' . __('Conditions by the link template', 'gonzales') . '</li>';
264
- $upgrade_to_premium_info .= '<li>' . __('Conditions by the regular expression', 'gonzales') . '</li>';
265
- $upgrade_to_premium_info .= '<li>' . __('Safe mode', 'gonzales') . '</li>';
266
- $upgrade_to_premium_info .= '<li>' . __('Statistics and optimization results', 'gonzales') . '</li>';
267
- $upgrade_to_premium_info .= '</ul>';
268
- $upgrade_to_premium_info .= '</div>';
269
- echo apply_filters('wbcr_gnz_upgrade_to_premium_info', $upgrade_to_premium_info);
270
- echo '</div>';
271
-
272
- global $plugin_state;
273
-
274
- foreach($this->collection as $resource_type => $resources) {
275
- // Tabs content
276
- echo '<div class="wbcr-gnz-tabs-content">';
277
- echo '<div class="wbcr-gnz-table">';
278
- echo '<table>';
279
- echo '<col class="wbcr-gnz-table__loaded"/>';
280
- echo '<col class="wbcr-gnz-table__size"/>';
281
- echo '<col class="wbcr-gnz-table__script"/>';
282
- echo '<col class="wbcr-gnz-table__state"/>';
283
- echo '<col class="wbcr-gnz-table__turn-on"/>';
284
-
285
- foreach($resources as $resource_name => $types) {
286
- $plugin_state = false;
287
-
288
- if( 'plugins' == $resource_type && !empty($resource_name) ) {
289
- $plugin_data = $this->getPluginData($resource_name);
290
-
291
- echo '<tbody>';
292
-
293
- if( !empty($plugin_data) ) {
294
- $is_disabled = $this->getIsDisabled($options, $resource_type, $resource_name);
295
- $disabled = $this->getDisabled($is_disabled, $options, $resource_type, $resource_name);
296
-
297
- $is_enabled = $this->getIsEnabled($options, $resource_type, $resource_name);
298
- $enabled = $this->getEnabled($is_enabled, $options, $resource_type, $resource_name);
299
-
300
- $plugin_state = $this->getState($is_disabled, $disabled, $current_url);
301
- $plugin_state = apply_filters('wbcr_gnz_get_plugin_state', false, $plugin_state);
302
-
303
- echo '<tr class="wbcr-gnz-table__alternate">';
304
- echo '<th style="width:5%">' . __('Loaded', 'gonzales') . '</th>';
305
- echo '<th colspan="2">' . __('Plugin', 'gonzales') . '</th>';
306
-
307
- echo apply_filters('wbcr_gnz_get_additional_head_columns', '');
308
-
309
- echo '<th class="wbcr-gnz-table__column_switch"><b>' . __('Load resource?', 'gonzales') . '</b></th>';
310
- echo '<th class="wbcr-gnz-table__column_condition">' . __('Conditions', 'gonzales') . '</th>';
311
- echo '</tr>';
312
  echo '<tr>';
 
 
 
 
 
 
 
 
 
 
 
 
313
  echo '<td>';
314
- echo '<div class="wbcr-gnz-table__loaded-state wbcr-gnz-table__loaded-' . ($plugin_state ? 'no' : 'yes') . ' wbcr-state"></div>';
315
  echo '</td>';
316
- echo '<td colspan="2" class="wbcr-gnz-table__item">';
317
- echo '<div class="wbcr-gnz-table__item-name">' . $plugin_data['Name'] . '</div>';
318
- echo '<div class="wbcr-gnz-table__item-author"><strong>' . __('Author', 'gonzales') . ':</strong> ' . $plugin_data['Author'] . '</div>';
319
- echo '<div class="wbcr-gnz-table__item-version"><strong>' . __('Version', 'gonzales') . ':</strong> ' . $plugin_data['Version'] . '</div>';
 
 
 
 
 
 
 
 
 
320
  echo '</td>';
321
-
322
- echo apply_filters('wbcr_gnz_get_additional_controls_columns', '', $resource_type, $resource_name, $resource_name);
323
-
 
324
  // State Controls
325
- $id = '[' . $resource_type . '][' . $resource_name . ']';
326
- echo $this->getStateControrlHTML($id, $plugin_state, $is_disabled, $is_enabled, $resource_type, $resource_name, $disabled, $enabled, $current_url);
 
 
327
  echo '</tr>';
 
 
328
  }
329
  }
330
-
331
- echo '<tr class="wbcr-gnz-table__alternate">';
332
- echo '<th style="width:5%">' . __('Loaded', 'gonzales') . '</th>';
333
- echo '<th style="width:5%">' . __('Size', 'gonzales') . '</th>';
334
- echo '<th class="wgz-th">' . __('Resource', 'gonzales') . '</th>';
335
-
336
- echo apply_filters('wbcr_gnz_get_additional_head_columns', '');
337
-
338
- echo '<th class="wbcr-gnz-table__column_switch"><b>' . __('Load resource?', 'gonzales') . '</b></th>';
339
- echo '<th class="wbcr-gnz-table__column_condition">' . __('Conditions', 'gonzales') . '</th>';
340
- echo '</tr>';
341
-
342
- foreach($types as $type_name => $rows) {
343
-
344
- if( !empty($rows) ) {
345
- foreach($rows as $handle => $row) {
346
- $is_disabled = $this->getIsDisabled($options, $type_name, $handle);
347
- $disabled = $this->getDisabled($is_disabled, $options, $type_name, $handle);
348
-
349
- $is_enabled = $this->getIsEnabled($options, $type_name, $handle);
350
- $enabled = $this->getEnabled($is_enabled, $options, $type_name, $handle);
351
-
352
- /**
353
- * Find dependency
354
- */
355
- $deps = array();
356
- foreach($rows as $dep_key => $dep_val) {
357
- if( in_array($handle, $dep_val['deps']) /*&& $is_disabled*/ ) {
358
- $deps[] = '<a href="#' . $type_name . '-' . $dep_key . '">' . $dep_key . '</a>';
359
- }
360
- }
361
-
362
- $comment = (!empty($deps) ? '<span class="wbcr-use-by-comment">' . __('In use by', 'gonzales') . ' ' . implode(', ', $deps) . '</span>' : '');
363
- $requires = '';
364
- if( !empty($row['deps']) ) {
365
- $rdeps = array();
366
- foreach($row['deps'] as $dep_val) {
367
- $rdeps[] = '<a href="#' . $type_name . '-' . $dep_val . '">' . $dep_val . '</a>';
368
- }
369
- $requires = ($comment ? '<br>' : '') . '<span class="wbcr-use-by-comment">' . __('Requires', 'gonzales') . ' ' . implode(', ', $rdeps) . '</span>';
370
- }
371
-
372
- echo '<tr>';
373
-
374
- // Loaded
375
- $state = $this->getState($is_disabled, $disabled, $current_url);
376
- $display_state = $plugin_state === 1 ? 1 : $state;
377
- echo '<td>';
378
- echo '<div class="wbcr-gnz-table__loaded-state wbcr-gnz-table__loaded-' . ($plugin_state ? 'no' : 'yes');
379
- echo ' wbcr-state' . ($state ? ' wbcr-gnz-table__loaded-super-no' : '');
380
- echo ('plugins' == $resource_type ? ' wbcr-state-' . $resource_name : '') . '">';
381
- echo '</div>';
382
- echo '</td>';
383
-
384
- // Size
385
- echo '<td>';
386
- echo '<div class="wbcr-gnz-table__size-value">' . $row['size'] . ' <b>KB</b></div>';
387
- echo '</td>';
388
-
389
- // Handle + Path + In use
390
- echo '<td class="wgz-td">';
391
- echo '<div class="wbcr-gnz-table__script-name"><b class="wbcr-wgz-resource-type-' . $type_name . '">' . $type_name . '</b>[' . $handle . ']</div>';
392
- echo "<a id='" . $type_name . "-" . $handle . "' class='wbcr-anchor'></a>";
393
- echo '<div class="wbcr-gnz-table__script-path">';
394
- echo "<a href='" . $row['url_full'] . "' target='_blank'>";
395
- echo str_replace(get_home_url(), '', $row['url_full']) . "</a>";
396
- echo '</div>';
397
- echo '<div class="wbcr-gnz-table__script-version">';
398
- echo __('Version', 'gonzales') . ': ' . (!empty($row['ver']) ? $row['ver'] : __('--', 'gonzales'));
399
- echo '</div>';
400
- echo '<div>' . $comment . $requires . '</div>';
401
- echo '</td>';
402
-
403
- // Controls for other plugins
404
- echo apply_filters('wbcr_gnz_get_additional_controls_columns', '', $type_name, $row['url_full'], $resource_name);
405
-
406
- // State Controls
407
- $id = '[' . $type_name . '][' . $handle . ']';
408
- echo $this->getStateControrlHTML($id, $state, $is_disabled, $is_enabled, $type_name, $handle, $disabled, $enabled, $current_url);
409
-
410
- echo "<input type='hidden' class='wbcr-info-data' data-type='{$type_name}' data-off='{$display_state}' value='{$row['size']}'>";
411
- echo '</tr>';
412
-
413
- echo apply_filters('wbcr_gnz_after_scripts_table_row', '', $resource_type, $resource_name, $type_name, $handle);
414
- }
415
- }
416
- }
417
-
418
- if( 'plugins' == $resource_type && !empty($resource_name) ) {
419
- echo '</tbody>';
420
- }
421
  }
422
-
423
- echo '</table>';
424
- echo '</div>';
425
- echo '</div>';
426
- }
427
- echo '</main>';
428
- echo '</form> <!-- /endform -->';
429
- echo '</div> <!-- /div2 -->';
430
- }
431
-
432
- /**
433
- * Get is disabled
434
- *
435
- * @param $options
436
- * @param $type_name
437
- * @param $handle
438
- *
439
- * @return bool
440
- */
441
- public function getIsDisabled($options, $type_name, $handle)
442
- {
443
- return isset($options['disabled']) && isset($options['disabled'][$type_name]) && isset($options['disabled'][$type_name][$handle]);
444
- }
445
-
446
- /**
447
- * Get disabled
448
- *
449
- * @param $is_disabled
450
- * @param $options
451
- * @param $type_name
452
- * @param $handle
453
- *
454
- * @return array
455
- */
456
- public function getDisabled($is_disabled, $options, $type_name, $handle)
457
- {
458
- $disabled = array();
459
-
460
- if( $is_disabled ) {
461
- $disabled = &$options['disabled'][$type_name][$handle];
462
- if( !isset($disabled['current']) ) {
463
- $disabled['current'] = array();
464
- }
465
- if( !isset($disabled['everywhere']) ) {
466
- $disabled['everywhere'] = array();
467
  }
468
-
469
- $disabled = apply_filters('wbcr_gnz_get_disabled', $disabled);
470
  }
471
-
472
- return $disabled;
473
- }
474
-
475
- /**
476
- * Get is enabled
477
- *
478
- * @param $options
479
- * @param $type_name
480
- * @param $handle
481
- *
482
- * @return bool
483
- */
484
- public function getIsEnabled($options, $type_name, $handle)
485
- {
486
- return isset($options['enabled']) && isset($options['enabled'][$type_name]) && isset($options['enabled'][$type_name][$handle]);
487
  }
488
-
489
- /**
490
- * Get enabled
491
- *
492
- * @param $is_enabled
493
- * @param $options
494
- * @param $type_name
495
- * @param $handle
496
- *
497
- * @return array
498
- */
499
- public function getEnabled($is_enabled, $options, $type_name, $handle)
500
- {
501
- $enabled = array();
502
-
503
- if( $is_enabled ) {
504
- $enabled = &$options['enabled'][$type_name][$handle];
505
-
506
- if( !isset($enabled['current']) ) {
507
- $enabled['current'] = array();
508
- }
509
- if( !isset($enabled['everywhere']) ) {
510
- $enabled['everywhere'] = array();
511
- }
512
-
513
- $enabled = apply_filters('wbcr_gnz_get_enabled', $enabled);
 
 
 
 
 
 
 
 
 
514
  }
515
-
516
- return $enabled;
517
- }
518
-
519
- /**
520
- * Get State
521
- *
522
- * @param $is_disabled
523
- * @param $disabled
524
- * @param $current_url
525
- *
526
- * @return int
527
- */
528
- public function getState($is_disabled, $disabled, $current_url)
529
- {
530
- $state = 0;
531
- if( $is_disabled && ($disabled['everywhere'] == 1 || in_array($current_url, $disabled['current']) || apply_filters('wbcr_gnz_check_state_disabled', false, $disabled)) ) {
532
- $state = 1;
533
  }
534
-
535
- return $state;
536
  }
537
-
538
- /**
539
- * Get state controrl HTML
540
- *
541
- * @param $id
542
- * @param $state
543
- * @param $is_disabled
544
- * @param $is_enabled
545
- * @param $type_name
546
- * @param $handle
547
- * @param $disabled
548
- * @param $enabled
549
- * @param $current_url
550
- *
551
- * @return string
552
- */
553
- public function getStateControrlHTML($id, $state, $is_disabled, $is_enabled, $type_name, $handle, $disabled, $enabled, $current_url)
554
- {
555
- // Disable
556
- $html = '<td>';
557
- $html .= '<label class="wbcr-gnz-switch' . ($type_name == 'plugins' ? apply_filters('wbcr_gnz_switch_premium', ' wbcr-gnz-switch-premium') : '') . '">';
558
- $html .= '<input class="wbcr-gnz-switch__input visually-hidden' . apply_filters('wbcr_gnz_switch_plugin_premium', $type_name == 'plugins' ? '' : ' wbcr-gnz-disable') . '" type="checkbox"' . checked($state, true, false);
559
- $html .= ('plugins' == $type_name ? " data-handle='{$handle}'" : "") . '/>';
560
- $html .= '<input type="hidden" name="disabled' . $id . '[state]" value="' . ($state ? 'disable' : '') . '"/>';
561
- $html .= '<span class="wbcr-gnz-switch__inner" data-off="' . __('No', 'gonzales') . '" data-on="' . __('Yes', 'gonzales') . '"></span>';
562
- $html .= '<span class="wbcr-gnz-switch__slider"></span>';
563
- $html .= '</label>';
564
- $html .= '</td>';
565
-
566
- // Enable
567
- $class_name = 'wbcr-assets-manager-enable';
568
- if( 'plugins' == $type_name ) {
569
- $class_name = apply_filters('wbcr_gnz_control_classname', 'wbcr-gnz');
570
- }
571
- $html .= '<td>';
572
- $html .= '<div class="wbcr-gnz-table__note ' . $class_name . '-placeholder"';
573
- if( $state ) {
574
- $html .= ' style="display: none;"';
575
- }
576
- if( 'plugins' != $type_name ) {
577
- $html .= '><p>' . __('Click the switch in the <b>Load resource?</b> column to display the conditions for loading the resource.', 'gonzales') . '</p>';
578
- } else {
579
- $html .= '><p>' . apply_filters('wbcr_gnz_conditions_note_premium', __('Set the plugin logic to apply it to all plugin’s resources. This feature available at the paid version.', 'gonzales')) . '</p>';
580
- }
581
- $html .= '</div>';
582
- $html .= '<span class="' . $class_name . '"';
583
- if( !$state ) {
584
- $html .= ' style="display: none;"';
585
- }
586
- $html .= '>';
587
- $html .= '<select class="wbcr-gnz-table__select wbcr-gnz-action-select" name="wgz_action' . $id . '">';
588
- $html .= '<option value="current"' . selected($is_disabled && !empty($disabled['current']), true, false) . '>' . __('Current URL', 'gonzales') . '</option>';
589
- $html .= '<option value="everywhere"' . selected($is_disabled && !empty($disabled['everywhere']), true, false) . '>' . __('Everywhere', 'gonzales') . '</option>';
590
- $options = '<option value="custom"' . selected($is_disabled && !empty($disabled['custom']), true, false) . ' class="wbcr-gnz-table__select-pro">' . __('Custom URL (PRO)', 'gonzales') . '</option>';
591
- $options .= '<option value="regex"' . selected($is_disabled && !empty($disabled['regex']), true, false) . ' class="wbcr-gnz-table__select-pro">' . __('Regular expression (PRO)', 'gonzales') . '</option>';
592
- $html .= apply_filters('wbcr_gnz_select_options', $options, $is_disabled, $disabled);
593
- $html .= '</select>';
594
-
595
- // Everywhere
596
- $html .= "<span class='wbcr-assets-manager everywhere'";
597
- if( !$is_disabled || empty($disabled['everywhere']) ) {
598
- $html .= " style='display: none;'";
599
  }
600
- $html .= ">";
601
- $html .= '<div class="wbcr-gnz-table__label">' . __('Exclude', 'gonzales') . ': <i class="wbcr-gnz-help-hint wbcr-gnz-tooltip wbcr-gnz-tooltip-bottom" data-tooltip="' . __('You can disable this resource for all pages, except sections and page types listed below. Specify sections and page types with the enabled resource.', 'gonzales') . '"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAQAAABKmM6bAAAAUUlEQVQIHU3BsQ1AQABA0X/komIrnQHYwyhqQ1hBo9KZRKL9CBfeAwy2ri42JA4mPQ9rJ6OVt0BisFM3Po7qbEliru7m/FkY+TN64ZVxEzh4ndrMN7+Z+jXCAAAAAElFTkSuQmCC" alt=""></i></div>';
602
- $html .= '<ul class="wbcr-gnz-table__options">';
603
-
604
- $html .= '<li class="wbcr-gnz-table__options-item">';
605
- $html .= "<input type='hidden' name='enabled{$id}[current]' value='' />";
606
- $html .= '<label class="wbcr-gnz-table__checkbox">';
607
- $html .= '<input class="wbcr-gnz-table__checkbox-input visually-hidden" type="checkbox" name="enabled' . $id . '[current]" value="' . $current_url . '"';
608
- if( $is_enabled && in_array($current_url, $enabled['current']) ) {
609
- $html .= ' checked';
610
  }
611
- $html .= '/>';
612
- $html .= '<span class="wbcr-gnz-table__checkbox-text">' . __('Current URL', 'gonzales') . '</span>';
613
- $html .= '</label>';
614
- $html .= '</li>';
615
-
616
- $post_types = get_post_types(array('public' => true), 'objects', 'and');
617
- if( !empty($post_types) ) {
618
- $html .= "<input type='hidden' name='enabled{$id}[post_types]' value='' />";
619
- foreach($post_types as $key => $value) {
620
- $html .= '<li class="wbcr-gnz-table__options-item">';
621
- $html .= '<label class="wbcr-gnz-table__checkbox">';
622
- $html .= '<input class="wbcr-gnz-table__checkbox-input visually-hidden" type="checkbox" name="enabled' . $id . '[post_types][]" value="' . $key . '"';
623
- if( isset($enabled['post_types']) ) {
624
- if( in_array($key, $enabled['post_types']) ) {
625
- $html .= ' checked';
626
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
627
  }
628
- $html .= '/>';
629
- $html .= '<span class="wbcr-gnz-table__checkbox-text">' . $value->label . '</span>';
630
- $html .= '</label>';
631
- $html .= '</li>';
632
  }
 
 
 
 
633
  }
634
-
635
- $taxonomies = get_taxonomies(array('public' => true), 'objects', 'and');
636
-
637
- if( !empty($taxonomies) ) {
638
- unset($taxonomies['category']);
639
- $html .= "<input type='hidden' name='enabled{$id}[taxonomies]' value='' />";
640
- foreach($taxonomies as $key => $value) {
641
- $html .= '<li class="wbcr-gnz-table__options-item">';
642
- $html .= '<label class="wbcr-gnz-table__checkbox">';
643
- $html .= '<input class="wbcr-gnz-table__checkbox-input visually-hidden" type="checkbox" name="enabled' . $id . '[taxonomies][]" value="' . $key . '"';
644
- if( isset($enabled['taxonomies']) ) {
645
- if( in_array($key, $enabled['taxonomies']) ) {
646
- $html .= ' checked';
647
- }
648
  }
649
- $html .= '/>';
650
- $html .= '<span class="wbcr-gnz-table__checkbox-text">' . $value->label . '</span>';
651
- $html .= '</label>';
652
- $html .= '</li>';
653
  }
 
 
 
 
654
  }
655
-
656
- $categories = get_categories();
657
-
658
- if( !empty($categories) ) {
659
- $html .= "<input type='hidden' name='enabled{$id}[categories]' value='' />";
660
- foreach($categories as $key => $cat) {
661
- $html .= '<li class="wbcr-gnz-table__options-item">';
662
- $html .= '<label class="wbcr-gnz-table__checkbox">';
663
- $html .= '<input class="wbcr-gnz-table__checkbox-input visually-hidden" type="checkbox" name="enabled' . $id . '[categories][]" value="' . $cat->term_id . '"';
664
- if( isset($enabled['categories']) ) {
665
- if( in_array($cat->term_id, $enabled['categories']) ) {
666
- $html .= ' checked';
667
- }
668
  }
669
- $html .= '/>';
670
- $html .= '<span class="wbcr-gnz-table__checkbox-text">' . $cat->name . '</span>';
671
- $html .= '</label>';
672
- $html .= '</li>';
673
  }
 
 
 
 
674
  }
675
-
676
- $html .= '</ul>';
677
- $html .= '</span>';
678
-
679
- // Custom URL
680
- $control_html = '<div class="wbcr-gnz-table__field wbcr-assets-manager custom"';
681
- if( !$is_disabled || empty($disabled['custom']) ) {
682
- $control_html .= ' style="display: none;"';
683
- }
684
- $control_html .= '>';
685
- $control_html .= '<label class="wbcr-gnz-table__label" for="disabled' . $id . '[custom][]" title="' . __('Example', 'gonzales') . ': ' . site_url() . '/post/*, ' . site_url() . '/page-*>">' . __('Enter URL (set * for mask)', 'gonzales') . ': <i class="wbcr-gnz-help-hint wbcr-gnz-tooltip wbcr-gnz-tooltip-bottom" data-tooltip="' . __('You can disable the resource only for the pages with the matched to the template address. For example, if you set the template for the link as http://yoursite.test/profile/*, then the resource is disabled for the following pages: http://yoursite.test/profile/12, http://yoursite.test/profile/43, http://yoursite.test/profile/999. If you don’t use the asterisk symbol in the template then the plugin will disable the resource only for the pages with 100% match in the specified link type. This feature is available at the paid version.', 'gonzales') . '"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAQAAABKmM6bAAAAUUlEQVQIHU3BsQ1AQABA0X/komIrnQHYwyhqQ1hBo9KZRKL9CBfeAwy2ri42JA4mPQ9rJ6OVt0BisFM3Po7qbEliru7m/FkY+TN64ZVxEzh4ndrMN7+Z+jXCAAAAAElFTkSuQmCC" alt=""></i></label>';
686
- $control_html .= '<div class="wbcr-gnz-table__field-item">';
687
- $control_html .= '<input class="wbcr-gnz-table__field-input" name="disabled' . $id . '[custom][]" type="text" placeholder="http://yoursite.test/profile/*" value="" disabled="disabled">';
688
- $control_html .= '<button class="wbcr-gnz-table__field-add" type="button" aria-label="' . __('Add field', 'gonzales') . '" disabled></button>';
689
- $control_html .= '</div>';
690
- //$control_html .= '<em>Пример: http://yoursite.test/profile/*</em>';
691
- $control_html .= '</div>';
692
- // Regex
693
- $control_html .= "<div class='wbcr-gnz-table__field wbcr-assets-manager regex'";
694
- if( !$is_disabled || empty($disabled['regex']) ) {
695
- $control_html .= " style='display: none;'";
696
- }
697
- $control_html .= ">";
698
- $control_html .= '<label class="wbcr-gnz-table__label" for="disabled' . $id . '[regex]">' . __('Enter regular expression', 'gonzales') . ': <i class="wbcr-gnz-help-hint wbcr-gnz-tooltip wbcr-gnz-tooltip-bottom" data-tooltip="' . __('Regular expressions can be used by experts. This tool creates flexible conditions to disable the resource. For example, if you specify this expression: ^([A-z0-9]+-)?gifts? then the resource will be disabled at the following pages http://yoursite.test/get-gift/, http://yoursite.test/gift/, http://yoursite.test/get-gifts/, http://yoursite.test/gifts/. The plugin ignores the backslash at the beginning of the query string, so you can dismiss it. Check your regular expressions in here: https://regex101.com, this will prevent you from the mistakes. This feature is available at the paid version.', 'gonzales') . '"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAQAAABKmM6bAAAAUUlEQVQIHU3BsQ1AQABA0X/komIrnQHYwyhqQ1hBo9KZRKL9CBfeAwy2ri42JA4mPQ9rJ6OVt0BisFM3Po7qbEliru7m/FkY+TN64ZVxEzh4ndrMN7+Z+jXCAAAAAElFTkSuQmCC" alt=""></i></label>';
699
- $control_html .= '<textarea class="wbcr-gnz-table__textarea" rows="3" name="disabled' . $id . '[regex]" placeholder="^rockstar-[0-9]{2,5}" disabled="disabled"></textarea>';
700
- $control_html .= "</div>";
701
- $html .= apply_filters('wbcr_gnz_control_html', $control_html, $id, $is_disabled, $disabled);
702
-
703
- $html .= '</span>';
704
-
705
- if( isset($disabled['current']) && !empty($disabled['current'])
706
- ) {
707
- $custom_urls = "";
708
-
709
- foreach($disabled['current'] as $item_url) {
710
- if( $current_url != $item_url ) {
711
- $full_url = site_url() . $item_url;
712
- $custom_urls .= "<span><a href='" . $full_url . "'>" . $full_url . "</a></span>";
713
- }
714
- }
715
-
716
- if( !empty($custom_urls) ) {
717
- $html .= '<div class="wbcr-gnz-table__also">';
718
- $html .= '<div class="wbcr-gnz-table__label">' . __('Also disabled for pages', 'gonzales') . ':</div>';
719
- $html .= '<div class="wbcr-gnz-table__also-url">' . $custom_urls . '</div>';
720
- $html .= '</div>';
721
  }
722
  }
723
- $html .= '</td>';
724
-
725
- return $html;
 
 
 
 
726
  }
 
727
 
728
- public function formSave()
729
- {
730
- if( isset($_GET['wbcr_assets_manager']) && isset($_POST['wbcr_assets_manager_save']) ) {
731
-
732
- if( !$this->isUserCan() || !wp_verify_nonce(filter_input(INPUT_POST, 'wbcr_assets_manager_save'), 'wbcr_assets_manager_nonce') ) {
733
- wp_die(__('You don\'t have enough capability to edit this information.', 'gonzales'), 403);
734
-
735
- return;
736
- }
737
-
738
- // todo: вынести в метод
739
- if( is_multisite() && is_network_admin() ) {
740
- $options = $this->getNetworkOption('assets_manager_options', array());
741
- } else {
742
- $options = $this->getOption('assets_manager_options', array());
743
- }
744
-
745
- $current_url = esc_url($this->getCurrentUrl());
746
-
747
- if( isset($_POST['disabled']) && !empty($_POST['disabled']) ) {
748
- foreach($_POST['disabled'] as $type => $assets) {
749
- if( !empty($assets) ) {
750
- foreach($assets as $handle => $where) {
751
- $handle = sanitize_text_field($handle);
752
- $where = sanitize_text_field($where['state']);
753
-
754
- if( !isset($options['disabled'][$type][$handle]) ) {
755
- $options['disabled'][$type][$handle] = array();
756
- }
757
- $disabled = &$options['disabled'][$type][$handle];
 
 
 
 
 
758
 
759
- if( !empty($where) && 'disable' == $where ) {
760
- $action = isset($_POST['wgz_action'][$type][$handle]) ? $_POST['wgz_action'][$type][$handle] : '';
761
-
762
- if( "everywhere" == $action ) {
763
- $disabled = apply_filters('wbcr_gnz_unset_disabled', $disabled, $action);
764
-
765
- $disabled['everywhere'] = 1;
766
- } elseif( "current" == $action ) {
767
- $disabled = apply_filters('wbcr_gnz_unset_disabled', $disabled, $action);
768
-
769
- if( !isset($disabled['current']) || !is_array($disabled['current']) ) {
770
- $disabled['current'] = array();
771
- }
772
-
773
- if( !in_array($current_url, $disabled['current']) ) {
774
- array_push($disabled['current'], $current_url);
775
- }
776
- } else {
777
- $post_value = isset($_POST['disabled'][$type][$handle]) ? $_POST['disabled'][$type][$handle] : null;
778
- $disabled = apply_filters('wbcr_gnz_pre_save_disabled', $disabled, $action, $post_value);
779
  }
780
- } else {
781
- $disabled = apply_filters('wbcr_gnz_unset_disabled', $disabled, 'current');
782
 
783
- if( isset($disabled['current']) ) {
784
- $current_key = array_search($current_url, $disabled['current']);
785
-
786
- if( !empty($current_key) || $current_key === 0 ) {
787
- unset($disabled['current'][$current_key]);
788
- if( empty($disabled['current']) ) {
789
- unset($disabled['current']);
790
- }
791
- }
792
  }
 
 
 
793
  }
 
 
794
 
795
- if( empty($disabled) ) {
796
- unset($options['disabled'][$type][$handle]);
797
- if( empty($options['disabled'][$type]) ) {
798
- unset($options['disabled'][$type]);
799
- if( empty($options['disabled']) ) {
800
- unset($options['disabled']);
 
801
  }
802
  }
803
  }
804
  }
 
 
 
 
 
 
 
 
 
 
805
  }
806
  }
807
  }
808
-
809
- if( isset($_POST['enabled']) && !empty($_POST['enabled']) ) {
810
- foreach($_POST['enabled'] as $type => $assets) {
811
- if( !empty($assets) ) {
812
- foreach($assets as $handle => $where) {
813
-
814
- if( !isset($options['enabled'][$type][$handle]) ) {
815
- $options['enabled'][$type][$handle] = array();
 
 
 
 
 
 
 
 
 
816
  }
817
- $enabled = &$options['enabled'][$type][$handle];
818
-
819
- $action = isset($_POST['wgz_action'][$type][$handle]) ? $_POST['wgz_action'][$type][$handle] : '';
820
-
821
- if( "everywhere" == $action && (!empty($where['current']) || $where['current'] === "0")
822
- ) {
823
- if( !isset($enabled['current']) || !is_array($enabled['current']) ) {
824
- $enabled['current'] = array();
825
- }
826
- if( !in_array($where['current'], $enabled['current']) ) {
827
- array_push($enabled['current'], $where['current']);
828
- }
829
- } else {
830
- if( isset($enabled['current']) ) {
831
- $current_key = array_search($current_url, $enabled['current']);
832
- if( !empty($current_key) || $current_key === 0 ) {
833
- unset($enabled['current'][$current_key]);
834
- if( empty($enabled['current']) ) {
835
- unset($options['enabled'][$type][$handle]['current']);
836
- }
837
  }
838
  }
839
  }
840
-
841
- if( "everywhere" == $action && !empty($where['post_types']) ) {
842
- $enabled['post_types'] = array();
843
- foreach($where['post_types'] as $key => $post_type) {
844
- if( isset($enabled['post_types']) ) {
845
- if( !in_array($post_type, $enabled['post_types']) ) {
846
- array_push($enabled['post_types'], $post_type);
847
- }
848
  }
849
  }
850
- } else {
851
- unset($enabled['post_types']);
852
  }
853
-
854
- if( "everywhere" == $action && !empty($where['taxonomies']) ) {
855
- $enabled['taxonomies'] = array();
856
- foreach($where['taxonomies'] as $key => $taxonomy) {
857
- if( isset($enabled['taxonomies']) ) {
858
- if( !in_array($taxonomy, $enabled['taxonomies']) ) {
859
- array_push($enabled['taxonomies'], $taxonomy);
860
- }
 
 
861
  }
862
  }
863
- } else {
864
- unset($enabled['taxonomies']);
865
  }
866
-
867
- if( "everywhere" == $action && !empty($where['categories']) ) {
868
- $enabled['categories'] = array();
869
- foreach($where['categories'] as $key => $category) {
870
- if( isset($enabled['categories']) ) {
871
- if( !in_array($category, $enabled['categories']) ) {
872
- array_push($enabled['categories'], $category);
873
- }
 
 
874
  }
875
  }
876
- } else {
877
- unset($enabled['categories']);
878
  }
879
-
880
- if( empty($enabled) ) {
881
- unset($options['enabled'][$type][$handle]);
882
- if( empty($options['enabled'][$type]) ) {
883
- unset($options['enabled'][$type]);
884
- if( empty($options['enabled']) ) {
885
- unset($options['enabled']);
886
- }
 
 
887
  }
888
  }
889
  }
890
  }
891
  }
892
  }
893
-
894
- do_action('wbcr_gnz_form_save');
895
-
896
- if( is_multisite() && is_network_admin() ) {
897
- $this->updateNetworkOption('assets_manager_options', $options);
898
- } else {
899
- $this->updateOption('assets_manager_options', $options);
900
- }
901
-
902
- WbcrFactoryClearfy206_Helpers::flushPageCache();
903
  }
904
- }
905
-
906
- /**
907
- * Get disabled from options
908
- *
909
- * @param $type
910
- * @param $handle
911
- *
912
- * @return null
913
- */
914
- private function getDisabledFromOptions($type, $handle)
915
- {
916
- // todo: вынести в метод
917
- if( is_multisite() && is_network_admin() ) {
918
- $options = $this->getNetworkOption('assets_manager_options', array());
919
  } else {
920
- $options = $this->getOption('assets_manager_options', array());
921
- }
922
-
923
- $results = apply_filters('wbcr_gnz_get_disabled_from_options', false, $options, $type, $handle);
924
- if( false !== $results ) {
925
- return $results;
926
- }
927
-
928
- if( isset($options['disabled']) && isset($options['disabled'][$type]) && isset($options['disabled'][$type][$handle]) ) {
929
- return $options['disabled'][$type][$handle];
930
  }
931
-
932
- return null;
933
  }
934
-
935
- /**
936
- * Get enabled from options
937
- *
938
- * @param $type
939
- * @param $handle
940
- *
941
- * @return null
942
- */
943
- private function getEnabledFromOptions($type, $handle)
944
- {
945
- // todo: вынести в метод
946
- if( is_multisite() && is_network_admin() ) {
947
- $options = $this->getNetworkOption('assets_manager_options', array());
948
- } else {
949
- $options = $this->getOption('assets_manager_options', array());
950
- }
951
-
952
- $results = apply_filters('wbcr_gnz_get_enabled_from_options', false, $options, $type, $handle);
953
- if( false !== $results ) {
954
- return $results;
955
- }
956
-
957
- if( isset($options['enabled']) && isset($options['enabled'][$type]) && isset($options['enabled'][$type][$handle]) ) {
958
- return $options['enabled'][$type][$handle];
959
- }
960
-
961
- return null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
962
  }
963
 
964
- function unloadAssets($src, $handle)
965
- {
966
- if( isset($_GET['wbcr_assets_manager']) ) {
 
 
 
 
 
 
 
967
  return $src;
968
  }
969
-
970
- if( apply_filters('wbcr_gnz_check_unload_assets', false) ) {
971
  return $src;
972
  }
973
-
974
- $type = (current_filter() == 'script_loader_src') ? 'js' : 'css';
975
-
976
- $current_url = esc_url($this->getCurrentUrl());
977
-
978
- $disabled = $this->getDisabledFromOptions($type, $handle);
979
- $enabled = $this->getEnabledFromOptions($type, $handle);
980
-
981
- if( (isset($disabled['everywhere']) && $disabled['everywhere'] == 1) || (isset($disabled['current']) && is_array($disabled['current']) && in_array($current_url, $disabled['current'])) || apply_filters('wbcr_gnz_check_disabled_is_set', false, $disabled, $current_url) ) {
982
-
983
- if( isset($enabled['current']) && is_array($enabled['current']) && in_array($current_url, $enabled['current']) ) {
984
- return $src;
985
- }
986
-
987
- if( apply_filters('wbcr_gnz_check_unload_disabled', false, $disabled, $current_url) ) {
988
- return $src;
989
- }
990
-
991
- if( isset($enabled['post_types']) && is_singular() && in_array(get_post_type(), $enabled['post_types']) ) {
992
- return $src;
993
- }
994
-
995
- if( isset($enabled['taxonomies']) && in_array(get_queried_object()->taxonomy, $enabled['taxonomies']) ) {
996
- return $src;
997
- }
998
-
999
- if( isset($enabled['categories']) && in_array(get_query_var('cat'), $enabled['categories']) ) {
1000
- return $src;
1001
- }
1002
-
1003
- return false;
1004
  }
1005
 
1006
- return $src;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1007
  }
1008
 
 
 
 
 
 
 
1009
  /**
1010
- * Get information regarding used assets
1011
- *
1012
- * @return bool
1013
  */
1014
- public function collectAssets()
1015
- {
1016
- if( !isset($_GET['wbcr_assets_manager']) || (defined('DOING_AJAX') && DOING_AJAX) ) {
1017
- return false;
1018
- }
1019
-
1020
- $denied = array(
1021
- 'js' => array('wbcr-assets-manager', 'admin-bar'),
1022
- 'css' => array('wbcr-assets-manager', 'admin-bar', 'dashicons'),
1023
- );
1024
- $denied = apply_filters('wbcr_gnz_denied_assets', $denied);
1025
-
1026
- /**
1027
- * Imitate full untouched list without dequeued assets
1028
- * Appends part of original table. Safe approach.
1029
- */
1030
- $data_assets = array(
1031
- 'js' => wp_scripts(),
1032
- 'css' => wp_styles(),
1033
- );
1034
-
1035
- foreach($data_assets as $type => $data) {
1036
- //$resource = array();
1037
- foreach($data->groups as $el => $val) {
1038
- if( isset($data->registered[$el]) ) {
1039
- //foreach($resource as $el) {
1040
- if( !in_array($el, $denied[$type]) ) {
1041
- if( isset($data->registered[$el]->src) ) {
1042
- $url = $this->prepareCorrectUrl($data->registered[$el]->src);
1043
- $url_short = str_replace(get_home_url(), '', $url);
1044
-
1045
- if( false !== strpos($url, get_theme_root_uri()) ) {
1046
- $resource_type = 'theme';
1047
- } elseif( false !== strpos($url, plugins_url()) ) {
1048
- $resource_type = 'plugins';
1049
- } else {
1050
- $resource_type = 'misc';
1051
- }
1052
-
1053
- $resource_name = '';
1054
- if( 'plugins' == $resource_type ) {
1055
- $clean_url = str_replace(WP_PLUGIN_URL . '/', '', $url);
1056
- $url_parts = explode('/', $clean_url);
1057
- $resource_name = isset($url_parts[0]) ? $url_parts[0] : '';
1058
- }
1059
-
1060
- $this->collection[$resource_type][$resource_name][$type][$el] = array(
1061
- 'url_full' => $url,
1062
- 'url_short' => $url_short,
1063
- //'state' => $this->get_visibility($type, $el),
1064
- 'size' => $this->getAssetSize($url),
1065
- 'ver' => $data->registered[$el]->ver,
1066
- 'deps' => (isset($data->registered[$el]->deps) ? $data->registered[$el]->deps : array()),
1067
- );
1068
  }
 
 
 
 
 
 
 
 
 
1069
  }
1070
- //}
1071
  }
 
1072
  }
1073
  }
1074
-
1075
- return false;
1076
  }
1077
-
1078
- /**
1079
- * Loads functionality that allows to enable/disable js/css without site reload
1080
- */
1081
- public function appendAsset()
1082
- {
1083
- if( $this->isUserCan() && isset($_GET['wbcr_assets_manager']) ) {
1084
- wp_enqueue_style('wbcr-assets-manager', WGZ_PLUGIN_URL . '/assets/css/assets-manager.css', array(), $this->plugin->getPluginVersion());
1085
- wp_enqueue_script('wbcr-assets-manager', WGZ_PLUGIN_URL . '/assets/js/assets-manager.js', array('jquery'), $this->plugin->getPluginVersion(), true);
1086
- }
 
1087
  }
1088
-
1089
- /**
1090
- * Exception for address starting from "//example.com" instead of
1091
- * "http://example.com". WooCommerce likes such a format
1092
- *
1093
- * @param string $url Incorrect URL.
1094
- * @return string Correct URL.
1095
- */
1096
- private function prepareCorrectUrl($url)
1097
- {
1098
- if( isset($url[0]) && isset($url[1]) && '/' == $url[0] && '/' == $url[1] ) {
1099
- $out = (is_ssl() ? 'https:' : 'http:') . $url;
1100
- } else {
1101
- $out = $url;
1102
- }
1103
-
1104
- return $out;
1105
  }
1106
 
1107
- /**
1108
- * Get current URL
1109
- *
1110
- * @return string
1111
- */
1112
- private function getCurrentUrl()
1113
- {
1114
- $url = explode('?', $_SERVER['REQUEST_URI'], 2);
1115
- if( strlen($url[0]) > 1 ) {
1116
- $out = rtrim($url[0], '/');
1117
- } else {
1118
- $out = $url[0];
1119
- }
1120
-
1121
- return $out;
1122
  }
1123
-
1124
- /**
1125
- * Checks how heavy is file
1126
- *
1127
- * @param string $src URL.
1128
- * @return int Size in KB.
1129
- */
1130
- private function getAssetSize($src)
1131
- {
1132
- $weight = 0;
1133
-
1134
- $home = get_theme_root() . '/../..';
1135
- $src = explode('?', $src);
1136
-
1137
- if( !filter_var($src[0], FILTER_VALIDATE_URL) === false && strpos($src[0], get_home_url()) === false ) {
1138
- return 0;
1139
- }
1140
-
1141
- $src_relative = $home . str_replace(get_home_url(), '', $this->prepareCorrectUrl($src[0]));
1142
-
1143
- if( file_exists($src_relative) ) {
1144
- $weight = round(filesize($src_relative) / 1024, 1);
1145
- }
1146
-
1147
- return $weight;
1148
  }
1149
-
1150
- /**
1151
- * Unset disabled
1152
- *
1153
- * @param $disabled
1154
- * @param $action
1155
- *
1156
- * @return mixed
1157
- */
1158
- public function unsetDisabled($disabled, $action)
1159
- {
1160
- if( "everywhere" == $action ) {
1161
- unset($disabled['current']);
1162
- } elseif( "current" == $action ) {
1163
- unset($disabled['everywhere']);
1164
- }
1165
-
1166
- return $disabled;
1167
  }
1168
-
1169
- /**
1170
- * Get plugin data from folder name
1171
- *
1172
- * @param $name
1173
- *
1174
- * @return array
1175
- */
1176
- private function getPluginData($name)
1177
- {
1178
- $data = array();
1179
-
1180
- if( $name ) {
1181
- if( !function_exists('get_plugins') ) {
1182
- // подключим файл с функцией get_plugins()
1183
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
1184
- }
1185
- $all_plugins = get_plugins();
1186
- if( !empty($all_plugins) ) {
1187
- foreach($all_plugins as $plugin_path => $plugin_data) {
1188
- if( strpos($plugin_path, $name . '/') !== false ) {
1189
- $data = $plugin_data;
1190
- $data['path'] = $plugin_path;
1191
- break;
1192
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1193
  }
1194
  }
1195
  }
1196
-
1197
- return $data;
1198
  }
1199
-
1200
- /**
1201
- * Get sided plugin name
1202
- *
1203
- * @param string $index
1204
- *
1205
- * @return string
1206
- */
1207
- private function getSidedPluginName($index)
1208
- {
1209
- return $index;
1210
- /*if( isset($this->sided_plugins[$index]) ) {
 
 
1211
  $parts = explode('/', $this->sided_plugins[$index]);
1212
 
1213
  return isset($parts[0]) ? $parts[0] : $this->sided_plugins[$index];
1214
  }
1215
 
1216
  return "";*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1217
  }
1218
-
1219
- /**
1220
- * Get exclude sided plugin files
1221
- *
1222
- * @param string $index
1223
- * @param string $type
1224
- * @param bool $full
1225
- *
1226
- * @return array
1227
- */
1228
- private function getSidedPluginFiles($index, $type, $full = false)
1229
- {
1230
- if( isset($this->sided_plugin_files[$index][$type]) && !empty($this->sided_plugin_files[$index][$type]) ) {
1231
- return $this->sided_plugin_files[$index][$type];
1232
- }
1233
-
1234
- $this->sided_plugin_files[$index][$type] = array();
1235
-
1236
- // todo: вынести в метод
1237
- if( is_multisite() && is_network_admin() ) {
1238
- $options = $this->getNetworkOption('assets_manager_sided_plugins', array());
1239
- } else {
1240
- $options = $this->getOption('assets_manager_sided_plugins', array());
1241
- }
1242
-
1243
- $plugin = $this->getSidedPluginName($index);
1244
-
1245
- if( $plugin && $options ) {
1246
- if( isset($options[$plugin][$type]) ) {
1247
- $urls = $options[$plugin][$type];
1248
-
1249
- if( is_array($urls) ) {
1250
- foreach($urls as $url) {
1251
-
1252
- if( $full ) {
1253
- $file = (false !== strpos($url, site_url()) ? $url : site_url() . '/' . trim($url, '/\\'));
1254
- } else {
1255
- $parts = explode('/', $url);
1256
- $file = array_pop($parts);
1257
- if( empty($file) ) {
1258
- $file = $url;
1259
- }
1260
  }
1261
-
1262
- $this->sided_plugin_files[$index][$type][] = $file;
1263
  }
 
 
1264
  }
1265
  }
1266
  }
1267
-
1268
- return $this->sided_plugin_files[$index][$type];
1269
  }
1270
-
1271
- /**
1272
- * Is component active
1273
- *
1274
- * @param $index
1275
- *
1276
- * @return bool
1277
- */
1278
- private function isComponentActive($index)
1279
- {
1280
- include_once(ABSPATH . 'wp-admin/includes/plugin.php');
1281
-
1282
- $plugin_path = isset($this->sided_plugins[$index]) ? $this->sided_plugins[$index] : null;
1283
-
1284
- if( $index == 'wmac' && defined('LOADING_ASSETS_MANAGER_AS_ADDON') && class_exists('WCL_Plugin') ) {
1285
- return WCL_Plugin::app()->isActivateComponent('minify_and_combine');
1286
- }
1287
-
1288
- return is_plugin_active($plugin_path);
1289
  }
1290
-
1291
- /**
1292
- * Get component name
1293
- *
1294
- * @param $plugin_path
1295
- * @param $index
1296
- *
1297
- * @return string
1298
- */
1299
- private function getComponentName($plugin_path, $index)
1300
- {
1301
- if( $index == 'wclp' ) {
1302
- $name = 'Clearfy';
1303
- } else if( $index == 'wmac' ) {
1304
- $name = __('Minify and Combine', 'gonzales');
1305
- } else {
1306
- $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
1307
- $name = $data['Name'];
1308
- }
1309
-
1310
- return $name;
1311
  }
1312
-
1313
- /**
1314
- * Get head columns
1315
- *
1316
- * @param string $html
1317
- *
1318
- * @return string
1319
- */
1320
- public function getAdditionalHeadColumns($html)
1321
- {
1322
- if( !empty($this->sided_plugins) ) {
1323
- foreach($this->sided_plugins as $index => $plugin_path) {
1324
- if( $this->isComponentActive($index) ) {
1325
- $title = $this->getComponentName($plugin_path, $index);
1326
- $text = $index == 'wclp' ? __('remove version?', 'gonzales') : __('optimize?', 'gonzales');
1327
-
1328
- $hint = '';
1329
- if( $index == 'wclp' ) {
1330
- $hint = __('You’ve enabled &#34;Remove query strings&#34; from static resources in the &#34;Clearfy&#34; plugin. This list of settings helps you to exclude the necessary scripts and styles with remaining query strings. Press No to add a file to the excluded list.', 'gonzales');
1331
- } else if( $index == 'wmac' ) {
1332
- $hint = __('You’ve enabled the &#34;Optimize js scripts?&#34; and &#34;Optimize CSS options&#34; in the &#34;Minify & Combine plugin&#34;. These settings exclude scripts and styles that you don’t want to optimize. Press No to add a file to the excluded list.', 'gonzales');
1333
- } else if( $index == 'aopt' ) {
1334
- $hint = __('You’ve enabled the &#34;Optimize js scripts?&#34; and &#34;Optimize CSS options&#34; in the &#34;Autoptimize&#34;. These settings exclude scripts and styles that you don’t want to optimize. Press No to add a file to the excluded list.', 'gonzales');
1335
- }
1336
- $html .= '<th class="wbcr-gnz-table__column_switch"><span class="wbcr-gnz-table__th-external-plugin">' . $title . ':<i class="wbcr-gnz-help-hint wbcr-gnz-tooltip wbcr-gnz-tooltip-bottom" data-tooltip="' . $hint . '."><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAQAAABKmM6bAAAAUUlEQVQIHU3BsQ1AQABA0X/komIrnQHYwyhqQ1hBo9KZRKL9CBfeAwy2ri42JA4mPQ9rJ6OVt0BisFM3Po7qbEliru7m/FkY+TN64ZVxEzh4ndrMN7+Z+jXCAAAAAElFTkSuQmCC" alt=""></i></span><em>' . $text . '</em></th>';
1337
  }
 
1338
  }
1339
  }
1340
-
1341
- return $html;
1342
  }
1343
-
1344
- /**
1345
- * Get active status for sided plugin
1346
- *
1347
- * @param $index
1348
- * @param $options
1349
- * @param $plugin
1350
- * @param $type
1351
- * @param $handle
1352
- *
1353
- * @return bool
1354
- */
1355
- private function getActiveStatusForSidedPlugin($index, $options, $plugin, $type, $handle)
1356
- {
1357
- $active = isset($options[$plugin][$type]) && is_array($options[$plugin][$type]) && in_array($handle, $options[$plugin][$type]);
1358
-
1359
- /*if( !$active && !isset($options[$plugin]) ) {
 
 
1360
 
1361
  switch( $index ) {
1362
  case 'wclp':
@@ -1373,324 +1343,310 @@
1373
  break;
1374
  }
1375
  }*/
1376
-
1377
- return $active;
1378
- }
1379
-
1380
- /**
1381
- * Get controls columns
1382
- *
1383
- * @param string $html
1384
- * @param string $type
1385
- * @param string $handle
1386
- * @param string $plugin_handle
1387
- *
1388
- * @return string
1389
- */
1390
- public function getAdditionalControlsColumns($html, $type, $handle, $plugin_handle)
1391
- {
1392
- if( !empty($this->sided_plugins) ) {
1393
-
1394
- // todo: вынести в метод
1395
- if( is_multisite() && is_network_admin() ) {
1396
- $options = $this->getNetworkOption('assets_manager_sided_plugins', array());
1397
- } else {
1398
- $options = $this->getOption('assets_manager_sided_plugins', array());
1399
- }
1400
-
1401
- foreach($this->sided_plugins as $index => $plugin_path) {
1402
- if( $this->isComponentActive($index) ) {
1403
- $plugin = $this->getSidedPluginName($index);
1404
-
1405
- $active = $this->getActiveStatusForSidedPlugin($index, $options, $plugin, $type, $handle);
1406
- $name = "sided_plugins[{$plugin}][{$type}][{$handle}]";
1407
-
1408
- $html .= "<td>";
1409
-
1410
- if( !empty($handle) && ('plugins' != $type && false !== strpos($handle, '.' . $type) || 'plugins' == $type) ) {
1411
- $html .= '<label class="wbcr-gnz-switch">';
1412
- $html .= '<input class="wbcr-gnz-switch__input visually-hidden wbcr-gnz-sided-disable';
1413
- $html .= ('plugins' != $type ? ' wbcr-gnz-sided-' . $index . '-' . $plugin_handle : '');
1414
- $html .= '" type="checkbox"' . checked($active, true, false);
1415
- $html .= ('plugins' == $type ? ' data-handle="' . $index . '-' . $plugin_handle . '"' : '') . '/>';
1416
- $html .= '<input type="hidden" name="' . $name . '" value="' . ($active ? 1 : 0) . '"/>';
1417
- $html .= '<span class="wbcr-gnz-switch__inner" data-off="' . __('No', 'gonzales') . '" data-on="' . __('Yes', 'gonzales') . '"></span>';
1418
- $html .= '<span class="wbcr-gnz-switch__slider"></span>';
1419
- $html .= '</label>';
1420
- }
1421
- $html .= "</td>";
1422
  }
 
1423
  }
1424
  }
1425
-
1426
- return $html;
1427
  }
1428
-
1429
- /**
1430
- * @param $index
1431
- * @param $type
1432
- * @param $exclude
1433
- *
1434
- * @return array
1435
- */
1436
- private function filterExclusions($index, $type, $exclude)
1437
- {
1438
- $files = $this->getSidedPluginFiles($index, $type);
1439
-
1440
- if( !empty($files) ) {
1441
- if( is_array($exclude) ) {
1442
- $exclude = array_merge($exclude, $files);
1443
- } else {
1444
- $dontmove = implode(',', $files);
1445
- $exclude .= !empty($exclude) ? ',' . $dontmove : $dontmove;
1446
- }
 
1447
  }
1448
-
1449
- return $exclude;
1450
- }
1451
-
1452
- /**
1453
- * aopt filter js exclude
1454
- *
1455
- * @param $exclude
1456
- * @param $content
1457
- *
1458
- * @return array
1459
- */
1460
- public function aoptFilterJsExclude($exclude, $content)
1461
- {
1462
- return $this->filterExclusions('aopt', 'js', $exclude);
1463
- }
1464
-
1465
- /**
1466
- * aopt filter css exclude
1467
- *
1468
- * @param $exclude
1469
- * @param $content
1470
- *
1471
- * @return array
1472
- */
1473
- public function aoptFilterCssExclude($exclude, $content)
1474
- {
1475
- return $this->filterExclusions('aopt', 'css', $exclude);
1476
- }
1477
-
1478
- /**
1479
- * wmac filter js exclude
1480
- *
1481
- * @param $exclude
1482
- * @param $content
1483
- *
1484
- * @return array
1485
- */
1486
- public function wmacFilterJsExclude($exclude, $content)
1487
- {
1488
- return $this->filterExclusions('wmac', 'js', $exclude);
1489
- }
1490
-
1491
- /**
1492
- * wmac filter css exclude
1493
- *
1494
- * @param $exclude
1495
- * @param $content
1496
- *
1497
- * @return array
1498
- */
1499
- public function wmacFilterCssExclude($exclude, $content)
1500
- {
1501
- return $this->filterExclusions('wmac', 'css', $exclude);
1502
  }
1503
-
1504
- /**
1505
- * Filter js minify exclusions
1506
- *
1507
- * @param $index
1508
- * @param $type
1509
- * @param $result
1510
- * @param $url
1511
- *
1512
- * @return bool
1513
- */
1514
- private function filterJsMinifyExclusions($index, $type, $result, $url)
1515
- {
1516
- $files = $this->getSidedPluginFiles($index, $type);
1517
-
1518
- if( !empty($files) ) {
1519
- foreach($files as $file) {
1520
- if( false !== strpos($url, $file) ) {
1521
- return false;
1522
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1523
  }
1524
  }
1525
-
1526
- return $result;
1527
- }
1528
-
1529
- /**
1530
- * Action wmac_filter_js_minify_excluded
1531
- *
1532
- * @param $result
1533
- * @param $url
1534
- *
1535
- * @return mixed
1536
- */
1537
- public function wmacFilterJsMinifyExclude($result, $url)
1538
- {
1539
- return $this->filterJsMinifyExclusions('wmac', 'js', $result, $url);
1540
- }
1541
-
1542
- /**
1543
- * Action wmac_filter_css_minify_excluded
1544
- *
1545
- * @param $result
1546
- * @param $url
1547
- *
1548
- * @return mixed
1549
- */
1550
- public function wmacFilterCssMinifyExclude($result, $url)
1551
- {
1552
- return $this->filterJsMinifyExclusions('wmac', 'css', $result, $url);
1553
  }
1554
-
1555
- /**
1556
- * Manage excluded files
1557
- *
1558
- * @param $sided_exclude_files
1559
- * @param $index
1560
- * @param $type
1561
- */
1562
- private function manageExcludeFiles($sided_exclude_files, $index, $type)
1563
- {
1564
- switch( $index ) {
1565
- case 'aopt':
1566
- if( get_option('autoptimize_js', false) || get_option('autoptimize_css', false)
1567
- ) {
1568
- $exclude_files = get_option('autoptimize_' . $type . '_exclude', '');
1569
- } else {
1570
- return;
1571
- }
1572
- break;
1573
- case 'wmac':
1574
- if( class_exists('WMAC_Plugin') && (WMAC_Plugin::app()->getPopulateOption('js_optimize', false) || WMAC_Plugin::app()->getPopulateOption('css_optimize', false))
1575
- ) {
1576
- $exclude_files = WMAC_Plugin::app()->getPopulateOption($type . '_exclude', '');
1577
- } else {
1578
- return;
1579
- }
1580
- break;
1581
- case 'wclp':
1582
- if( class_exists('WCL_Plugin') && (WCL_Plugin::app()->getPopulateOption('remove_js_version', false) || WCL_Plugin::app()->getPopulateOption('remove_css_version', false))
1583
- ) {
1584
- $exclude_files = WCL_Plugin::app()->getPopulateOption('remove_version_exclude', '');
1585
- } else {
1586
- return;
1587
- }
1588
- break;
1589
- default:
 
 
 
 
 
1590
  return;
1591
- }
1592
-
1593
- // For clearfy need new line
1594
- $delimeter = $index == 'wclp' ? "\n" : ",";
1595
- $current_exclude_files = !empty($exclude_files) ? array_filter(array_map('trim', explode($delimeter, $exclude_files))) : array();
1596
-
1597
- $delete_files = array_diff($sided_exclude_files['before'][$type], $sided_exclude_files['after'][$type]);
1598
- $new_files = array_diff($sided_exclude_files['after'][$type], $current_exclude_files);
1599
-
1600
- if( empty($current_exclude_files) && !empty($new_files) ) {
1601
- $current_exclude_files = $new_files;
1602
- } else if( !empty($current_exclude_files) ) {
1603
- $new_exclude_files = array();
1604
- foreach($current_exclude_files as $file) {
1605
-
1606
- if( !in_array($file, $delete_files) ) {
1607
- $new_exclude_files[] = $file;
1608
- }
1609
  }
1610
- $current_exclude_files = array_merge($new_exclude_files, $new_files);
1611
- }
1612
-
1613
- $current_exclude_files = array_filter(array_unique($current_exclude_files));
1614
-
1615
- switch( $index ) {
1616
- case 'aopt':
1617
- update_option('autoptimize_' . $type . '_exclude', implode(', ', $current_exclude_files));
1618
- break;
1619
- case 'wmac':
1620
- if( class_exists('WMAC_Plugin') ) {
1621
- WMAC_Plugin::app()->updatePopulateOption($type . '_exclude', implode(', ', $current_exclude_files));
1622
- }
1623
- break;
1624
- case 'wclp':
1625
- if( class_exists('WCL_Plugin') ) {
1626
- WCL_Plugin::app()->updatePopulateOption('remove_version_exclude', implode($delimeter, $current_exclude_files));
1627
- }
1628
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1629
  }
 
1630
  }
1631
-
1632
- /**
1633
- * Action form save
1634
- *
1635
- * @param bool $empty_before
1636
- */
1637
- public function actionFormSave($empty_before = false)
1638
- {
1639
- if( !empty($this->sided_plugins) && !$empty_before ) {
1640
- foreach($this->sided_plugins as $index => $sided_plugin) {
1641
- $sided_exclude_files[$index]['before'] = array(
1642
- 'js' => array(),
1643
- 'css' => array()
1644
- );
1645
- // For clearfy need full url
1646
- $full = ($index == 'wclp' ? true : false);
1647
-
1648
- $sided_exclude_files[$index]['before']['js'] += $this->getSidedPluginFiles($index, 'js', $full);
1649
- $sided_exclude_files[$index]['before']['css'] += $this->getSidedPluginFiles($index, 'css', $full);
1650
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1651
  }
1652
-
1653
- if( isset($_POST['sided_plugins']) && !empty($_POST['sided_plugins']) ) {
1654
- $sided_plugins_options = array();
1655
- foreach($_POST['sided_plugins'] as $plugin => $types) {
1656
- foreach($types as $type => $urls) {
1657
- foreach($urls as $url => $active) {
1658
-
1659
- if( !empty($url) && $active ) {
1660
- $sided_plugins_options[$plugin][$type][] = $url;
1661
- }
1662
  }
1663
  }
1664
  }
1665
-
1666
- if( is_multisite() && is_network_admin() ) {
1667
- $this->updateNetworkOption('assets_manager_sided_plugins', $sided_plugins_options);
1668
- } else {
1669
- $this->updateOption('assets_manager_sided_plugins', $sided_plugins_options);
1670
- }
1671
  }
1672
-
1673
- if( !empty($this->sided_plugins) ) {
1674
- $this->sided_plugin_files = array();
1675
- foreach($this->sided_plugins as $index => $sided_plugin) {
1676
- $sided_exclude_files[$index]['after'] = array(
1677
- 'js' => array(),
1678
- 'css' => array()
1679
- );
1680
- // For clearfy need full url
1681
- $full = ($index == 'wclp' ? true : false);
1682
-
1683
- $sided_exclude_files[$index]['after']['js'] += $this->getSidedPluginFiles($index, 'js', $full);
1684
- $sided_exclude_files[$index]['after']['css'] += $this->getSidedPluginFiles($index, 'css', $full);
1685
-
1686
- if( !empty($sided_exclude_files[$index]['before']['js']) || !empty($sided_exclude_files[$index]['after']['js']) ) {
1687
- $this->manageExcludeFiles($sided_exclude_files[$index], $index, 'js');
1688
- }
1689
-
1690
- if( !empty($sided_exclude_files[$index]['before']['css']) || !empty($sided_exclude_files[$index]['after']['css']) ) {
1691
- $this->manageExcludeFiles($sided_exclude_files[$index], $index, 'css');
1692
- }
 
 
 
 
 
 
1693
  }
1694
  }
1695
  }
1696
- }
 
1
  <?php
2
+
3
+ /**
4
+ * Assets manager base class
5
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
6
+ * @copyright (c) 05.11.2017, Webcraftic
7
+ * @version 1.0
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ class WbcrGnz_ConfigAssetsManager extends Wbcr_FactoryClearfy206_Configurate {
16
 
17
  /**
18
+ * Stores list of all available assets (used in rendering panel)
19
+ *
20
+ * @var array
 
21
  */
22
+ public $collection = array();
23
+
24
+ /**
25
+ * Plugins for additional columns
26
+ *
27
+ * @var array
28
+ */
29
+ private $sided_plugins = array();
30
+
31
+ /**
32
+ * Css and js files excluded in sided plugins
33
+ *
34
+ * @var array
35
+ */
36
+ private $sided_plugin_files = array();
37
+
38
+ /**
39
+ * @var bool
40
+ */
41
+ private $is_user_can;
42
+
43
+ /**
44
+ * @param Wbcr_Factory409_Plugin $plugin
45
+ */
46
+ public function __construct( Wbcr_Factory409_Plugin $plugin ) {
47
+ parent::__construct( $plugin );
48
+ $this->plugin = $plugin;
49
  }
50
+
51
+ protected function isUserCan() {
52
+ return current_user_can( 'manage_options' ) || current_user_can( 'manage_network' );
53
+ }
54
+
55
+ /**
56
+ * Initilize entire machine
57
+ */
58
+ protected function registerActionsAndFilters() {
59
+ if ( $this->getPopulateOption( 'disable_assets_manager', false ) ) {
60
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
 
63
+ $on_frontend = $this->getPopulateOption( 'disable_assets_manager_on_front' );
64
+ $on_backend = $this->getPopulateOption( 'disable_assets_manager_on_backend', true );
65
+ $is_panel = $this->getPopulateOption( 'disable_assets_manager_panel' );
66
+
67
+ if ( ( ! is_admin() && ! $on_frontend ) || ( is_admin() && ! $on_backend ) ) {
68
+ add_filter( 'script_loader_src', array( $this, 'unloadAssets' ), 10, 2 );
69
+ add_filter( 'style_loader_src', array( $this, 'unloadAssets' ), 10, 2 );
70
  }
71
+
72
+ if ( ! $is_panel && ( ( is_admin() && ! $on_backend ) || ( ! is_admin() && ! $on_frontend ) ) ) {
73
+ if ( ! is_admin() ) {
74
+ add_action( 'wp_enqueue_scripts', array( $this, 'appendAsset' ), - 100001 );
75
+ add_action( 'wp_footer', array( $this, 'assetsManager' ), 100001 );
76
+ } else {
77
+ add_action( 'admin_enqueue_scripts', array( $this, 'appendAsset' ), - 100001 );
78
+ add_action( 'admin_footer', array( $this, 'assetsManager' ), 100001 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
+
82
+ if ( ! is_admin() && ! $on_frontend ) {
83
+ add_action( 'wp_head', array( $this, 'collectAssets' ), 10000 );
84
+ add_action( 'wp_footer', array( $this, 'collectAssets' ), 10000 );
 
 
 
 
 
 
 
85
  }
86
+
87
+ if ( is_admin() && ! $on_backend ) {
88
+ add_action( 'admin_head', array( $this, 'collectAssets' ), 10000 );
89
+ add_action( 'admin_footer', array( $this, 'collectAssets' ), 10000 );
90
+ }
91
+
92
+ if ( ! $is_panel && ( ( is_admin() && ! $on_backend ) || ( ! is_admin() && ! $on_frontend ) ) ) {
93
+ if ( defined( 'LOADING_ASSETS_MANAGER_AS_ADDON' ) ) {
94
+ add_action( 'wbcr/clearfy/adminbar_menu_items', array( $this, 'clearfyAdminBarMenu' ) );
95
+ } else {
96
+ add_action( 'admin_bar_menu', array( $this, 'assetsManagerAdminBar' ), 1000 );
97
  }
98
+ }
99
+
100
+ if ( ! is_admin() && ! $on_frontend ) {
101
+ add_action( 'init', array( $this, 'formSave' ) );
102
+ }
103
+
104
+ if ( is_admin() && ! $on_backend ) {
105
+ add_action( 'admin_init', array( $this, 'formSave' ) );
106
+ }
107
+
108
+ add_action( 'plugins_loaded', array( $this, 'pluginsLoaded' ) );
109
+ add_action( 'wbcr_gnz_form_save', array( $this, 'actionFormSave' ) );
110
+
111
+ add_filter( 'wbcr_gnz_unset_disabled', array( $this, 'unsetDisabled' ), 10, 2 );
112
+ add_filter( 'wbcr_gnz_get_additional_head_columns', array( $this, 'getAdditionalHeadColumns' ) );
113
+ add_filter( 'wbcr_gnz_get_additional_controls_columns', array( $this, 'getAdditionalControlsColumns' ), 10, 4 );
114
+
115
+ add_filter( 'autoptimize_filter_js_exclude', array( $this, 'aoptFilterJsExclude' ), 10, 2 );
116
+ add_filter( 'autoptimize_filter_css_exclude', array( $this, 'aoptFilterCssExclude' ), 10, 2 );
117
+ add_filter( 'wmac_filter_js_exclude', array( $this, 'wmacFilterJsExclude' ), 10, 2 );
118
+ add_filter( 'wmac_filter_css_exclude', array( $this, 'wmacFilterCssExclude' ), 10, 2 );
119
+ add_filter( 'wmac_filter_js_minify_excluded', array( $this, 'wmacFilterJsMinifyExclude' ), 10, 2 );
120
+ add_filter( 'wmac_filter_css_minify_excluded', array( $this, 'wmacFilterCssMinifyExclude' ), 10, 2 );
121
+ }
122
+
123
+ function clearfyAdminBarMenu( $menu_items ) {
124
+ $current_url = add_query_arg( array( 'wbcr_assets_manager' => 1 ) );
125
+
126
+ $menu_items['assetsManager'] = array(
127
+ 'title' => '<span class="dashicons dashicons-list-view"></span> ' . __( 'Assets Manager', 'gonzales' ),
128
+ 'href' => $current_url
129
+ );
130
+
131
+ return $menu_items;
132
+ }
133
+
134
+ /**
135
+ * @param WP_Admin_Bar $wp_admin_bar
136
+ */
137
+ function assetsManagerAdminBar( $wp_admin_bar ) {
138
+ if ( ! $this->isUserCan() ) {
139
+ return;
140
+ }
141
+
142
+ $current_url = add_query_arg( array( 'wbcr_assets_manager' => 1 ) );
143
+
144
+ $args = array(
145
+ 'id' => 'assetsManager',
146
+ 'title' => __( 'Assets Manager', 'gonzales' ),
147
+ 'href' => $current_url
148
+ );
149
+ $wp_admin_bar->add_node( $args );
150
+ }
151
+
152
+ /**
153
+ * Action plugins loaded
154
+ */
155
+ public function pluginsLoaded() {
156
+ if ( ! is_admin() ) {
157
+ $this->sided_plugins = array(
158
+ 'aopt' => 'autoptimize/autoptimize.php',
159
+ 'wmac' => 'minify-and-combine/minify-and-combine.php'
160
  );
 
161
  }
162
+
163
+ if ( class_exists( 'WCL_Plugin' ) && ( WCL_Plugin::app()->getPopulateOption( 'remove_js_version', false ) || WCL_Plugin::app()->getPopulateOption( 'remove_css_version', false ) ) ) {
164
+ $this->sided_plugins['wclp'] = 'clearfy/clearfy.php';
165
+ }
166
+
167
+
168
+
169
+ $this->sided_plugins = apply_filters( 'wbcr_gnz_sided_plugins', $this->sided_plugins );
170
+ }
171
+
172
+ function assetsManager() {
173
+ if ( ! $this->isUserCan() || ! isset( $_GET['wbcr_assets_manager'] ) ) {
174
+ return;
175
+ }
176
+
177
+ $current_url = esc_url( $this->getCurrentUrl() );
178
+
179
+ // todo: вынести в метод
180
+ if ( is_multisite() && is_network_admin() ) {
181
+ $options = $this->getNetworkOption( 'assets_manager_options', array() );
182
+ } else {
183
+ $options = $this->getOption( 'assets_manager_options', array() );
184
+ }
185
+
186
+ echo '<div id="WBCR" class="wbcr-gnz-wrapper"';
187
+ if ( isset( $_GET['wbcr_assets_manager'] ) ) {
188
+ echo 'style="display: block;"';
189
+ }
190
+ echo '>';
191
+
192
+ //Form
193
+ echo '<form method="POST">';
194
+ wp_nonce_field( 'wbcr_assets_manager_nonce', 'wbcr_assets_manager_save' );
195
+
196
+ //Header
197
+ echo '<header class="wbcr-gnz-panel">';
198
+ echo '<div class="wbcr-gnz-panel__left">';
199
+ echo '<div class="wbcr-gnz-panel__logo"></div>';
200
+ echo '<ul class="wbcr-gnz-panel__data panel__data-main">';
201
+ echo '<li class="wbcr-gnz-panel__data-item __info-query">' . __( 'Total requests', 'gonzales' ) . ': <b class="wbcr-gnz-panel__item_value">--</b></li>';
202
+ echo '<li class="wbcr-gnz-panel__data-item __info-all-weight">' . __( 'Total size', 'gonzales' ) . ': <b class="wbcr-gnz-panel__item_value"><span class="wbcr-gnz-panel__color-1">--</span></b></li>';
203
+ echo '<li class="wbcr-gnz-panel__data-item __info-opt-weight">' . __( 'Optimized size', 'gonzales' ) . ': <b class="wbcr-gnz-panel__item_value"><span class="wbcr-gnz-panel__color-2">--</span></b></li>';
204
+ echo '<li class="wbcr-gnz-panel__data-item __info-off-js">' . __( 'Disabled js', 'gonzales' ) . ': <b class="wbcr-gnz-panel__item_value">--</li></b>';
205
+ echo '<li class="wbcr-gnz-panel__data-item __info-off-css">' . __( 'Disabled css', 'gonzales' ) . ': <b class="wbcr-gnz-panel__item_value">--</li></b>';
206
+ echo '</ul>';
207
+ $panel_to_premium_info = '<div class="wbcr-gnz-panel__premium"><div class="wbcr-gnz-tooltip wbcr-gnz-tooltip-bottom" data-tooltip="' . __( 'This is the general statistics to see the optimization result. Available in the paid version only.', 'gonzales' ) . '.">PRO</div></div>';
208
+ echo apply_filters( 'wbcr_gnz_panel_premium', $panel_to_premium_info );
209
+ echo '</div>';
210
+ echo '<div class="wbcr-gnz-panel__right">';
211
+ echo '<button class="wbcr-gnz-panel__reset wbcr-reset-button" type="button">' . __( 'Reset', 'gonzales' ) . '</button>';
212
+ echo '<input class="wbcr-gnz-panel__save" type="submit" value="' . __( 'Save', 'gonzales' ) . '">';
213
+ echo '<label class="wbcr-gnz-panel__checkbox wbcr-gnz-tooltip wbcr-gnz-tooltip-bottom" data-tooltip="' . __( 'In test mode, you can experiment with disabling unused scripts safely for your site. The resources that you disabled will be visible only to you (the administrator), and all other users will receive an unoptimized version of the site, until you remove this tick', 'gonzales' ) . '.">';
214
+ echo apply_filters( 'wbcr_gnz_test_mode_checkbox', '<input class="wbcr-gnz-panel__checkbox-input visually-hidden" type="checkbox" disabled="disabled" checked/><span class="wbcr-gnz-panel__checkbox-text-premium">' . __( 'Safe mode <b>PRO</b>', 'gonzales' ) . '</span>' );
215
+ echo '</label>';
216
+ echo '<button class="wbcr-gnz-panel__close wbcr-close-button" type="button" aria-label="' . __( 'Close', 'gonzales' ) . '" data-href="' . remove_query_arg( 'wbcr_assets_manager' ) . '"></button>';
217
+ echo '</div>';
218
+ echo '</header>';
219
+
220
+ // Main content
221
+ echo '<main class="wbcr-gnz-content">';
222
+
223
+ uksort( $this->collection, function ( $a, $b ) {
224
+ if ( 'plugins' == $a ) {
225
+ return - 1;
226
  }
227
+
228
+ if ( 'plugins' == $b ) {
229
+ return 1;
230
  }
 
231
 
232
+ return strcasecmp( $a, $b );
233
+ } );
234
+
235
+ // Tabs
236
+ echo '<ul class="wbcr-gnz-tabs">';
237
+ foreach ( $this->collection as $resource_type => $resources ) {
238
+ echo '<li class="wbcr-gnz-tabs__item">';
239
+ echo '<div class="wbcr-gnz-tabs__button wbcr-gnz-tabs__button--' . $resource_type . '" data-hash="' . $resource_type . '" aria-label="' . $resource_type . '"></div>';
240
+ echo '</li>';
241
  }
242
+ echo '</ul>';
243
+
244
+ // Info
245
+ echo '<div class="wbcr-gnz-info"><div class="wbcr-gnz-info__warning">';
246
+ echo '<p><b>' . __( 'Important! Each page of your website has different sets of scripts and styles files.', 'gonzales' ) . '</b></p>';
247
+ echo '<p>' . __( 'Use this feature to disable unwanted scripts and styles by setting up the logic for different types of pages. We recommend working in "Safe mode" because disabling any necessary system script file can corrupt the website. All changes done in Safe mode are available for administrator only. This way only you, as the administrator, can see the result of optimization. To enable the changes for other users, uncheck Safe mode.', 'gonzales' ) . '</p>';
248
+ echo '<p>' . sprintf( __( 'For more details and user guides, check the plugin’s <a href="%s" target="_blank" rel="noreferrer noopener">documentation</a>.', 'gonzales' ), WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl( WGZ_Plugin::app()->getPluginName(), 'docs' ) ) . '</p>';
249
+ echo '</div>';
250
+
251
+ $premium_button = '<a class="wbcr-gnz-button__pro" href="' . WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl( WGZ_Plugin::app()->getPluginName(), 'assets-manager' ) . '" target="_blank" rel="noreferrer noopener">' . __( 'Upgrade to Premium', 'gonzales' ) . '</a>';
252
+
253
+ $upgrade_to_premium_info = '<div class="wbcr-gnz-info__go-to-premium"><ul>';
254
+ $upgrade_to_premium_info .= '<h3><span>' . __( 'MORE IN CLEARFY BUSINESS', 'gonzales' ) . '</span>' . $premium_button . '</h3><ul>';
255
+ $upgrade_to_premium_info .= '<li>' . __( 'Disable plugins (groups of scripts)', 'gonzales' ) . '</li>';
256
+ $upgrade_to_premium_info .= '<li>' . __( 'Conditions by the link template', 'gonzales' ) . '</li>';
257
+ $upgrade_to_premium_info .= '<li>' . __( 'Conditions by the regular expression', 'gonzales' ) . '</li>';
258
+ $upgrade_to_premium_info .= '<li>' . __( 'Safe mode', 'gonzales' ) . '</li>';
259
+ $upgrade_to_premium_info .= '<li>' . __( 'Statistics and optimization results', 'gonzales' ) . '</li>';
260
+ $upgrade_to_premium_info .= '</ul>';
261
+ $upgrade_to_premium_info .= '</div>';
262
+ echo apply_filters( 'wbcr_gnz_upgrade_to_premium_info', $upgrade_to_premium_info );
263
+ echo '</div>';
264
+
265
+ global $plugin_state;
266
+
267
+ foreach ( $this->collection as $resource_type => $resources ) {
268
+ // Tabs content
269
+ echo '<div class="wbcr-gnz-tabs-content">';
270
+ echo '<div class="wbcr-gnz-table">';
271
+ echo '<table>';
272
+ echo '<col class="wbcr-gnz-table__loaded"/>';
273
+ echo '<col class="wbcr-gnz-table__size"/>';
274
+ echo '<col class="wbcr-gnz-table__script"/>';
275
+ echo '<col class="wbcr-gnz-table__state"/>';
276
+ echo '<col class="wbcr-gnz-table__turn-on"/>';
277
+
278
+ foreach ( $resources as $resource_name => $types ) {
279
+ $plugin_state = false;
280
+
281
+ if ( 'plugins' == $resource_type && ! empty( $resource_name ) ) {
282
+ $plugin_data = $this->getPluginData( $resource_name );
283
+
284
+ echo '<tbody>';
285
+
286
+ if ( ! empty( $plugin_data ) ) {
287
+ $is_disabled = $this->getIsDisabled( $options, $resource_type, $resource_name );
288
+ $disabled = $this->getDisabled( $is_disabled, $options, $resource_type, $resource_name );
289
+
290
+ $is_enabled = $this->getIsEnabled( $options, $resource_type, $resource_name );
291
+ $enabled = $this->getEnabled( $is_enabled, $options, $resource_type, $resource_name );
292
+
293
+ $plugin_state = $this->getState( $is_disabled, $disabled, $current_url );
294
+ $plugin_state = apply_filters( 'wbcr_gnz_get_plugin_state', false, $plugin_state );
295
+
296
+ echo '<tr class="wbcr-gnz-table__alternate">';
297
+ echo '<th style="width:5%">' . __( 'Loaded', 'gonzales' ) . '</th>';
298
+ echo '<th colspan="2">' . __( 'Plugin', 'gonzales' ) . '</th>';
299
+
300
+ echo apply_filters( 'wbcr_gnz_get_additional_head_columns', '' );
301
+
302
+ echo '<th class="wbcr-gnz-table__column_switch"><b>' . __( 'Load resource?', 'gonzales' ) . '</b></th>';
303
+ echo '<th class="wbcr-gnz-table__column_condition">' . __( 'Conditions', 'gonzales' ) . '</th>';
304
+ echo '</tr>';
305
+ echo '<tr>';
306
+ echo '<td>';
307
+ echo '<div class="wbcr-gnz-table__loaded-state wbcr-gnz-table__loaded-' . ( $plugin_state ? 'no' : 'yes' ) . ' wbcr-state"></div>';
308
+ echo '</td>';
309
+ echo '<td colspan="2" class="wbcr-gnz-table__item">';
310
+ echo '<div class="wbcr-gnz-table__item-name">' . $plugin_data['Name'] . '</div>';
311
+ echo '<div class="wbcr-gnz-table__item-author"><strong>' . __( 'Author', 'gonzales' ) . ':</strong> ' . $plugin_data['Author'] . '</div>';
312
+ echo '<div class="wbcr-gnz-table__item-version"><strong>' . __( 'Version', 'gonzales' ) . ':</strong> ' . $plugin_data['Version'] . '</div>';
313
+ echo '</td>';
314
+
315
+ echo apply_filters( 'wbcr_gnz_get_additional_controls_columns', '', $resource_type, $resource_name, $resource_name );
316
+
317
+ // State Controls
318
+ $id = '[' . $resource_type . '][' . $resource_name . ']';
319
+ echo $this->getStateControrlHTML( $id, $plugin_state, $is_disabled, $is_enabled, $resource_type, $resource_name, $disabled, $enabled, $current_url );
320
+ echo '</tr>';
321
+ }
322
  }
323
+
324
+ echo '<tr class="wbcr-gnz-table__alternate">';
325
+ echo '<th style="width:5%">' . __( 'Loaded', 'gonzales' ) . '</th>';
326
+ echo '<th style="width:5%">' . __( 'Size', 'gonzales' ) . '</th>';
327
+ echo '<th class="wgz-th">' . __( 'Resource', 'gonzales' ) . '</th>';
328
+
329
+ echo apply_filters( 'wbcr_gnz_get_additional_head_columns', '' );
330
+
331
+ echo '<th class="wbcr-gnz-table__column_switch"><b>' . __( 'Load resource?', 'gonzales' ) . '</b></th>';
332
+ echo '<th class="wbcr-gnz-table__column_condition">' . __( 'Conditions', 'gonzales' ) . '</th>';
333
+ echo '</tr>';
334
+
335
+ foreach ( $types as $type_name => $rows ) {
336
+
337
+ if ( ! empty( $rows ) ) {
338
+ foreach ( $rows as $handle => $row ) {
339
+ $is_disabled = $this->getIsDisabled( $options, $type_name, $handle );
340
+ $disabled = $this->getDisabled( $is_disabled, $options, $type_name, $handle );
341
+
342
+ $is_enabled = $this->getIsEnabled( $options, $type_name, $handle );
343
+ $enabled = $this->getEnabled( $is_enabled, $options, $type_name, $handle );
344
+
345
+ /**
346
+ * Find dependency
347
+ */
348
+ $deps = array();
349
+ foreach ( $rows as $dep_key => $dep_val ) {
350
+ if ( in_array( $handle, $dep_val['deps'] ) /*&& $is_disabled*/ ) {
351
+ $deps[] = '<a href="#' . $type_name . '-' . $dep_key . '">' . $dep_key . '</a>';
352
+ }
353
+ }
354
+
355
+ $comment = ( ! empty( $deps ) ? '<span class="wbcr-use-by-comment">' . __( 'In use by', 'gonzales' ) . ' ' . implode( ', ', $deps ) . '</span>' : '' );
356
+ $requires = '';
357
+ if ( ! empty( $row['deps'] ) ) {
358
+ $rdeps = array();
359
+ foreach ( $row['deps'] as $dep_val ) {
360
+ $rdeps[] = '<a href="#' . $type_name . '-' . $dep_val . '">' . $dep_val . '</a>';
361
+ }
362
+ $requires = ( $comment ? '<br>' : '' ) . '<span class="wbcr-use-by-comment">' . __( 'Requires', 'gonzales' ) . ' ' . implode( ', ', $rdeps ) . '</span>';
363
+ }
364
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  echo '<tr>';
366
+
367
+ // Loaded
368
+ $state = $this->getState( $is_disabled, $disabled, $current_url );
369
+ $display_state = $plugin_state === 1 ? 1 : $state;
370
+ echo '<td>';
371
+ echo '<div class="wbcr-gnz-table__loaded-state wbcr-gnz-table__loaded-' . ( $plugin_state ? 'no' : 'yes' );
372
+ echo ' wbcr-state' . ( $state ? ' wbcr-gnz-table__loaded-super-no' : '' );
373
+ echo ( 'plugins' == $resource_type ? ' wbcr-state-' . $resource_name : '' ) . '">';
374
+ echo '</div>';
375
+ echo '</td>';
376
+
377
+ // Size
378
  echo '<td>';
379
+ echo '<div class="wbcr-gnz-table__size-value">' . $row['size'] . ' <b>KB</b></div>';
380
  echo '</td>';
381
+
382
+ // Handle + Path + In use
383
+ echo '<td class="wgz-td">';
384
+ echo '<div class="wbcr-gnz-table__script-name"><b class="wbcr-wgz-resource-type-' . $type_name . '">' . $type_name . '</b>[' . $handle . ']</div>';
385
+ echo "<a id='" . $type_name . "-" . $handle . "' class='wbcr-anchor'></a>";
386
+ echo '<div class="wbcr-gnz-table__script-path">';
387
+ echo "<a href='" . $row['url_full'] . "' target='_blank'>";
388
+ echo str_replace( get_home_url(), '', $row['url_full'] ) . "</a>";
389
+ echo '</div>';
390
+ echo '<div class="wbcr-gnz-table__script-version">';
391
+ echo __( 'Version', 'gonzales' ) . ': ' . ( ! empty( $row['ver'] ) ? $row['ver'] : __( '--', 'gonzales' ) );
392
+ echo '</div>';
393
+ echo '<div>' . $comment . $requires . '</div>';
394
  echo '</td>';
395
+
396
+ // Controls for other plugins
397
+ echo apply_filters( 'wbcr_gnz_get_additional_controls_columns', '', $type_name, $row['url_full'], $resource_name );
398
+
399
  // State Controls
400
+ $id = '[' . $type_name . '][' . $handle . ']';
401
+ echo $this->getStateControrlHTML( $id, $state, $is_disabled, $is_enabled, $type_name, $handle, $disabled, $enabled, $current_url );
402
+
403
+ echo "<input type='hidden' class='wbcr-info-data' data-type='{$type_name}' data-off='{$display_state}' value='{$row['size']}'>";
404
  echo '</tr>';
405
+
406
+ echo apply_filters( 'wbcr_gnz_after_scripts_table_row', '', $resource_type, $resource_name, $type_name, $handle );
407
  }
408
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  }
410
+
411
+ if ( 'plugins' == $resource_type && ! empty( $resource_name ) ) {
412
+ echo '</tbody>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
  }
 
 
414
  }
415
+
416
+ echo '</table>';
417
+ echo '</div>';
418
+ echo '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
419
  }
420
+ echo '</main>';
421
+ echo '</form> <!-- /endform -->';
422
+ echo '</div> <!-- /div2 -->';
423
+ }
424
+
425
+ /**
426
+ * Get is disabled
427
+ *
428
+ * @param $options
429
+ * @param $type_name
430
+ * @param $handle
431
+ *
432
+ * @return bool
433
+ */
434
+ public function getIsDisabled( $options, $type_name, $handle ) {
435
+ return isset( $options['disabled'] ) && isset( $options['disabled'][ $type_name ] ) && isset( $options['disabled'][ $type_name ][ $handle ] );
436
+ }
437
+
438
+ /**
439
+ * Get disabled
440
+ *
441
+ * @param $is_disabled
442
+ * @param $options
443
+ * @param $type_name
444
+ * @param $handle
445
+ *
446
+ * @return array
447
+ */
448
+ public function getDisabled( $is_disabled, $options, $type_name, $handle ) {
449
+ $disabled = array();
450
+
451
+ if ( $is_disabled ) {
452
+ $disabled = &$options['disabled'][ $type_name ][ $handle ];
453
+ if ( ! isset( $disabled['current'] ) ) {
454
+ $disabled['current'] = array();
455
  }
456
+ if ( ! isset( $disabled['everywhere'] ) ) {
457
+ $disabled['everywhere'] = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
  }
459
+
460
+ $disabled = apply_filters( 'wbcr_gnz_get_disabled', $disabled );
461
  }
462
+
463
+ return $disabled;
464
+ }
465
+
466
+ /**
467
+ * Get is enabled
468
+ *
469
+ * @param $options
470
+ * @param $type_name
471
+ * @param $handle
472
+ *
473
+ * @return bool
474
+ */
475
+ public function getIsEnabled( $options, $type_name, $handle ) {
476
+ return isset( $options['enabled'] ) && isset( $options['enabled'][ $type_name ] ) && isset( $options['enabled'][ $type_name ][ $handle ] );
477
+ }
478
+
479
+ /**
480
+ * Get enabled
481
+ *
482
+ * @param $is_enabled
483
+ * @param $options
484
+ * @param $type_name
485
+ * @param $handle
486
+ *
487
+ * @return array
488
+ */
489
+ public function getEnabled( $is_enabled, $options, $type_name, $handle ) {
490
+ $enabled = array();
491
+
492
+ if ( $is_enabled ) {
493
+ $enabled = &$options['enabled'][ $type_name ][ $handle ];
494
+
495
+ if ( ! isset( $enabled['current'] ) ) {
496
+ $enabled['current'] = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
497
  }
498
+ if ( ! isset( $enabled['everywhere'] ) ) {
499
+ $enabled['everywhere'] = array();
 
 
 
 
 
 
 
 
500
  }
501
+
502
+ $enabled = apply_filters( 'wbcr_gnz_get_enabled', $enabled );
503
+ }
504
+
505
+ return $enabled;
506
+ }
507
+
508
+ /**
509
+ * Get State
510
+ *
511
+ * @param $is_disabled
512
+ * @param $disabled
513
+ * @param $current_url
514
+ *
515
+ * @return int
516
+ */
517
+ public function getState( $is_disabled, $disabled, $current_url ) {
518
+ $state = 0;
519
+ if ( $is_disabled && ( $disabled['everywhere'] == 1 || in_array( $current_url, $disabled['current'] ) || apply_filters( 'wbcr_gnz_check_state_disabled', false, $disabled ) ) ) {
520
+ $state = 1;
521
+ }
522
+
523
+ return $state;
524
+ }
525
+
526
+ /**
527
+ * Get state controrl HTML
528
+ *
529
+ * @param $id
530
+ * @param $state
531
+ * @param $is_disabled
532
+ * @param $is_enabled
533
+ * @param $type_name
534
+ * @param $handle
535
+ * @param $disabled
536
+ * @param $enabled
537
+ * @param $current_url
538
+ *
539
+ * @return string
540
+ */
541
+ public function getStateControrlHTML( $id, $state, $is_disabled, $is_enabled, $type_name, $handle, $disabled, $enabled, $current_url ) {
542
+ // Disable
543
+ $html = '<td>';
544
+ $html .= '<label class="wbcr-gnz-switch' . ( $type_name == 'plugins' ? apply_filters( 'wbcr_gnz_switch_premium', ' wbcr-gnz-switch-premium' ) : '' ) . '">';
545
+ $html .= '<input class="wbcr-gnz-switch__input visually-hidden' . apply_filters( 'wbcr_gnz_switch_plugin_premium', $type_name == 'plugins' ? '' : ' wbcr-gnz-disable' ) . '" type="checkbox"' . checked( $state, true, false );
546
+ $html .= ( 'plugins' == $type_name ? " data-handle='{$handle}'" : "" ) . '/>';
547
+ $html .= '<input type="hidden" name="disabled' . $id . '[state]" value="' . ( $state ? 'disable' : '' ) . '"/>';
548
+ $html .= '<span class="wbcr-gnz-switch__inner" data-off="' . __( 'No', 'gonzales' ) . '" data-on="' . __( 'Yes', 'gonzales' ) . '"></span>';
549
+ $html .= '<span class="wbcr-gnz-switch__slider"></span>';
550
+ $html .= '</label>';
551
+ $html .= '</td>';
552
+
553
+ // Enable
554
+ $class_name = 'wbcr-assets-manager-enable';
555
+ if ( 'plugins' == $type_name ) {
556
+ $class_name = apply_filters( 'wbcr_gnz_control_classname', 'wbcr-gnz' );
557
+ }
558
+ $html .= '<td>';
559
+ $html .= '<div class="wbcr-gnz-table__note ' . $class_name . '-placeholder"';
560
+ if ( $state ) {
561
+ $html .= ' style="display: none;"';
562
+ }
563
+ if ( 'plugins' != $type_name ) {
564
+ $html .= '><p>' . __( 'Click the switch in the <b>Load resource?</b> column to display the conditions for loading the resource.', 'gonzales' ) . '</p>';
565
+ } else {
566
+ $html .= '><p>' . apply_filters( 'wbcr_gnz_conditions_note_premium', __( 'Set the plugin logic to apply it to all plugin’s resources. This feature available at the paid version.', 'gonzales' ) ) . '</p>';
567
+ }
568
+ $html .= '</div>';
569
+ $html .= '<span class="' . $class_name . '"';
570
+ if ( ! $state ) {
571
+ $html .= ' style="display: none;"';
572
+ }
573
+ $html .= '>';
574
+ $html .= '<select class="wbcr-gnz-table__select wbcr-gnz-action-select" name="wgz_action' . $id . '">';
575
+ $html .= '<option value="current"' . selected( $is_disabled && ! empty( $disabled['current'] ), true, false ) . '>' . __( 'Current URL', 'gonzales' ) . '</option>';
576
+ $html .= '<option value="everywhere"' . selected( $is_disabled && ! empty( $disabled['everywhere'] ), true, false ) . '>' . __( 'Everywhere', 'gonzales' ) . '</option>';
577
+ $options = '<option value="custom"' . selected( $is_disabled && ! empty( $disabled['custom'] ), true, false ) . ' class="wbcr-gnz-table__select-pro">' . __( 'Custom URL (PRO)', 'gonzales' ) . '</option>';
578
+ $options .= '<option value="regex"' . selected( $is_disabled && ! empty( $disabled['regex'] ), true, false ) . ' class="wbcr-gnz-table__select-pro">' . __( 'Regular expression (PRO)', 'gonzales' ) . '</option>';
579
+ $html .= apply_filters( 'wbcr_gnz_select_options', $options, $is_disabled, $disabled );
580
+ $html .= '</select>';
581
+
582
+ // Everywhere
583
+ $html .= "<span class='wbcr-assets-manager everywhere'";
584
+ if ( ! $is_disabled || empty( $disabled['everywhere'] ) ) {
585
+ $html .= " style='display: none;'";
586
+ }
587
+ $html .= ">";
588
+ $html .= '<div class="wbcr-gnz-table__label">' . __( 'Exclude', 'gonzales' ) . ': <i class="wbcr-gnz-help-hint wbcr-gnz-tooltip wbcr-gnz-tooltip-bottom" data-tooltip="' . __( 'You can disable this resource for all pages, except sections and page types listed below. Specify sections and page types with the enabled resource.', 'gonzales' ) . '"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAQAAABKmM6bAAAAUUlEQVQIHU3BsQ1AQABA0X/komIrnQHYwyhqQ1hBo9KZRKL9CBfeAwy2ri42JA4mPQ9rJ6OVt0BisFM3Po7qbEliru7m/FkY+TN64ZVxEzh4ndrMN7+Z+jXCAAAAAElFTkSuQmCC" alt=""></i></div>';
589
+ $html .= '<ul class="wbcr-gnz-table__options">';
590
+
591
+ $html .= '<li class="wbcr-gnz-table__options-item">';
592
+ $html .= "<input type='hidden' name='enabled{$id}[current]' value='' />";
593
+ $html .= '<label class="wbcr-gnz-table__checkbox">';
594
+ $html .= '<input class="wbcr-gnz-table__checkbox-input visually-hidden" type="checkbox" name="enabled' . $id . '[current]" value="' . $current_url . '"';
595
+ if ( $is_enabled && in_array( $current_url, $enabled['current'] ) ) {
596
+ $html .= ' checked';
597
+ }
598
+ $html .= '/>';
599
+ $html .= '<span class="wbcr-gnz-table__checkbox-text">' . __( 'Current URL', 'gonzales' ) . '</span>';
600
+ $html .= '</label>';
601
+ $html .= '</li>';
602
+
603
+ $post_types = get_post_types( array( 'public' => true ), 'objects', 'and' );
604
+ if ( ! empty( $post_types ) ) {
605
+ $html .= "<input type='hidden' name='enabled{$id}[post_types]' value='' />";
606
+ foreach ( $post_types as $key => $value ) {
607
+ $html .= '<li class="wbcr-gnz-table__options-item">';
608
+ $html .= '<label class="wbcr-gnz-table__checkbox">';
609
+ $html .= '<input class="wbcr-gnz-table__checkbox-input visually-hidden" type="checkbox" name="enabled' . $id . '[post_types][]" value="' . $key . '"';
610
+ if ( isset( $enabled['post_types'] ) ) {
611
+ if ( in_array( $key, $enabled['post_types'] ) ) {
612
+ $html .= ' checked';
613
  }
 
 
 
 
614
  }
615
+ $html .= '/>';
616
+ $html .= '<span class="wbcr-gnz-table__checkbox-text">' . $value->label . '</span>';
617
+ $html .= '</label>';
618
+ $html .= '</li>';
619
  }
620
+ }
621
+
622
+ $taxonomies = get_taxonomies( array( 'public' => true ), 'objects', 'and' );
623
+
624
+ if ( ! empty( $taxonomies ) ) {
625
+ unset( $taxonomies['category'] );
626
+ $html .= "<input type='hidden' name='enabled{$id}[taxonomies]' value='' />";
627
+ foreach ( $taxonomies as $key => $value ) {
628
+ $html .= '<li class="wbcr-gnz-table__options-item">';
629
+ $html .= '<label class="wbcr-gnz-table__checkbox">';
630
+ $html .= '<input class="wbcr-gnz-table__checkbox-input visually-hidden" type="checkbox" name="enabled' . $id . '[taxonomies][]" value="' . $key . '"';
631
+ if ( isset( $enabled['taxonomies'] ) ) {
632
+ if ( in_array( $key, $enabled['taxonomies'] ) ) {
633
+ $html .= ' checked';
634
  }
 
 
 
 
635
  }
636
+ $html .= '/>';
637
+ $html .= '<span class="wbcr-gnz-table__checkbox-text">' . $value->label . '</span>';
638
+ $html .= '</label>';
639
+ $html .= '</li>';
640
  }
641
+ }
642
+
643
+ $categories = get_categories();
644
+
645
+ if ( ! empty( $categories ) ) {
646
+ $html .= "<input type='hidden' name='enabled{$id}[categories]' value='' />";
647
+ foreach ( $categories as $key => $cat ) {
648
+ $html .= '<li class="wbcr-gnz-table__options-item">';
649
+ $html .= '<label class="wbcr-gnz-table__checkbox">';
650
+ $html .= '<input class="wbcr-gnz-table__checkbox-input visually-hidden" type="checkbox" name="enabled' . $id . '[categories][]" value="' . $cat->term_id . '"';
651
+ if ( isset( $enabled['categories'] ) ) {
652
+ if ( in_array( $cat->term_id, $enabled['categories'] ) ) {
653
+ $html .= ' checked';
654
  }
 
 
 
 
655
  }
656
+ $html .= '/>';
657
+ $html .= '<span class="wbcr-gnz-table__checkbox-text">' . $cat->name . '</span>';
658
+ $html .= '</label>';
659
+ $html .= '</li>';
660
  }
661
+ }
662
+
663
+ $html .= '</ul>';
664
+ $html .= '</span>';
665
+
666
+ // Custom URL
667
+ $control_html = '<div class="wbcr-gnz-table__field wbcr-assets-manager custom"';
668
+ if ( ! $is_disabled || empty( $disabled['custom'] ) ) {
669
+ $control_html .= ' style="display: none;"';
670
+ }
671
+ $control_html .= '>';
672
+ $control_html .= '<label class="wbcr-gnz-table__label" for="disabled' . $id . '[custom][]" title="' . __( 'Example', 'gonzales' ) . ': ' . site_url() . '/post/*, ' . site_url() . '/page-*>">' . __( 'Enter URL (set * for mask)', 'gonzales' ) . ': <i class="wbcr-gnz-help-hint wbcr-gnz-tooltip wbcr-gnz-tooltip-bottom" data-tooltip="' . __( 'You can disable the resource only for the pages with the matched to the template address. For example, if you set the template for the link as http://yoursite.test/profile/*, then the resource is disabled for the following pages: http://yoursite.test/profile/12, http://yoursite.test/profile/43, http://yoursite.test/profile/999. If you don’t use the asterisk symbol in the template then the plugin will disable the resource only for the pages with 100% match in the specified link type. This feature is available at the paid version.', 'gonzales' ) . '"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAQAAABKmM6bAAAAUUlEQVQIHU3BsQ1AQABA0X/komIrnQHYwyhqQ1hBo9KZRKL9CBfeAwy2ri42JA4mPQ9rJ6OVt0BisFM3Po7qbEliru7m/FkY+TN64ZVxEzh4ndrMN7+Z+jXCAAAAAElFTkSuQmCC" alt=""></i></label>';
673
+ $control_html .= '<div class="wbcr-gnz-table__field-item">';
674
+ $control_html .= '<input class="wbcr-gnz-table__field-input" name="disabled' . $id . '[custom][]" type="text" placeholder="http://yoursite.test/profile/*" value="" disabled="disabled">';
675
+ $control_html .= '<button class="wbcr-gnz-table__field-add" type="button" aria-label="' . __( 'Add field', 'gonzales' ) . '" disabled></button>';
676
+ $control_html .= '</div>';
677
+ //$control_html .= '<em>Пример: http://yoursite.test/profile/*</em>';
678
+ $control_html .= '</div>';
679
+ // Regex
680
+ $control_html .= "<div class='wbcr-gnz-table__field wbcr-assets-manager regex'";
681
+ if ( ! $is_disabled || empty( $disabled['regex'] ) ) {
682
+ $control_html .= " style='display: none;'";
683
+ }
684
+ $control_html .= ">";
685
+ $control_html .= '<label class="wbcr-gnz-table__label" for="disabled' . $id . '[regex]">' . __( 'Enter regular expression', 'gonzales' ) . ': <i class="wbcr-gnz-help-hint wbcr-gnz-tooltip wbcr-gnz-tooltip-bottom" data-tooltip="' . __( 'Regular expressions can be used by experts. This tool creates flexible conditions to disable the resource. For example, if you specify this expression: ^([A-z0-9]+-)?gifts? then the resource will be disabled at the following pages http://yoursite.test/get-gift/, http://yoursite.test/gift/, http://yoursite.test/get-gifts/, http://yoursite.test/gifts/. The plugin ignores the backslash at the beginning of the query string, so you can dismiss it. Check your regular expressions in here: https://regex101.com, this will prevent you from the mistakes. This feature is available at the paid version.', 'gonzales' ) . '"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAQAAABKmM6bAAAAUUlEQVQIHU3BsQ1AQABA0X/komIrnQHYwyhqQ1hBo9KZRKL9CBfeAwy2ri42JA4mPQ9rJ6OVt0BisFM3Po7qbEliru7m/FkY+TN64ZVxEzh4ndrMN7+Z+jXCAAAAAElFTkSuQmCC" alt=""></i></label>';
686
+ $control_html .= '<textarea class="wbcr-gnz-table__textarea" rows="3" name="disabled' . $id . '[regex]" placeholder="^rockstar-[0-9]{2,5}" disabled="disabled"></textarea>';
687
+ $control_html .= "</div>";
688
+ $html .= apply_filters( 'wbcr_gnz_control_html', $control_html, $id, $is_disabled, $disabled );
689
+
690
+ $html .= '</span>';
691
+
692
+ if ( isset( $disabled['current'] ) && ! empty( $disabled['current'] ) ) {
693
+ $custom_urls = "";
694
+
695
+ foreach ( $disabled['current'] as $item_url ) {
696
+ if ( $current_url != $item_url ) {
697
+ $full_url = site_url() . $item_url;
698
+ $custom_urls .= "<span><a href='" . $full_url . "'>" . $full_url . "</a></span>";
 
 
 
 
 
 
 
 
699
  }
700
  }
701
+
702
+ if ( ! empty( $custom_urls ) ) {
703
+ $html .= '<div class="wbcr-gnz-table__also">';
704
+ $html .= '<div class="wbcr-gnz-table__label">' . __( 'Also disabled for pages', 'gonzales' ) . ':</div>';
705
+ $html .= '<div class="wbcr-gnz-table__also-url">' . $custom_urls . '</div>';
706
+ $html .= '</div>';
707
+ }
708
  }
709
+ $html .= '</td>';
710
 
711
+ return $html;
712
+ }
713
+
714
+ public function formSave() {
715
+ if ( isset( $_GET['wbcr_assets_manager'] ) && isset( $_POST['wbcr_assets_manager_save'] ) ) {
716
+
717
+ if ( ! $this->isUserCan() || ! wp_verify_nonce( filter_input( INPUT_POST, 'wbcr_assets_manager_save' ), 'wbcr_assets_manager_nonce' ) ) {
718
+ wp_die( __( 'You don\'t have enough capability to edit this information.', 'gonzales' ), 403 );
719
+
720
+ return;
721
+ }
722
+
723
+ // todo: вынести в метод
724
+ if ( is_multisite() && is_network_admin() ) {
725
+ $options = $this->getNetworkOption( 'assets_manager_options', array() );
726
+ } else {
727
+ $options = $this->getOption( 'assets_manager_options', array() );
728
+ }
729
+
730
+ $current_url = esc_url( $this->getCurrentUrl() );
731
+
732
+ if ( isset( $_POST['disabled'] ) && ! empty( $_POST['disabled'] ) ) {
733
+ foreach ( $_POST['disabled'] as $type => $assets ) {
734
+ if ( ! empty( $assets ) ) {
735
+ foreach ( $assets as $handle => $where ) {
736
+ $handle = sanitize_text_field( $handle );
737
+ $where = sanitize_text_field( $where['state'] );
738
+
739
+ if ( ! isset( $options['disabled'][ $type ][ $handle ] ) ) {
740
+ $options['disabled'][ $type ][ $handle ] = array();
741
+ }
742
+ $disabled = &$options['disabled'][ $type ][ $handle ];
743
+
744
+ if ( ! empty( $where ) && 'disable' == $where ) {
745
+ $action = isset( $_POST['wgz_action'][ $type ][ $handle ] ) ? $_POST['wgz_action'][ $type ][ $handle ] : '';
746
 
747
+ if ( "everywhere" == $action ) {
748
+ $disabled = apply_filters( 'wbcr_gnz_unset_disabled', $disabled, $action );
749
+
750
+ $disabled['everywhere'] = 1;
751
+ } else if ( "current" == $action ) {
752
+ $disabled = apply_filters( 'wbcr_gnz_unset_disabled', $disabled, $action );
753
+
754
+ if ( ! isset( $disabled['current'] ) || ! is_array( $disabled['current'] ) ) {
755
+ $disabled['current'] = array();
 
 
 
 
 
 
 
 
 
 
 
756
  }
 
 
757
 
758
+ if ( ! in_array( $current_url, $disabled['current'] ) ) {
759
+ array_push( $disabled['current'], $current_url );
 
 
 
 
 
 
 
760
  }
761
+ } else {
762
+ $post_value = isset( $_POST['disabled'][ $type ][ $handle ] ) ? $_POST['disabled'][ $type ][ $handle ] : null;
763
+ $disabled = apply_filters( 'wbcr_gnz_pre_save_disabled', $disabled, $action, $post_value );
764
  }
765
+ } else {
766
+ $disabled = apply_filters( 'wbcr_gnz_unset_disabled', $disabled, 'current' );
767
 
768
+ if ( isset( $disabled['current'] ) ) {
769
+ $current_key = array_search( $current_url, $disabled['current'] );
770
+
771
+ if ( ! empty( $current_key ) || $current_key === 0 ) {
772
+ unset( $disabled['current'][ $current_key ] );
773
+ if ( empty( $disabled['current'] ) ) {
774
+ unset( $disabled['current'] );
775
  }
776
  }
777
  }
778
  }
779
+
780
+ if ( empty( $disabled ) ) {
781
+ unset( $options['disabled'][ $type ][ $handle ] );
782
+ if ( empty( $options['disabled'][ $type ] ) ) {
783
+ unset( $options['disabled'][ $type ] );
784
+ if ( empty( $options['disabled'] ) ) {
785
+ unset( $options['disabled'] );
786
+ }
787
+ }
788
+ }
789
  }
790
  }
791
  }
792
+ }
793
+
794
+ if ( isset( $_POST['enabled'] ) && ! empty( $_POST['enabled'] ) ) {
795
+ foreach ( $_POST['enabled'] as $type => $assets ) {
796
+ if ( ! empty( $assets ) ) {
797
+ foreach ( $assets as $handle => $where ) {
798
+
799
+ if ( ! isset( $options['enabled'][ $type ][ $handle ] ) ) {
800
+ $options['enabled'][ $type ][ $handle ] = array();
801
+ }
802
+ $enabled = &$options['enabled'][ $type ][ $handle ];
803
+
804
+ $action = isset( $_POST['wgz_action'][ $type ][ $handle ] ) ? $_POST['wgz_action'][ $type ][ $handle ] : '';
805
+
806
+ if ( "everywhere" == $action && ( ! empty( $where['current'] ) || $where['current'] === "0" ) ) {
807
+ if ( ! isset( $enabled['current'] ) || ! is_array( $enabled['current'] ) ) {
808
+ $enabled['current'] = array();
809
  }
810
+ if ( ! in_array( $where['current'], $enabled['current'] ) ) {
811
+ array_push( $enabled['current'], $where['current'] );
812
+ }
813
+ } else {
814
+ if ( isset( $enabled['current'] ) ) {
815
+ $current_key = array_search( $current_url, $enabled['current'] );
816
+ if ( ! empty( $current_key ) || $current_key === 0 ) {
817
+ unset( $enabled['current'][ $current_key ] );
818
+ if ( empty( $enabled['current'] ) ) {
819
+ unset( $options['enabled'][ $type ][ $handle ]['current'] );
 
 
 
 
 
 
 
 
 
 
820
  }
821
  }
822
  }
823
+ }
824
+
825
+ if ( "everywhere" == $action && ! empty( $where['post_types'] ) ) {
826
+ $enabled['post_types'] = array();
827
+ foreach ( $where['post_types'] as $key => $post_type ) {
828
+ if ( isset( $enabled['post_types'] ) ) {
829
+ if ( ! in_array( $post_type, $enabled['post_types'] ) ) {
830
+ array_push( $enabled['post_types'], $post_type );
831
  }
832
  }
 
 
833
  }
834
+ } else {
835
+ unset( $enabled['post_types'] );
836
+ }
837
+
838
+ if ( "everywhere" == $action && ! empty( $where['taxonomies'] ) ) {
839
+ $enabled['taxonomies'] = array();
840
+ foreach ( $where['taxonomies'] as $key => $taxonomy ) {
841
+ if ( isset( $enabled['taxonomies'] ) ) {
842
+ if ( ! in_array( $taxonomy, $enabled['taxonomies'] ) ) {
843
+ array_push( $enabled['taxonomies'], $taxonomy );
844
  }
845
  }
 
 
846
  }
847
+ } else {
848
+ unset( $enabled['taxonomies'] );
849
+ }
850
+
851
+ if ( "everywhere" == $action && ! empty( $where['categories'] ) ) {
852
+ $enabled['categories'] = array();
853
+ foreach ( $where['categories'] as $key => $category ) {
854
+ if ( isset( $enabled['categories'] ) ) {
855
+ if ( ! in_array( $category, $enabled['categories'] ) ) {
856
+ array_push( $enabled['categories'], $category );
857
  }
858
  }
 
 
859
  }
860
+ } else {
861
+ unset( $enabled['categories'] );
862
+ }
863
+
864
+ if ( empty( $enabled ) ) {
865
+ unset( $options['enabled'][ $type ][ $handle ] );
866
+ if ( empty( $options['enabled'][ $type ] ) ) {
867
+ unset( $options['enabled'][ $type ] );
868
+ if ( empty( $options['enabled'] ) ) {
869
+ unset( $options['enabled'] );
870
  }
871
  }
872
  }
873
  }
874
  }
875
  }
 
 
 
 
 
 
 
 
 
 
876
  }
877
+
878
+ do_action( 'wbcr_gnz_form_save' );
879
+
880
+ if ( is_multisite() && is_network_admin() ) {
881
+ $this->updateNetworkOption( 'assets_manager_options', $options );
 
 
 
 
 
 
 
 
 
 
882
  } else {
883
+ $this->updateOption( 'assets_manager_options', $options );
 
 
 
 
 
 
 
 
 
884
  }
885
+
886
+ WbcrFactoryClearfy206_Helpers::flushPageCache();
887
  }
888
+ }
889
+
890
+ /**
891
+ * Get disabled from options
892
+ *
893
+ * @param $type
894
+ * @param $handle
895
+ *
896
+ * @return null
897
+ */
898
+ private function getDisabledFromOptions( $type, $handle ) {
899
+ // todo: вынести в метод
900
+ if ( is_multisite() && is_network_admin() ) {
901
+ $options = $this->getNetworkOption( 'assets_manager_options', array() );
902
+ } else {
903
+ $options = $this->getOption( 'assets_manager_options', array() );
904
+ }
905
+
906
+ $results = apply_filters( 'wbcr_gnz_get_disabled_from_options', false, $options, $type, $handle );
907
+ if ( false !== $results ) {
908
+ return $results;
909
+ }
910
+
911
+ if ( isset( $options['disabled'] ) && isset( $options['disabled'][ $type ] ) && isset( $options['disabled'][ $type ][ $handle ] ) ) {
912
+ return $options['disabled'][ $type ][ $handle ];
913
+ }
914
+
915
+ return null;
916
+ }
917
+
918
+ /**
919
+ * Get enabled from options
920
+ *
921
+ * @param $type
922
+ * @param $handle
923
+ *
924
+ * @return null
925
+ */
926
+ private function getEnabledFromOptions( $type, $handle ) {
927
+ // todo: вынести в метод
928
+ if ( is_multisite() && is_network_admin() ) {
929
+ $options = $this->getNetworkOption( 'assets_manager_options', array() );
930
+ } else {
931
+ $options = $this->getOption( 'assets_manager_options', array() );
932
+ }
933
+
934
+ $results = apply_filters( 'wbcr_gnz_get_enabled_from_options', false, $options, $type, $handle );
935
+ if ( false !== $results ) {
936
+ return $results;
937
+ }
938
+
939
+ if ( isset( $options['enabled'] ) && isset( $options['enabled'][ $type ] ) && isset( $options['enabled'][ $type ][ $handle ] ) ) {
940
+ return $options['enabled'][ $type ][ $handle ];
941
+ }
942
+
943
+ return null;
944
+ }
945
+
946
+ function unloadAssets( $src, $handle ) {
947
+ if ( isset( $_GET['wbcr_assets_manager'] ) ) {
948
+ return $src;
949
+ }
950
+
951
+ if ( apply_filters( 'wbcr_gnz_check_unload_assets', false ) ) {
952
+ return $src;
953
  }
954
 
955
+ $type = ( current_filter() == 'script_loader_src' ) ? 'js' : 'css';
956
+
957
+ $current_url = esc_url( $this->getCurrentUrl() );
958
+
959
+ $disabled = $this->getDisabledFromOptions( $type, $handle );
960
+ $enabled = $this->getEnabledFromOptions( $type, $handle );
961
+
962
+ if ( ( isset( $disabled['everywhere'] ) && $disabled['everywhere'] == 1 ) || ( isset( $disabled['current'] ) && is_array( $disabled['current'] ) && in_array( $current_url, $disabled['current'] ) ) || apply_filters( 'wbcr_gnz_check_disabled_is_set', false, $disabled, $current_url ) ) {
963
+
964
+ if ( isset( $enabled['current'] ) && is_array( $enabled['current'] ) && in_array( $current_url, $enabled['current'] ) ) {
965
  return $src;
966
  }
967
+
968
+ if ( apply_filters( 'wbcr_gnz_check_unload_disabled', false, $disabled, $current_url ) ) {
969
  return $src;
970
  }
971
+
972
+ if ( isset( $enabled['post_types'] ) && is_singular() && in_array( get_post_type(), $enabled['post_types'] ) ) {
973
+ return $src;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
974
  }
975
 
976
+ if ( isset( $enabled['taxonomies'] ) && in_array( get_queried_object()->taxonomy, $enabled['taxonomies'] ) ) {
977
+ return $src;
978
+ }
979
+
980
+ if ( isset( $enabled['categories'] ) && in_array( get_query_var( 'cat' ), $enabled['categories'] ) ) {
981
+ return $src;
982
+ }
983
+
984
+ return false;
985
+ }
986
+
987
+ return $src;
988
+ }
989
+
990
+ /**
991
+ * Get information regarding used assets
992
+ *
993
+ * @return bool
994
+ */
995
+ public function collectAssets() {
996
+ if ( ! isset( $_GET['wbcr_assets_manager'] ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
997
+ return false;
998
  }
999
 
1000
+ $denied = array(
1001
+ 'js' => array( 'wbcr-assets-manager', 'admin-bar' ),
1002
+ 'css' => array( 'wbcr-assets-manager', 'admin-bar', 'dashicons' ),
1003
+ );
1004
+ $denied = apply_filters( 'wbcr_gnz_denied_assets', $denied );
1005
+
1006
  /**
1007
+ * Imitate full untouched list without dequeued assets
1008
+ * Appends part of original table. Safe approach.
 
1009
  */
1010
+ $data_assets = array(
1011
+ 'js' => wp_scripts(),
1012
+ 'css' => wp_styles(),
1013
+ );
1014
+
1015
+ foreach ( $data_assets as $type => $data ) {
1016
+ //$resource = array();
1017
+ foreach ( $data->groups as $el => $val ) {
1018
+ if ( isset( $data->registered[ $el ] ) ) {
1019
+ //foreach($resource as $el) {
1020
+ if ( ! in_array( $el, $denied[ $type ] ) ) {
1021
+ if ( isset( $data->registered[ $el ]->src ) ) {
1022
+ $url = $this->prepareCorrectUrl( $data->registered[ $el ]->src );
1023
+ $url_short = str_replace( get_home_url(), '', $url );
1024
+
1025
+ if ( false !== strpos( $url, get_theme_root_uri() ) ) {
1026
+ $resource_type = 'theme';
1027
+ } else if ( false !== strpos( $url, plugins_url() ) ) {
1028
+ $resource_type = 'plugins';
1029
+ } else {
1030
+ $resource_type = 'misc';
1031
+ }
1032
+
1033
+ $resource_name = '';
1034
+ if ( 'plugins' == $resource_type ) {
1035
+ $clean_url = str_replace( WP_PLUGIN_URL . '/', '', $url );
1036
+ $url_parts = explode( '/', $clean_url );
1037
+ $resource_name = isset( $url_parts[0] ) ? $url_parts[0] : '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1038
  }
1039
+
1040
+ $this->collection[ $resource_type ][ $resource_name ][ $type ][ $el ] = array(
1041
+ 'url_full' => $url,
1042
+ 'url_short' => $url_short,
1043
+ //'state' => $this->get_visibility($type, $el),
1044
+ 'size' => $this->getAssetSize( $url ),
1045
+ 'ver' => $data->registered[ $el ]->ver,
1046
+ 'deps' => ( isset( $data->registered[ $el ]->deps ) ? $data->registered[ $el ]->deps : array() ),
1047
+ );
1048
  }
 
1049
  }
1050
+ //}
1051
  }
1052
  }
 
 
1053
  }
1054
+
1055
+ return false;
1056
+ }
1057
+
1058
+ /**
1059
+ * Loads functionality that allows to enable/disable js/css without site reload
1060
+ */
1061
+ public function appendAsset() {
1062
+ if ( $this->isUserCan() && isset( $_GET['wbcr_assets_manager'] ) ) {
1063
+ wp_enqueue_style( 'wbcr-assets-manager', WGZ_PLUGIN_URL . '/assets/css/assets-manager.css', array(), $this->plugin->getPluginVersion() );
1064
+ wp_enqueue_script( 'wbcr-assets-manager', WGZ_PLUGIN_URL . '/assets/js/assets-manager.js', array( 'jquery' ), $this->plugin->getPluginVersion(), true );
1065
  }
1066
+ }
1067
+
1068
+ /**
1069
+ * Exception for address starting from "//example.com" instead of
1070
+ * "http://example.com". WooCommerce likes such a format
1071
+ *
1072
+ * @param string $url Incorrect URL.
1073
+ *
1074
+ * @return string Correct URL.
1075
+ */
1076
+ private function prepareCorrectUrl( $url ) {
1077
+ if ( isset( $url[0] ) && isset( $url[1] ) && '/' == $url[0] && '/' == $url[1] ) {
1078
+ $out = ( is_ssl() ? 'https:' : 'http:' ) . $url;
1079
+ } else {
1080
+ $out = $url;
 
 
1081
  }
1082
 
1083
+ return $out;
1084
+ }
1085
+
1086
+ /**
1087
+ * Get current URL
1088
+ *
1089
+ * @return string
1090
+ */
1091
+ private function getCurrentUrl() {
1092
+ $url = explode( '?', $_SERVER['REQUEST_URI'], 2 );
1093
+ if ( strlen( $url[0] ) > 1 ) {
1094
+ $out = rtrim( $url[0], '/' );
1095
+ } else {
1096
+ $out = $url[0];
 
1097
  }
1098
+
1099
+ return $out;
1100
+ }
1101
+
1102
+ /**
1103
+ * Checks how heavy is file
1104
+ *
1105
+ * @param string $src URL.
1106
+ *
1107
+ * @return int Size in KB.
1108
+ */
1109
+ private function getAssetSize( $src ) {
1110
+ $weight = 0;
1111
+
1112
+ $home = get_theme_root() . '/../..';
1113
+ $src = explode( '?', $src );
1114
+
1115
+ if ( ! filter_var( $src[0], FILTER_VALIDATE_URL ) === false && strpos( $src[0], get_home_url() ) === false ) {
1116
+ return 0;
 
 
 
 
 
 
1117
  }
1118
+
1119
+ $src_relative = $home . str_replace( get_home_url(), '', $this->prepareCorrectUrl( $src[0] ) );
1120
+
1121
+ if ( file_exists( $src_relative ) ) {
1122
+ $weight = round( filesize( $src_relative ) / 1024, 1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
1123
  }
1124
+
1125
+ return $weight;
1126
+ }
1127
+
1128
+ /**
1129
+ * Unset disabled
1130
+ *
1131
+ * @param $disabled
1132
+ * @param $action
1133
+ *
1134
+ * @return mixed
1135
+ */
1136
+ public function unsetDisabled( $disabled, $action ) {
1137
+ if ( "everywhere" == $action ) {
1138
+ unset( $disabled['current'] );
1139
+ } else if ( "current" == $action ) {
1140
+ unset( $disabled['everywhere'] );
1141
+ }
1142
+
1143
+ return $disabled;
1144
+ }
1145
+
1146
+ /**
1147
+ * Get plugin data from folder name
1148
+ *
1149
+ * @param $name
1150
+ *
1151
+ * @return array
1152
+ */
1153
+ private function getPluginData( $name ) {
1154
+ $data = array();
1155
+
1156
+ if ( $name ) {
1157
+ if ( ! function_exists( 'get_plugins' ) ) {
1158
+ // подключим файл с функцией get_plugins()
1159
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
1160
+ }
1161
+ $all_plugins = get_plugins();
1162
+ if ( ! empty( $all_plugins ) ) {
1163
+ foreach ( $all_plugins as $plugin_path => $plugin_data ) {
1164
+ if ( strpos( $plugin_path, $name . '/' ) !== false ) {
1165
+ $data = $plugin_data;
1166
+ $data['path'] = $plugin_path;
1167
+ break;
1168
  }
1169
  }
1170
  }
 
 
1171
  }
1172
+
1173
+ return $data;
1174
+ }
1175
+
1176
+ /**
1177
+ * Get sided plugin name
1178
+ *
1179
+ * @param string $index
1180
+ *
1181
+ * @return string
1182
+ */
1183
+ private function getSidedPluginName( $index ) {
1184
+ return $index;
1185
+ /*if( isset($this->sided_plugins[$index]) ) {
1186
  $parts = explode('/', $this->sided_plugins[$index]);
1187
 
1188
  return isset($parts[0]) ? $parts[0] : $this->sided_plugins[$index];
1189
  }
1190
 
1191
  return "";*/
1192
+ }
1193
+
1194
+ /**
1195
+ * Get exclude sided plugin files
1196
+ *
1197
+ * @param string $index
1198
+ * @param string $type
1199
+ * @param bool $full
1200
+ *
1201
+ * @return array
1202
+ */
1203
+ private function getSidedPluginFiles( $index, $type, $full = false ) {
1204
+ if ( isset( $this->sided_plugin_files[ $index ][ $type ] ) && ! empty( $this->sided_plugin_files[ $index ][ $type ] ) ) {
1205
+ return $this->sided_plugin_files[ $index ][ $type ];
1206
  }
1207
+
1208
+ $this->sided_plugin_files[ $index ][ $type ] = array();
1209
+
1210
+ // todo: вынести в метод
1211
+ if ( is_multisite() && is_network_admin() ) {
1212
+ $options = $this->getNetworkOption( 'assets_manager_sided_plugins', array() );
1213
+ } else {
1214
+ $options = $this->getOption( 'assets_manager_sided_plugins', array() );
1215
+ }
1216
+
1217
+ $plugin = $this->getSidedPluginName( $index );
1218
+
1219
+ if ( $plugin && $options ) {
1220
+ if ( isset( $options[ $plugin ][ $type ] ) ) {
1221
+ $urls = $options[ $plugin ][ $type ];
1222
+
1223
+ if ( is_array( $urls ) ) {
1224
+ foreach ( $urls as $url ) {
1225
+
1226
+ if ( $full ) {
1227
+ $file = ( false !== strpos( $url, site_url() ) ? $url : site_url() . '/' . trim( $url, '/\\' ) );
1228
+ } else {
1229
+ $parts = explode( '/', $url );
1230
+ $file = array_pop( $parts );
1231
+ if ( empty( $file ) ) {
1232
+ $file = $url;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1233
  }
 
 
1234
  }
1235
+
1236
+ $this->sided_plugin_files[ $index ][ $type ][] = $file;
1237
  }
1238
  }
1239
  }
 
 
1240
  }
1241
+
1242
+ return $this->sided_plugin_files[ $index ][ $type ];
1243
+ }
1244
+
1245
+ /**
1246
+ * Is component active
1247
+ *
1248
+ * @param $index
1249
+ *
1250
+ * @return bool
1251
+ */
1252
+ private function isComponentActive( $index ) {
1253
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1254
+
1255
+ $plugin_path = isset( $this->sided_plugins[ $index ] ) ? $this->sided_plugins[ $index ] : null;
1256
+
1257
+ if ( $index == 'wmac' && defined( 'LOADING_ASSETS_MANAGER_AS_ADDON' ) && class_exists( 'WCL_Plugin' ) ) {
1258
+ return WCL_Plugin::app()->isActivateComponent( 'minify_and_combine' );
 
1259
  }
1260
+
1261
+ return is_plugin_active( $plugin_path );
1262
+ }
1263
+
1264
+ /**
1265
+ * Get component name
1266
+ *
1267
+ * @param $plugin_path
1268
+ * @param $index
1269
+ *
1270
+ * @return string
1271
+ */
1272
+ private function getComponentName( $plugin_path, $index ) {
1273
+ if ( $index == 'wclp' ) {
1274
+ $name = 'Clearfy';
1275
+ } else if ( $index == 'wmac' ) {
1276
+ $name = __( 'Minify and Combine', 'gonzales' );
1277
+ } else {
1278
+ $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_path );
1279
+ $name = $data['Name'];
 
1280
  }
1281
+
1282
+ return $name;
1283
+ }
1284
+
1285
+ /**
1286
+ * Get head columns
1287
+ *
1288
+ * @param string $html
1289
+ *
1290
+ * @return string
1291
+ */
1292
+ public function getAdditionalHeadColumns( $html ) {
1293
+ if ( ! empty( $this->sided_plugins ) ) {
1294
+ foreach ( $this->sided_plugins as $index => $plugin_path ) {
1295
+ if ( $this->isComponentActive( $index ) ) {
1296
+ $title = $this->getComponentName( $plugin_path, $index );
1297
+ $text = $index == 'wclp' ? __( 'remove version?', 'gonzales' ) : __( 'optimize?', 'gonzales' );
1298
+
1299
+ $hint = '';
1300
+ if ( $index == 'wclp' ) {
1301
+ $hint = __( 'You’ve enabled &#34;Remove query strings&#34; from static resources in the &#34;Clearfy&#34; plugin. This list of settings helps you to exclude the necessary scripts and styles with remaining query strings. Press No to add a file to the excluded list.', 'gonzales' );
1302
+ } else if ( $index == 'wmac' ) {
1303
+ $hint = __( 'You’ve enabled the &#34;Optimize js scripts?&#34; and &#34;Optimize CSS options&#34; in the &#34;Minify & Combine plugin&#34;. These settings exclude scripts and styles that you don’t want to optimize. Press No to add a file to the excluded list.', 'gonzales' );
1304
+ } else if ( $index == 'aopt' ) {
1305
+ $hint = __( 'You’ve enabled the &#34;Optimize js scripts?&#34; and &#34;Optimize CSS options&#34; in the &#34;Autoptimize&#34;. These settings exclude scripts and styles that you don’t want to optimize. Press No to add a file to the excluded list.', 'gonzales' );
1306
  }
1307
+ $html .= '<th class="wbcr-gnz-table__column_switch"><span class="wbcr-gnz-table__th-external-plugin">' . $title . ':<i class="wbcr-gnz-help-hint wbcr-gnz-tooltip wbcr-gnz-tooltip-bottom" data-tooltip="' . $hint . '."><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAQAAABKmM6bAAAAUUlEQVQIHU3BsQ1AQABA0X/komIrnQHYwyhqQ1hBo9KZRKL9CBfeAwy2ri42JA4mPQ9rJ6OVt0BisFM3Po7qbEliru7m/FkY+TN64ZVxEzh4ndrMN7+Z+jXCAAAAAElFTkSuQmCC" alt=""></i></span><em>' . $text . '</em></th>';
1308
  }
1309
  }
 
 
1310
  }
1311
+
1312
+ return $html;
1313
+ }
1314
+
1315
+ /**
1316
+ * Get active status for sided plugin
1317
+ *
1318
+ * @param $index
1319
+ * @param $options
1320
+ * @param $plugin
1321
+ * @param $type
1322
+ * @param $handle
1323
+ *
1324
+ * @return bool
1325
+ */
1326
+ private function getActiveStatusForSidedPlugin( $index, $options, $plugin, $type, $handle ) {
1327
+ $active = isset( $options[ $plugin ][ $type ] ) && is_array( $options[ $plugin ][ $type ] ) && in_array( $handle, $options[ $plugin ][ $type ] );
1328
+
1329
+ /*if( !$active && !isset($options[$plugin]) ) {
1330
 
1331
  switch( $index ) {
1332
  case 'wclp':
1343
  break;
1344
  }
1345
  }*/
1346
+
1347
+ return $active;
1348
+ }
1349
+
1350
+ /**
1351
+ * Get controls columns
1352
+ *
1353
+ * @param string $html
1354
+ * @param string $type
1355
+ * @param string $handle
1356
+ * @param string $plugin_handle
1357
+ *
1358
+ * @return string
1359
+ */
1360
+ public function getAdditionalControlsColumns( $html, $type, $handle, $plugin_handle ) {
1361
+ if ( ! empty( $this->sided_plugins ) ) {
1362
+
1363
+ // todo: вынести в метод
1364
+ if ( is_multisite() && is_network_admin() ) {
1365
+ $options = $this->getNetworkOption( 'assets_manager_sided_plugins', array() );
1366
+ } else {
1367
+ $options = $this->getOption( 'assets_manager_sided_plugins', array() );
1368
+ }
1369
+
1370
+ foreach ( $this->sided_plugins as $index => $plugin_path ) {
1371
+ if ( $this->isComponentActive( $index ) ) {
1372
+ $plugin = $this->getSidedPluginName( $index );
1373
+
1374
+ $active = $this->getActiveStatusForSidedPlugin( $index, $options, $plugin, $type, $handle );
1375
+ $name = "sided_plugins[{$plugin}][{$type}][{$handle}]";
1376
+
1377
+ $html .= "<td>";
1378
+
1379
+ if ( ! empty( $handle ) && ( 'plugins' != $type && false !== strpos( $handle, '.' . $type ) || 'plugins' == $type ) ) {
1380
+ $html .= '<label class="wbcr-gnz-switch">';
1381
+ $html .= '<input class="wbcr-gnz-switch__input visually-hidden wbcr-gnz-sided-disable';
1382
+ $html .= ( 'plugins' != $type ? ' wbcr-gnz-sided-' . $index . '-' . $plugin_handle : '' );
1383
+ $html .= '" type="checkbox"' . checked( $active, true, false );
1384
+ $html .= ( 'plugins' == $type ? ' data-handle="' . $index . '-' . $plugin_handle . '"' : '' ) . '/>';
1385
+ $html .= '<input type="hidden" name="' . $name . '" value="' . ( $active ? 1 : 0 ) . '"/>';
1386
+ $html .= '<span class="wbcr-gnz-switch__inner" data-off="' . __( 'No', 'gonzales' ) . '" data-on="' . __( 'Yes', 'gonzales' ) . '"></span>';
1387
+ $html .= '<span class="wbcr-gnz-switch__slider"></span>';
1388
+ $html .= '</label>';
 
 
 
1389
  }
1390
+ $html .= "</td>";
1391
  }
1392
  }
 
 
1393
  }
1394
+
1395
+ return $html;
1396
+ }
1397
+
1398
+ /**
1399
+ * @param $index
1400
+ * @param $type
1401
+ * @param $exclude
1402
+ *
1403
+ * @return array
1404
+ */
1405
+ private function filterExclusions( $index, $type, $exclude ) {
1406
+ $files = $this->getSidedPluginFiles( $index, $type );
1407
+
1408
+ if ( ! empty( $files ) ) {
1409
+ if ( is_array( $exclude ) ) {
1410
+ $exclude = array_merge( $exclude, $files );
1411
+ } else {
1412
+ $dontmove = implode( ',', $files );
1413
+ $exclude .= ! empty( $exclude ) ? ',' . $dontmove : $dontmove;
1414
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1415
  }
1416
+
1417
+ return $exclude;
1418
+ }
1419
+
1420
+ /**
1421
+ * aopt filter js exclude
1422
+ *
1423
+ * @param $exclude
1424
+ * @param $content
1425
+ *
1426
+ * @return array
1427
+ */
1428
+ public function aoptFilterJsExclude( $exclude, $content ) {
1429
+ return $this->filterExclusions( 'aopt', 'js', $exclude );
1430
+ }
1431
+
1432
+ /**
1433
+ * aopt filter css exclude
1434
+ *
1435
+ * @param $exclude
1436
+ * @param $content
1437
+ *
1438
+ * @return array
1439
+ */
1440
+ public function aoptFilterCssExclude( $exclude, $content ) {
1441
+ return $this->filterExclusions( 'aopt', 'css', $exclude );
1442
+ }
1443
+
1444
+ /**
1445
+ * wmac filter js exclude
1446
+ *
1447
+ * @param $exclude
1448
+ * @param $content
1449
+ *
1450
+ * @return array
1451
+ */
1452
+ public function wmacFilterJsExclude( $exclude, $content ) {
1453
+ return $this->filterExclusions( 'wmac', 'js', $exclude );
1454
+ }
1455
+
1456
+ /**
1457
+ * wmac filter css exclude
1458
+ *
1459
+ * @param $exclude
1460
+ * @param $content
1461
+ *
1462
+ * @return array
1463
+ */
1464
+ public function wmacFilterCssExclude( $exclude, $content ) {
1465
+ return $this->filterExclusions( 'wmac', 'css', $exclude );
1466
+ }
1467
+
1468
+ /**
1469
+ * Filter js minify exclusions
1470
+ *
1471
+ * @param $index
1472
+ * @param $type
1473
+ * @param $result
1474
+ * @param $url
1475
+ *
1476
+ * @return bool
1477
+ */
1478
+ private function filterJsMinifyExclusions( $index, $type, $result, $url ) {
1479
+ $files = $this->getSidedPluginFiles( $index, $type );
1480
+
1481
+ if ( ! empty( $files ) ) {
1482
+ foreach ( $files as $file ) {
1483
+ if ( false !== strpos( $url, $file ) ) {
1484
+ return false;
1485
  }
1486
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1487
  }
1488
+
1489
+ return $result;
1490
+ }
1491
+
1492
+ /**
1493
+ * Action wmac_filter_js_minify_excluded
1494
+ *
1495
+ * @param $result
1496
+ * @param $url
1497
+ *
1498
+ * @return mixed
1499
+ */
1500
+ public function wmacFilterJsMinifyExclude( $result, $url ) {
1501
+ return $this->filterJsMinifyExclusions( 'wmac', 'js', $result, $url );
1502
+ }
1503
+
1504
+ /**
1505
+ * Action wmac_filter_css_minify_excluded
1506
+ *
1507
+ * @param $result
1508
+ * @param $url
1509
+ *
1510
+ * @return mixed
1511
+ */
1512
+ public function wmacFilterCssMinifyExclude( $result, $url ) {
1513
+ return $this->filterJsMinifyExclusions( 'wmac', 'css', $result, $url );
1514
+ }
1515
+
1516
+ /**
1517
+ * Manage excluded files
1518
+ *
1519
+ * @param $sided_exclude_files
1520
+ * @param $index
1521
+ * @param $type
1522
+ */
1523
+ private function manageExcludeFiles( $sided_exclude_files, $index, $type ) {
1524
+ switch ( $index ) {
1525
+ case 'aopt':
1526
+ if ( get_option( 'autoptimize_js', false ) || get_option( 'autoptimize_css', false ) ) {
1527
+ $exclude_files = get_option( 'autoptimize_' . $type . '_exclude', '' );
1528
+ } else {
1529
  return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1530
  }
1531
+ break;
1532
+ case 'wmac':
1533
+ if ( class_exists( 'WMAC_Plugin' ) && ( WMAC_Plugin::app()->getPopulateOption( 'js_optimize', false ) || WMAC_Plugin::app()->getPopulateOption( 'css_optimize', false ) ) ) {
1534
+ $exclude_files = WMAC_Plugin::app()->getPopulateOption( $type . '_exclude', '' );
1535
+ } else {
1536
+ return;
1537
+ }
1538
+ break;
1539
+ case 'wclp':
1540
+ if ( class_exists( 'WCL_Plugin' ) && ( WCL_Plugin::app()->getPopulateOption( 'remove_js_version', false ) || WCL_Plugin::app()->getPopulateOption( 'remove_css_version', false ) ) ) {
1541
+ $exclude_files = WCL_Plugin::app()->getPopulateOption( 'remove_version_exclude', '' );
1542
+ } else {
1543
+ return;
1544
+ }
1545
+ break;
1546
+ default:
1547
+ return;
1548
+ }
1549
+
1550
+ // For clearfy need new line
1551
+ $delimeter = $index == 'wclp' ? "\n" : ",";
1552
+ $current_exclude_files = ! empty( $exclude_files ) ? array_filter( array_map( 'trim', explode( $delimeter, $exclude_files ) ) ) : array();
1553
+
1554
+ $delete_files = array_diff( $sided_exclude_files['before'][ $type ], $sided_exclude_files['after'][ $type ] );
1555
+ $new_files = array_diff( $sided_exclude_files['after'][ $type ], $current_exclude_files );
1556
+
1557
+ if ( empty( $current_exclude_files ) && ! empty( $new_files ) ) {
1558
+ $current_exclude_files = $new_files;
1559
+ } else if ( ! empty( $current_exclude_files ) ) {
1560
+ $new_exclude_files = array();
1561
+ foreach ( $current_exclude_files as $file ) {
1562
+
1563
+ if ( ! in_array( $file, $delete_files ) ) {
1564
+ $new_exclude_files[] = $file;
1565
+ }
1566
  }
1567
+ $current_exclude_files = array_merge( $new_exclude_files, $new_files );
1568
  }
1569
+
1570
+ $current_exclude_files = array_filter( array_unique( $current_exclude_files ) );
1571
+
1572
+ switch ( $index ) {
1573
+ case 'aopt':
1574
+ update_option( 'autoptimize_' . $type . '_exclude', implode( ', ', $current_exclude_files ) );
1575
+ break;
1576
+ case 'wmac':
1577
+ if ( class_exists( 'WMAC_Plugin' ) ) {
1578
+ WMAC_Plugin::app()->updatePopulateOption( $type . '_exclude', implode( ', ', $current_exclude_files ) );
1579
+ }
1580
+ break;
1581
+ case 'wclp':
1582
+ if ( class_exists( 'WCL_Plugin' ) ) {
1583
+ WCL_Plugin::app()->updatePopulateOption( 'remove_version_exclude', implode( $delimeter, $current_exclude_files ) );
 
 
 
 
1584
  }
1585
+ break;
1586
+ }
1587
+ }
1588
+
1589
+ /**
1590
+ * Action form save
1591
+ *
1592
+ * @param bool $empty_before
1593
+ */
1594
+ public function actionFormSave( $empty_before = false ) {
1595
+ if ( ! empty( $this->sided_plugins ) && ! $empty_before ) {
1596
+ foreach ( $this->sided_plugins as $index => $sided_plugin ) {
1597
+ $sided_exclude_files[ $index ]['before'] = array(
1598
+ 'js' => array(),
1599
+ 'css' => array()
1600
+ );
1601
+ // For clearfy need full url
1602
+ $full = ( $index == 'wclp' ? true : false );
1603
+
1604
+ $sided_exclude_files[ $index ]['before']['js'] += $this->getSidedPluginFiles( $index, 'js', $full );
1605
+ $sided_exclude_files[ $index ]['before']['css'] += $this->getSidedPluginFiles( $index, 'css', $full );
1606
  }
1607
+ }
1608
+
1609
+ if ( isset( $_POST['sided_plugins'] ) && ! empty( $_POST['sided_plugins'] ) ) {
1610
+ $sided_plugins_options = array();
1611
+ foreach ( $_POST['sided_plugins'] as $plugin => $types ) {
1612
+ foreach ( $types as $type => $urls ) {
1613
+ foreach ( $urls as $url => $active ) {
1614
+
1615
+ if ( ! empty( $url ) && $active ) {
1616
+ $sided_plugins_options[ $plugin ][ $type ][] = $url;
1617
  }
1618
  }
1619
  }
 
 
 
 
 
 
1620
  }
1621
+
1622
+ if ( is_multisite() && is_network_admin() ) {
1623
+ $this->updateNetworkOption( 'assets_manager_sided_plugins', $sided_plugins_options );
1624
+ } else {
1625
+ $this->updateOption( 'assets_manager_sided_plugins', $sided_plugins_options );
1626
+ }
1627
+ }
1628
+
1629
+ if ( ! empty( $this->sided_plugins ) ) {
1630
+ $this->sided_plugin_files = array();
1631
+ foreach ( $this->sided_plugins as $index => $sided_plugin ) {
1632
+ $sided_exclude_files[ $index ]['after'] = array(
1633
+ 'js' => array(),
1634
+ 'css' => array()
1635
+ );
1636
+ // For clearfy need full url
1637
+ $full = ( $index == 'wclp' ? true : false );
1638
+
1639
+ $sided_exclude_files[ $index ]['after']['js'] += $this->getSidedPluginFiles( $index, 'js', $full );
1640
+ $sided_exclude_files[ $index ]['after']['css'] += $this->getSidedPluginFiles( $index, 'css', $full );
1641
+
1642
+ if ( ! empty( $sided_exclude_files[ $index ]['before']['js'] ) || ! empty( $sided_exclude_files[ $index ]['after']['js'] ) ) {
1643
+ $this->manageExcludeFiles( $sided_exclude_files[ $index ], $index, 'js' );
1644
+ }
1645
+
1646
+ if ( ! empty( $sided_exclude_files[ $index ]['before']['css'] ) || ! empty( $sided_exclude_files[ $index ]['after']['css'] ) ) {
1647
+ $this->manageExcludeFiles( $sided_exclude_files[ $index ], $index, 'css' );
1648
  }
1649
  }
1650
  }
1651
+ }
1652
+ }
components/comments-plus/admin/boot.php CHANGED
@@ -98,11 +98,6 @@
98
  'title' => __('Replace external links from comment authors on the JavaScript code', 'comments-plus'),
99
  'tags' => array('recommended', 'seo_optimize')
100
  );
101
- $options[] = array(
102
- 'name' => 'remove_x_pingback',
103
- 'title' => __('Disable X-Pingback', 'comments-plus'),
104
- 'tags' => array('recommended', 'defence', 'disable_all_comments', 'hide_my_wp')
105
- );
106
  $options[] = array(
107
  'name' => 'remove_url_from_comment_form',
108
  'title' => __('Remove field "site" in comment form', 'comments-plus'),
98
  'title' => __('Replace external links from comment authors on the JavaScript code', 'comments-plus'),
99
  'tags' => array('recommended', 'seo_optimize')
100
  );
 
 
 
 
 
101
  $options[] = array(
102
  'name' => 'remove_url_from_comment_form',
103
  'title' => __('Remove field "site" in comment form', 'comments-plus'),
components/cyrlitera/admin/assets/js/cyrlitera-for-acf.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function($){
2
+ // transliterate field-name
3
+ acf.addFilter('generate_field_object_name', function(val){
4
+ return replace_field(val);
5
+ });
6
+
7
+ $(document).on('keyup change', '.acf-field .field-name', function(){
8
+ if ( $(this).is(':focus') ){
9
+ return false;
10
+ }else{
11
+ var val = $(this).val();
12
+ val = replace_field( val );
13
+
14
+ if ( val !== $(this).val() ) {
15
+ $(this).val(val);
16
+ }
17
+ }
18
+
19
+ });
20
+ function replace_field( val ){
21
+ console.log(val);
22
+ val = $.trim(val);
23
+ if(window.cyr_and_lat_dict === undefined){
24
+ console.error('Cyrlitera for ACF: lang dictionary not loaded!')
25
+ return val;
26
+ }
27
+ var table = window.cyr_and_lat_dict;
28
+
29
+ $.each( table, function(k, v){
30
+ var regex = new RegExp( k, 'g' );
31
+ val = val.replace( regex, v );
32
+ });
33
+
34
+ val = val.replace( /[^\w\d-_]/g, '' );
35
+ val = val.replace( /_+/g, '_' );
36
+ val = val.replace( /^_?(.*)$/g, '$1' );
37
+ val = val.replace( /^(.*)_$/g, '$1' );
38
+
39
+ return val;
40
+ }
41
+ });
components/cyrlitera/includes/class.helpers.php CHANGED
@@ -55,6 +55,12 @@
55
  }
56
  }
57
 
 
 
 
 
 
 
58
  $term = $is_term ? $wpdb->get_var($wpdb->prepare("SELECT slug FROM {$wpdb->terms} WHERE name = '%s'", $title)) : '';
59
 
60
  if( empty($term) ) {
@@ -225,7 +231,138 @@
225
  );
226
  }
227
 
228
- $custom_rules = WCTR_Plugin::app()->getPopulateOption('custom_symbols_pack');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
 
230
  if( !empty($custom_rules) ) {
231
  $split_rules = explode(',', $custom_rules);
@@ -279,6 +416,85 @@
279
  delete_option('wbcr_wp_term_' . $term->term_id . '_old_slug');
280
  }
281
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  }
283
 
284
  /**
@@ -312,5 +528,82 @@
312
  $wpdb->update($wpdb->terms, array('slug' => $sanitized_slug), array('term_id' => $term->term_id), array('%s'), array('%d'));
313
  }
314
  }
315
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  }
55
  }
56
  }
57
 
58
+ foreach ($backtrace as $backtrace_entry) {
59
+ if($backtrace_entry['function'] == 'query_posts' and isset($backtrace_entry['class']) and $backtrace_entry['class'] == 'WP'){
60
+ return $origin_title;
61
+ }
62
+ }
63
+
64
  $term = $is_term ? $wpdb->get_var($wpdb->prepare("SELECT slug FROM {$wpdb->terms} WHERE name = '%s'", $title)) : '';
65
 
66
  if( empty($term) ) {
231
  );
232
  }
233
 
234
+
235
+ // Armenian
236
+ if( $loc == 'hy'){
237
+ $ret = array_merge($ret, array(
238
+ 'Ա' => 'A',
239
+ 'ա' => 'a',
240
+ 'Բ' => 'B',
241
+ 'բ' => 'b',
242
+ 'Գ' => 'G',
243
+ 'գ' => 'g',
244
+ 'Դ' => 'D',
245
+ 'դ' => 'd',
246
+ ' Ե' => ' Ye',
247
+ 'Ե' => 'E',
248
+ ' ե' => ' ye',
249
+ 'ե' => 'e',
250
+ 'Զ' => 'Z',
251
+ 'զ' => 'z',
252
+ 'Է' => 'E',
253
+ 'է' => 'e',
254
+ 'Ը' => 'Y',
255
+ 'ը' => 'y',
256
+ 'Թ' => 'T',
257
+ 'թ' => 't',
258
+ 'Ժ' => 'Zh',
259
+ 'ժ' => 'zh',
260
+ 'Ի' => 'I',
261
+ 'ի' => 'i',
262
+ 'Լ' => 'L',
263
+ 'լ' => 'l',
264
+ 'Խ' => 'KH',
265
+ 'խ' => 'kh',
266
+ 'Ծ' => 'TS',
267
+ 'ծ' => 'ts',
268
+ 'Կ' => 'K',
269
+ 'կ' => 'K',
270
+ 'Հ' => 'H',
271
+ 'հ' => 'h',
272
+ 'Ձ' => 'DZ',
273
+ 'ձ' => 'dz',
274
+ 'Ղ' => 'GH',
275
+ 'ղ' => 'gh',
276
+ 'Ճ' => 'J',
277
+ 'Ճ' => 'j',
278
+ 'Մ' => 'M',
279
+ 'մ' => 'm',
280
+ 'Յ' => 'Y',
281
+ 'յ' => 'y',
282
+ 'Ն' => 'N',
283
+ 'ն' => 'n',
284
+ 'Շ' => 'SH',
285
+ 'շ' => 'sh',
286
+ ' Ո' => 'VO',
287
+ 'Ո' => 'VO',
288
+ ' ո' => ' vo',
289
+ 'ո' => 'o',
290
+ 'Չ' => 'Ch',
291
+ 'չ' => 'ch',
292
+ 'Պ' => 'P',
293
+ 'պ' => 'p',
294
+ 'Ջ' => 'J',
295
+ 'ջ' => 'j',
296
+ 'Ռ' => 'R',
297
+ 'ռ' => 'r',
298
+ 'Ս' => 'S',
299
+ 'ս' => 's',
300
+ 'Վ' => 'V',
301
+ 'վ' => 'v',
302
+ 'Տ' => 'T',
303
+ 'տ' => 't',
304
+ 'Ր' => 'R',
305
+ 'ր' => 'r',
306
+ 'Ց' => 'C',
307
+ 'ց' => 'c',
308
+ 'Ու' => 'U',
309
+ 'ու' => 'u',
310
+ 'Փ' => 'P',
311
+ 'փ' => 'p',
312
+ 'Ք' => 'Q',
313
+ 'ք' => 'q',
314
+ 'Եվ' => 'EV',
315
+ 'և' => 'ev',
316
+ 'Օ' => 'O',
317
+ 'օ' => 'o',
318
+ 'Ֆ' => 'F',
319
+ 'ֆ' => 'f'
320
+ ));
321
+ }
322
+
323
+ // Serbian
324
+ if($loc == 'sr_RS'){
325
+ $ret = array_merge($ret, array(
326
+ "Ђ" => "DJ",
327
+ "Ж" => "Z",
328
+ "З" => "Z",
329
+ "Љ" => "LJ",
330
+ "Њ" => "NJ",
331
+ "Ш" => "S",
332
+ "Ћ" => "C",
333
+ "Ц" => "C",
334
+ "Ч" => "C",
335
+ "Џ" => "DZ",
336
+ "ђ" => "dj",
337
+ "ж" => "z",
338
+ "з" => "z",
339
+ "и" => "i",
340
+ "љ" => "lj",
341
+ "њ" => "nj",
342
+ "ш" => "s",
343
+ "ћ" => "c",
344
+ "ч" => "c",
345
+ "џ" => "dz",
346
+ "Ња" => "Nja",
347
+ "Ње" => "Nje",
348
+ "Њи" => "Nji",
349
+ "Њо" => "Njo",
350
+ "Њу" => "Nju",
351
+ "Ља" => "Lja",
352
+ "Ље" => "Lje",
353
+ "Љи" => "Lji",
354
+ "Љо" => "Ljo",
355
+ "Љу" => "Lju",
356
+ "Џа" => "Dza",
357
+ "Џе" => "Dze",
358
+ "Џи" => "Dzi",
359
+ "Џо" => "Dzo",
360
+ "Џу" => "Dzu"
361
+ ));
362
+ }
363
+
364
+
365
+ $custom_rules = WCTR_Plugin::app()->getPopulateOption('custom_symbols_pack');
366
 
367
  if( !empty($custom_rules) ) {
368
  $split_rules = explode(',', $custom_rules);
416
  delete_option('wbcr_wp_term_' . $term->term_id . '_old_slug');
417
  }
418
  }
419
+
420
+ // BuddyPress group slug
421
+ // ! slug maybe urlencoded
422
+ if(is_plugin_active('buddypress/bp-loader.php')){
423
+ $groups = $wpdb->get_results("SELECT t.id, t.name, t.slug, o.option_value as old_term_slug FROM {$wpdb->prefix}bp_groups t
424
+ LEFT JOIN {$wpdb->options} o
425
+ ON o.option_name=concat('wbcr_bp_groups_',t.id, '_old_slug')
426
+ WHERE o.option_value IS NOT NULL");
427
+ foreach ((array)$groups as $group) {
428
+ if( $group->slug != $group->old_term_slug ){
429
+ $wpdb->update("{$wpdb->prefix}bp_groups", array('slug' => $group->old_term_slug), array('id' => $group->id), array('%s'), array('%d'));
430
+ delete_option('wbcr_bp_groups_'.$group->id.'_old_slug');
431
+ }
432
+ }
433
+ }
434
+
435
+
436
+ // Asgaros Forum
437
+ if(is_plugin_active('asgaros-forum/asgaros-forum.php')){
438
+ $forums = $wpdb->get_results("SELECT t.id, t.name, t.slug, o.option_value as old_term_slug FROM {$wpdb->prefix}forum_forums t
439
+ LEFT JOIN {$wpdb->options} o
440
+ ON o.option_name=concat('wbcr_asgaros_forums_',t.id, '_old_slug')
441
+ WHERE o.option_value IS NOT NULL");
442
+ foreach( (array) $forums as $forum){
443
+ if( $forum->slug != $forum->old_term_slug ){
444
+ $wpdb->update("{$wpdb->prefix}forum_forums", array('slug' => $forum->old_term_slug), array('id' => $forum->id), array('%s'), array('%d'));
445
+ delete_option('wbcr_asgaros_forums_'.$forum->id.'_old_slug');
446
+ }
447
+ }
448
+
449
+ //topic
450
+ $topics = $wpdb->get_results("SELECT t.id, t.name, t.slug, o.option_value as old_term_slug FROM {$wpdb->prefix}forum_topics t
451
+ LEFT JOIN {$wpdb->options} o
452
+ ON o.option_name=concat('wbcr_asgaros_topics_',t.id, '_old_slug')
453
+ WHERE o.option_value IS NOT NULL");
454
+ foreach ( (array) $topics as $topic){
455
+ if( $topic->slug != $topic->old_term_slug ){
456
+ $wpdb->update("{$wpdb->prefix}forum_topics", array('slug' => $topic->old_term_slug), array('id' => $topic->id), array('%s'), array('%d'));
457
+ delete_option('wbcr_asgaros_topics_'.$topic->id.'_old_slug');
458
+ }
459
+ }
460
+
461
+ }
462
+
463
+ // WP Foro
464
+ if(is_plugin_active('wpforo/wpforo.php')) {
465
+ // forums
466
+ $forums = $wpdb->get_results("SELECT t.forumid, t.title, t.slug, o.option_value as old_term_slug FROM {$wpdb->prefix}wpforo_forums t
467
+ LEFT JOIN {$wpdb->options} o
468
+ ON o.option_name=concat('wbcr_wpforo_forums_',t.forumid, '_old_slug')
469
+ WHERE o.option_value IS NOT NULL");
470
+
471
+ foreach ( (array) $forums as $forum){
472
+ if( $forum->slug != $forum->old_term_slug ){
473
+ $wpdb->update("{$wpdb->prefix}wpforo_forums", array('slug' => $forum->old_term_slug), array('forumid' => $forum->forumid), array('%s'), array('%d'));
474
+ delete_option('wbcr_wpforo_forums_'.$topic->id.'_old_slug');
475
+ }
476
+ }
477
+
478
+ // topics
479
+ $topics = $wpdb->get_results("SELECT t.topicid, t.title, t.slug, o.option_value as old_term_slug FROM {$wpdb->prefix}wpforo_topics t
480
+ LEFT JOIN {$wpdb->options} o
481
+ ON o.option_name=concat('wbcr_wpforo_topics_',t.topicid, '_old_slug')
482
+ WHERE o.option_value IS NOT NULL");
483
+
484
+ foreach ( (array) $topics as $topic){
485
+ if( $topic->slug != $topic->old_term_slug ){
486
+ $wpdb->update("{$wpdb->prefix}wpforo_topics", array('slug' => $topic->old_term_slug), array('topicid' => $topic->topicid), array('%s'), array('%d'));
487
+ delete_option('wbcr_wpforo_topics_'.$topic->id.'_old_slug');
488
+ }
489
+ }
490
+
491
+ // clear cache
492
+ WPF()->phrase->clear_cache();
493
+ WPF()->member->clear_db_cache();
494
+ wpforo_clean_cache();
495
+ }
496
+
497
+
498
  }
499
 
500
  /**
528
  $wpdb->update($wpdb->terms, array('slug' => $sanitized_slug), array('term_id' => $term->term_id), array('%s'), array('%d'));
529
  }
530
  }
531
+
532
+ // BuddyPress group slug
533
+ // ! slug maybe urlencoded
534
+ if(is_plugin_active('buddypress/bp-loader.php')){
535
+
536
+ $groups = $wpdb->get_results("SELECT `id`, `name`, `slug` FROM {$wpdb->prefix}bp_groups WHERE slug REGEXP('%|[^_A-Za-z0-9\-]+')");
537
+ if(is_array($groups)){
538
+ foreach ($groups as $group){
539
+ $sanitized_slug = WCTR_Helper::sanitizeTitle(urldecode($group->slug));
540
+ if($group->slug != $sanitized_slug){
541
+ update_option('wbcr_bp_groups_'.$group->id.'_old_slug', $group->slug, false);
542
+ $wpdb->update($wpdb->prefix.'bp_groups', array('slug' => $sanitized_slug), array('id' => $group->id), array('%s'), array('%d'));
543
+ }
544
+ }
545
+ }
546
+ }
547
+
548
+ // Asgaros Forum
549
+ if(is_plugin_active('asgaros-forum/asgaros-forum.php')){
550
+ // forum slug
551
+ $groups = $wpdb->get_results("SELECT `id`, `name`, `slug` FROM {$wpdb->prefix}forum_forums WHERE slug REGEXP('%|[^_A-Za-z0-9\-]+')");
552
+ if(is_array($groups)){
553
+ foreach ($groups as $group){
554
+ $sanitized_slug = WCTR_Helper::sanitizeTitle(urldecode($group->slug));
555
+ if($group->slug != $sanitized_slug){
556
+ update_option('wbcr_asgaros_forums_'.$group->id.'_old_slug', $group->slug, false);
557
+ $wpdb->update($wpdb->prefix.'forum_forums', array('slug' => $sanitized_slug), array('id' => $group->id), array('%s'), array('%d'));
558
+ }
559
+ }
560
+ }
561
+ // topic slug
562
+ $groups = $wpdb->get_results("SELECT `id`, `name`, `slug` FROM {$wpdb->prefix}forum_topics WHERE slug REGEXP('%|[^_A-Za-z0-9\-]+')");
563
+ if(is_array($groups)){
564
+ foreach ($groups as $group){
565
+ $sanitized_slug = WCTR_Helper::sanitizeTitle(urldecode($group->slug));
566
+ if($group->slug != $sanitized_slug){
567
+ update_option('wbcr_asgaros_topics_'.$group->id.'_old_slug', $group->slug, false);
568
+ $wpdb->update($wpdb->prefix.'forum_topics', array('slug' => $sanitized_slug), array('id' => $group->id), array('%s'), array('%d'));
569
+ }
570
+ }
571
+ }
572
+
573
+ }
574
+
575
+ // WP Foro
576
+ if(is_plugin_active('wpforo/wpforo.php')){
577
+ // forum slug
578
+ $forums = $wpdb->get_results("SELECT `forumid`, `title`, `slug` FROM {$wpdb->prefix}wpforo_forums WHERE slug REGEXP('%|[^_A-Za-z0-9\-]+')");
579
+ if(is_array($forums)){
580
+ foreach ($forums as $forum){
581
+ $sanitized_slug = WCTR_Helper::sanitizeTitle(urldecode($forum->slug));
582
+ if($forum->slug != $sanitized_slug){
583
+ update_option('wbcr_wpforo_forums_'.$forum->forumid.'_old_slug', $forum->slug, false);
584
+ $wpdb->update($wpdb->prefix.'wpforo_forums', array('slug' => $sanitized_slug), array('forumid' => $forum->forumid), array('%s'), array('%d'));
585
+ }
586
+ }
587
+ }
588
+
589
+ // topic slug
590
+ $topics = $wpdb->get_results("SELECT `topicid`, `title`, `slug` FROM {$wpdb->prefix}wpforo_topics WHERE slug REGEXP('%|[^_A-Za-z0-9\-]+')");
591
+ if(is_array($topics)){
592
+ foreach ($topics as $topic) {
593
+ $sanitized_slug = WCTR_Helper::sanitizeTitle(urldecode($topic->slug));
594
+ if($topic->slug != $sanitized_slug){
595
+ update_option('wbcr_wpforo_topics_'.$topic->topicid.'_old_slug', $topic->slug, false);
596
+ $wpdb->update($wpdb->prefix.'wpforo_topics', array('slug' => $sanitized_slug), array('topicid' => $topic->topicid), array('%s'), array('%d'));
597
+ }
598
+ }
599
+ }
600
+
601
+ // clear cache
602
+ WPF()->phrase->clear_cache();
603
+ WPF()->member->clear_db_cache();
604
+ wpforo_clean_cache();
605
+ }
606
+
607
+
608
+ }
609
  }
components/cyrlitera/includes/class.plugin.php CHANGED
@@ -128,7 +128,7 @@
128
  private function globalScripts()
129
  {
130
  require_once(WCTR_PLUGIN_DIR . '/includes/classes/class.configurate-cyrlitera.php');
131
- new WCTR_ConfigСyrlitera(self::$app);
132
  }
133
  }
134
  }
128
  private function globalScripts()
129
  {
130
  require_once(WCTR_PLUGIN_DIR . '/includes/classes/class.configurate-cyrlitera.php');
131
+ new WCTR_ConfigurateCyrlitera(self::$app);
132
  }
133
  }
134
  }
components/cyrlitera/includes/classes/class.configurate-cyrlitera.php CHANGED
@@ -1,226 +1,264 @@
1
  <?php
2
- /**
3
- * This class configures cyrlitera
4
- * @author Webcraftic <wordpress.webraftic@gmail.com>
5
- * @copyright (c) 2017 Webraftic Ltd
6
- * @version 1.0
7
- */
8
-
9
- // Exit if accessed directly
10
- if( !defined('ABSPATH') ) {
11
- exit;
12
- }
13
-
14
-
15
- class WCTR_ConfigСyrlitera extends Wbcr_FactoryClearfy206_Configurate {
16
-
17
- public function registerActionsAndFilters()
18
- {
19
- if( is_admin() || !$this->getPopulateOption('dont_use_transliteration_on_frontend') ) {
20
- if( $this->getPopulateOption('use_transliteration') ) {
21
- if( !$this->getPopulateOption('use_force_transliteration') ) {
22
- add_filter('sanitize_title', 'WCTR_Helper::sanitizeTitle', 0);
23
- } else {
24
- add_filter('sanitize_title', array($this, 'forceSanitizeTitle'), 99, 2);
25
- }
26
- }
27
- if( $this->getPopulateOption('use_transliteration_filename') ) {
28
- if( !$this->getPopulateOption('use_force_transliteration') ) {
29
- add_filter('sanitize_file_name', array($this, 'sanitizeFileName'), 9);
30
- } else {
31
- add_filter('sanitize_file_name', array($this, 'forceSanitizeFileName'), 99, 2);
32
- }
33
  }
 
 
34
  }
35
-
36
- if( !is_admin() ) {
37
- add_action('wp', array($this, 'redirectFromOldUrls'), $this->wpForoIsActivated() ? 11 : 10);
 
 
 
 
38
  }
39
  }
40
-
41
- /**
42
- * @param string $title обработанный заголовок
43
- * @param string $raw_title не обработанный заголовок
44
- * @return string
45
- */
46
- public function forceSanitizeTitle($title, $raw_title)
47
- {
48
- $title = WCTR_Helper::sanitizeTitle($raw_title);
49
- $force_transliterate = sanitize_title_with_dashes($title);
50
-
51
- return apply_filters('wbcr_cyrlitera_sanitize_title', $force_transliterate, $raw_title);
52
  }
53
-
54
- /**
55
- * @param string $title
56
- * @return string
57
- */
58
- public function sanitizeFileName($filename)
59
- {
60
- $origin_title = $filename;
61
-
62
- $filename = WCTR_Helper::transliterate($filename);
63
-
64
- if( $this->getPopulateOption('filename_to_lowercase') ) {
65
- $filename = strtolower($filename);
66
- }
67
-
68
- return apply_filters('wbcr_cyrlitera_sanitize_filename', $filename, $origin_title);
69
  }
70
-
71
- /**
72
- * @param string $title
73
- * @return string
74
- */
75
- public function forceSanitizeFileName($filename, $filename_raw)
76
- {
77
- $filename = $filename_raw;
78
-
79
- $special_chars = array(
80
- "?",
81
- "[",
82
- "]",
83
- "/",
84
- "\\",
85
- "=",
86
- "<",
87
- ">",
88
- ":",
89
- ";",
90
- ",",
91
- "'",
92
- "\"",
93
- "&",
94
- "$",
95
- "#",
96
- "*",
97
- "(",
98
- ")",
99
- "|",
100
- "~",
101
- "`",
102
- "!",
103
- "{",
104
- "}",
105
- "%",
106
- "+",
107
- chr(0)
108
- );
109
-
110
- /**
111
- * Filters the list of characters to remove from a filename.
112
- *
113
- * @since 2.8.0
114
- *
115
- * @param array $special_chars Characters to remove.
116
- * @param string $filename_raw Filename as it was passed into sanitize_file_name().
117
- */
118
- $special_chars = apply_filters('sanitize_file_name_chars', $special_chars, $filename_raw);
119
- $filename = preg_replace("#\x{00a0}#siu", ' ', $filename);
120
- $filename = str_replace($special_chars, '', $filename);
121
- $filename = str_replace(array('%20', '+'), '-', $filename);
122
- $filename = preg_replace('/[\r\n\t -]+/', '-', $filename);
123
- $filename = trim($filename, '.-_');
124
-
125
- if( false === strpos($filename, '.') ) {
126
- $mime_types = wp_get_mime_types();
127
- $filetype = wp_check_filetype('test.' . $filename, $mime_types);
128
- if( $filetype['ext'] === $filename ) {
129
- $filename = 'unnamed-file.' . $filetype['ext'];
130
- }
131
- }
132
-
133
- // Split the filename into a base and extension[s]
134
- $parts = explode('.', $filename);
135
-
136
- // Return if only one extension
137
- if( count($parts) <= 2 ) {
138
- $filename = WCTR_Helper::transliterate($filename);
139
-
140
- if( $this->getPopulateOption('filename_to_lowercase') ) {
141
- $filename = strtolower($filename);
142
- }
143
-
144
- return apply_filters('wbcr_cyrlitera_sanitize_filename', $filename, $filename_raw);
145
- }
146
-
147
- // Process multiple extensions
148
- $filename = array_shift($parts);
149
- $extension = array_pop($parts);
150
- $mimes = get_allowed_mime_types();
151
-
152
- /*
153
- * Loop over any intermediate extensions. Postfix them with a trailing underscore
154
- * if they are a 2 - 5 character long alpha string not in the extension whitelist.
155
- */
156
- foreach((array)$parts as $part) {
157
- $filename .= '.' . $part;
158
-
159
- if( preg_match("/^[a-zA-Z]{2,5}\d?$/", $part) ) {
160
- $allowed = false;
161
- foreach($mimes as $ext_preg => $mime_match) {
162
- $ext_preg = '!^(' . $ext_preg . ')$!i';
163
- if( preg_match($ext_preg, $part) ) {
164
- $allowed = true;
165
- break;
166
- }
167
- }
168
- if( !$allowed ) {
169
- $filename .= '_';
170
  }
171
  }
172
  }
173
- $filename .= '.' . $extension;
174
-
175
- $filename = WCTR_Helper::transliterate($filename);
176
-
177
- if( $this->getPopulateOption('filename_to_lowercase') ) {
178
- $filename = strtolower($filename);
179
- }
180
-
181
- return apply_filters('wbcr_cyrlitera_sanitize_filename', $filename, $filename_raw);
182
  }
183
-
184
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  /**
186
- * @return bool
 
 
 
 
 
187
  */
188
- protected function wpForoIsActivated()
189
- {
190
- $activeplugins = get_option('active_plugins');
191
- if( gettype($activeplugins) != 'array' ) {
192
- $activeplugins = array();
 
 
 
 
 
 
 
193
  }
194
-
195
- return in_array("wpforo/wpforo.php", $activeplugins);
196
  }
197
-
198
- /**
199
- * Перенаправление со старых url, которые были уже преобразованы
200
- */
201
- public function redirectFromOldUrls()
202
- {
203
- if( !WbcrFactoryClearfy206_Helpers::isPermalink() ) {
204
- return;
 
 
205
  }
206
- $is404 = is_404();
207
-
208
- if( $this->wpForoIsActivated() ) {
209
- global $wpforo;
210
- if( $is404 || $wpforo->current_object['is_404'] ) {
211
- $is404 = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  }
213
  }
214
-
215
- if( $is404 ) {
216
- if( $this->getPopulateOption('redirect_from_old_urls') ) {
217
- $current_url = urldecode($_SERVER['REQUEST_URI']);
218
- $new_url = WCTR_Helper::transliterate($current_url, true);
219
-
220
- if( $current_url != $new_url ) {
221
- wp_redirect($new_url, 301);
222
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  }
224
  }
225
  }
226
- }
 
1
  <?php
2
+ /**
3
+ * This class configures cyrlitera
4
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
5
+ * @copyright (c) 2017 Webraftic Ltd
6
+ * @version 1.0
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ class WCTR_ConfigurateCyrlitera extends Wbcr_FactoryClearfy206_Configurate {
15
+
16
+ public function registerActionsAndFilters() {
17
+
18
+ if ( is_admin() || ! $this->getPopulateOption( 'dont_use_transliteration_on_frontend' ) ) {
19
+ if ( $this->getPopulateOption( 'use_transliteration' ) ) {
20
+ if ( ! $this->getPopulateOption( 'use_force_transliteration' ) ) {
21
+ add_filter( 'sanitize_title', 'WCTR_Helper::sanitizeTitle', 0 );
22
+ } else {
23
+ add_filter( 'sanitize_title', array( $this, 'forceSanitizeTitle' ), 99, 2 );
 
 
 
 
 
 
 
 
 
24
  }
25
+
26
+ add_action( 'admin_init', array( $this, 'acfScripts' ) );
27
  }
28
+ }
29
+
30
+ if ( $this->getPopulateOption( 'use_transliteration_filename' ) ) {
31
+ if ( ! $this->getPopulateOption( 'use_force_transliteration' ) ) {
32
+ add_filter( 'sanitize_file_name', array( $this, 'sanitizeFileName' ), 9 );
33
+ } else {
34
+ add_filter( 'sanitize_file_name', array( $this, 'forceSanitizeFileName' ), 99, 2 );
35
  }
36
  }
37
+
38
+ if ( ! is_admin() ) {
39
+ add_action( 'wp', array( $this, 'redirectFromOldUrls' ), $this->wpForoIsActivated() ? 11 : 10 );
 
 
 
 
 
 
 
 
 
40
  }
41
+
42
+ // Asgaros Forum set 404
43
+ if ( is_plugin_active( 'asgaros-forum/asgaros-forum.php' ) ) {
44
+ add_action( 'asgarosforum_prepare_forum', array( $this, 'asgarosSet404' ) );
45
+ add_action( 'asgarosforum_prepare_topic', array( $this, 'asgarosSet404' ) );
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
+ }
48
+
49
+ public function asgarosSet404() {
50
+ $trace = debug_backtrace();
51
+ foreach ( $trace as $item ) {
52
+ if ( $item['function'] == 'prepare' and $item['class'] == 'AsgarosForum' and is_object( $item['object'] ) ) {
53
+ if ( ! $item['object']->parents_set ) {
54
+ if ( ! defined( 'ASGAROS_404' ) ) {
55
+ define( 'ASGAROS_404', true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
  }
58
  }
 
 
 
 
 
 
 
 
 
59
  }
60
+ }
61
+
62
+ public function acfScripts() {
63
+ global $pagenow;
64
+
65
+ $on_acf_edit_page = 'post.php' === $pagenow && isset( $_GET['post'] ) && 'acf-field-group' === get_post_type( $_GET['post'] );
66
+ if ( is_plugin_active( 'advanced-custom-fields/acf.php' ) and $on_acf_edit_page ) {
67
+ $data = "window.cyr_and_lat_dict = " . json_encode( WCTR_Helper::getSymbolsPack() ) . ";";
68
+
69
+ wp_enqueue_script( 'cyrlitera-for-acf', WCTR_PLUGIN_URL . '/admin/assets/js/cyrlitera-for-acf.js', array(
70
+ 'jquery',
71
+ 'acf-field-group'
72
+ ) );
73
+ wp_add_inline_script( 'cyrlitera-for-acf', $data, 'before' );
74
+ }
75
+ }
76
+
77
+ /**
78
+ * @param string $title обработанный заголовок
79
+ * @param string $raw_title не обработанный заголовок
80
+ *
81
+ * @return string
82
+ */
83
+ public function forceSanitizeTitle( $title, $raw_title ) {
84
+ $title = WCTR_Helper::sanitizeTitle( $raw_title );
85
+ $force_transliterate = sanitize_title_with_dashes( $title );
86
+
87
+ return apply_filters( 'wbcr_cyrlitera_sanitize_title', $force_transliterate, $raw_title );
88
+ }
89
+
90
+ /**
91
+ * @param string $title
92
+ *
93
+ * @return string
94
+ */
95
+ public function sanitizeFileName( $filename ) {
96
+ $origin_title = $filename;
97
+
98
+ $filename = WCTR_Helper::transliterate( $filename );
99
+
100
+ if ( $this->getPopulateOption( 'filename_to_lowercase' ) ) {
101
+ $filename = strtolower( $filename );
102
+ }
103
+
104
+ return apply_filters( 'wbcr_cyrlitera_sanitize_filename', $filename, $origin_title );
105
+ }
106
+
107
+ /**
108
+ * @param string $title
109
+ *
110
+ * @return string
111
+ */
112
+ public function forceSanitizeFileName( $filename, $filename_raw ) {
113
+ $filename = $filename_raw;
114
+
115
+ $special_chars = array(
116
+ "?",
117
+ "[",
118
+ "]",
119
+ "/",
120
+ "\\",
121
+ "=",
122
+ "<",
123
+ ">",
124
+ ":",
125
+ ";",
126
+ ",",
127
+ "'",
128
+ "\"",
129
+ "&",
130
+ "$",
131
+ "#",
132
+ "*",
133
+ "(",
134
+ ")",
135
+ "|",
136
+ "~",
137
+ "`",
138
+ "!",
139
+ "{",
140
+ "}",
141
+ "%",
142
+ "+",
143
+ chr( 0 )
144
+ );
145
+
146
  /**
147
+ * Filters the list of characters to remove from a filename.
148
+ *
149
+ * @since 2.8.0
150
+ *
151
+ * @param array $special_chars Characters to remove.
152
+ * @param string $filename_raw Filename as it was passed into sanitize_file_name().
153
  */
154
+ $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );
155
+ $filename = preg_replace( "#\x{00a0}#siu", ' ', $filename );
156
+ $filename = str_replace( $special_chars, '', $filename );
157
+ $filename = str_replace( array( '%20', '+' ), '-', $filename );
158
+ $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
159
+ $filename = trim( $filename, '.-_' );
160
+
161
+ if ( false === strpos( $filename, '.' ) ) {
162
+ $mime_types = wp_get_mime_types();
163
+ $filetype = wp_check_filetype( 'test.' . $filename, $mime_types );
164
+ if ( $filetype['ext'] === $filename ) {
165
+ $filename = 'unnamed-file.' . $filetype['ext'];
166
  }
 
 
167
  }
168
+
169
+ // Split the filename into a base and extension[s]
170
+ $parts = explode( '.', $filename );
171
+
172
+ // Return if only one extension
173
+ if ( count( $parts ) <= 2 ) {
174
+ $filename = WCTR_Helper::transliterate( $filename );
175
+
176
+ if ( $this->getPopulateOption( 'filename_to_lowercase' ) ) {
177
+ $filename = strtolower( $filename );
178
  }
179
+
180
+ return apply_filters( 'wbcr_cyrlitera_sanitize_filename', $filename, $filename_raw );
181
+ }
182
+
183
+ // Process multiple extensions
184
+ $filename = array_shift( $parts );
185
+ $extension = array_pop( $parts );
186
+ $mimes = get_allowed_mime_types();
187
+
188
+ /*
189
+ * Loop over any intermediate extensions. Postfix them with a trailing underscore
190
+ * if they are a 2 - 5 character long alpha string not in the extension whitelist.
191
+ */
192
+ foreach ( (array) $parts as $part ) {
193
+ $filename .= '.' . $part;
194
+
195
+ if ( preg_match( "/^[a-zA-Z]{2,5}\d?$/", $part ) ) {
196
+ $allowed = false;
197
+ foreach ( $mimes as $ext_preg => $mime_match ) {
198
+ $ext_preg = '!^(' . $ext_preg . ')$!i';
199
+ if ( preg_match( $ext_preg, $part ) ) {
200
+ $allowed = true;
201
+ break;
202
+ }
203
+ }
204
+ if ( ! $allowed ) {
205
+ $filename .= '_';
206
  }
207
  }
208
+ }
209
+ $filename .= '.' . $extension;
210
+
211
+ $filename = WCTR_Helper::transliterate( $filename );
212
+
213
+ if ( $this->getPopulateOption( 'filename_to_lowercase' ) ) {
214
+ $filename = strtolower( $filename );
215
+ }
216
+
217
+ return apply_filters( 'wbcr_cyrlitera_sanitize_filename', $filename, $filename_raw );
218
+ }
219
+
220
+
221
+ /**
222
+ * @return bool
223
+ */
224
+ protected function wpForoIsActivated() {
225
+ $activeplugins = get_option( 'active_plugins' );
226
+ if ( gettype( $activeplugins ) != 'array' ) {
227
+ $activeplugins = array();
228
+ }
229
+
230
+ return in_array( "wpforo/wpforo.php", $activeplugins );
231
+ }
232
+
233
+ /**
234
+ * Перенаправление со старых url, которые были уже преобразованы
235
+ */
236
+ public function redirectFromOldUrls() {
237
+ if ( ! WbcrFactoryClearfy206_Helpers::isPermalink() ) {
238
+ return;
239
+ }
240
+ $is404 = is_404();
241
+
242
+ if ( $this->wpForoIsActivated() ) {
243
+ global $wpforo;
244
+ if ( $is404 || $wpforo->current_object['is_404'] || ( $wpforo->current_object['template'] == 'post' and ! count( $wpforo->current_object['topic'] ) ) ) {
245
+ $is404 = true;
246
+ }
247
+ }
248
+
249
+ if ( is_plugin_active( 'asgaros-forum/asgaros-forum.php' ) and defined( 'ASGAROS_404' ) and ASGAROS_404 === true ) {
250
+ $is404 = true;
251
+ }
252
+
253
+ if ( $is404 ) {
254
+ if ( $this->getPopulateOption( 'redirect_from_old_urls' ) ) {
255
+ $current_url = urldecode( $_SERVER['REQUEST_URI'] );
256
+ $new_url = WCTR_Helper::transliterate( $current_url, true );
257
+
258
+ if ( $current_url != $new_url ) {
259
+ wp_redirect( $new_url, 301 );
260
  }
261
  }
262
  }
263
+ }
264
+ }
components/disable-admin-notices/includes/classes/class.configurate-notices.php CHANGED
@@ -1,437 +1,424 @@
1
  <?php
2
 
3
- /**
4
- * This class configures hide admin notices
5
- * @author Webcraftic <wordpress.webraftic@gmail.com>
6
- * @copyright (c) 2017 Webraftic Ltd
7
- * @version 1.0
8
- */
9
-
10
- // Exit if accessed directly
11
- if( !defined('ABSPATH') ) {
12
- exit;
13
- }
14
-
15
- class WDN_ConfigHideNotices extends Wbcr_FactoryClearfy206_Configurate {
16
-
17
- public function registerActionsAndFilters()
18
- {
19
- if( is_admin() ) {
20
- $hide_notices_type = $this->getPopulateOption('hide_admin_notices');
21
-
22
- if( $hide_notices_type != 'not_hide' ) {
23
- add_action('admin_print_scripts', array($this, 'catchNotices'), 999);
24
-
25
- if( empty($hide_notices_type) || $hide_notices_type == 'only_selected' ) {
26
- add_action('admin_head', array($this, 'printNotices'), 999);
27
- }
28
-
29
- if( !empty($hide_notices_type) ) {
30
- add_action('admin_bar_menu', array($this, 'notificationsPanel'), 999);
31
- add_action('admin_enqueue_scripts', array($this, 'notificationsPanelStyles'));
32
- }
33
  }
34
  }
35
  }
36
-
37
- public function printNotices()
38
- {
39
- if( is_multisite() && is_network_admin() ) {
40
- add_action('network_admin_notices', array($this, 'noticesCollection'));
41
- } else {
42
- add_action('admin_notices', array($this, 'noticesCollection'));
43
- }
44
  }
45
-
46
-
47
- public function notificationsPanelStyles()
48
- {
49
- if( !$this->getPopulateOption('show_notices_in_adminbar', false) && current_user_can('manage_network') ) {
50
- return;
51
- }
52
-
53
- wp_enqueue_style('wbcr-notification-panel-styles', WDN_PLUGIN_URL . '/admin/assets/css/notifications-panel.css', array(), $this->plugin->getPluginVersion());
54
- wp_enqueue_script('wbcr-notification-panel-scripts', WDN_PLUGIN_URL . '/admin/assets/js/notifications-panel.js', array(), $this->plugin->getPluginVersion());
55
  }
56
-
57
- public function notificationsPanel(&$wp_admin_bar)
58
- {
59
- if( !$this->getPopulateOption('show_notices_in_adminbar', false) && current_user_can('manage_network') ) {
 
 
 
 
 
 
 
 
 
 
 
 
60
  return;
61
  }
62
-
63
- if( current_user_can('manage_options') || current_user_can('manage_network') ) {
64
- $titles = array();
65
-
66
- $notifications = get_user_meta(get_current_user_id(), WDN_Plugin::app()->getOptionName('hidden_notices'), true);
67
-
68
- if( empty($notifications) ) {
69
- return;
70
- }
71
-
72
- $cont_notifications = sizeof($notifications);
73
-
74
- // Add top menu
75
- $wp_admin_bar->add_menu(array(
76
- 'id' => 'wbcr-han-notify-panel',
77
- 'parent' => 'top-secondary',
78
- 'title' => sprintf(__('Notifications %s', 'disable-admin-notices'), '<span class="wbcr-han-adminbar-counter">' . $cont_notifications . '</span>'),
79
- 'href' => false
80
- ));
81
-
82
- // loop
83
- if( !empty($notifications) ) {
84
- $i = 0;
85
- foreach($notifications as $notice_id => $message) {
86
- $message = $this->getExcerpt(stripslashes($message), 0, 350);
87
- $message .= '<div class="wbcr-han-panel-restore-notify-line">';
88
- $message .= '<a href="#" data-nonce="' . wp_create_nonce($this->plugin->getPluginName() . '_ajax_restore_notice_nonce');
89
- $message .= '" data-notice-id="' . esc_attr($notice_id) . '" class="wbcr-han-panel-restore-notify-link">';
90
- $message .= __('Restore notice', 'clearfy') . (isset($titles[$notice_id]) ? ' (' . $titles[$notice_id] . ')' : '');
91
- $message .= '</a></div>';
92
-
93
- $wp_admin_bar->add_menu(array(
94
- 'id' => 'wbcr-han-notify-panel-item-' . $i,
95
- 'parent' => 'wbcr-han-notify-panel',
96
- 'title' => $message,
97
- 'href' => false,
98
- 'meta' => array(
99
- 'class' => ''
100
- )
101
- ));
102
-
103
- $i++;
104
- }
105
  }
106
  }
107
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
- public function noticesCollection()
110
- {
111
- global $wbcr_dan_plugin_all_notices;
112
-
113
- if( empty($wbcr_dan_plugin_all_notices) ) {
114
- return;
115
- }
116
- ?>
117
- <!-- Disable admin notices plugin (Clearfy tools) -->
118
- <style>
119
- .wbcr-dan-hide-notices {
120
- position: relative;
121
- padding: 5px 5px 0;
122
- background: #fff;
123
- }
124
-
125
- .wbcr-dan-hide-notices > div {
126
- margin: 0 !important;
127
- }
128
-
129
- .wbcr-dan-hide-notice-link {
130
- display: block;
131
- text-align: right;
132
- margin: 5px 0 5px 5px;
133
- font-weight: bold;
134
- color: #F44336;
135
- }
136
-
137
- .is-dismissible .wbcr-dan-hide-notice-link {
138
- margin-right: -30px;
139
- }
140
-
141
- .wbcr-dan-hide-notice-link:active, .wbcr-dan-hide-notice-link:focus {
142
- box-shadow: none;
143
- outline: none;
144
- }
145
- </style>
146
-
147
- <!-- Disable admin notices plugin (Clearfy tools) -->
148
- <script>
149
- jQuery(document).ready(function($) {
150
- $(document).on('click', '.wbcr-dan-hide-notice-link', function() {
151
- var self = $(this),
152
- noticeID = self.data('notice-id'),
153
- nonce = self.data('nonce'),
154
- noticeHtml = self.closest('.wbcr-dan-hide-notices').clone(),
155
- contanierEl = self.closest('.wbcr-dan-hide-notices').parent();
156
-
157
- noticeHtml.find('.wbcr-dan-hide-notice-link').remove();
158
-
159
- if( !noticeID ) {
160
- alert('Undefinded error. Please report the bug to our support forum.');
161
- }
162
 
163
- contanierEl.hide();
 
 
 
 
 
 
164
 
165
- $.ajax(ajaxurl, {
166
- type: 'post',
167
- dataType: 'json',
168
- data: {
169
- action: 'wbcr-dan-hide-notices',
170
- security: nonce,
171
- notice_id: noticeID,
172
- notice_html: noticeHtml.html()
173
- },
174
- success: function(response) {
175
- if( !response || !response.success ) {
176
 
177
- if( response.data.error_message ) {
178
- console.log(response.data.error_message);
179
- self.closest('li').show();
180
- } else {
181
- console.log(response);
182
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
 
184
- contanierEl.show();
185
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  }
187
 
188
- contanierEl.remove();
189
- },
190
- error: function(xhr, ajaxOptions, thrownError) {
191
- console.log(xhr.status);
192
- console.log(xhr.responseText);
193
- console.log(thrownError);
194
  }
195
- });
196
 
197
- return false;
 
 
 
 
 
 
198
  });
 
 
199
  });
200
- </script>
201
- <?php
202
- foreach($wbcr_dan_plugin_all_notices as $val) {
203
- echo $val;
204
- }
205
  }
206
-
207
- public function catchNotices()
208
- {
209
- global $wbcr_dan_plugin_all_notices;
210
-
211
- try{
212
- $wp_filter_admin_notices = & $this->getWPFilter('admin_notices');
213
- }catch (Exception $e){
214
- $wp_filter_admin_notices = null;
215
- }
216
-
217
- $hide_notices_type = $this->getPopulateOption('hide_admin_notices');
218
-
219
- if( empty($hide_notices_type) || $hide_notices_type == 'only_selected' ) {
220
- $get_hidden_notices = get_user_meta(get_current_user_id(), WDN_Plugin::app()->getOptionName('hidden_notices'), true);
221
-
222
- $content = array();
223
- foreach((array)$wp_filter_admin_notices as $filters) {
224
- foreach($filters as $callback_name => $callback) {
225
-
226
- if( 'usof_hide_admin_notices_start' == $callback_name || 'usof_hide_admin_notices_end' == $callback_name ) {
227
- continue;
228
- }
229
-
230
- ob_start();
231
-
232
- // #CLRF-140 fix bug for php7
233
- // when the developers forgot to delete the argument in the function of implementing the notification.
234
- $args = array();
235
- $accepted_args = isset($callback['accepted_args']) && !empty($callback['accepted_args']) ? $callback['accepted_args'] : 0;
236
-
237
- if( $accepted_args > 0 ) {
238
- for($i = 0; $i < (int)$accepted_args; $i++) {
239
- $args[] = null;
240
- }
241
- }
242
- //===========
243
-
244
- call_user_func_array($callback['function'], $args);
245
- $cont = ob_get_clean();
246
-
247
- if( empty($cont) ) {
248
- continue;
249
  }
250
-
251
- $salt = is_multisite() ? get_current_blog_id() : '';
252
- $uniq_id1 = md5($cont . $salt);
253
- $uniq_id2 = md5($callback_name . $salt);
254
-
255
- if( is_array($callback['function']) && sizeof($callback['function']) == 2 ) {
256
- $class = $callback['function'][0];
257
- if( is_object($class) ) {
258
- $class_name = get_class($class);
259
- $method_name = $callback['function'][1];
260
- $uniq_id2 = md5($class_name . ':' . $method_name);
261
-
262
- if( strpos($class_name, 'Wbcr_FactoryNotices') !== false ) {
263
- continue;
264
- }
265
- }
 
 
 
 
266
  }
267
- //838339d1a188e17fec838c2df3058603
268
- //838339d1a188e17fec838c2df3058603
269
- if( !empty($get_hidden_notices) ) {
270
-
271
- $skip_notice = true;
272
- foreach((array)$get_hidden_notices as $key => $notice) {
273
- $splited_notice_id = explode('_', $key);
274
- if( empty($splited_notice_id) || sizeof($splited_notice_id) < 2 ) {
275
- continue;
276
- }
277
- $compare_notice_id_1 = $splited_notice_id[0];
278
- $compare_notice_id_2 = $splited_notice_id[1];
279
-
280
- if( $compare_notice_id_1 == $uniq_id1 || $compare_notice_id_2 == $uniq_id2 ) {
281
- $skip_notice = false;
282
- }
283
- }
284
-
285
- if( !$skip_notice ) {
286
  continue;
287
  }
 
 
 
 
 
 
288
  }
289
-
290
- $hide_link = '<a href="#" data-nonce="' . wp_create_nonce($this->plugin->getPluginName() . '_ajax_hide_notices_nonce') . '" data-notice-id="' . $uniq_id1 . '_' . $uniq_id2 . '" class="wbcr-dan-hide-notice-link">[' . __('Hide notification forever', 'disable-admin-notices') . ']</a>';
291
-
292
- $cont = preg_replace('/<(script|style)([^>]+)?>(.*?)<\/(script|style)>/is', '', $cont);
293
- $cont = rtrim(trim($cont));
294
- $cont = preg_replace('/^(<div[^>]+>)(.*?)(<\/div>)$/is', '$1<div class="wbcr-dan-hide-notices">$2' . $hide_link . '</div>$3', $cont);
295
-
296
- if( empty($cont) ) {
297
  continue;
298
  }
299
- $content[] = $cont;
300
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  }
302
-
303
- $wbcr_dan_plugin_all_notices = $content;
304
  }
305
-
306
- try{
307
- $wp_filter_user_admin_notices = & $this->getWPFilter('user_admin_notices');
308
- }catch (Exception $e){
309
- $wp_filter_user_admin_notices = null;
310
- }
311
-
312
- try{
313
- $wp_filter_network_admin_notices = & $this->getWPFilter('network_admin_notices');
314
- }catch (Exception $e){
315
- $wp_filter_network_admin_notices = null;
316
- }
317
-
318
- if( is_user_admin() && $wp_filter_user_admin_notices !== null) {
319
- $wp_filter_user_admin_notices = null;
320
- } else if( is_network_admin() && $wp_filter_network_admin_notices !== null ) {
321
- //unset($wp_filter['network_admin_notices']);
322
- foreach($wp_filter_network_admin_notices as $f_key => $f) {
323
- foreach($f as $c_name => $clback) {
324
- if( is_array($clback['function']) && sizeof($clback['function']) == 2 ) {
325
- $class = $clback['function'][0];
326
- if( is_object($class) ) {
327
- $class_name = get_class($class);
328
- if( strpos($class_name, 'Wbcr_FactoryNotices') !== false ) {
329
- continue;
330
- }
331
- }
332
  }
333
-
334
- unset($wp_filter_network_admin_notices[$f_key][$c_name]);
335
  }
 
 
336
  }
337
- } elseif( $wp_filter_admin_notices !== null ) {
338
- foreach($wp_filter_admin_notices as $f_key => $f) {
339
- foreach($f as $c_name => $clback) {
340
- if( is_array($clback['function']) && sizeof($clback['function']) == 2 ) {
341
- $class = $clback['function'][0];
342
- if( is_object($class) ) {
343
- $class_name = get_class($class);
344
- if( strpos($class_name, 'Wbcr_FactoryNotices') !== false ) {
345
- continue;
346
- }
347
- }
348
  }
349
-
350
- unset($wp_filter_admin_notices[$f_key][$c_name]);
351
  }
 
 
352
  }
353
-
354
- unset($f_key);
355
- unset($f);
356
  }
357
-
358
- try{
359
- $wp_filter_all_admin_notices = & $this->getWPfilter('all_admin_notices');
360
- }catch (Exception $e){
361
- $wp_filter_all_admin_notices = null;
362
- }
363
-
364
- if($wp_filter_all_admin_notices !== null ) {
365
- foreach($wp_filter_all_admin_notices as $f_key => $f) {
366
- foreach($f as $c_name => $clback) {
367
- if( is_array($clback['function']) && sizeof($clback['function']) == 2 ) {
368
- $class = $clback['function'][0];
369
- if( is_object($class) ) {
370
- $class_name = get_class($class);
371
-
372
- #Fix for Learn dash
373
- if( $class_name == 'Learndash_Admin_Menus_Tabs' ) {
374
- continue;
375
- }
 
 
 
376
  }
377
  }
378
-
379
- #Fix for Divi theme
380
- if( $c_name == 'et_pb_export_layouts_interface' ) {
381
- continue;
382
- }
383
-
384
- unset($wp_filter_all_admin_notices[$f_key][$c_name]);
385
  }
 
 
 
 
 
 
 
386
  }
387
-
388
- unset($f_key);
389
- unset($f);
390
  }
 
 
 
391
  }
392
-
393
-
394
- /**
395
- * Get excerpt from string
396
- *
397
- * @param String $str String to get an excerpt from
398
- * @param Integer $startPos Position int string to start excerpt from
399
- * @param Integer $maxLength Maximum length the excerpt may be
400
- * @return String excerpt
401
- */
402
- public function getExcerpt($str, $startPos = 0, $maxLength = 100)
403
- {
404
- if( strlen($str) > $maxLength ) {
405
- $excerpt = substr($str, $startPos, $maxLength - 3);
406
- $lastSpace = strrpos($excerpt, ' ');
407
- $excerpt = substr($excerpt, 0, $lastSpace);
408
- $excerpt .= '...';
409
- } else {
410
- $excerpt = $str;
411
- }
412
-
413
- return $excerpt;
414
  }
415
-
416
- /**
417
- * Access to global variable $wp_filter in WP core.
418
- * Migration from WP 4.2 to 4.9
419
- * @see https://codex.wordpress.org/Version_4.7 WP 4.7 changelog (WP_Hook)
420
- * @param $key string filter name
421
- * @return array $wp_filter callbacks array by link
422
- * @throws Exception if key not exists
423
- */
424
- private function &getWPFilter($key)
425
- {
426
- global $wp_version, $wp_filter;
427
-
428
- if(!isset($wp_filter[$key])) {
429
- throw new Exception('key not exists');
430
- }
431
- if(version_compare($wp_version, '4.7.0', '>=')) {
432
- return $wp_filter[$key]->callbacks;
433
- }else{
434
- return $wp_filter[$key];
435
- }
436
- }
437
- }
 
 
 
 
1
  <?php
2
 
3
+ /**
4
+ * This class configures hide admin notices
5
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
6
+ * @copyright (c) 2017 Webraftic Ltd
7
+ * @version 1.0
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ class WDN_ConfigHideNotices extends Wbcr_FactoryClearfy206_Configurate {
16
+
17
+ public function registerActionsAndFilters() {
18
+ if ( is_admin() ) {
19
+ $hide_notices_type = $this->getPopulateOption( 'hide_admin_notices' );
20
+
21
+ if ( $hide_notices_type != 'not_hide' ) {
22
+ add_action( 'admin_print_scripts', array( $this, 'catchNotices' ), 999 );
23
+
24
+ if ( empty( $hide_notices_type ) || $hide_notices_type == 'only_selected' ) {
25
+ add_action( 'admin_head', array( $this, 'printNotices' ), 999 );
26
+ }
27
+
28
+ if ( ! empty( $hide_notices_type ) ) {
29
+ add_action( 'admin_bar_menu', array( $this, 'notificationsPanel' ), 999 );
30
+ add_action( 'admin_enqueue_scripts', array( $this, 'notificationsPanelStyles' ) );
 
 
31
  }
32
  }
33
  }
34
+ }
35
+
36
+ public function printNotices() {
37
+ if ( is_multisite() && is_network_admin() ) {
38
+ add_action( 'network_admin_notices', array( $this, 'noticesCollection' ) );
39
+ } else {
40
+ add_action( 'admin_notices', array( $this, 'noticesCollection' ) );
 
41
  }
42
+ }
43
+
44
+
45
+ public function notificationsPanelStyles() {
46
+ if ( ! $this->getPopulateOption( 'show_notices_in_adminbar', false ) && current_user_can( 'manage_network' ) ) {
47
+ return;
 
 
 
 
48
  }
49
+
50
+ wp_enqueue_style( 'wbcr-notification-panel-styles', WDN_PLUGIN_URL . '/admin/assets/css/notifications-panel.css', array(), $this->plugin->getPluginVersion() );
51
+ wp_enqueue_script( 'wbcr-notification-panel-scripts', WDN_PLUGIN_URL . '/admin/assets/js/notifications-panel.js', array(), $this->plugin->getPluginVersion() );
52
+ }
53
+
54
+ public function notificationsPanel( &$wp_admin_bar ) {
55
+ if ( ! $this->getPopulateOption( 'show_notices_in_adminbar', false ) && current_user_can( 'manage_network' ) ) {
56
+ return;
57
+ }
58
+
59
+ if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_network' ) ) {
60
+ $titles = array();
61
+
62
+ $notifications = get_user_meta( get_current_user_id(), WDN_Plugin::app()->getOptionName( 'hidden_notices' ), true );
63
+
64
+ if ( empty( $notifications ) ) {
65
  return;
66
  }
67
+
68
+ $cont_notifications = sizeof( $notifications );
69
+
70
+ // Add top menu
71
+ $wp_admin_bar->add_menu( array(
72
+ 'id' => 'wbcr-han-notify-panel',
73
+ 'parent' => 'top-secondary',
74
+ 'title' => sprintf( __( 'Notifications %s', 'disable-admin-notices' ), '<span class="wbcr-han-adminbar-counter">' . $cont_notifications . '</span>' ),
75
+ 'href' => false
76
+ ) );
77
+
78
+ // loop
79
+ if ( ! empty( $notifications ) ) {
80
+ $i = 0;
81
+ foreach ( $notifications as $notice_id => $message ) {
82
+ $message = $this->getExcerpt( stripslashes( $message ), 0, 350 );
83
+ $message .= '<div class="wbcr-han-panel-restore-notify-line">';
84
+ $message .= '<a href="#" data-nonce="' . wp_create_nonce( $this->plugin->getPluginName() . '_ajax_restore_notice_nonce' );
85
+ $message .= '" data-notice-id="' . esc_attr( $notice_id ) . '" class="wbcr-han-panel-restore-notify-link">';
86
+ $message .= __( 'Restore notice', 'clearfy' ) . ( isset( $titles[ $notice_id ] ) ? ' (' . $titles[ $notice_id ] . ')' : '' );
87
+ $message .= '</a></div>';
88
+
89
+ $wp_admin_bar->add_menu( array(
90
+ 'id' => 'wbcr-han-notify-panel-item-' . $i,
91
+ 'parent' => 'wbcr-han-notify-panel',
92
+ 'title' => $message,
93
+ 'href' => false,
94
+ 'meta' => array(
95
+ 'class' => ''
96
+ )
97
+ ) );
98
+
99
+ $i ++;
 
 
 
 
 
 
 
 
 
 
100
  }
101
  }
102
  }
103
+ }
104
+
105
+ public function noticesCollection() {
106
+ global $wbcr_dan_plugin_all_notices;
107
+
108
+ if ( empty( $wbcr_dan_plugin_all_notices ) ) {
109
+ return;
110
+ }
111
+ ?>
112
+ <!-- Disable admin notices plugin (Clearfy tools) -->
113
+ <style>
114
+ .wbcr-dan-hide-notices {
115
+ position: relative;
116
+ padding: 5px 5px 0;
117
+ background: #fff;
118
+ }
119
 
120
+ .wbcr-dan-hide-notices > div {
121
+ margin: 0 !important;
122
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
+ .wbcr-dan-hide-notice-link {
125
+ display: block;
126
+ text-align: right;
127
+ margin: 5px 0 5px 5px;
128
+ font-weight: bold;
129
+ color: #F44336;
130
+ }
131
 
132
+ .is-dismissible .wbcr-dan-hide-notice-link {
133
+ margin-right: -30px;
134
+ }
 
 
 
 
 
 
 
 
135
 
136
+ .wbcr-dan-hide-notice-link:active, .wbcr-dan-hide-notice-link:focus {
137
+ box-shadow: none;
138
+ outline: none;
139
+ }
140
+ </style>
141
+ <!-- Disable admin notices plugin (Clearfy tools) -->
142
+ <script>
143
+ jQuery(document).ready(function($) {
144
+ $(document).on('click', '.wbcr-dan-hide-notice-link', function() {
145
+ var self = $(this),
146
+ noticeID = self.data('notice-id'),
147
+ nonce = self.data('nonce'),
148
+ noticeHtml = self.closest('.wbcr-dan-hide-notices').clone(),
149
+ contanierEl = self.closest('.wbcr-dan-hide-notices').parent();
150
+
151
+ noticeHtml.find('.wbcr-dan-hide-notice-link').remove();
152
+
153
+ if( !noticeID ) {
154
+ alert('Undefinded error. Please report the bug to our support forum.');
155
+ }
156
 
157
+ contanierEl.hide();
158
+
159
+ $.ajax(ajaxurl, {
160
+ type: 'post',
161
+ dataType: 'json',
162
+ data: {
163
+ action: 'wbcr-dan-hide-notices',
164
+ security: nonce,
165
+ notice_id: noticeID,
166
+ notice_html: noticeHtml.html()
167
+ },
168
+ success: function(response) {
169
+ if( !response || !response.success ) {
170
+
171
+ if( response.data.error_message ) {
172
+ console.log(response.data.error_message);
173
+ self.closest('li').show();
174
+ } else {
175
+ console.log(response);
176
  }
177
 
178
+ contanierEl.show();
179
+ return;
 
 
 
 
180
  }
 
181
 
182
+ contanierEl.remove();
183
+ },
184
+ error: function(xhr, ajaxOptions, thrownError) {
185
+ console.log(xhr.status);
186
+ console.log(xhr.responseText);
187
+ console.log(thrownError);
188
+ }
189
  });
190
+
191
+ return false;
192
  });
193
+ });
194
+ </script>
195
+ <?php
196
+ foreach ( $wbcr_dan_plugin_all_notices as $val ) {
197
+ echo $val;
198
  }
199
+ }
200
+
201
+ public function catchNotices() {
202
+ global $wbcr_dan_plugin_all_notices;
203
+
204
+ try {
205
+ $wp_filter_admin_notices = &$this->getWPFilter( 'admin_notices' );
206
+ } catch( Exception $e ) {
207
+ $wp_filter_admin_notices = null;
208
+ }
209
+
210
+ $hide_notices_type = $this->getPopulateOption( 'hide_admin_notices' );
211
+
212
+ if ( empty( $hide_notices_type ) || $hide_notices_type == 'only_selected' ) {
213
+ $get_hidden_notices = get_user_meta( get_current_user_id(), WDN_Plugin::app()->getOptionName( 'hidden_notices' ), true );
214
+
215
+ $content = array();
216
+ foreach ( (array) $wp_filter_admin_notices as $filters ) {
217
+ foreach ( $filters as $callback_name => $callback ) {
218
+
219
+ if ( 'usof_hide_admin_notices_start' == $callback_name || 'usof_hide_admin_notices_end' == $callback_name ) {
220
+ continue;
221
+ }
222
+
223
+ ob_start();
224
+
225
+ // #CLRF-140 fix bug for php7
226
+ // when the developers forgot to delete the argument in the function of implementing the notification.
227
+ $args = array();
228
+ $accepted_args = isset( $callback['accepted_args'] ) && ! empty( $callback['accepted_args'] ) ? $callback['accepted_args'] : 0;
229
+
230
+ if ( $accepted_args > 0 ) {
231
+ for ( $i = 0; $i < (int) $accepted_args; $i ++ ) {
232
+ $args[] = null;
 
 
 
 
 
 
 
 
 
233
  }
234
+ }
235
+ //===========
236
+
237
+ call_user_func_array( $callback['function'], $args );
238
+ $cont = ob_get_clean();
239
+
240
+ if ( empty( $cont ) ) {
241
+ continue;
242
+ }
243
+
244
+ $salt = is_multisite() ? get_current_blog_id() : '';
245
+ $uniq_id1 = md5( $cont . $salt );
246
+ $uniq_id2 = md5( $callback_name . $salt );
247
+
248
+ if ( is_array( $callback['function'] ) && sizeof( $callback['function'] ) == 2 ) {
249
+ $class = $callback['function'][0];
250
+ if ( is_object( $class ) ) {
251
+ $class_name = get_class( $class );
252
+ $method_name = $callback['function'][1];
253
+ $uniq_id2 = md5( $class_name . ':' . $method_name );
254
  }
255
+ }
256
+ //838339d1a188e17fec838c2df3058603
257
+ //838339d1a188e17fec838c2df3058603
258
+ if ( ! empty( $get_hidden_notices ) ) {
259
+
260
+ $skip_notice = true;
261
+ foreach ( (array) $get_hidden_notices as $key => $notice ) {
262
+ $splited_notice_id = explode( '_', $key );
263
+ if ( empty( $splited_notice_id ) || sizeof( $splited_notice_id ) < 2 ) {
 
 
 
 
 
 
 
 
 
 
264
  continue;
265
  }
266
+ $compare_notice_id_1 = $splited_notice_id[0];
267
+ $compare_notice_id_2 = $splited_notice_id[1];
268
+
269
+ if ( $compare_notice_id_1 == $uniq_id1 || $compare_notice_id_2 == $uniq_id2 ) {
270
+ $skip_notice = false;
271
+ }
272
  }
273
+
274
+ if ( ! $skip_notice ) {
 
 
 
 
 
 
275
  continue;
276
  }
 
277
  }
278
+
279
+ $hide_link = '<a href="#" data-nonce="' . wp_create_nonce( $this->plugin->getPluginName() . '_ajax_hide_notices_nonce' ) . '" data-notice-id="' . $uniq_id1 . '_' . $uniq_id2 . '" class="wbcr-dan-hide-notice-link">[' . __( 'Hide notification forever', 'disable-admin-notices' ) . ']</a>';
280
+
281
+ // Fix for Woocommerce membership
282
+ if ( $cont != '<div class="js-wc-memberships-admin-notice-placeholder"></div>' ) {
283
+ $cont = preg_replace( '/<(script|style)([^>]+)?>(.*?)<\/(script|style)>/is', '', $cont );
284
+ $cont = rtrim( trim( $cont ) );
285
+ $cont = preg_replace( '/^(<div[^>]+>)(.*?)(<\/div>)$/is', '$1<div class="wbcr-dan-hide-notices">$2' . $hide_link . '</div>$3', $cont );
286
+ }
287
+
288
+ if ( empty( $cont ) ) {
289
+ continue;
290
+ }
291
+ $content[] = $cont;
292
  }
 
 
293
  }
294
+
295
+ $wbcr_dan_plugin_all_notices = $content;
296
+ }
297
+
298
+ try {
299
+ $wp_filter_user_admin_notices = &$this->getWPFilter( 'user_admin_notices' );
300
+ } catch( Exception $e ) {
301
+ $wp_filter_user_admin_notices = null;
302
+ }
303
+
304
+ try {
305
+ $wp_filter_network_admin_notices = &$this->getWPFilter( 'network_admin_notices' );
306
+ } catch( Exception $e ) {
307
+ $wp_filter_network_admin_notices = null;
308
+ }
309
+
310
+ if ( is_user_admin() && $wp_filter_user_admin_notices !== null ) {
311
+ $wp_filter_user_admin_notices = null;
312
+ } else if ( is_network_admin() && $wp_filter_network_admin_notices !== null ) {
313
+ //unset($wp_filter['network_admin_notices']);
314
+ foreach ( $wp_filter_network_admin_notices as $f_key => $f ) {
315
+ foreach ( $f as $c_name => $clback ) {
316
+ if ( is_array( $clback['function'] ) && sizeof( $clback['function'] ) == 2 ) {
317
+ $class = $clback['function'][0];
318
+ if ( is_object( $class ) ) {
319
+ $class_name = get_class( $class );
 
320
  }
 
 
321
  }
322
+
323
+ unset( $wp_filter_network_admin_notices[ $f_key ][ $c_name ] );
324
  }
325
+ }
326
+ } else if ( $wp_filter_admin_notices !== null ) {
327
+ foreach ( $wp_filter_admin_notices as $f_key => $f ) {
328
+ foreach ( $f as $c_name => $clback ) {
329
+ if ( is_array( $clback['function'] ) && sizeof( $clback['function'] ) == 2 ) {
330
+ $class = $clback['function'][0];
331
+ if ( is_object( $class ) ) {
332
+ $class_name = get_class( $class );
 
 
 
333
  }
 
 
334
  }
335
+
336
+ unset( $wp_filter_admin_notices[ $f_key ][ $c_name ] );
337
  }
 
 
 
338
  }
339
+
340
+ unset( $f_key );
341
+ unset( $f );
342
+ }
343
+
344
+ try {
345
+ $wp_filter_all_admin_notices = &$this->getWPfilter( 'all_admin_notices' );
346
+ } catch( Exception $e ) {
347
+ $wp_filter_all_admin_notices = null;
348
+ }
349
+
350
+ if ( $wp_filter_all_admin_notices !== null ) {
351
+ foreach ( $wp_filter_all_admin_notices as $f_key => $f ) {
352
+ foreach ( $f as $c_name => $clback ) {
353
+ if ( is_array( $clback['function'] ) && sizeof( $clback['function'] ) == 2 ) {
354
+ $class = $clback['function'][0];
355
+ if ( is_object( $class ) ) {
356
+ $class_name = get_class( $class );
357
+
358
+ #Fix for Learn dash && Woocommerce membership
359
+ if ( $class_name == 'Learndash_Admin_Menus_Tabs' || $class_name == 'WC_Memberships_Admin' ) {
360
+ continue;
361
  }
362
  }
 
 
 
 
 
 
 
363
  }
364
+
365
+ #Fix for Divi theme
366
+ if ( $c_name == 'et_pb_export_layouts_interface' ) {
367
+ continue;
368
+ }
369
+
370
+ unset( $wp_filter_all_admin_notices[ $f_key ][ $c_name ] );
371
  }
 
 
 
372
  }
373
+
374
+ unset( $f_key );
375
+ unset( $f );
376
  }
377
+ }
378
+
379
+
380
+ /**
381
+ * Get excerpt from string
382
+ *
383
+ * @param String $str String to get an excerpt from
384
+ * @param Integer $startPos Position int string to start excerpt from
385
+ * @param Integer $maxLength Maximum length the excerpt may be
386
+ *
387
+ * @return String excerpt
388
+ */
389
+ public function getExcerpt( $str, $startPos = 0, $maxLength = 100 ) {
390
+ if ( strlen( $str ) > $maxLength ) {
391
+ $excerpt = substr( $str, $startPos, $maxLength - 3 );
392
+ $lastSpace = strrpos( $excerpt, ' ' );
393
+ $excerpt = substr( $excerpt, 0, $lastSpace );
394
+ $excerpt .= '...';
395
+ } else {
396
+ $excerpt = $str;
 
 
397
  }
398
+
399
+ return $excerpt;
400
+ }
401
+
402
+ /**
403
+ * Access to global variable $wp_filter in WP core.
404
+ * Migration from WP 4.2 to 4.9
405
+ * @see https://codex.wordpress.org/Version_4.7 WP 4.7 changelog (WP_Hook)
406
+ *
407
+ * @param $key string filter name
408
+ *
409
+ * @return array $wp_filter callbacks array by link
410
+ * @throws Exception if key not exists
411
+ */
412
+ private function &getWPFilter( $key ) {
413
+ global $wp_version, $wp_filter;
414
+
415
+ if ( ! isset( $wp_filter[ $key ] ) ) {
416
+ throw new Exception( 'key not exists' );
417
+ }
418
+ if ( version_compare( $wp_version, '4.7.0', '>=' ) ) {
419
+ return $wp_filter[ $key ]->callbacks;
420
+ } else {
421
+ return $wp_filter[ $key ];
422
+ }
423
+ }
424
+ }
components/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
components/minify-and-combine/admin/pages/settings.php CHANGED
@@ -1,351 +1,430 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  /**
4
- * The page Settings.
 
 
 
5
  *
6
  * @since 1.0.0
 
7
  */
 
 
 
 
 
 
 
 
8
 
9
- // Exit if accessed directly
10
- if( !defined('ABSPATH') ) {
11
- exit;
12
- }
13
-
14
- class WMAC_MinifyAndCombineSettingsPage extends Wbcr_FactoryClearfy206_PageBase {
15
-
16
- /**
17
- * The id of the page in the admin menu.
18
- *
19
- * Mainly used to navigate between pages.
20
- * @see Wbcr_FactoryPages410_AdminPage
21
- *
22
- * @since 1.0.0
23
- * @var string
24
- */
25
- public $id = "minify_and_combine"; // Уникальный идентификатор страницы
26
- public $page_menu_dashicon = 'dashicons-testimonial'; // Иконка для закладки страницы, дашикон
27
- public $page_parent_page = "performance"; // Уникальный идентификатор родительской страницы
28
- /**
29
- * Доступена для мультисайтов
30
- * @var bool
31
- */
32
- public $available_for_multisite = true;
33
-
34
- /**
35
- * @param Wbcr_Factory409_Plugin $plugin
36
- */
37
- public function __construct(Wbcr_Factory409_Plugin $plugin)
38
- {
39
- // Заголовок страницы
40
- $this->menu_title = __('Minify (JS/CSS)', 'minify-and-combine');
41
-
42
- // Если плагин загружен, как самостоятельный, то мы меняем настройки страницы и делаем ее внешней,
43
- // а не внутренней страницей родительского плагина. Внешнии страницы добавляются в Wordpress меню "Общие"
44
-
45
- if( !defined('LOADING_MINIFY_AND_COMBINE_AS_ADDON') ) {
46
- // true - внутреняя, false- внешняя страница
47
- $this->internal = false;
48
- // меню к которому, нужно прикрепить ссылку на страницу
49
- $this->menu_target = 'options-general.php';
50
- // Если true, добавляет ссылку "Настройки", рядом с действиями активации, деактивации плагина, на странице плагинов.
51
- $this->add_link_to_plugin_actions = true;
52
-
53
- $this->page_parent_page = null;
54
- }
55
-
56
- parent::__construct($plugin);
57
- }
58
-
59
- // Метод позволяет менять заголовок меню, в зависимости от сборки плагина.
60
- public function getMenuTitle()
61
- {
62
- return defined('LOADING_MINIFY_AND_COMBINE_AS_ADDON') ? __('Minify (Html/JS/CSS)', 'minify-and-combine') : __('General', 'minify-and-combine');
63
- }
64
-
65
- /**
66
- * Регистрируем уведомления для страницы
67
- *
68
- * @see libs\factory\pages\templates\FactoryPages410_ImpressiveThemplate
69
- * @param $notices
70
- * @return array
71
- */
72
- public function getActionNotices($notices)
73
- {
74
- $notices[] = array(
75
- 'conditions' => array(
76
- 'wbcr_mac_clear_cache_success' => 1
77
- ),
78
- 'type' => 'success',
79
- 'message' => __('The cache has been successfully cleaned.', 'minify-and-combine')
80
- );
81
-
82
- return $notices;
83
- }
84
-
85
- /**
86
- * Метод должен передать массив опций для создания формы с полями.
87
- * Созданием страницы и формы занимается фреймворк
88
- *
89
- * @since 1.0.0
90
- * @return mixed[]
91
- */
92
- public function getPageOptions()
93
- {
94
- $options = array();
95
-
96
- $options[] = array(
97
- 'type' => 'html',
98
- 'html' => '<div class="wbcr-factory-page-group-header"><strong>' . __('JavaScript Options', 'minify-and-combine') . '</strong><p></p></div>'
99
- );
100
-
101
- $options[] = array(
102
- 'type' => 'checkbox',
103
- 'way' => 'buttons',
104
- 'name' => 'js_optimize',
105
- 'title' => __('Optimize JavaScript Code?', 'minify-and-combine'),
106
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
107
- //'hint' => __('Optimize JavaScript Code.', 'minify-and-combine'),
108
- 'default' => false,
109
- 'eventsOn' => array(
110
- 'show' => '#wbcr-mac-optimize-js-fields'
111
- ),
112
- 'eventsOff' => array(
113
- 'hide' => '#wbcr-mac-optimize-js-fields'
114
- )
115
- );
116
-
117
- $js_options[] = array(
118
- 'type' => 'checkbox',
119
- 'way' => 'buttons',
120
- 'name' => 'js_aggregate',
121
- 'title' => __('Aggregate JS-files?', 'minify-and-combine'),
122
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
123
- 'hint' => __('Aggregate all linked JS-files to have them loaded non-render blocking? If this option is off, the individual JS-files will remain in place but will be minified.', 'minify-and-combine'),
124
- 'default' => false
125
- );
126
-
127
- $js_options[] = array(
128
- 'type' => 'checkbox',
129
- 'way' => 'buttons',
130
- 'name' => 'js_include_inline',
131
- 'title' => __('Also aggregate inline JS?', 'minify-and-combine'),
132
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
133
- 'hint' => __('Let Мinify And Combine also extract JS from the HTML. Warning: this can make Мinify And Combine\'s cache size grow quickly, so only enable this if you know what you\'re doing.', 'minify-and-combine'),
134
- 'default' => false
135
- );
136
-
137
- $js_options[] = array(
138
- 'type' => 'checkbox',
139
- 'way' => 'buttons',
140
- 'name' => 'js_forcehead',
141
- 'title' => __('Force JavaScript in &lt;head&gt;?', 'minify-and-combine'),
142
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
143
- 'hint' => __('Load JavaScript early, this can potentially fix some JS-errors, but makes the JS render blocking.', 'minify-and-combine'),
144
- 'default' => false
145
- );
146
-
147
- $js_options[] = array(
148
- 'type' => 'textarea',
149
- 'name' => 'js_exclude',
150
- 'title' => __('Exclude scripts from Мinify And Combine:', 'minify-and-combine'),
151
- //'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
152
- 'hint' => __('A comma-separated list of scripts you want to exclude from being optimized, for example \'whatever.js, another.js\' (without the quotes) to exclude those scripts from being aggregated and minimized by Мinify And Combine.', 'minify-and-combine'),
153
- 'default' => 'seal.js, js/jquery/jquery.js'
154
- );
155
-
156
- $js_options[] = array(
157
- 'type' => 'checkbox',
158
- 'way' => 'buttons',
159
- 'name' => 'js_trycatch',
160
- 'title' => __('Add try-catch wrapping?', 'minify-and-combine'),
161
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
162
- 'hint' => __('If your scripts break because of a JS-error, you might want to try this.', 'minify-and-combine'),
163
- 'default' => false
164
- );
165
-
166
- $options[] = array(
167
- 'type' => 'div',
168
- 'id' => 'wbcr-mac-optimize-js-fields',
169
- 'items' => $js_options
170
- );
171
-
172
- $options[] = array(
173
- 'type' => 'html',
174
- 'html' => '<div class="wbcr-factory-page-group-header"><strong>' . __('CSS Options', 'minify-and-combine') . '</strong><p></p></div>'
175
- );
176
-
177
- $options[] = array(
178
- 'type' => 'checkbox',
179
- 'way' => 'buttons',
180
- 'name' => 'css_optimize',
181
- 'title' => __('Optimize CSS Code?', 'minify-and-combine'),
182
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
183
- 'hint' => __('If your scripts break because of a JS-error, you might want to try this.', 'minify-and-combine'),
184
- 'default' => false,
185
- 'eventsOn' => array(
186
- 'show' => '#wbcr-clr-optimize-css-fields'
187
- ),
188
- 'eventsOff' => array(
189
- 'hide' => '#wbcr-clr-optimize-css-fields'
190
- )
191
- );
192
-
193
- $css_options[] = array(
194
- 'type' => 'checkbox',
195
- 'way' => 'buttons',
196
- 'name' => 'css_aggregate',
197
- 'title' => __('Aggregate CSS-files?', 'minify-and-combine'),
198
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
199
- 'hint' => __('Aggregate all linked CSS-files? If this option is off, the individual CSS-files will remain in place but will be minified.', 'minify-and-combine'),
200
- 'default' => false
201
- );
202
-
203
- $css_options[] = array(
204
- 'type' => 'checkbox',
205
- 'way' => 'buttons',
206
- 'name' => 'css_include_inline',
207
- 'title' => __('Also aggregate inline CSS?', 'minify-and-combine'),
208
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
209
- 'hint' => __('Check this option for Мinify And Combine to also aggregate CSS in the HTML.', 'minify-and-combine'),
210
- 'default' => false
211
- );
212
-
213
- $css_options[] = array(
214
- 'type' => 'checkbox',
215
- 'way' => 'buttons',
216
- 'name' => 'css_datauris',
217
- 'title' => __('Generate data: URIs for images?', 'minify-and-combine'),
218
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
219
- 'hint' => __('Enable this to include small background-images in the CSS itself instead of as separate downloads.', 'minify-and-combine'),
220
- 'default' => false
221
- );
222
-
223
- $css_options[] = array(
224
- 'type' => 'checkbox',
225
- 'way' => 'buttons',
226
- 'name' => 'css_defer',
227
- 'title' => __('Inline and Defer CSS?', 'minify-and-combine'),
228
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
229
- 'hint' => __('Inline "above the fold CSS" while loading the main auto optimized CSS only after page load. Check the FAQ for more info.
230
- This can be fully automated for different types of pages with the Мinify And Combine CriticalCSS Power-Up.', 'minify-and-combine'),
231
- 'default' => false
232
- );
233
-
234
- $css_options[] = array(
235
- 'type' => 'checkbox',
236
- 'way' => 'buttons',
237
- 'name' => 'css_inline',
238
- 'title' => __('Inline all CSS?', 'minify-and-combine'),
239
- 'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
240
- 'hint' => __('Inlining all CSS can improve performance for sites with a low pageviews/ visitor-rate, but may slow down performance otherwise.', 'minify-and-combine'),
241
- 'default' => false
242
- );
243
-
244
- $css_options[] = array(
245
- 'type' => 'textarea',
246
- 'name' => 'css_exclude',
247
- 'title' => __('Exclude CSS from Мinify And Combine:', 'minify-and-combine'),
248
- //'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
249
- 'hint' => __('A comma-separated list of CSS you want to exclude from being optimized.', 'minify-and-combine'),
250
- 'default' => 'wp-content/cache/, wp-content/uploads/, admin-bar.min.css, dashicons.min.css'
251
- );
252
-
253
- $options[] = array(
254
- 'type' => 'div',
255
- 'id' => 'wbcr-clr-optimize-css-fields',
256
- 'items' => $css_options
257
- );
258
-
259
- $options[] = array(
260
- 'type' => 'html',
261
- 'html' => '<div class="wbcr-factory-page-group-header"><strong>' . __('Cache Info', 'minify-and-combine') . '</strong><p>' . __('Описание раздела оптимизация', 'minify-and-combine') . '</p></div>'
262
- );
263
-
264
- // Произвольный html код
265
- $options[] = array(
266
- 'type' => 'html',
267
- 'html' => array($this, 'cacheInfo')
268
- );
269
-
270
- $formOptions = array();
271
-
272
- $formOptions[] = array(
273
- 'type' => 'form-group',
274
- 'items' => $options,
275
- //'cssClass' => 'postbox'
276
- );
277
 
278
- return apply_filters('wbcr_mac_settings_form_options', $formOptions);
279
  }
280
-
281
- public function cacheInfo()
282
- {
283
- $is_network = is_network_admin();
284
-
285
- $cache = $is_network ? WMAC_PluginCache::getUsedCacheMultisite() : WMAC_PluginCache::getUsedCache();
286
- ?>
287
- <div class="form-group">
288
- <label for="wbcr_mac_css_optimize" class="col-sm-4 control-label">
289
- Cache folder<?php echo $is_network ? 's' : '' ?>
290
- </label>
291
-
292
- <div class="control-group col-sm-8">
293
- <?php echo $is_network ? WP_CONTENT_DIR . WMAC_CACHE_CHILD_DIR . '[...]/' : WMAC_PluginCache::getCacheDir() ?>
294
- </div>
295
- </div>
296
- <div class="form-group">
297
- <label for="wbcr_mac_css_optimize" class="col-sm-4 control-label">
298
- Can we write?
299
- </label>
300
-
301
- <div class="control-group col-sm-8">
302
- Yes
303
- </div>
304
- </div>
305
- <div class="form-group">
306
- <label for="wbcr_mac_css_optimize" class="col-sm-4 control-label">
307
- Cached styles and scripts<?php echo $is_network ? ' (all sites)' : '' ?>
308
- </label>
309
-
310
- <div class="control-group col-sm-8">
311
- <?php if( $is_network ) : ?>
312
- <?php echo $cache['files'] ?> files, totalling <?php echo $cache['size'] ?> (calculated
313
- at <?php echo gmdate('H:i') ?> UTC)
314
- <?php else: ?>
315
- <?php echo $cache['percent'] . '%, ' . $cache['files'] ?> files,
316
- totalling <?php echo $cache['size'] ?> (calculated at <?php echo gmdate('H:i') ?> UTC)
317
- <?php endif; ?>
318
- </div>
319
- </div>
320
- <div class="form-group">
321
- <label for="wbcr_mac_css_optimize" class="col-sm-4 control-label">
322
- </label>
323
-
324
- <div class="control-group col-sm-8">
325
- <a class="btn btn-default" href="<?= wp_nonce_url($this->getActionUrl('clear-cache'), 'clear_cache_' . $this->getResultId()); ?>">
326
- <?php _e('Clear cache', 'minify-and-combine') ?>
327
- </a>
328
- </div>
329
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  }
332
-
333
- /**
334
- * Действие rollback
335
- * Если мы перейдем по ссылке, которую мы создали для кнопки "Восстановить" для метода rollbackButton,
336
- * То выполнится это действие
337
- */
338
- public function clearCacheAction()
339
- {
340
- check_admin_referer('clear_cache_' . $this->getResultId());
341
-
342
- if( is_network_admin() ) {
343
- WMAC_PluginCache::clearAllMultisite();
344
- } else {
345
- WMAC_PluginCache::clearAll();
346
- }
347
-
348
- // редирект с выводом уведомления
349
- $this->redirectToAction('index', array('wbcr_mac_clear_cache_success' => 1));
350
- }
351
- }
1
  <?php
2
+
3
+ /**
4
+ * The page Settings.
5
+ *
6
+ * @since 1.0.0
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ class WMAC_MinifyAndCombineSettingsPage extends Wbcr_FactoryClearfy206_PageBase {
15
 
16
  /**
17
+ * The id of the page in the admin menu.
18
+ *
19
+ * Mainly used to navigate between pages.
20
+ * @see Wbcr_FactoryPages410_AdminPage
21
  *
22
  * @since 1.0.0
23
+ * @var string
24
  */
25
+ public $id = "minify_and_combine"; // Уникальный идентификатор страницы
26
+ public $page_menu_dashicon = 'dashicons-testimonial'; // Иконка для закладки страницы, дашикон
27
+ public $page_parent_page = "performance"; // Уникальный идентификатор родительской страницы
28
+ /**
29
+ * Доступена для мультисайтов
30
+ * @var bool
31
+ */
32
+ public $available_for_multisite = true;
33
 
34
+ /**
35
+ * @param Wbcr_Factory409_Plugin $plugin
36
+ */
37
+ public function __construct( Wbcr_Factory409_Plugin $plugin ) {
38
+ // Заголовок страницы
39
+ $this->menu_title = __( 'Minify (JS/CSS)', 'minify-and-combine' );
40
+
41
+ // Если плагин загружен, как самостоятельный, то мы меняем настройки страницы и делаем ее внешней,
42
+ // а не внутренней страницей родительского плагина. Внешнии страницы добавляются в Wordpress меню "Общие"
43
+
44
+ if ( ! defined( 'LOADING_MINIFY_AND_COMBINE_AS_ADDON' ) ) {
45
+ // true - внутреняя, false- внешняя страница
46
+ $this->internal = false;
47
+ // меню к которому, нужно прикрепить ссылку на страницу
48
+ $this->menu_target = 'options-general.php';
49
+ // Если true, добавляет ссылку "Настройки", рядом с действиями активации, деактивации плагина, на странице плагинов.
50
+ $this->add_link_to_plugin_actions = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
+ $this->page_parent_page = null;
53
  }
54
+
55
+ parent::__construct( $plugin );
56
+ }
57
+
58
+ // Метод позволяет менять заголовок меню, в зависимости от сборки плагина.
59
+ public function getMenuTitle() {
60
+ return defined( 'LOADING_MINIFY_AND_COMBINE_AS_ADDON' ) ? __( 'Minify (Html/JS/CSS)', 'minify-and-combine' ) : __( 'General', 'minify-and-combine' );
61
+ }
62
+
63
+ /**
64
+ * Регистрируем уведомления для страницы
65
+ *
66
+ * @see libs\factory\pages\templates\FactoryPages410_ImpressiveThemplate
67
+ *
68
+ * @param $notices
69
+ *
70
+ * @return array
71
+ */
72
+ public function getActionNotices( $notices ) {
73
+ $notices[] = array(
74
+ 'conditions' => array(
75
+ 'wbcr_mac_clear_cache_success' => 1
76
+ ),
77
+ 'type' => 'success',
78
+ 'message' => __( 'The cache has been successfully cleaned.', 'minify-and-combine' )
79
+ );
80
+
81
+ return $notices;
82
+ }
83
+
84
+ /**
85
+ * Метод должен передать массив опций для создания формы с полями.
86
+ * Созданием страницы и формы занимается фреймворк
87
+ *
88
+ * @since 1.0.0
89
+ * @return mixed[]
90
+ */
91
+ public function getPageOptions() {
92
+ $options = array();
93
+
94
+ $options[] = array(
95
+ 'type' => 'html',
96
+ 'html' => '<div class="wbcr-factory-page-group-header"><strong>' . __( 'JavaScript Options', 'minify-and-combine' ) . '</strong><p></p></div>'
97
+ );
98
+
99
+ $options[] = array(
100
+ 'type' => 'checkbox',
101
+ 'way' => 'buttons',
102
+ 'name' => 'js_optimize',
103
+ 'title' => __( 'Optimize JavaScript Code?', 'minify-and-combine' ),
104
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
105
+ //'hint' => __('Optimize JavaScript Code.', 'minify-and-combine'),
106
+ 'default' => false,
107
+ 'eventsOn' => array(
108
+ 'show' => '#wbcr-mac-optimize-js-fields,#wbcr-mac-optimization-danger-message-1'
109
+ ),
110
+ 'eventsOff' => array(
111
+ 'hide' => '#wbcr-mac-optimize-js-fields,#wbcr-mac-optimization-danger-message-1'
112
+ )
113
+ );
114
+
115
+ /*$options[] = array(
116
+ 'type' => 'html',
117
+ 'html' => array( $this, 'optimizationDangerMessage1' )
118
+ );*/
119
+
120
+ $js_options[] = array(
121
+ 'type' => 'checkbox',
122
+ 'way' => 'buttons',
123
+ 'name' => 'js_aggregate',
124
+ 'title' => __( 'Aggregate JS-files?', 'minify-and-combine' ),
125
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
126
+ 'hint' => __( 'Aggregate all linked JS-files to have them loaded non-render blocking? If this option is off, the individual JS-files will remain in place but will be minified.', 'minify-and-combine' ),
127
+ 'default' => false,
128
+ 'eventsOn' => array(
129
+ 'show' => '#wbcr-mac-optimization-danger-message-2'
130
+ ),
131
+ 'eventsOff' => array(
132
+ 'hide' => '#wbcr-mac-optimization-danger-message-2'
133
+ )
134
+ );
135
+
136
+ $js_options[] = array(
137
+ 'type' => 'html',
138
+ 'html' => array( $this, 'optimizationDangerMessage2' )
139
+ );
140
+
141
+ $js_options[] = array(
142
+ 'type' => 'checkbox',
143
+ 'way' => 'buttons',
144
+ 'name' => 'js_include_inline',
145
+ 'title' => __( 'Also aggregate inline JS?', 'minify-and-combine' ),
146
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
147
+ 'hint' => __( 'Let Мinify And Combine also extract JS from the HTML. Warning: this can make Мinify And Combine\'s cache size grow quickly, so only enable this if you know what you\'re doing.', 'minify-and-combine' ),
148
+ 'default' => false,
149
+ 'eventsOn' => array(
150
+ 'show' => '#wbcr-mac-optimization-danger-message-3'
151
+ ),
152
+ 'eventsOff' => array(
153
+ 'hide' => '#wbcr-mac-optimization-danger-message-3'
154
+ )
155
+ );
156
+
157
+ $js_options[] = array(
158
+ 'type' => 'html',
159
+ 'html' => array( $this, 'optimizationDangerMessage3' )
160
+ );
161
+
162
+ $js_options[] = array(
163
+ 'type' => 'checkbox',
164
+ 'way' => 'buttons',
165
+ 'name' => 'js_forcehead',
166
+ 'title' => __( 'Force JavaScript in &lt;head&gt;?', 'minify-and-combine' ),
167
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
168
+ 'hint' => __( 'Load JavaScript early, this can potentially fix some JS-errors, but makes the JS render blocking.', 'minify-and-combine' ),
169
+ 'default' => false
170
+ );
171
+
172
+ $js_options[] = array(
173
+ 'type' => 'textarea',
174
+ 'name' => 'js_exclude',
175
+ 'title' => __( 'Exclude scripts from Мinify And Combine:', 'minify-and-combine' ),
176
+ //'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
177
+ 'hint' => __( 'A comma-separated list of scripts you want to exclude from being optimized, for example \'whatever.js, another.js\' (without the quotes) to exclude those scripts from being aggregated and minimized by Мinify And Combine.', 'minify-and-combine' ),
178
+ 'default' => 'seal.js, js/jquery/jquery.js'
179
+ );
180
+
181
+ $js_options[] = array(
182
+ 'type' => 'checkbox',
183
+ 'way' => 'buttons',
184
+ 'name' => 'js_trycatch',
185
+ 'title' => __( 'Add try-catch wrapping?', 'minify-and-combine' ),
186
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
187
+ 'hint' => __( 'If your scripts break because of a JS-error, you might want to try this.', 'minify-and-combine' ),
188
+ 'default' => false
189
+ );
190
+
191
+ $options[] = array(
192
+ 'type' => 'div',
193
+ 'id' => 'wbcr-mac-optimize-js-fields',
194
+ 'items' => $js_options
195
+ );
196
+
197
+ $options[] = array(
198
+ 'type' => 'html',
199
+ 'html' => '<div class="wbcr-factory-page-group-header"><strong>' . __( 'CSS Options', 'minify-and-combine' ) . '</strong><p></p></div>'
200
+ );
201
+
202
+ $options[] = array(
203
+ 'type' => 'checkbox',
204
+ 'way' => 'buttons',
205
+ 'name' => 'css_optimize',
206
+ 'title' => __( 'Optimize CSS Code?', 'minify-and-combine' ),
207
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
208
+ 'hint' => __( 'If your scripts break because of a JS-error, you might want to try this.', 'minify-and-combine' ),
209
+ 'default' => false,
210
+ 'eventsOn' => array(
211
+ 'show' => '#wbcr-clr-optimize-css-fields'
212
+ ),
213
+ 'eventsOff' => array(
214
+ 'hide' => '#wbcr-clr-optimize-css-fields'
215
+ )
216
+ );
217
+
218
+ $css_options[] = array(
219
+ 'type' => 'checkbox',
220
+ 'way' => 'buttons',
221
+ 'name' => 'css_aggregate',
222
+ 'title' => __( 'Aggregate CSS-files?', 'minify-and-combine' ),
223
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
224
+ 'hint' => __( 'Aggregate all linked CSS-files? If this option is off, the individual CSS-files will remain in place but will be minified.', 'minify-and-combine' ),
225
+ 'default' => false,
226
+ 'eventsOn' => array(
227
+ 'show' => '#wbcr-mac-optimization-danger-message-4'
228
+ ),
229
+ 'eventsOff' => array(
230
+ 'hide' => '#wbcr-mac-optimization-danger-message-4'
231
+ )
232
+ );
233
+
234
+ $css_options[] = array(
235
+ 'type' => 'html',
236
+ 'html' => array( $this, 'optimizationDangerMessage4' )
237
+ );
238
+
239
+ $css_options[] = array(
240
+ 'type' => 'checkbox',
241
+ 'way' => 'buttons',
242
+ 'name' => 'css_include_inline',
243
+ 'title' => __( 'Also aggregate inline CSS?', 'minify-and-combine' ),
244
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
245
+ 'hint' => __( 'Check this option for Мinify And Combine to also aggregate CSS in the HTML.', 'minify-and-combine' ),
246
+ 'default' => false,
247
+ 'eventsOn' => array(
248
+ 'show' => '#wbcr-mac-optimization-danger-message-5'
249
+ ),
250
+ 'eventsOff' => array(
251
+ 'hide' => '#wbcr-mac-optimization-danger-message-5'
252
+ )
253
+ );
254
+
255
+ $css_options[] = array(
256
+ 'type' => 'html',
257
+ 'html' => array( $this, 'optimizationDangerMessage5' )
258
+ );
259
+
260
+ $css_options[] = array(
261
+ 'type' => 'checkbox',
262
+ 'way' => 'buttons',
263
+ 'name' => 'css_datauris',
264
+ 'title' => __( 'Generate data: URIs for images?', 'minify-and-combine' ),
265
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
266
+ 'hint' => __( 'Enable this to include small background-images in the CSS itself instead of as separate downloads.', 'minify-and-combine' ),
267
+ 'default' => false
268
+ );
269
+
270
+ $css_options[] = array(
271
+ 'type' => 'checkbox',
272
+ 'way' => 'buttons',
273
+ 'name' => 'css_defer',
274
+ 'title' => __( 'Inline and Defer CSS?', 'minify-and-combine' ),
275
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
276
+ 'hint' => __( 'Inline "above the fold CSS" while loading the main auto optimized CSS only after page load. Check the FAQ for more info.
277
+ This can be fully automated for different types of pages with the Мinify And Combine CriticalCSS Power-Up.', 'minify-and-combine' ),
278
+ 'default' => false
279
+ );
280
+
281
+ $css_options[] = array(
282
+ 'type' => 'checkbox',
283
+ 'way' => 'buttons',
284
+ 'name' => 'css_inline',
285
+ 'title' => __( 'Inline all CSS?', 'minify-and-combine' ),
286
+ 'layout' => array( 'hint-type' => 'icon', 'hint-icon-color' => 'grey' ),
287
+ 'hint' => __( 'Inlining all CSS can improve performance for sites with a low pageviews/ visitor-rate, but may slow down performance otherwise.', 'minify-and-combine' ),
288
+ 'default' => false
289
+ );
290
+
291
+ $css_options[] = array(
292
+ 'type' => 'textarea',
293
+ 'name' => 'css_exclude',
294
+ 'title' => __( 'Exclude CSS from Мinify And Combine:', 'minify-and-combine' ),
295
+ //'layout' => array('hint-type' => 'icon', 'hint-icon-color' => 'grey'),
296
+ 'hint' => __( 'A comma-separated list of CSS you want to exclude from being optimized.', 'minify-and-combine' ),
297
+ 'default' => 'wp-content/cache/, wp-content/uploads/, admin-bar.min.css, dashicons.min.css'
298
+ );
299
+
300
+ $options[] = array(
301
+ 'type' => 'div',
302
+ 'id' => 'wbcr-clr-optimize-css-fields',
303
+ 'items' => $css_options
304
+ );
305
+
306
+ $options[] = array(
307
+ 'type' => 'html',
308
+ 'html' => '<div class="wbcr-factory-page-group-header"><strong>' . __( 'Cache Info', 'minify-and-combine' ) . '</strong><p>' . __( 'Описание раздела оптимизация', 'minify-and-combine' ) . '</p></div>'
309
+ );
310
+
311
+ // Произвольный html код
312
+ $options[] = array(
313
+ 'type' => 'html',
314
+ 'html' => array( $this, 'cacheInfo' )
315
+ );
316
+
317
+ $formOptions = array();
318
+
319
+ $formOptions[] = array(
320
+ 'type' => 'form-group',
321
+ 'items' => $options,
322
+ //'cssClass' => 'postbox'
323
+ );
324
+
325
+ return apply_filters( 'wbcr_mac_settings_form_options', $formOptions );
326
+ }
327
+
328
+ public function cacheInfo() {
329
+ $is_network = is_network_admin();
330
+
331
+ $cache = $is_network ? WMAC_PluginCache::getUsedCacheMultisite() : WMAC_PluginCache::getUsedCache();
332
+ ?>
333
+ <div class="form-group">
334
+ <label for="wbcr_mac_css_optimize" class="col-sm-4 control-label">
335
+ Cache folder<?php echo $is_network ? 's' : '' ?>
336
+ </label>
337
+ <div class="control-group col-sm-8">
338
+ <?php echo $is_network ? WP_CONTENT_DIR . WMAC_CACHE_CHILD_DIR . '[...]/' : WMAC_PluginCache::getCacheDir() ?>
339
+ </div>
340
+ </div>
341
+ <div class="form-group">
342
+ <label for="wbcr_mac_css_optimize" class="col-sm-4 control-label">
343
+ Can we write?
344
+ </label>
345
+ <div class="control-group col-sm-8">
346
+ Yes
347
+ </div>
348
+ </div>
349
+ <div class="form-group">
350
+ <label for="wbcr_mac_css_optimize" class="col-sm-4 control-label">
351
+ Cached styles and scripts<?php echo $is_network ? ' (all sites)' : '' ?>
352
+ </label>
353
+ <div class="control-group col-sm-8">
354
+ <?php if ( $is_network ) : ?>
355
+ <?php echo $cache['files'] ?> files, totalling <?php echo $cache['size'] ?> (calculated
356
+ at <?php echo gmdate( 'H:i' ) ?> UTC)
357
+ <?php else: ?>
358
+ <?php echo $cache['percent'] . '%, ' . $cache['files'] ?> files,
359
+ totalling <?php echo $cache['size'] ?> (calculated at <?php echo gmdate( 'H:i' ) ?> UTC)
360
+ <?php endif; ?>
361
+ </div>
362
+ </div>
363
+ <div class="form-group">
364
+ <label for="wbcr_mac_css_optimize" class="col-sm-4 control-label">
365
+ </label>
366
+ <div class="control-group col-sm-8">
367
+ <a class="btn btn-default" href="<?= wp_nonce_url( $this->getActionUrl( 'clear-cache' ), 'clear_cache_' . $this->getResultId() ); ?>">
368
+ <?php _e( 'Clear cache', 'minify-and-combine' ) ?>
369
+ </a>
370
+ </div>
371
+ </div>
372
  <?php
373
+ }
374
+
375
+ /**
376
+ * Adds an html warning notification html markup.
377
+ *
378
+ * @param int $selector_id
379
+ */
380
+ public function optimizationDangerMessage( $selector_id = 1 ) {
381
+ ?>
382
+ <div class="form-group">
383
+ <label class="col-sm-4 control-label"></label>
384
+ <div class="control-group col-sm-8">
385
+ <div id="wbcr-mac-optimization-danger-message-<?= $selector_id ?>" class="wbcr-clearfy-danger-message">
386
+ <?php _e( '<b>This could break things!</b><br>If you notice any errors on your website after having activated this setting, just deactivate it again, and your site will be back to normal.', 'clearfy' ) ?>
387
+ </div>
388
+ </div>
389
+ </div>
390
+ <?php
391
+ }
392
+
393
+ public function optimizationDangerMessage1() {
394
+ $this->optimizationDangerMessage( 1 );
395
+ }
396
+
397
+ public function optimizationDangerMessage2() {
398
+ $this->optimizationDangerMessage( 2 );
399
+ }
400
+
401
+ public function optimizationDangerMessage3() {
402
+ $this->optimizationDangerMessage( 3 );
403
+ }
404
+
405
+ public function optimizationDangerMessage4() {
406
+ $this->optimizationDangerMessage( 4 );
407
+ }
408
+
409
+ public function optimizationDangerMessage5() {
410
+ $this->optimizationDangerMessage( 5 );
411
+ }
412
+
413
+ /**
414
+ * Действие rollback
415
+ * Если мы перейдем по ссылке, которую мы создали для кнопки "Восстановить" для метода rollbackButton,
416
+ * То выполнится это действие
417
+ */
418
+ public function clearCacheAction() {
419
+ check_admin_referer( 'clear_cache_' . $this->getResultId() );
420
+
421
+ if ( is_network_admin() ) {
422
+ WMAC_PluginCache::clearAllMultisite();
423
+ } else {
424
+ WMAC_PluginCache::clearAll();
425
  }
426
+
427
+ // редирект с выводом уведомления
428
+ $this->redirectToAction( 'index', array( 'wbcr_mac_clear_cache_success' => 1 ) );
429
+ }
430
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/updates-manager/admin/assets/css/general.css CHANGED
@@ -1,153 +1,155 @@
1
- /**
2
- * General styles
3
- * @author Alex Kovalev <alex.kovalevv@gmail.com>
4
- * @copyright Alex Kovalev 23.08.2017
5
- */
6
- #WBCR {
7
- /* upm */
8
- }
9
- #WBCR .wp-list-table th,
10
- #WBCR .wp-list-table .plugin-name {
11
- font-size: 13px;
12
- font-weight: 600;
13
- }
14
- #WBCR .wp-list-table.wbcr-upm-list-table-pro.wbcr-upm-column-premium td {
15
- background: #f9f2f0 !important;
16
- }
17
- #WBCR .wp-list-table.wbcr-upm-list-table-pro.wbcr-upm-column-premium td .factory-buttons-way,
18
- #WBCR .wp-list-table.wbcr-upm-list-table-pro.wbcr-upm-column-premium td input[type="checkbox"] {
19
- border-color: #fff;
20
- background: #fff;
21
- }
22
- #WBCR .wp-list-table th.wbcr-upm-column-premium,
23
- #WBCR .wp-list-table td.wbcr-upm-column-premium {
24
- background: #f9f2f0 !important;
25
- }
26
- #WBCR .wp-list-table th.wbcr-upm-column-premium .factory-buttons-way,
27
- #WBCR .wp-list-table td.wbcr-upm-column-premium .factory-buttons-way,
28
- #WBCR .wp-list-table th.wbcr-upm-column-premium input[type="checkbox"],
29
- #WBCR .wp-list-table td.wbcr-upm-column-premium input[type="checkbox"] {
30
- border-color: #fff;
31
- background: #fff;
32
- }
33
- #WBCR .wp-list-table .plugin-update-tr.active td,
34
- #WBCR .wp-list-table.plugins .active th.check-column {
35
- border-left: 4px solid #e6e6e6 !important;
36
- padding-left: 8px !important;
37
- }
38
- #WBCR .wp-list-table.plugins .row-actions,
39
- #WBCR .wp-list-table.plugins .second {
40
- padding: 0 0 5px;
41
- color: #949292;
42
- }
43
- #WBCR .wp-list-table.plugins .active td,
44
- #WBCR .wp-list-table.plugins .active th {
45
- background-color: #ffffff;
46
- }
47
- #WBCR .wp-list-table.plugins,
48
- #WBCR .wp-list-table.plugins td,
49
- #WBCR .wp-list-table.plugins th,
50
- #WBCR .wp-list-table .row-actions .network_active,
51
- #WBCR .wp-list-table .row-actions .network_only {
52
- color: #777;
53
- }
54
- #WBCR .wp-list-table .widefat ol,
55
- #WBCR .wp-list-table .widefat p,
56
- #WBCR .wp-list-table .widefat tfoot tr td,
57
- #WBCR .wp-list-table .widefat tfoot tr th,
58
- #WBCR .wp-list-table .widefat thead tr td,
59
- #WBCR .wp-list-table .widefat thead tr th,
60
- #WBCR .wp-list-table .widefat ul {
61
- color: #7d7d7d;
62
- }
63
- #WBCR .wp-list-table #disable_updates,
64
- #WBCR .wp-list-table #disable_auto_updates,
65
- #WBCR .wp-list-table #disable_translation_updates,
66
- #WBCR .wp-list-table #hide_item {
67
- width: 100px;
68
- }
69
- #WBCR .column-flags .factory-checkbox {
70
- display: inline-flex;
71
- }
72
- #WBCR .wp-list-table.autoupdate th {
73
- white-space: normal !important;
74
- }
75
- #WBCR .wp-list-table.autoupdate .plugin-title {
76
- white-space: normal !important;
77
- }
78
- #WBCR .wp-list-table__plugins .plugin-title {
79
- max-width: 12rem;
80
- }
81
- #WBCR .wbcr-upm-group-header-pro {
82
- position: relative;
83
- display: inline-block;
84
- }
85
- #WBCR .wbcr-upm-group-header-pro:after {
86
- display: inline-block;
87
- position: relative;
88
- content: 'PRO';
89
- background: #ff5722;
90
- border-radius: 4px;
91
- color: #fff;
92
- font-size: 10px;
93
- line-height: 1;
94
- font-style: normal;
95
- padding: 4px 6px;
96
- margin-left: 4px;
97
- vertical-align: top;
98
- top: 0;
99
- left: auto;
100
- right: 0;
101
- z-index: 11;
102
- }
103
- #WBCR #disable_translation_updates,
104
- #WBCR #hide_item {
105
- position: relative;
106
- }
107
- #WBCR #disable_translation_updates.wbcr-upm-column-pro:after,
108
- #WBCR #hide_item.wbcr-upm-column-pro:after {
109
- display: inline-block;
110
- position: absolute;
111
- content: 'PRO';
112
- background: #ff5722;
113
- border-radius: 4px;
114
- color: #fff;
115
- font-size: 10px;
116
- line-height: 1;
117
- font-style: normal;
118
- padding: 4px 6px;
119
- margin-left: 4px;
120
- vertical-align: top;
121
- top: -10px;
122
- left: auto;
123
- right: 0;
124
- z-index: 11;
125
- }
126
- #WBCR .factory-checkbox.wbcr-upm-icon-pro:after {
127
- display: inline-block;
128
- position: relative;
129
- content: 'PRO';
130
- background: #ff5722;
131
- border-radius: 4px;
132
- color: #fff;
133
- font-size: 10px;
134
- line-height: 1;
135
- font-style: normal;
136
- padding: 4px 6px;
137
- margin-left: 4px;
138
- vertical-align: top;
139
- top: -8px;
140
- left: -10px;
141
- right: auto;
142
- z-index: 11;
143
- }
144
- .factory-checkbox-disabled input,
145
- .factory-checkbox-disabled button {
146
- pointer-events: none;
147
- cursor: not-allowed;
148
- opacity: 0.65;
149
- filter: alpha(opacity=65);
150
- -webkit-box-shadow: none;
151
- box-shadow: none;
152
- }
153
- /*# sourceMappingURL=general.css.map */
 
 
1
+ /**
2
+ * General styles
3
+ * @author Alex Kovalev <alex.kovalevv@gmail.com>
4
+ * @copyright Alex Kovalev 23.08.2017
5
+ */
6
+ #WBCR {
7
+ /* upm */
8
+ }
9
+ #WBCR .wp-list-table th,
10
+ #WBCR .wp-list-table .plugin-name {
11
+ font-size: 13px;
12
+ font-weight: 600;
13
+ }
14
+ #WBCR .wp-list-table.wbcr-upm-list-table-pro.wbcr-upm-column-premium td {
15
+ background: #f9f2f0 !important;
16
+ }
17
+ #WBCR .wp-list-table.wbcr-upm-list-table-pro.wbcr-upm-column-premium td .factory-buttons-way,
18
+ #WBCR .wp-list-table.wbcr-upm-list-table-pro.wbcr-upm-column-premium td input[type="checkbox"] {
19
+ border-color: #fff;
20
+ background: #fff;
21
+ }
22
+ #WBCR .wp-list-table th.wbcr-upm-column-premium,
23
+ #WBCR .wp-list-table td.wbcr-upm-column-premium {
24
+ background: #f9f2f0 !important;
25
+ }
26
+ #WBCR .wp-list-table th.wbcr-upm-column-premium .factory-buttons-way,
27
+ #WBCR .wp-list-table td.wbcr-upm-column-premium .factory-buttons-way,
28
+ #WBCR .wp-list-table th.wbcr-upm-column-premium input[type="checkbox"],
29
+ #WBCR .wp-list-table td.wbcr-upm-column-premium input[type="checkbox"] {
30
+ border-color: #fff;
31
+ background: #fff;
32
+ }
33
+ #WBCR .wp-list-table .plugin-update-tr.active td,
34
+ #WBCR .wp-list-table.plugins .active th.check-column {
35
+ border-left: 4px solid #e6e6e6 !important;
36
+ padding-left: 8px !important;
37
+ }
38
+ #WBCR .wp-list-table.plugins .row-actions,
39
+ #WBCR .wp-list-table.plugins .second {
40
+ padding: 0 0 5px;
41
+ color: #949292;
42
+ }
43
+ #WBCR .wp-list-table.plugins .active td,
44
+ #WBCR .wp-list-table.plugins .active th {
45
+ background-color: #ffffff;
46
+ }
47
+ #WBCR .wp-list-table.plugins,
48
+ #WBCR .wp-list-table.plugins td,
49
+ #WBCR .wp-list-table.plugins th,
50
+ #WBCR .wp-list-table .row-actions .network_active,
51
+ #WBCR .wp-list-table .row-actions .network_only {
52
+ color: #777;
53
+ }
54
+ #WBCR .wp-list-table .widefat ol,
55
+ #WBCR .wp-list-table .widefat p,
56
+ #WBCR .wp-list-table .widefat tfoot tr td,
57
+ #WBCR .wp-list-table .widefat tfoot tr th,
58
+ #WBCR .wp-list-table .widefat thead tr td,
59
+ #WBCR .wp-list-table .widefat thead tr th,
60
+ #WBCR .wp-list-table .widefat ul {
61
+ color: #7d7d7d;
62
+ }
63
+ #WBCR .wp-list-table #disable_updates,
64
+ #WBCR .wp-list-table #disable_auto_updates,
65
+ #WBCR .wp-list-table #disable_translation_updates,
66
+ #WBCR .wp-list-table #hide_item {
67
+ width: 100px;
68
+ }
69
+ #WBCR .column-flags .factory-checkbox {
70
+ display: inline-flex;
71
+ }
72
+ #WBCR .wp-list-table.autoupdate th {
73
+ white-space: normal !important;
74
+ }
75
+ #WBCR .wp-list-table.autoupdate .plugin-title {
76
+ white-space: normal !important;
77
+ }
78
+ #WBCR .wp-list-table__plugins .plugin-title {
79
+ max-width: 12rem;
80
+ }
81
+ #WBCR .wbcr-upm-group-header-pro {
82
+ position: relative;
83
+ display: inline-block;
84
+ }
85
+ #WBCR .wbcr-upm-group-header-pro:after {
86
+ display: inline-block;
87
+ position: relative;
88
+ content: 'PRO';
89
+ background: #ff5722;
90
+ border-radius: 4px;
91
+ color: #fff;
92
+ font-size: 10px;
93
+ line-height: 1;
94
+ font-style: normal;
95
+ padding: 4px 6px;
96
+ margin-left: 4px;
97
+ vertical-align: top;
98
+ top: 0;
99
+ left: auto;
100
+ right: 0;
101
+ z-index: 11;
102
+ }
103
+ #WBCR #disable_translation_updates,
104
+ #WBCR #hide_item {
105
+ position: relative;
106
+ }
107
+ #WBCR #disable_translation_updates.wbcr-upm-column-pro:after,
108
+ #WBCR #hide_item.wbcr-upm-column-pro:after {
109
+ display: inline-block;
110
+ position: absolute;
111
+ content: 'PRO';
112
+ background: #ff5722;
113
+ border-radius: 4px;
114
+ color: #fff;
115
+ font-size: 10px;
116
+ line-height: 1;
117
+ font-style: normal;
118
+ padding: 4px 6px;
119
+ margin-left: 4px;
120
+ vertical-align: top;
121
+ top: -10px;
122
+ left: auto;
123
+ right: 0;
124
+ z-index: 11;
125
+ }
126
+ #WBCR .factory-checkbox.wbcr-upm-icon-pro:after {
127
+ display: inline-block;
128
+ position: relative;
129
+ content: 'PRO';
130
+ background: #ff5722;
131
+ border-radius: 4px;
132
+ color: #fff;
133
+ font-size: 10px;
134
+ line-height: 1;
135
+ font-style: normal;
136
+ padding: 4px 6px;
137
+ margin-left: 4px;
138
+ vertical-align: top;
139
+ top: -8px;
140
+ left: -10px;
141
+ right: auto;
142
+ z-index: 11;
143
+ }
144
+ #WBCR .wp-list-table.autoupdate .check-column {
145
+ padding: 10px 9px;
146
+ }
147
+ .factory-checkbox-disabled input,
148
+ .factory-checkbox-disabled button {
149
+ pointer-events: none;
150
+ cursor: not-allowed;
151
+ opacity: .65;
152
+ filter: alpha(opacity=65);
153
+ -webkit-box-shadow: none;
154
+ box-shadow: none;
155
+ }
components/updates-manager/admin/assets/css/general.css.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["general.less"],"names":[],"mappings":";;;;;AAMA;;;AAAA,KAoBE,eACE;AArBJ,KAoBE,eACM;EACF,eAAA;EACA,gBAAA;;AAGA,KANJ,eAKG,wBACE,wBACC;EACE,mBAAA;;AAFJ,KANJ,eAKG,wBACE,wBACC,GAEE;AAHJ,KANJ,eAKG,wBACE,wBACC,GAEwB,MAAK;EACzB,kBAAA;EACA,gBAAA;;AAON,KAlBJ,eAiBE,GACG;AAAD,KAlBJ,eAiBM,GACD;EACC,mBAAA;;AADF,KAlBJ,eAiBE,GACG,wBAEC;AAFF,KAlBJ,eAiBM,GACD,wBAEC;AAFF,KAlBJ,eAiBE,GACG,wBAEuB,MAAK;AAF7B,KAlBJ,eAiBM,GACD,wBAEuB,MAAK;EACzB,kBAAA;EACA,gBAAA;;AA1CV,KAoBE,eA2BE,kBAAiB,OAAQ;AAAI,KA3B/B,eA2BgC,QAAS,QAAQ,GAAE;EAC/C,8BAAA;EACA,4BAAA;;AAEF,KA/BF,eA+BG,QAAS;AAAc,KA/B1B,eA+B2B,QAAS;EAChC,gBAAA;EACA,cAAA;;AAEF,KAnCF,eAmCG,QAAS,QAAQ;AAAI,KAnCxB,eAmCyB,QAAS,QAAQ;EACtC,yBAAA;;AAEF,KAtCF,eAsCG;AAAU,KAtCb,eAsCc,QAAS;AAAI,KAtC3B,eAsC4B,QAAS;AA1DvC,KAoBE,eAsCyC,aAAa;AA1DxD,KAoBE,eAsCuE,aAAa;EAChF,WAAA;;AA3DN,KAoBE,eAyCE,SAAS;AA7Db,KAoBE,eAyCe,SAAS;AA7D1B,KAoBE,eAyC2B,SAAS,MAAM,GAAG;AA7D/C,KAoBE,eAyCiD,SAAS,MAAM,GAAG;AA7DrE,KAoBE,eAyCuE,SAAS,MAAM,GAAG;AA7D3F,KAoBE,eAyC6F,SAAS,MAAM,GAAG;AA7DjH,KAoBE,eAyCmH,SAAS;EACxH,cAAA;;AA9DN,KAoBE,eA6CE;AAjEJ,KAoBE,eA6CoB;AAjEtB,KAoBE,eA6C2C;AAjE7C,KAoBE,eA6CyE;EACrE,YAAA;;AAlEN,KAsEE,cAAc;EACZ,oBAAA;;AAvEJ,KA2EE,eAAc,WACZ;EACE,8BAAA;;AA7EN,KA2EE,eAAc,WAIZ;EACE,8BAAA;;AAhFN,KAmFE,wBACE;EACE,gBAAA;;AArFN,KAyFE;EACE,kBAAA;EACA,qBAAA;;AACA,KAHF,2BAGG;EA1FD,qBAAA;EACA,kBAAA;EACA,SAAS,KAAT;EACA,mBAAA;EACA,kBAAA;EACA,WAAA;EACA,eAAA;EACA,cAAA;EACA,kBAAA;EACA,gBAAA;EACA,gBAAA;EACA,mBAAA;EACA,MAAA;EACA,UAAA;EACA,QAAA;EACA,WAAA;;AAjBJ,KAiGE;AAjGF,KAiGgC;EAC5B,kBAAA;;AACA,KAFF,6BAEG,oBAAoB;AAArB,KAF4B,WAE3B,oBAAoB;EAjGrB,qBAAA;EACA,kBAAA;EACA,SAAS,KAAT;EACA,mBAAA;EACA,kBAAA;EACA,WAAA;EACA,eAAA;EACA,cAAA;EACA,kBAAA;EACA,gBAAA;EACA,gBAAA;EACA,mBAAA;EACA,UAAA;EACA,UAAA;EACA,QAAA;EACA,WAAA;;AAjBJ,KAwGE,kBAAiB,kBAAkB;EAtGjC,qBAAA;EACA,kBAAA;EACA,SAAS,KAAT;EACA,mBAAA;EACA,kBAAA;EACA,WAAA;EACA,eAAA;EACA,cAAA;EACA,kBAAA;EACA,gBAAA;EACA,gBAAA;EACA,mBAAA;EACA,SAAA;EACA,WAAA;EACA,WAAA;EACA,WAAA;;AA4FJ,0BAA2B;AAAO,0BAA2B;EAC3D,oBAAA;EACA,mBAAA;EACA,aAAA;EACA,yBAAA;EACA,wBAAA;EACA,gBAAA","file":"general.css"}
1
+ {"version":3,"sources":["general.less"],"names":[],"mappings":";;;;;AAMA;;;AAAA,KAoBE,eACE;AArBJ,KAoBE,eACM;EACF,eAAA;EACA,gBAAA;;AAGA,KANJ,eAKG,wBACE,wBACC;EACE,mBAAA;;AAFJ,KANJ,eAKG,wBACE,wBACC,GAEE;AAHJ,KANJ,eAKG,wBACE,wBACC,GAEwB,MAAK;EACzB,kBAAA;EACA,gBAAA;;AAON,KAlBJ,eAiBE,GACG;AAAD,KAlBJ,eAiBM,GACD;EACC,mBAAA;;AADF,KAlBJ,eAiBE,GACG,wBAEC;AAFF,KAlBJ,eAiBM,GACD,wBAEC;AAFF,KAlBJ,eAiBE,GACG,wBAEuB,MAAK;AAF7B,KAlBJ,eAiBM,GACD,wBAEuB,MAAK;EACzB,kBAAA;EACA,gBAAA;;AA1CV,KAoBE,eA2BE,kBAAiB,OAAQ;AAAI,KA3B/B,eA2BgC,QAAS,QAAQ,GAAE;EAC/C,8BAAA;EACA,4BAAA;;AAEF,KA/BF,eA+BG,QAAS;AAAc,KA/B1B,eA+B2B,QAAS;EAChC,gBAAA;EACA,cAAA;;AAEF,KAnCF,eAmCG,QAAS,QAAQ;AAAI,KAnCxB,eAmCyB,QAAS,QAAQ;EACtC,yBAAA;;AAEF,KAtCF,eAsCG;AAAU,KAtCb,eAsCc,QAAS;AAAI,KAtC3B,eAsC4B,QAAS;AA1DvC,KAoBE,eAsCyC,aAAa;AA1DxD,KAoBE,eAsCuE,aAAa;EAChF,WAAA;;AA3DN,KAoBE,eAyCE,SAAS;AA7Db,KAoBE,eAyCe,SAAS;AA7D1B,KAoBE,eAyC2B,SAAS,MAAM,GAAG;AA7D/C,KAoBE,eAyCiD,SAAS,MAAM,GAAG;AA7DrE,KAoBE,eAyCuE,SAAS,MAAM,GAAG;AA7D3F,KAoBE,eAyC6F,SAAS,MAAM,GAAG;AA7DjH,KAoBE,eAyCmH,SAAS;EACxH,cAAA;;AA9DN,KAoBE,eA6CE;AAjEJ,KAoBE,eA6CoB;AAjEtB,KAoBE,eA6C2C;AAjE7C,KAoBE,eA6CyE;EACrE,YAAA;;AAlEN,KAsEE,cAAc;EACZ,oBAAA;;AAvEJ,KA2EE,eAAc,WACZ;EACE,8BAAA;;AA7EN,KA2EE,eAAc,WAIZ;EACE,8BAAA;;AAhFN,KAmFE,wBACE;EACE,gBAAA;;AArFN,KAyFE;EACE,kBAAA;EACA,qBAAA;;AACA,KAHF,2BAGG;EA1FD,qBAAA;EACA,kBAAA;EACA,SAAS,KAAT;EACA,mBAAA;EACA,kBAAA;EACA,WAAA;EACA,eAAA;EACA,cAAA;EACA,kBAAA;EACA,gBAAA;EACA,gBAAA;EACA,mBAAA;EACA,MAAA;EACA,UAAA;EACA,QAAA;EACA,WAAA;;AAjBJ,KAiGE;AAjGF,KAiGgC;EAC5B,kBAAA;;AACA,KAFF,6BAEG,oBAAoB;AAArB,KAF4B,WAE3B,oBAAoB;EAjGrB,qBAAA;EACA,kBAAA;EACA,SAAS,KAAT;EACA,mBAAA;EACA,kBAAA;EACA,WAAA;EACA,eAAA;EACA,cAAA;EACA,kBAAA;EACA,gBAAA;EACA,gBAAA;EACA,mBAAA;EACA,UAAA;EACA,UAAA;EACA,QAAA;EACA,WAAA;;AAjBJ,KAwGE,kBAAiB,kBAAkB;EAtGjC,qBAAA;EACA,kBAAA;EACA,SAAS,KAAT;EACA,mBAAA;EACA,kBAAA;EACA,WAAA;EACA,eAAA;EACA,cAAA;EACA,kBAAA;EACA,gBAAA;EACA,gBAAA;EACA,mBAAA;EACA,SAAA;EACA,WAAA;EACA,WAAA;EACA,WAAA;;AAjBJ,KA2GE,eAAc,WAAY;EACxB,iBAAA;;AAIJ,0BAA2B;AAAO,0BAA2B;EAC3D,oBAAA;EACA,mBAAA;EACA,aAAA;EACA,yBAAA;EACA,wBAAA;EACA,gBAAA","file":"general.css"}
components/updates-manager/admin/assets/css/plugins.css CHANGED
@@ -1,32 +1,32 @@
1
- /**
2
- * Plugins page interface
3
- * @author Webcraftic <wordpress.webraftic@gmail.com>
4
- * @copyright Webcraftic 03.09.2018
5
- */
6
- /* wordpress default plugins page */
7
- .wbcr-upm-plugin-status,
8
- tbody .check-column:not(.hide-placeholder):after {
9
- display: block;
10
- content: "\f463";
11
- line-height: 1;
12
- font-family: dashicons;
13
- text-decoration: inherit;
14
- font-weight: 400;
15
- font-style: normal;
16
- vertical-align: top;
17
- text-align: center;
18
- margin: 4px 0 0 8px;
19
- color: #b4b9be;
20
- border: 1px solid #b4b9be;
21
- font-size: 14px;
22
- height: 14px;
23
- width: 14px;
24
- }
25
- .wbcr-upm-plugin-status.wbcr-upm-red {
26
- color: rgba(170, 0, 0, 0.58);
27
- border-color: rgba(170, 0, 0, 0.45);
28
- }
29
- .wbcr-upm-plugin-status.wbcr-upm-purple {
30
- color: #ac62b9;
31
- border-color: #a767b3;
32
- }
1
+ /**
2
+ * Plugins page interface
3
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
4
+ * @copyright Webcraftic 03.09.2018
5
+ */
6
+ /* wordpress default plugins page */
7
+ .wbcr-upm-plugin-status,
8
+ tbody .check-column:not(.hide-placeholder):after {
9
+ display: block;
10
+ content: "\f463";
11
+ line-height: 1;
12
+ font-family: dashicons;
13
+ text-decoration: inherit;
14
+ font-weight: 400;
15
+ font-style: normal;
16
+ vertical-align: top;
17
+ text-align: center;
18
+ margin: 4px 0 0 8px;
19
+ color: #b4b9be;
20
+ border: 1px solid #b4b9be;
21
+ font-size: 14px;
22
+ height: 14px;
23
+ width: 14px;
24
+ }
25
+ .wbcr-upm-plugin-status.wbcr-upm-red {
26
+ color: rgba(170, 0, 0, 0.58);
27
+ border-color: rgba(170, 0, 0, 0.45);
28
+ }
29
+ .wbcr-upm-plugin-status.wbcr-upm-purple {
30
+ color: #ac62b9;
31
+ border-color: #a767b3;
32
+ }
components/updates-manager/admin/assets/css/themes.css CHANGED
@@ -1,20 +1,20 @@
1
  /* update manager button */
2
- #wpbody .search-form:not(.hide-placeholder):before {
3
- display: inline-block;
4
- content: 'Update manager';
5
- margin-left: 4px;
6
- padding: 4px 8px;
7
- position: relative;
8
- top: -3px;
9
- text-decoration: none;
10
- border: 1px solid #ccc;
11
- border-radius: 2px;
12
- background: #f7f7f7;
13
- text-shadow: none;
14
- font-weight: 600;
15
- font-size: 13px;
16
- line-height: normal;
17
- color: #0073aa;
18
- cursor: pointer;
19
- outline: 0;
20
- }
1
  /* update manager button */
2
+ /*#wpbody .search-form:not(.hide-placeholder):before {
3
+ display: inline-block;
4
+ content: 'Update manager';
5
+ margin-left: 4px;
6
+ padding: 4px 8px;
7
+ position: relative;
8
+ top: -3px;
9
+ text-decoration: none;
10
+ border: 1px solid #ccc;
11
+ border-radius: 2px;
12
+ background: #f7f7f7;
13
+ text-shadow: none;
14
+ font-weight: 600;
15
+ font-size: 13px;
16
+ line-height: normal;
17
+ color: #0073aa;
18
+ cursor: pointer;
19
+ outline: 0;
20
+ }*/
components/updates-manager/admin/assets/css/themes.css.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["themes.less"],"names":[],"mappings":";AACA,OAAQ,aAAY,IAAI,mBAAmB;EACvC,qBAAA;EACA,SAAS,gBAAT;EACA,gBAAA;EACA,gBAAA;EACA,kBAAA;EACA,SAAA;EACA,qBAAA;EACA,sBAAA;EACA,kBAAA;EACA,mBAAA;EACA,iBAAA;EACA,gBAAA;EACA,eAAA;EACA,mBAAA;EACA,cAAA;EACA,eAAA;EACA,UAAA","file":"themes.css"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"themes.css"}
components/updates-manager/admin/assets/css/themes.less CHANGED
@@ -1,5 +1,5 @@
1
  /* update manager button */
2
- #wpbody .search-form:not(.hide-placeholder):before {
3
  display: inline-block;
4
  content: 'Update manager';
5
  margin-left: 4px;
@@ -17,4 +17,4 @@
17
  color: #0073aa;
18
  cursor: pointer;
19
  outline: 0;
20
- }
1
  /* update manager button */
2
+ /*#wpbody .search-form:not(.hide-placeholder):before {
3
  display: inline-block;
4
  content: 'Update manager';
5
  margin-left: 4px;
17
  color: #0073aa;
18
  cursor: pointer;
19
  outline: 0;
20
+ }*/
components/updates-manager/admin/assets/js/ajax-components.js CHANGED
@@ -1,6 +1,22 @@
1
  jQuery(function($) {
2
-
3
  var initAjaxControls = function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  $('.factory-ajax-checkbox').on('change', function(ev) {
5
  var action = $(this).data('action');
6
  var new_value = $(this).val();
@@ -13,25 +29,24 @@ jQuery(function($) {
13
  }
14
  data['flag'] = $(this).data('action');
15
  data['value'] = new_value;
 
 
 
16
 
17
  var disable_group = $(this).data('disable-group');
18
  if( disable_group ) {
19
 
20
  if( new_value == true ) {
21
  $("." + disable_group).find('button, input').prop('disabled', true);
22
- var row = $(this).parents('tr');
23
- row.removeClass('active').addClass('inactive');
24
 
25
  } else {
26
  $("." + disable_group).each(function(k, v) {
27
  if( !$(v).hasClass('global-disabled') ) {
28
  $(v).find('button, input').prop('disabled', false);
29
  }
 
30
 
31
- var row = $(this).parents('tr');
32
- if( !row.hasClass('row-global-disabled') ){
33
- row.removeClass('inactive').addClass('active');
34
- }
35
  });
36
  }
37
 
@@ -65,6 +80,17 @@ jQuery(function($) {
65
  });
66
  });
67
 
 
 
 
 
 
 
 
 
 
 
 
68
  };
69
 
70
  initAjaxControls();
1
  jQuery(function($) {
 
2
  var initAjaxControls = function() {
3
+ function toggleRedLine(val){
4
+ var row = $(this).parents('tr');
5
+ if( !row.hasClass('row-global-disabled') ){
6
+ var disable_display = row.find('#wbcr_updates_manager_hide_item').val();
7
+ var disable_all_updates = row.find('#wbcr_updates_manager_disable_updates').val();
8
+ if(disable_display !== undefined) disable_display = parseInt(disable_display);
9
+ if(disable_all_updates !== undefined) disable_all_updates = parseInt(disable_all_updates);
10
+
11
+ if(!disable_all_updates && (disable_display === undefined || !disable_display)){
12
+ row.removeClass('inactive').addClass('active');
13
+ }else{
14
+ row.removeClass('active').addClass('inactive');
15
+ }
16
+ }
17
+
18
+ }
19
+
20
  $('.factory-ajax-checkbox').on('change', function(ev) {
21
  var action = $(this).data('action');
22
  var new_value = $(this).val();
29
  }
30
  data['flag'] = $(this).data('action');
31
  data['value'] = new_value;
32
+ if( $(this).data('inverse') ){
33
+ data['value'] = 0 + ! parseInt(new_value);
34
+ }
35
 
36
  var disable_group = $(this).data('disable-group');
37
  if( disable_group ) {
38
 
39
  if( new_value == true ) {
40
  $("." + disable_group).find('button, input').prop('disabled', true);
41
+ toggleRedLine.apply(this);
 
42
 
43
  } else {
44
  $("." + disable_group).each(function(k, v) {
45
  if( !$(v).hasClass('global-disabled') ) {
46
  $(v).find('button, input').prop('disabled', false);
47
  }
48
+ toggleRedLine.apply(this);
49
 
 
 
 
 
50
  });
51
  }
52
 
80
  });
81
  });
82
 
83
+ $('.wbcr_um_select_item').on('change', function(){
84
+ $('.wbcr_um_select_all').prop('checked', false);
85
+ });
86
+ $('.wbcr_um_select_all').on('change', function(){
87
+ if($(this).prop('checked')){
88
+ $('.wbcr_um_select_item').prop('checked', true);
89
+ }else{
90
+ $('.wbcr_um_select_item').prop('checked', false);
91
+ }
92
+ });
93
+
94
  };
95
 
96
  initAjaxControls();
components/updates-manager/admin/boot.php CHANGED
@@ -245,7 +245,7 @@
245
  'filters' => $filters,
246
  )); ?>;
247
  um_add_plugin_icons(info);
248
- um_add_plugin_actions("<?= $btn_title ?>", "<?= $btn_url ?>");
249
  });
250
 
251
  <?php
@@ -281,7 +281,7 @@
281
 
282
 
283
  jQuery(function($){
284
- window.um_add_theme_actions("<?= $btn_title ?>", "<?= $btn_url ?>");
285
  });
286
 
287
  <?php
245
  'filters' => $filters,
246
  )); ?>;
247
  um_add_plugin_icons(info);
248
+ // um_add_plugin_actions("<?= $btn_title ?>", "<?= $btn_url ?>");
249
  });
250
 
251
  <?php
281
 
282
 
283
  jQuery(function($){
284
+ // window.um_add_theme_actions("<?= $btn_title ?>", "<?= $btn_url ?>");
285
  });
286
 
287
  <?php
components/updates-manager/admin/includes/class.plugin-filters.php CHANGED
@@ -105,6 +105,11 @@ class WUPM_PluginFilters extends WUPM_AbstractFilters
105
  if(isset($this->update_filters['disable_translation_updates'][$plugin_slug]) and $this->update_filters['disable_translation_updates'][$plugin_slug]){
106
  $result['disable_translation_updates'][$plugin_slug] = true;
107
  }
 
 
 
 
 
108
 
109
  // global rules
110
  if($all_update_disabled){
105
  if(isset($this->update_filters['disable_translation_updates'][$plugin_slug]) and $this->update_filters['disable_translation_updates'][$plugin_slug]){
106
  $result['disable_translation_updates'][$plugin_slug] = true;
107
  }
108
+ if(isset($this->update_filters['disable_display'][$plugin_slug]) and $this->update_filters['disable_display'][$plugin_slug]){
109
+ $result['disable_updates'][$plugin_slug] = true;
110
+ $result['disable_auto_updates'][$plugin_slug] = true;
111
+ $result['disable_translation_updates'][$plugin_slug] = true;
112
+ }
113
 
114
  // global rules
115
  if($all_update_disabled){
components/updates-manager/admin/pages/plugins.php CHANGED
@@ -357,7 +357,9 @@
357
  <table class="wp-list-table widefat autoupdate striped plugins wp-list-table__plugins">
358
  <thead>
359
  <tr>
360
- <th id='cb' class='manage-column column-cb check-column'>&nbsp;</th>
 
 
361
  <th id='name' class='manage-column column-name column-primary'>
362
  <strong><?php _e('Plugin', 'webcraftic-updates-manager'); ?></strong></th>
363
  <th id="disable_updates">
@@ -407,15 +409,13 @@
407
  $is_auto_updates = false;
408
  }
409
  if( (isset($this->plugins_update_filters['disable_updates']) && isset($this->plugins_update_filters['disable_updates'][$actual_slug])) ) {
410
- $class = 'inactive';
411
  $is_disable_updates = true;
412
  }
413
  }
414
 
415
- if( $this->is_disable_updates ) {
416
- $class = 'inactive row-global-disabled';
417
- $is_disable_updates = true;
418
- }
419
 
420
  if( !empty($this->plugins_update_filters) ) {
421
  if( isset($this->plugins_update_filters['disable_translation_updates']) && isset($this->plugins_update_filters['disable_translation_updates'][$actual_slug]) ) {
@@ -426,6 +426,15 @@
426
  if( isset($this->plugins_update_filters['disable_display']) && isset($this->plugins_update_filters['disable_display'][$actual_slug]) ) {
427
  $is_disable_display = true;
428
  }
 
 
 
 
 
 
 
 
 
429
  ?>
430
  <tr id="post-<?= esc_attr($slug_hash) ?>" class="<?= $class ?>">
431
  <td scope="row" class="check-column">
@@ -442,9 +451,12 @@
442
  </td>
443
  <!-- отключить все обновления -->
444
  <td class="column-flags">
445
- <div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group">
446
  <?php
447
  $disabled = $this->is_disable_updates;
 
 
 
448
  $checked = false;
449
  if( $is_disable_updates ) {
450
  $checked = true;
@@ -462,41 +474,35 @@
462
  </td>
463
  <!-- отключить авто-обновления -->
464
  <td class="column-flags">
465
- <div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group <?= 'group-' . $slug_hash; ?> <?= (!$this->is_auto_updates) ? 'global-disabled' : ''; ?>">
466
  <?php
467
  $disabled = false;
468
- if( !$this->is_auto_updates or $is_disable_updates ) {
469
  $disabled = true;
470
  }
471
- $checked = false;
472
- if( !$is_auto_updates ) {
473
- $checked = true;
474
- }
475
 
476
  ?>
477
- <button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ($checked ? 'active' : ''); ?>" <?= ($disabled) ? 'disabled' : ''; ?>><?php _e('On', 'webcraftic-updates-manager'); ?></button>
478
- <button type="button" class="btn btn-default btn-small btn-sm factory-off <?= (!$checked ? 'active' : ''); ?>" data-value="0" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('Off', 'webcraftic-updates-manager'); ?></button>
479
  <input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_auto_updates" class="factory-result factory-ajax-checkbox"
480
- data-action="AutoUpdates" data-plugin-slug="<?= $actual_slug ?>" value="<?= (int)$checked ?>" <?= ($checked ? 'checked' : ''); ?> <?= ($disabled ? 'disabled' : ''); ?>>
481
  </div>
482
  </td>
483
  <!-- отключить обновления переводов -->
484
  <td class="column-flags <?= (!$is_premium) ? "wbcr-upm-column-premium" : ""; ?>">
485
- <div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group <?= 'group-' . $slug_hash; ?> <?= (!$is_premium or $this->is_disable_translation_updates ? 'global-disabled' : ''); ?>">
486
  <?php
487
  $disabled = false;
488
- if( !$is_premium or $is_disable_updates or $this->is_disable_translation_updates ) {
489
  $disabled = true;
490
  }
491
- $checked = false;
492
- if( $is_disable_translation_update ) {
493
- $checked = true;
494
- }
495
  ?>
496
  <button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ($checked) ? 'active' : ''; ?>" <?= ($disabled) ? 'disabled' : ''; ?>><?php _e('On', 'webcraftic-updates-manager'); ?></button>
497
  <button type="button" class="btn btn-default btn-small btn-sm factory-off <?= (!$checked) ? 'active' : ''; ?>" data-value="0" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('Off', 'webcraftic-updates-manager'); ?></button>
498
  <input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_translation_updates" class="factory-result factory-ajax-checkbox"
499
- data-action="TranslationUpdates" data-plugin-slug="<?= $actual_slug ?>" value="<?= (int)$checked ?>" <?= ($checked ? 'checked' : ''); ?> <?= ($disabled ? 'disabled' : ''); ?>>
500
  </div>
501
  </td>
502
  <!-- скрыть плагин -->
@@ -512,7 +518,7 @@
512
  <button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ($checked ? 'active' : ''); ?>" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('On', 'webcraftic-updates-manager'); ?></button>
513
  <button type="button" class="btn btn-default btn-small btn-sm factory-off <?= (!$checked ? 'active' : ''); ?>" data-value="0" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('Off', 'webcraftic-updates-manager'); ?></button>
514
  <input type="checkbox" style="display: none" id="wbcr_updates_manager_hide_item" class="factory-result factory-ajax-checkbox"
515
- data-action="Display" data-plugin-slug="<?= $actual_slug ?>" value="<?= (int)$checked ?>" <?= ($checked ? 'checked' : ''); ?> <?= ($disabled ? 'disabled' : ''); ?>>
516
  </div>
517
  </td>
518
  </tr>
357
  <table class="wp-list-table widefat autoupdate striped plugins wp-list-table__plugins">
358
  <thead>
359
  <tr>
360
+ <th id='cb' class='manage-column column-cb check-column'>
361
+ <input class="wbcr_um_select_all" type="checkbox">
362
+ </th>
363
  <th id='name' class='manage-column column-name column-primary'>
364
  <strong><?php _e('Plugin', 'webcraftic-updates-manager'); ?></strong></th>
365
  <th id="disable_updates">
409
  $is_auto_updates = false;
410
  }
411
  if( (isset($this->plugins_update_filters['disable_updates']) && isset($this->plugins_update_filters['disable_updates'][$actual_slug])) ) {
 
412
  $is_disable_updates = true;
413
  }
414
  }
415
 
416
+ if( $this->is_disable_updates ) {
417
+ $is_disable_updates = true;
418
+ }
 
419
 
420
  if( !empty($this->plugins_update_filters) ) {
421
  if( isset($this->plugins_update_filters['disable_translation_updates']) && isset($this->plugins_update_filters['disable_translation_updates'][$actual_slug]) ) {
426
  if( isset($this->plugins_update_filters['disable_display']) && isset($this->plugins_update_filters['disable_display'][$actual_slug]) ) {
427
  $is_disable_display = true;
428
  }
429
+ if($is_disable_display or $is_disable_updates){
430
+ $class = 'inactive';
431
+ }
432
+
433
+ if( $this->is_disable_updates ) {
434
+ $class = 'inactive row-global-disabled';
435
+ }
436
+
437
+
438
  ?>
439
  <tr id="post-<?= esc_attr($slug_hash) ?>" class="<?= $class ?>">
440
  <td scope="row" class="check-column">
451
  </td>
452
  <!-- отключить все обновления -->
453
  <td class="column-flags">
454
+ <div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group <?= 'group-all-' . $slug_hash; ?>">
455
  <?php
456
  $disabled = $this->is_disable_updates;
457
+ if($is_disable_display){
458
+ $disabled = true;
459
+ }
460
  $checked = false;
461
  if( $is_disable_updates ) {
462
  $checked = true;
474
  </td>
475
  <!-- отключить авто-обновления -->
476
  <td class="column-flags">
477
+ <div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group <?= 'group-' . $slug_hash; ?> <?= 'group-all-' . $slug_hash; ?> <?= (!$this->is_auto_updates) ? 'global-disabled' : ''; ?> ">
478
  <?php
479
  $disabled = false;
480
+ if( !$this->is_auto_updates or $is_disable_updates or $is_disable_display) {
481
  $disabled = true;
482
  }
483
+ $checked = $is_auto_updates;
 
 
 
484
 
485
  ?>
486
+ <button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ($checked ? 'active' : ''); ?>" <?= ($disabled) ? 'disabled' : ''; ?>><?php _e('On', 'webcraftic-updates-manager'); ?></button>
487
+ <button type="button" class="btn btn-default btn-small btn-sm factory-off <?= (!$checked ? 'active' : ''); ?>" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('Off', 'webcraftic-updates-manager'); ?></button>
488
  <input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_auto_updates" class="factory-result factory-ajax-checkbox"
489
+ data-action="AutoUpdates" data-inverse="1" data-plugin-slug="<?= $actual_slug ?>" value="<?= (int)$checked ?>" <?= ($checked ? 'checked' : ''); ?> <?= ($disabled ? 'disabled' : ''); ?>>
490
  </div>
491
  </td>
492
  <!-- отключить обновления переводов -->
493
  <td class="column-flags <?= (!$is_premium) ? "wbcr-upm-column-premium" : ""; ?>">
494
+ <div class="factory-checkbox factory-from-control-checkbox factory-buttons-way btn-group <?= 'group-' . $slug_hash; ?> <?= 'group-all-' . $slug_hash; ?> <?= (!$is_premium or $this->is_disable_translation_updates ? 'global-disabled' : ''); ?>">
495
  <?php
496
  $disabled = false;
497
+ if( !$is_premium or $is_disable_updates or $this->is_disable_translation_updates or $is_disable_display) {
498
  $disabled = true;
499
  }
500
+ $checked = !$is_disable_translation_update;
 
 
 
501
  ?>
502
  <button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ($checked) ? 'active' : ''; ?>" <?= ($disabled) ? 'disabled' : ''; ?>><?php _e('On', 'webcraftic-updates-manager'); ?></button>
503
  <button type="button" class="btn btn-default btn-small btn-sm factory-off <?= (!$checked) ? 'active' : ''; ?>" data-value="0" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('Off', 'webcraftic-updates-manager'); ?></button>
504
  <input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_translation_updates" class="factory-result factory-ajax-checkbox"
505
+ data-action="TranslationUpdates" data-inverse="1" data-plugin-slug="<?= $actual_slug ?>" value="<?= (int)$checked ?>" <?= ($checked ? 'checked' : ''); ?> <?= ($disabled ? 'disabled' : ''); ?>>
506
  </div>
507
  </td>
508
  <!-- скрыть плагин -->
518
  <button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ($checked ? 'active' : ''); ?>" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('On', 'webcraftic-updates-manager'); ?></button>
519
  <button type="button" class="btn btn-default btn-small btn-sm factory-off <?= (!$checked ? 'active' : ''); ?>" data-value="0" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('Off', 'webcraftic-updates-manager'); ?></button>
520
  <input type="checkbox" style="display: none" id="wbcr_updates_manager_hide_item" class="factory-result factory-ajax-checkbox"
521
+ data-disable-group="<?= 'group-all-' . $slug_hash; ?>" data-action="Display" data-plugin-slug="<?= $actual_slug ?>" value="<?= (int)$checked ?>" <?= ($checked ? 'checked' : ''); ?> <?= ($disabled ? 'disabled' : ''); ?>>
522
  </div>
523
  </td>
524
  </tr>
components/updates-manager/admin/pages/themes.php CHANGED
@@ -331,7 +331,9 @@
331
  <table class="wp-list-table wbcr-upm-list-table-pro widefat autoupdate striped plugins <?= (!$is_premium ? "wbcr-upm-column-premium" : ""); ?>">
332
  <thead>
333
  <tr>
334
- <th id='cb' class='manage-column column-cb check-column'>&nbsp;</th>
 
 
335
  <th id='name' class='manage-column column-name column-primary'>
336
  <strong><?php _e('Theme', 'webcraftic-updates-manager'); ?></strong></th>
337
  <th id="disable_updates">
@@ -392,7 +394,7 @@
392
  <tr id="post-<?= esc_attr($slug_hash) ?>" class="<?= $class ?>">
393
  <td scope="row" class="check-column">
394
  <label class="screen-reader-text" for="cb-select-<?= esc_attr($slug_hash) ?>"><?php _e('Select', 'webcraftic-updates-manager') ?><?= esc_html($name) ?></label>
395
- <input id="cb-select-<?= esc_attr($slug_hash) ?>" type="checkbox" name="theme_slugs[]" value="<?= esc_attr($actual_slug) ?>" <?= (!$is_premium ? 'disabled' : ''); ?>>
396
  <label></label>
397
 
398
  <div class="locked-indicator"></div>
@@ -430,14 +432,14 @@
430
  $disabled = true;
431
  }
432
  $checked = false;
433
- if( !$is_auto_updates ) {
434
  $checked = true;
435
  }
436
  ?>
437
  <button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ($checked ? 'active' : ''); ?>" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('On', 'webcraftic-updates-manager'); ?></button>
438
  <button type="button" class="btn btn-default btn-small btn-sm factory-off <?= (!$checked) ? 'active' : ''; ?>" data-value="0" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('Off', 'webcraftic-updates-manager'); ?></button>
439
  <input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_auto_updates" class="factory-result factory-ajax-checkbox"
440
- data-action="AutoUpdates" data-theme-slug="<?= $actual_slug ?>" value="<?= (int)$checked ?>" <?= ($checked ? 'checked' : ''); ?> <?= ($disabled ? 'disabled' : ''); ?>>
441
  </div>
442
  </td>
443
  <!-- отключить обновления переводов -->
@@ -449,14 +451,14 @@
449
  $disabled = true;
450
  }
451
  $checked = false;
452
- if( $is_disable_translation_update ) {
453
  $checked = true;
454
  }
455
  ?>
456
  <button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ($checked ? 'active' : ''); ?>" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('On', 'webcraftic-updates-manager'); ?></button>
457
  <button type="button" class="btn btn-default btn-small btn-sm factory-off <?= (!$checked) ? 'active' : ''; ?>" data-value="0" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('Off', 'webcraftic-updates-manager'); ?></button>
458
  <input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_translation_updates" class="factory-result factory-ajax-checkbox"
459
- data-action="TranslationUpdates" data-theme-slug="<?= $actual_slug ?>" value="<?= (int)$checked ?>" <?= ($checked ? 'checked' : ''); ?> <?= ($disabled ? 'disabled' : ''); ?>>
460
  </div>
461
  </td>
462
  </tr>
331
  <table class="wp-list-table wbcr-upm-list-table-pro widefat autoupdate striped plugins <?= (!$is_premium ? "wbcr-upm-column-premium" : ""); ?>">
332
  <thead>
333
  <tr>
334
+ <th id='cb' class='manage-column column-cb check-column'>
335
+ <input class="wbcr_um_select_all" type="checkbox">
336
+ </th>
337
  <th id='name' class='manage-column column-name column-primary'>
338
  <strong><?php _e('Theme', 'webcraftic-updates-manager'); ?></strong></th>
339
  <th id="disable_updates">
394
  <tr id="post-<?= esc_attr($slug_hash) ?>" class="<?= $class ?>">
395
  <td scope="row" class="check-column">
396
  <label class="screen-reader-text" for="cb-select-<?= esc_attr($slug_hash) ?>"><?php _e('Select', 'webcraftic-updates-manager') ?><?= esc_html($name) ?></label>
397
+ <input id="cb-select-<?= esc_attr($slug_hash) ?>" class="wbcr_um_select_item" type="checkbox" name="theme_slugs[]" value="<?= esc_attr($actual_slug) ?>" <?= (!$is_premium ? 'disabled' : ''); ?>>
398
  <label></label>
399
 
400
  <div class="locked-indicator"></div>
432
  $disabled = true;
433
  }
434
  $checked = false;
435
+ if( $is_auto_updates ) {
436
  $checked = true;
437
  }
438
  ?>
439
  <button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ($checked ? 'active' : ''); ?>" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('On', 'webcraftic-updates-manager'); ?></button>
440
  <button type="button" class="btn btn-default btn-small btn-sm factory-off <?= (!$checked) ? 'active' : ''; ?>" data-value="0" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('Off', 'webcraftic-updates-manager'); ?></button>
441
  <input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_auto_updates" class="factory-result factory-ajax-checkbox"
442
+ data-action="AutoUpdates" data-inverse="1" data-theme-slug="<?= $actual_slug ?>" value="<?= (int)$checked ?>" <?= ($checked ? 'checked' : ''); ?> <?= ($disabled ? 'disabled' : ''); ?>>
443
  </div>
444
  </td>
445
  <!-- отключить обновления переводов -->
451
  $disabled = true;
452
  }
453
  $checked = false;
454
+ if( !$is_disable_translation_update ) {
455
  $checked = true;
456
  }
457
  ?>
458
  <button type="button" class="btn btn-default btn-small btn-sm factory-on <?= ($checked ? 'active' : ''); ?>" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('On', 'webcraftic-updates-manager'); ?></button>
459
  <button type="button" class="btn btn-default btn-small btn-sm factory-off <?= (!$checked) ? 'active' : ''; ?>" data-value="0" <?= ($disabled ? 'disabled' : ''); ?>><?php _e('Off', 'webcraftic-updates-manager'); ?></button>
460
  <input type="checkbox" style="display: none" id="wbcr_updates_manager_disable_translation_updates" class="factory-result factory-ajax-checkbox"
461
+ data-action="TranslationUpdates" data-inverse="1" data-theme-slug="<?= $actual_slug ?>" value="<?= (int)$checked ?>" <?= ($checked ? 'checked' : ''); ?> <?= ($disabled ? 'disabled' : ''); ?>>
462
  </div>
463
  </td>
464
  </tr>
components/updates-manager/includes/classes/class.configurate-updates.php CHANGED
@@ -25,10 +25,13 @@
25
 
26
  switch( $this->getPopulateOption('plugin_updates') ) {
27
  case 'disable_plugin_updates':
28
- add_filter('http_request_args', array($this, 'httpRequestArgsRemovePlugins'), 5, 2);
29
- add_filter('site_transient_update_plugins', array($this, 'disablePluginNotifications'), 50);
 
 
30
  break;
31
  case 'enable_plugin_auto_updates':
 
32
  add_filter('auto_update_plugin', array($this, 'pluginsAutoUpdate'), 50, 2);
33
  break;
34
  }
@@ -193,7 +196,7 @@
193
  */
194
  public function httpRequestArgsRemovePlugins($r, $url)
195
  {
196
- if( 0 !== strpos($url, 'https://api.wordpress.org/plugins/update-check/1.1/') ) {
197
  return $r;
198
  }
199
 
25
 
26
  switch( $this->getPopulateOption('plugin_updates') ) {
27
  case 'disable_plugin_updates':
28
+ // and disable version check
29
+ add_filter('site_transient_update_plugins', array($this, 'lastCheckedNow'), 50);
30
+ add_action('admin_init', array($this, 'adminInitForPlugins'));
31
+ add_filter('auto_update_plugin', '__return_false');
32
  break;
33
  case 'enable_plugin_auto_updates':
34
+ // exclude some plugins in update list
35
  add_filter('auto_update_plugin', array($this, 'pluginsAutoUpdate'), 50, 2);
36
  break;
37
  }
196
  */
197
  public function httpRequestArgsRemovePlugins($r, $url)
198
  {
199
+ if( !is_string($url) || 0 !== strpos($url, 'https://api.wordpress.org/plugins/update-check/1.1/') ) {
200
  return $r;
201
  }
202
 
components/updates-manager/languages/webcraftic-updates-manager-ru_RU.po CHANGED
@@ -1,501 +1,501 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: clearfy\n"
4
- "POT-Creation-Date: 2018-10-16 23:25+0300\n"
5
- "PO-Revision-Date: 2018-10-16 23:26+0300\n"
6
- "Last-Translator: alex.kovalevv@gmail.com <alex.kovalevv@gmail.com>\n"
7
- "Language-Team: Alex Kovalev <alex.kovalevv@gmail.com>\n"
8
- "Language: ru_RU\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 2.1.1\n"
13
- "X-Poedit-Basepath: ..\n"
14
- "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
15
- "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
16
- "X-Poedit-SourceCharset: UTF-8\n"
17
- "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c\n"
18
- "X-Poedit-SearchPath-0: .\n"
19
- "X-Poedit-SearchPathExcluded-0: libs\n"
20
-
21
- #: admin/ajax/change-flag.php:26
22
- msgid "Required arguments of slug, flag is empty!"
23
- msgstr "Не переданы обязательные аругменты slug, flag"
24
-
25
- #: admin/ajax/change-flag.php:38
26
- #, php-format
27
- msgid "Method %s is not found!"
28
- msgstr "Метод %s не найден!"
29
-
30
- #: admin/boot.php:23
31
- #, php-format
32
- msgid ""
33
- "We found that you have the plugin %s installed. The functions of this plugin "
34
- "already exist in %s. Please deactivate plugin %s to avoid conflicts between "
35
- "plugins' functions."
36
- msgstr ""
37
- "Мы обнаружили, что у вас установлен плагин %s, функции этого плагина уже "
38
- "есть в %s. Пожалуйста, деактивируйте плагин %s во избежание конфликтов между "
39
- "функциями плагинов."
40
-
41
- #: admin/boot.php:24
42
- #, php-format
43
- msgid ""
44
- "If you do not want to deactivate the plugin %s for some reason, we strongly "
45
- "recommend do not use the same plugins' functions at the same time!"
46
- msgstr ""
47
- "Если по какой-то причине вы не хотите деактивировать плагин %s, то мы "
48
- "настоятельно рекомендуем не использовать похожие функции плагинов "
49
- "одновременно!"
50
-
51
- #: admin/boot.php:68
52
- msgid "Disable plugin updates"
53
- msgstr "Отключить обновления плагинов"
54
-
55
- #: admin/boot.php:74
56
- msgid "Disable theme updates"
57
- msgstr "Отключить обновления тем"
58
-
59
- #: admin/boot.php:80 admin/pages/updates.php:128
60
- msgid "Disable Automatic Translation Updates"
61
- msgstr "Отключить автоматические обновления переводов"
62
-
63
- #: admin/boot.php:85
64
- msgid "Disable wordPress core updates"
65
- msgstr "Отключить обновления ядра Wordpress"
66
-
67
- #: admin/boot.php:91 admin/pages/updates.php:180
68
- msgid "Enable updates for VCS Installations"
69
- msgstr "Включить обновления для установок VCS"
70
-
71
- #: admin/boot.php:96
72
- msgid "Plugin filters"
73
- msgstr "Фильтры плагинов"
74
-
75
- #: admin/boot.php:101 admin/pages/updates.php:190
76
- msgid "Updates nags only for Admin"
77
- msgstr "Показывать уведомления об обновлении Wordpress только для админа"
78
-
79
- #: admin/boot.php:106 admin/pages/updates.php:238 admin/pages/updates.php:245
80
- msgid "Core notifications"
81
- msgstr "Оповещения ядра WP"
82
-
83
- #: admin/boot.php:111
84
- msgid "Notify me when update successful installed"
85
- msgstr "Уведомлять когда обновления установлены"
86
-
87
- #: admin/boot.php:116 admin/pages/updates.php:229
88
- msgid "Email address"
89
- msgstr "Е-мейл"
90
-
91
- #: admin/boot.php:128
92
- msgid "One click disable all updates"
93
- msgstr "Отключить все обновления в один клик"
94
-
95
- #: admin/boot.php:149
96
- msgid "Get ultimate plugin free"
97
- msgstr "Получите полную версию плагина бесплатно"
98
-
99
- #: admin/boot.php:200 admin/boot.php:247
100
- msgid "Update manager"
101
- msgstr "Менеджер обновлений"
102
-
103
- #: admin/boot.php:208
104
- msgid "Auto-update disabled"
105
- msgstr "Автообновление выключено"
106
-
107
- #: admin/boot.php:209
108
- msgid "Auto-update enabled"
109
- msgstr "Автообновление включено"
110
-
111
- #: admin/boot.php:210
112
- msgid "Update disabled"
113
- msgstr "Обновление отключено"
114
-
115
- #: admin/boot.php:211
116
- msgid "Translation update disabled"
117
- msgstr "Обновление переводов отключено"
118
-
119
- #: admin/pages/advanced.php:43
120
- msgid "Advanced"
121
- msgstr "Дополнительно"
122
-
123
- #: admin/pages/advanced.php:71
124
- msgid "Please, wait 90 sec. to see the forced automatic update result."
125
- msgstr ""
126
- "Пожалуйста, подождите 90 сек., чтобы увидеть результат принудительного "
127
- "автоматического обновления."
128
-
129
- #: admin/pages/advanced.php:81
130
- msgid "Force Automatic Updates"
131
- msgstr "Принудительное автоматическое обновление"
132
-
133
- #: admin/pages/advanced.php:83
134
- msgid ""
135
- "This will attempt to force automatic updates. This is useful for debugging."
136
- msgstr ""
137
- "Эта возможность вам понадобится для проверки автоматических обновлений. "
138
- "Настройте автоматические обновления и нажмите на эту кнопку, чтобы проверить "
139
- "работают они или нет."
140
-
141
- #: admin/pages/advanced.php:84
142
- msgid "Force update"
143
- msgstr "Запустить обновление"
144
-
145
- #: admin/pages/plugins.php:72
146
- msgid "Plugins"
147
- msgstr "Плагины"
148
-
149
- #: admin/pages/plugins.php:91
150
- msgid ""
151
- "- To disable updates individually choose the “Manual or automatic plugin "
152
- "updates” option then save settings and comeback to this page."
153
- msgstr ""
154
- "Чтобы индивидуально отключить обновления, выберите опцию “Ручные или "
155
- "автоматические обновления плагинов”, сохраните настройки и вернитесь на эту "
156
- "страницу."
157
-
158
- #: admin/pages/plugins.php:95
159
- msgid ""
160
- "- To configure plugin auto updates individually, choose the “Enable auto "
161
- "updates” option then save settings and comeback to this page."
162
- msgstr ""
163
- "Чтобы индивидуально настроить автоматические обновления плагинов, выберите "
164
- "опцию “Автоматические обновления”, сохраните настройки и вернитесь на эту "
165
- "страницу."
166
-
167
- #: admin/pages/plugins.php:326
168
- msgid "Plugins list"
169
- msgstr "Ваш список плагинов"
170
-
171
- #: admin/pages/plugins.php:329
172
- msgid "This page you can individually disable plugin updates and auto updates."
173
- msgstr ""
174
- "На этой странице вы можете индивидуально отключить обновления и "
175
- "автообновления плагинов."
176
-
177
- #: admin/pages/plugins.php:345 admin/pages/themes.php:321
178
- msgid "Bulk actions"
179
- msgstr "Массовые действия"
180
-
181
- #: admin/pages/plugins.php:346 admin/pages/themes.php:322
182
- #: admin/pages/updates.php:102 admin/pages/updates.php:117
183
- #: admin/pages/updates.php:139
184
- msgid "Disable updates"
185
- msgstr "Отключить все обновления"
186
-
187
- #: admin/pages/plugins.php:347 admin/pages/themes.php:323
188
- msgid "Enable updates"
189
- msgstr "Включить обновления"
190
-
191
- #: admin/pages/plugins.php:348 admin/pages/themes.php:324
192
- msgid "Enable auto-updates"
193
- msgstr "Включить авто-обновления"
194
-
195
- #: admin/pages/plugins.php:349 admin/pages/themes.php:325
196
- msgid "Disable auto-updates"
197
- msgstr "Отключить авто-обновления"
198
-
199
- #: admin/pages/plugins.php:350 admin/pages/themes.php:326
200
- msgid "Disable translation updates"
201
- msgstr "Отключить обновление переводов"
202
-
203
- #: admin/pages/plugins.php:351 admin/pages/themes.php:327
204
- msgid "Enable translation updates"
205
- msgstr "Включить обновление переводов"
206
-
207
- #: admin/pages/plugins.php:352 admin/pages/plugins.php:373
208
- msgid "Hide plugin"
209
- msgstr "Скрыть плагин"
210
-
211
- #: admin/pages/plugins.php:353
212
- msgid "Show plugin"
213
- msgstr "Показывать плагин"
214
-
215
- #: admin/pages/plugins.php:355 admin/pages/themes.php:329
216
- msgid "Apply"
217
- msgstr "Применить"
218
-
219
- #: admin/pages/plugins.php:362
220
- msgid "Plugin"
221
- msgstr "Плагин"
222
-
223
- #: admin/pages/plugins.php:364 admin/pages/themes.php:338
224
- #: admin/pages/updates.php:57
225
- msgid "Updates"
226
- msgstr "Обновления"
227
-
228
- #: admin/pages/plugins.php:367 admin/pages/themes.php:341
229
- msgid "Auto-updates"
230
- msgstr "Авто-обновление"
231
-
232
- #: admin/pages/plugins.php:370 admin/pages/themes.php:344
233
- msgid "Translation updates"
234
- msgstr "Обновление переводов"
235
-
236
- #: admin/pages/plugins.php:432 admin/pages/themes.php:394
237
- msgid "Select"
238
- msgstr "Выбор"
239
-
240
- #: admin/pages/plugins.php:453 admin/pages/plugins.php:472
241
- #: admin/pages/plugins.php:491 admin/pages/plugins.php:507
242
- #: admin/pages/themes.php:418 admin/pages/themes.php:437
243
- #: admin/pages/themes.php:456
244
- msgid "On"
245
- msgstr "Вкл"
246
-
247
- #: admin/pages/plugins.php:454 admin/pages/plugins.php:473
248
- #: admin/pages/plugins.php:492 admin/pages/plugins.php:508
249
- #: admin/pages/themes.php:419 admin/pages/themes.php:438
250
- #: admin/pages/themes.php:457
251
- msgid "Off"
252
- msgstr "Выкл"
253
-
254
- #: admin/pages/themes.php:69
255
- msgid "Themes"
256
- msgstr "Темы"
257
-
258
- #: admin/pages/themes.php:88
259
- msgid ""
260
- "- To disable updates individually choose the “Manual or automatic theme "
261
- "updates” option then save settings and comeback to this page."
262
- msgstr ""
263
- "Чтобы индивидуально отключить обновления, выберите опцию “Ручные или "
264
- "автоматические обновления плагинов”, сохраните настройки и вернитесь на эту "
265
- "страницу."
266
-
267
- #: admin/pages/themes.php:92
268
- msgid ""
269
- "- To configure theme auto updates individually, choose the “Enable auto "
270
- "updates” option then save settings and comeback to this page."
271
- msgstr ""
272
- "Чтобы индивидуально настроить автоматические обновления тем, выберите опцию "
273
- "“Автоматические обновления”, сохраните настройки и вернитесь на эту страницу."
274
-
275
- #: admin/pages/themes.php:302
276
- msgid "Themes list"
277
- msgstr "Ваш список тем"
278
-
279
- #: admin/pages/themes.php:305
280
- msgid "This page you can individually disable theme updates and auto updates."
281
- msgstr ""
282
- "На этой странице вы можете индивидуально отключить обновления и "
283
- "автообновления тем."
284
-
285
- #: admin/pages/themes.php:336
286
- msgid "Theme"
287
- msgstr "Тема"
288
-
289
- #: admin/pages/updates.php:43
290
- msgid "Updates manager"
291
- msgstr "Менеджер обновлений"
292
-
293
- #: admin/pages/updates.php:44
294
- msgid "Manage all site updates"
295
- msgstr "Упр. обновлениями сайта"
296
-
297
- #: admin/pages/updates.php:57
298
- msgid "General"
299
- msgstr "Основные"
300
-
301
- #: admin/pages/updates.php:91
302
- msgid "General settings for WordPress, plugins and themes updates"
303
- msgstr "Общие настройки для обновлений WordPress, плагинов и тем"
304
-
305
- #: admin/pages/updates.php:91
306
- msgid ""
307
- "This page, you can enable or disable automatic updates. To test the "
308
- "automatic updates, click the \"Advanced\" tab."
309
- msgstr ""
310
- "На этой странице можете включить или отключить автоматические обновления. "
311
- "Чтобы протестировать работу автоматических обновлений, перейдите на вкладку "
312
- "\"Дополнительно\"."
313
-
314
- #: admin/pages/updates.php:98
315
- msgid "Plugin Updates"
316
- msgstr "Обновления плагина"
317
-
318
- #: admin/pages/updates.php:100 admin/pages/updates.php:115
319
- msgid "Manual updates"
320
- msgstr "Ручные"
321
-
322
- #: admin/pages/updates.php:101 admin/pages/updates.php:116
323
- msgid "Enable auto updates"
324
- msgstr "Автоматические"
325
-
326
- #: admin/pages/updates.php:105
327
- msgid ""
328
- "You can disable all plugin updates or choose manual or automatic update mode."
329
- msgstr ""
330
- "Вы можете отключить все обновления плагинов или выбрать режим ручного или "
331
- "автоматического обновления."
332
-
333
- #: admin/pages/updates.php:113
334
- msgid "Theme Updates"
335
- msgstr "Обновления тем"
336
-
337
- #: admin/pages/updates.php:120
338
- msgid ""
339
- "You can disable all themes updates or choose manual or automatic update mode."
340
- msgstr ""
341
- "Вы можете отключить все обновления тем или выбрать режим ручного или "
342
- "автоматического обновления."
343
-
344
- #: admin/pages/updates.php:137
345
- msgid "WordPress Core Updates"
346
- msgstr "Базовые обновления Wordpress"
347
-
348
- #: admin/pages/updates.php:140
349
- msgid "Disable auto updates"
350
- msgstr "Отключить автоматические обновления"
351
-
352
- #: admin/pages/updates.php:143
353
- msgid "Allow minor auto updates"
354
- msgstr "Разрешить незначительные автоматические обновления"
355
-
356
- #: admin/pages/updates.php:147
357
- msgid "Allow major auto updates"
358
- msgstr "Разрешить основные автоматические обновления"
359
-
360
- #: admin/pages/updates.php:151
361
- msgid "Allow development auto updates"
362
- msgstr "Разрешить разрабатываемые автоматические обновления"
363
-
364
- #: admin/pages/updates.php:155
365
- msgid ""
366
- "You can disable all core WordPress updates, or disable only automatic "
367
- "updates. Also you can select the update mode. By default (minor)"
368
- msgstr ""
369
- "Вы можете отключить все основные обновления WordPress или отключить только "
370
- "автоматические обновления. Также вы можете выбрать режим обновления. По "
371
- "умолчанию (младший)"
372
-
373
- #: admin/pages/updates.php:155
374
- msgid "Major - automatically update to major releases (e.g., 4.1, 4.2, 4.3)."
375
- msgstr ""
376
- "Основные - автоматически обновления основных версий (4.1, 4.2, 4.3 и т.д)."
377
-
378
- #: admin/pages/updates.php:155
379
- msgid ""
380
- "Minor - automatically update to minor releases (e.g., 4.1.1, 4.1.2, 4.1.3).."
381
- msgstr ""
382
- "Незначительные - автоматически обновления промежуточных версий (4.1.1, "
383
- "4.1.2, 4.1.3 и т.д)."
384
-
385
- #: admin/pages/updates.php:155
386
- msgid "Development - update automatically to Bleeding Edge releases."
387
- msgstr "Разрабатываемые - автоматические обновления до финальных выпусков."
388
-
389
- #: admin/pages/updates.php:182
390
- msgid ""
391
- "Enable Automatic Updates even if a VCS folder (.git, .hg, .svn) was found in "
392
- "the WordPress directory"
393
- msgstr ""
394
- "Включить автоматическое обновление, даже если папка VCS (.git, .hg, .svn) "
395
- "была найдена в каталоге WordPress"
396
-
397
- #: admin/pages/updates.php:192
398
- msgid ""
399
- "This plugin allows you to hide the update WordPress reminder from all users "
400
- "that are not assumed Administrators (cannot upgrade plugins).\n"
401
- "\n"
402
- "If you have multiple users then this means those who are not admins don’t "
403
- "need to see the message. Useful for CMS based sites, so the client doesn’t "
404
- "see the notice."
405
- msgstr ""
406
- "Этот опция позволяет вам скрыть напоминание о обновлении WordPress для всех "
407
- "пользователей, которые не являются администраторами (не могут обновлять "
408
- "плагины).\n"
409
- "\n"
410
- "Если у вас несколько пользователей, это означает, что те, кто не являются "
411
- "админами, не должны видеть уведомления об обновлениях."
412
-
413
- #: admin/pages/updates.php:200
414
- msgid "Email Notifications"
415
- msgstr "Оповещения ядра WP"
416
-
417
- #: admin/pages/updates.php:200
418
- msgid ""
419
- "Email notifications are send once a day, you can choose what notifications "
420
- "to send below."
421
- msgstr ""
422
- "Оповещения отправляются раз в день, ниже Вы можете выбрать какие сообщения "
423
- "получать."
424
-
425
- #: admin/pages/updates.php:207
426
- msgid "Update available"
427
- msgstr "Доступно обновления"
428
-
429
- #: admin/pages/updates.php:208
430
- msgid "Send me emails when an update is available."
431
- msgstr "Уведомлять когда обновления доступны."
432
-
433
- #: admin/pages/updates.php:218
434
- msgid "Successful update"
435
- msgstr "При успешном обновлении"
436
-
437
- #: admin/pages/updates.php:219
438
- msgid "Send me emails when something has been updated."
439
- msgstr "Присылать оповещение когда обновления установлены."
440
-
441
- #: admin/pages/updates.php:230
442
- msgid "Seperate email addresses using commas."
443
- msgstr "Адреса электронной почты через запятую."
444
-
445
- #: admin/pages/updates.php:238
446
- msgid ""
447
- "Core notifications are handled by WordPress and not by this plugin. You can "
448
- "only disable them, changing your email address in the settings above will "
449
- "not affect these notifications."
450
- msgstr ""
451
- "Почтовые сообщения отправляются ядром Вордпресс, а не этим плагином. Вы "
452
- "можете только отключить их, изменение вашего почтового адреса в настройках "
453
- "выше не влияет на эти оповещения."
454
-
455
- #: admin/pages/updates.php:246
456
- msgid ""
457
- "By default wordpress sends an email when a core update happend. Uncheck this "
458
- "box to disable these emails."
459
- msgstr ""
460
- "По умолчанию сайт присылает сообщение когда ядро Вордпресс обновилось. "
461
- "Снимите галочку если не хотите получать его."
462
-
463
- #: webcraftic-updates-manager.php:58
464
- msgid "Webcraftic Updates Manager"
465
- msgstr "Webcraftic менеджер обновлений"
466
-
467
- #~ msgid "If off email notifications disabled for wp core updates"
468
- #~ msgstr "Если Выкл оповещения на почту об обновлении ядра не будут приходить"
469
-
470
- #~ msgid "theme"
471
- #~ msgstr "тема"
472
-
473
- #~ msgid "themes"
474
- #~ msgstr "темы"
475
-
476
- #~ msgid "Plugin update available."
477
- #~ msgstr "Доступны обновления плагина."
478
-
479
- #~ msgid "plugin"
480
- #~ msgstr "плагин"
481
-
482
- #~ msgid "plugins"
483
- #~ msgstr "плагины"
484
-
485
- #~ msgid "Plugins have been updated."
486
- #~ msgstr "Плагины были обновлены."
487
-
488
- #~ msgid "Themes have been updated."
489
- #~ msgstr "Темы были обновлены."
490
-
491
- #~ msgid ""
492
- #~ "We found that you have the \"Clearfy - disable unused features\" plugin "
493
- #~ "installed, this plugin already has update manager functions, so you can "
494
- #~ "deactivate plugin \"Update manager\"!"
495
- #~ msgstr ""
496
- #~ "Мы обнаружили, что у вас установлен плагин «Clearfy - отключить "
497
- #~ "неиспользуемые функции», этот плагин уже имеет функции менеджера "
498
- #~ "обновлений, поэтому вы можете отключить плагин «Менеджер обновлений»!"
499
-
500
- #~ msgid "Description"
501
- #~ msgstr "Описание"
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: clearfy\n"
4
+ "POT-Creation-Date: 2018-10-16 23:25+0300\n"
5
+ "PO-Revision-Date: 2018-10-16 23:26+0300\n"
6
+ "Last-Translator: alex.kovalevv@gmail.com <alex.kovalevv@gmail.com>\n"
7
+ "Language-Team: Alex Kovalev <alex.kovalevv@gmail.com>\n"
8
+ "Language: ru_RU\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 2.1.1\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
15
+ "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c\n"
18
+ "X-Poedit-SearchPath-0: .\n"
19
+ "X-Poedit-SearchPathExcluded-0: libs\n"
20
+
21
+ #: admin/ajax/change-flag.php:26
22
+ msgid "Required arguments of slug, flag is empty!"
23
+ msgstr "Не переданы обязательные аругменты slug, flag"
24
+
25
+ #: admin/ajax/change-flag.php:38
26
+ #, php-format
27
+ msgid "Method %s is not found!"
28
+ msgstr "Метод %s не найден!"
29
+
30
+ #: admin/boot.php:23
31
+ #, php-format
32
+ msgid ""
33
+ "We found that you have the plugin %s installed. The functions of this plugin "
34
+ "already exist in %s. Please deactivate plugin %s to avoid conflicts between "
35
+ "plugins' functions."
36
+ msgstr ""
37
+ "Мы обнаружили, что у вас установлен плагин %s, функции этого плагина уже "
38
+ "есть в %s. Пожалуйста, деактивируйте плагин %s во избежание конфликтов между "
39
+ "функциями плагинов."
40
+
41
+ #: admin/boot.php:24
42
+ #, php-format
43
+ msgid ""
44
+ "If you do not want to deactivate the plugin %s for some reason, we strongly "
45
+ "recommend do not use the same plugins' functions at the same time!"
46
+ msgstr ""
47
+ "Если по какой-то причине вы не хотите деактивировать плагин %s, то мы "
48
+ "настоятельно рекомендуем не использовать похожие функции плагинов "
49
+ "одновременно!"
50
+
51
+ #: admin/boot.php:68
52
+ msgid "Disable plugin updates"
53
+ msgstr "Отключить обновления плагинов"
54
+
55
+ #: admin/boot.php:74
56
+ msgid "Disable theme updates"
57
+ msgstr "Отключить обновления тем"
58
+
59
+ #: admin/boot.php:80 admin/pages/updates.php:128
60
+ msgid "Disable Automatic Translation Updates"
61
+ msgstr "Отключить автоматические обновления переводов"
62
+
63
+ #: admin/boot.php:85
64
+ msgid "Disable wordPress core updates"
65
+ msgstr "Отключить обновления ядра Wordpress"
66
+
67
+ #: admin/boot.php:91 admin/pages/updates.php:180
68
+ msgid "Enable updates for VCS Installations"
69
+ msgstr "Включить обновления для установок VCS"
70
+
71
+ #: admin/boot.php:96
72
+ msgid "Plugin filters"
73
+ msgstr "Фильтры плагинов"
74
+
75
+ #: admin/boot.php:101 admin/pages/updates.php:190
76
+ msgid "Updates nags only for Admin"
77
+ msgstr "Показывать уведомления об обновлении Wordpress только для админа"
78
+
79
+ #: admin/boot.php:106 admin/pages/updates.php:238 admin/pages/updates.php:245
80
+ msgid "Core notifications"
81
+ msgstr "Оповещения ядра WP"
82
+
83
+ #: admin/boot.php:111
84
+ msgid "Notify me when update successful installed"
85
+ msgstr "Уведомлять когда обновления установлены"
86
+
87
+ #: admin/boot.php:116 admin/pages/updates.php:229
88
+ msgid "Email address"
89
+ msgstr "Е-мейл"
90
+
91
+ #: admin/boot.php:128
92
+ msgid "One click disable all updates"
93
+ msgstr "Отключить все обновления в один клик"
94
+
95
+ #: admin/boot.php:149
96
+ msgid "Get ultimate plugin free"
97
+ msgstr "Получите полную версию плагина бесплатно"
98
+
99
+ #: admin/boot.php:200 admin/boot.php:247
100
+ msgid "Update manager"
101
+ msgstr "Менеджер обновлений"
102
+
103
+ #: admin/boot.php:208
104
+ msgid "Auto-update disabled"
105
+ msgstr "Автообновление выключено"
106
+
107
+ #: admin/boot.php:209
108
+ msgid "Auto-update enabled"
109
+ msgstr "Автообновление включено"
110
+
111
+ #: admin/boot.php:210
112
+ msgid "Update disabled"
113
+ msgstr "Обновление отключено"
114
+
115
+ #: admin/boot.php:211
116
+ msgid "Translation update disabled"
117
+ msgstr "Обновление переводов отключено"
118
+
119
+ #: admin/pages/advanced.php:43
120
+ msgid "Advanced"
121
+ msgstr "Дополнительно"
122
+
123
+ #: admin/pages/advanced.php:71
124
+ msgid "Please, wait 90 sec. to see the forced automatic update result."
125
+ msgstr ""
126
+ "Пожалуйста, подождите 90 сек., чтобы увидеть результат принудительного "
127
+ "автоматического обновления."
128
+
129
+ #: admin/pages/advanced.php:81
130
+ msgid "Force Automatic Updates"
131
+ msgstr "Принудительное автоматическое обновление"
132
+
133
+ #: admin/pages/advanced.php:83
134
+ msgid ""
135
+ "This will attempt to force automatic updates. This is useful for debugging."
136
+ msgstr ""
137
+ "Эта возможность вам понадобится для проверки автоматических обновлений. "
138
+ "Настройте автоматические обновления и нажмите на эту кнопку, чтобы проверить "
139
+ "работают они или нет."
140
+
141
+ #: admin/pages/advanced.php:84
142
+ msgid "Force update"
143
+ msgstr "Запустить обновление"
144
+
145
+ #: admin/pages/plugins.php:72
146
+ msgid "Plugins"
147
+ msgstr "Плагины"
148
+
149
+ #: admin/pages/plugins.php:91
150
+ msgid ""
151
+ "- To disable updates individually choose the “Manual or automatic plugin "
152
+ "updates” option then save settings and comeback to this page."
153
+ msgstr ""
154
+ "Чтобы индивидуально отключить обновления, выберите опцию “Ручные или "
155
+ "автоматические обновления плагинов”, сохраните настройки и вернитесь на эту "
156
+ "страницу."
157
+
158
+ #: admin/pages/plugins.php:95
159
+ msgid ""
160
+ "- To configure plugin auto updates individually, choose the “Enable auto "
161
+ "updates” option then save settings and comeback to this page."
162
+ msgstr ""
163
+ "Чтобы индивидуально настроить автоматические обновления плагинов, выберите "
164
+ "опцию “Автоматические обновления”, сохраните настройки и вернитесь на эту "
165
+ "страницу."
166
+
167
+ #: admin/pages/plugins.php:326
168
+ msgid "Plugins list"
169
+ msgstr "Ваш список плагинов"
170
+
171
+ #: admin/pages/plugins.php:329
172
+ msgid "This page you can individually disable plugin updates and auto updates."
173
+ msgstr ""
174
+ "На этой странице вы можете индивидуально отключить обновления и "
175
+ "автообновления плагинов."
176
+
177
+ #: admin/pages/plugins.php:345 admin/pages/themes.php:321
178
+ msgid "Bulk actions"
179
+ msgstr "Массовые действия"
180
+
181
+ #: admin/pages/plugins.php:346 admin/pages/themes.php:322
182
+ #: admin/pages/updates.php:102 admin/pages/updates.php:117
183
+ #: admin/pages/updates.php:139
184
+ msgid "Disable updates"
185
+ msgstr "Отключить все обновления"
186
+
187
+ #: admin/pages/plugins.php:347 admin/pages/themes.php:323
188
+ msgid "Enable updates"
189
+ msgstr "Включить обновления"
190
+
191
+ #: admin/pages/plugins.php:348 admin/pages/themes.php:324
192
+ msgid "Enable auto-updates"
193
+ msgstr "Включить авто-обновления"
194
+
195
+ #: admin/pages/plugins.php:349 admin/pages/themes.php:325
196
+ msgid "Disable auto-updates"
197
+ msgstr "Отключить авто-обновления"
198
+
199
+ #: admin/pages/plugins.php:350 admin/pages/themes.php:326
200
+ msgid "Disable translation updates"
201
+ msgstr "Отключить обновление переводов"
202
+
203
+ #: admin/pages/plugins.php:351 admin/pages/themes.php:327
204
+ msgid "Enable translation updates"
205
+ msgstr "Включить обновление переводов"
206
+
207
+ #: admin/pages/plugins.php:352 admin/pages/plugins.php:373
208
+ msgid "Hide plugin"
209
+ msgstr "Скрыть плагин"
210
+
211
+ #: admin/pages/plugins.php:353
212
+ msgid "Show plugin"
213
+ msgstr "Показывать плагин"
214
+
215
+ #: admin/pages/plugins.php:355 admin/pages/themes.php:329
216
+ msgid "Apply"
217
+ msgstr "Применить"
218
+
219
+ #: admin/pages/plugins.php:362
220
+ msgid "Plugin"
221
+ msgstr "Плагин"
222
+
223
+ #: admin/pages/plugins.php:364 admin/pages/themes.php:338
224
+ #: admin/pages/updates.php:57
225
+ msgid "Updates"
226
+ msgstr "Обновления"
227
+
228
+ #: admin/pages/plugins.php:367 admin/pages/themes.php:341
229
+ msgid "Auto-updates"
230
+ msgstr "Авто-обновление"
231
+
232
+ #: admin/pages/plugins.php:370 admin/pages/themes.php:344
233
+ msgid "Translation updates"
234
+ msgstr "Обновление переводов"
235
+
236
+ #: admin/pages/plugins.php:432 admin/pages/themes.php:394
237
+ msgid "Select"
238
+ msgstr "Выбор"
239
+
240
+ #: admin/pages/plugins.php:453 admin/pages/plugins.php:472
241
+ #: admin/pages/plugins.php:491 admin/pages/plugins.php:507
242
+ #: admin/pages/themes.php:418 admin/pages/themes.php:437
243
+ #: admin/pages/themes.php:456
244
+ msgid "On"
245
+ msgstr "Вкл"
246
+
247
+ #: admin/pages/plugins.php:454 admin/pages/plugins.php:473
248
+ #: admin/pages/plugins.php:492 admin/pages/plugins.php:508
249
+ #: admin/pages/themes.php:419 admin/pages/themes.php:438
250
+ #: admin/pages/themes.php:457
251
+ msgid "Off"
252
+ msgstr "Выкл"
253
+
254
+ #: admin/pages/themes.php:69
255
+ msgid "Themes"
256
+ msgstr "Темы"
257
+
258
+ #: admin/pages/themes.php:88
259
+ msgid ""
260
+ "- To disable updates individually choose the “Manual or automatic theme "
261
+ "updates” option then save settings and comeback to this page."
262
+ msgstr ""
263
+ "Чтобы индивидуально отключить обновления, выберите опцию “Ручные или "
264
+ "автоматические обновления плагинов”, сохраните настройки и вернитесь на эту "
265
+ "страницу."
266
+
267
+ #: admin/pages/themes.php:92
268
+ msgid ""
269
+ "- To configure theme auto updates individually, choose the “Enable auto "
270
+ "updates” option then save settings and comeback to this page."
271
+ msgstr ""
272
+ "Чтобы индивидуально настроить автоматические обновления тем, выберите опцию "
273
+ "“Автоматические обновления”, сохраните настройки и вернитесь на эту страницу."
274
+
275
+ #: admin/pages/themes.php:302
276
+ msgid "Themes list"
277
+ msgstr "Ваш список тем"
278
+
279
+ #: admin/pages/themes.php:305
280
+ msgid "This page you can individually disable theme updates and auto updates."
281
+ msgstr ""
282
+ "На этой странице вы можете индивидуально отключить обновления и "
283
+ "автообновления тем."
284
+
285
+ #: admin/pages/themes.php:336
286
+ msgid "Theme"
287
+ msgstr "Тема"
288
+
289
+ #: admin/pages/updates.php:43
290
+ msgid "Updates manager"
291
+ msgstr "Менеджер обновлений"
292
+
293
+ #: admin/pages/updates.php:44
294
+ msgid "Manage all site updates"
295
+ msgstr "Упр. обновлениями сайта"
296
+
297
+ #: admin/pages/updates.php:57
298
+ msgid "General"
299
+ msgstr "Основные"
300
+
301
+ #: admin/pages/updates.php:91
302
+ msgid "General settings for WordPress, plugins and themes updates"
303
+ msgstr "Общие настройки для обновлений WordPress, плагинов и тем"
304
+
305
+ #: admin/pages/updates.php:91
306
+ msgid ""
307
+ "This page, you can enable or disable automatic updates. To test the "
308
+ "automatic updates, click the \"Advanced\" tab."
309
+ msgstr ""
310
+ "На этой странице можете включить или отключить автоматические обновления. "
311
+ "Чтобы протестировать работу автоматических обновлений, перейдите на вкладку "
312
+ "\"Дополнительно\"."
313
+
314
+ #: admin/pages/updates.php:98
315
+ msgid "Plugin Updates"
316
+ msgstr "Обновления плагина"
317
+
318
+ #: admin/pages/updates.php:100 admin/pages/updates.php:115
319
+ msgid "Manual updates"
320
+ msgstr "Ручные"
321
+
322
+ #: admin/pages/updates.php:101 admin/pages/updates.php:116
323
+ msgid "Enable auto updates"
324
+ msgstr "Автоматические"
325
+
326
+ #: admin/pages/updates.php:105
327
+ msgid ""
328
+ "You can disable all plugin updates or choose manual or automatic update mode."
329
+ msgstr ""
330
+ "Вы можете отключить все обновления плагинов или выбрать режим ручного или "
331
+ "автоматического обновления."
332
+
333
+ #: admin/pages/updates.php:113
334
+ msgid "Theme Updates"
335
+ msgstr "Обновления тем"
336
+
337
+ #: admin/pages/updates.php:120
338
+ msgid ""
339
+ "You can disable all themes updates or choose manual or automatic update mode."
340
+ msgstr ""
341
+ "Вы можете отключить все обновления тем или выбрать режим ручного или "
342
+ "автоматического обновления."
343
+
344
+ #: admin/pages/updates.php:137
345
+ msgid "WordPress Core Updates"
346
+ msgstr "Базовые обновления Wordpress"
347
+
348
+ #: admin/pages/updates.php:140
349
+ msgid "Disable auto updates"
350
+ msgstr "Отключить автоматические обновления"
351
+
352
+ #: admin/pages/updates.php:143
353
+ msgid "Allow minor auto updates"
354
+ msgstr "Разрешить незначительные автоматические обновления"
355
+
356
+ #: admin/pages/updates.php:147
357
+ msgid "Allow major auto updates"
358
+ msgstr "Разрешить основные автоматические обновления"
359
+
360
+ #: admin/pages/updates.php:151
361
+ msgid "Allow development auto updates"
362
+ msgstr "Разрешить разрабатываемые автоматические обновления"
363
+
364
+ #: admin/pages/updates.php:155
365
+ msgid ""
366
+ "You can disable all core WordPress updates, or disable only automatic "
367
+ "updates. Also you can select the update mode. By default (minor)"
368
+ msgstr ""
369
+ "Вы можете отключить все основные обновления WordPress или отключить только "
370
+ "автоматические обновления. Также вы можете выбрать режим обновления. По "
371
+ "умолчанию (младший)"
372
+
373
+ #: admin/pages/updates.php:155
374
+ msgid "Major - automatically update to major releases (e.g., 4.1, 4.2, 4.3)."
375
+ msgstr ""
376
+ "Основные - автоматически обновления основных версий (4.1, 4.2, 4.3 и т.д)."
377
+
378
+ #: admin/pages/updates.php:155
379
+ msgid ""
380
+ "Minor - automatically update to minor releases (e.g., 4.1.1, 4.1.2, 4.1.3).."
381
+ msgstr ""
382
+ "Незначительные - автоматически обновления промежуточных версий (4.1.1, "
383
+ "4.1.2, 4.1.3 и т.д)."
384
+
385
+ #: admin/pages/updates.php:155
386
+ msgid "Development - update automatically to Bleeding Edge releases."
387
+ msgstr "Разрабатываемые - автоматические обновления до финальных выпусков."
388
+
389
+ #: admin/pages/updates.php:182
390
+ msgid ""
391
+ "Enable Automatic Updates even if a VCS folder (.git, .hg, .svn) was found in "
392
+ "the WordPress directory"
393
+ msgstr ""
394
+ "Включить автоматическое обновление, даже если папка VCS (.git, .hg, .svn) "
395
+ "была найдена в каталоге WordPress"
396
+
397
+ #: admin/pages/updates.php:192
398
+ msgid ""
399
+ "This plugin allows you to hide the update WordPress reminder from all users "
400
+ "that are not assumed Administrators (cannot upgrade plugins).\n"
401
+ "\n"
402
+ "If you have multiple users then this means those who are not admins don’t "
403
+ "need to see the message. Useful for CMS based sites, so the client doesn’t "
404
+ "see the notice."
405
+ msgstr ""
406
+ "Этот опция позволяет вам скрыть напоминание о обновлении WordPress для всех "
407
+ "пользователей, которые не являются администраторами (не могут обновлять "
408
+ "плагины).\n"
409
+ "\n"
410
+ "Если у вас несколько пользователей, это означает, что те, кто не являются "
411
+ "админами, не должны видеть уведомления об обновлениях."
412
+
413
+ #: admin/pages/updates.php:200
414
+ msgid "Email Notifications"
415
+ msgstr "Оповещения ядра WP"
416
+
417
+ #: admin/pages/updates.php:200
418
+ msgid ""
419
+ "Email notifications are send once a day, you can choose what notifications "
420
+ "to send below."
421
+ msgstr ""
422
+ "Оповещения отправляются раз в день, ниже Вы можете выбрать какие сообщения "
423
+ "получать."
424
+
425
+ #: admin/pages/updates.php:207
426
+ msgid "Update available"
427
+ msgstr "Доступно обновления"
428
+
429
+ #: admin/pages/updates.php:208
430
+ msgid "Send me emails when an update is available."
431
+ msgstr "Уведомлять когда обновления доступны."
432
+
433
+ #: admin/pages/updates.php:218
434
+ msgid "Successful update"
435
+ msgstr "При успешном обновлении"
436
+
437
+ #: admin/pages/updates.php:219
438
+ msgid "Send me emails when something has been updated."
439
+ msgstr "Присылать оповещение когда обновления установлены."
440
+
441
+ #: admin/pages/updates.php:230
442
+ msgid "Seperate email addresses using commas."
443
+ msgstr "Адреса электронной почты через запятую."
444
+
445
+ #: admin/pages/updates.php:238
446
+ msgid ""
447
+ "Core notifications are handled by WordPress and not by this plugin. You can "
448
+ "only disable them, changing your email address in the settings above will "
449
+ "not affect these notifications."
450
+ msgstr ""
451
+ "Почтовые сообщения отправляются ядром Вордпресс, а не этим плагином. Вы "
452
+ "можете только отключить их, изменение вашего почтового адреса в настройках "
453
+ "выше не влияет на эти оповещения."
454
+
455
+ #: admin/pages/updates.php:246
456
+ msgid ""
457
+ "By default wordpress sends an email when a core update happend. Uncheck this "
458
+ "box to disable these emails."
459
+ msgstr ""
460
+ "По умолчанию сайт присылает сообщение когда ядро Вордпресс обновилось. "
461
+ "Снимите галочку если не хотите получать его."
462
+
463
+ #: webcraftic-updates-manager.php:58
464
+ msgid "Webcraftic Updates Manager"
465
+ msgstr "Webcraftic менеджер обновлений"
466
+
467
+ #~ msgid "If off email notifications disabled for wp core updates"
468
+ #~ msgstr "Если Выкл оповещения на почту об обновлении ядра не будут приходить"
469
+
470
+ #~ msgid "theme"
471
+ #~ msgstr "тема"
472
+
473
+ #~ msgid "themes"
474
+ #~ msgstr "темы"
475
+
476
+ #~ msgid "Plugin update available."
477
+ #~ msgstr "Доступны обновления плагина."
478
+
479
+ #~ msgid "plugin"
480
+ #~ msgstr "плагин"
481
+
482
+ #~ msgid "plugins"
483
+ #~ msgstr "плагины"
484
+
485
+ #~ msgid "Plugins have been updated."
486
+ #~ msgstr "Плагины были обновлены."
487
+
488
+ #~ msgid "Themes have been updated."
489
+ #~ msgstr "Темы были обновлены."
490
+
491
+ #~ msgid ""
492
+ #~ "We found that you have the \"Clearfy - disable unused features\" plugin "
493
+ #~ "installed, this plugin already has update manager functions, so you can "
494
+ #~ "deactivate plugin \"Update manager\"!"
495
+ #~ msgstr ""
496
+ #~ "Мы обнаружили, что у вас установлен плагин «Clearfy - отключить "
497
+ #~ "неиспользуемые функции», этот плагин уже имеет функции менеджера "
498
+ #~ "обновлений, поэтому вы можете отключить плагин «Менеджер обновлений»!"
499
+
500
+ #~ msgid "Description"
501
+ #~ msgstr "Описание"
includes/boot.php CHANGED
@@ -82,6 +82,12 @@
82
  'title' => '<span class="dashicons dashicons-heart"></span> ' . __('Do you like our plugin?', 'gonzales'),
83
  'href' => 'https://wordpress.org/support/plugin/clearfy/reviews/'
84
  );
 
 
 
 
 
 
85
 
86
  $licensing = WCL_Licensing::instance();
87
 
82
  'title' => '<span class="dashicons dashicons-heart"></span> ' . __('Do you like our plugin?', 'gonzales'),
83
  'href' => 'https://wordpress.org/support/plugin/clearfy/reviews/'
84
  );
85
+ $menu_items['clearfy-support'] = array(
86
+ 'id' => 'clearfy-rating',
87
+ 'title' => '<span class="dashicons dashicons-sos"></span> ' . __('Getting started free support', 'gonzales'),
88
+ 'href' => WbcrFactoryClearfy206_Helpers::getWebcrafticSitePageUrl(WCL_Plugin::app()->getPluginName(), 'support', 'adminbar_menu')
89
+ );
90
+
91
 
92
  $licensing = WCL_Licensing::instance();
93
 
includes/class.plugin.php CHANGED
@@ -1,409 +1,404 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /**
3
- * Clearfy core class
4
- * @author Webcraftic <wordpress.webraftic@gmail.com>
5
- * @copyright (c) 19.02.2018, Webcraftic
6
- * @version 1.0
7
  */
8
-
9
- // Exit if accessed directly
10
- if( !defined('ABSPATH') ) {
11
- exit;
12
- }
13
-
14
- class WCL_Plugin extends Wbcr_Factory409_Plugin {
15
-
16
- /**
17
- * @var WCL_Plugin
18
- */
19
- private static $app;
20
-
21
- public function __construct($plugin_path, $data)
22
- {
23
- self::$app = $this;
24
-
25
- parent::__construct($plugin_path, $data);
26
-
27
- // Freemius
28
- require_once(WCL_PLUGIN_DIR . '/includes/freemius/class.storage.php');
29
-
30
- require_once(WCL_PLUGIN_DIR . '/includes/freemius/entities/class.wcl-fs-entity.php');
31
- require_once(WCL_PLUGIN_DIR . '/includes/freemius/entities/class.wcl-fs-scope-entity.php');
32
- require_once(WCL_PLUGIN_DIR . '/includes/freemius/entities/class.wcl-fs-user.php');
33
- require_once(WCL_PLUGIN_DIR . '/includes/freemius/entities/class.wcl-fs-site.php');
34
- require_once(WCL_PLUGIN_DIR . '/includes/freemius/entities/class.wcl-fs-plugin-license.php');
35
-
36
- require_once(WCL_PLUGIN_DIR . '/includes/freemius/sdk/FreemiusWordPress.php');
37
-
38
- //todo: перенести синхронизацию лицензии в глобальную область, остальные вызовы только для администратора
39
- require_once(WCL_PLUGIN_DIR . '/includes/classes/class.licensing.php');
40
- require_once(WCL_PLUGIN_DIR . '/includes/classes/class.package.php');
41
-
42
- if( is_admin() ) {
43
- require_once(WCL_PLUGIN_DIR . '/admin/includes/classes/class.option.php');
44
- require_once(WCL_PLUGIN_DIR . '/admin/includes/classes/class.group.php');
45
-
46
- require_once(WCL_PLUGIN_DIR . '/admin/activation.php');
47
-
48
- if( defined('DOING_AJAX') && DOING_AJAX ) {
49
- require(WCL_PLUGIN_DIR . '/admin/ajax/configurate.php');
50
- require(WCL_PLUGIN_DIR . '/admin/ajax/import-settings.php');
51
- require(WCL_PLUGIN_DIR . '/admin/ajax/install-addons.php');
52
- require(WCL_PLUGIN_DIR . '/admin/ajax/update-package.php');
53
- require(WCL_PLUGIN_DIR . '/admin/ajax/check-license.php');
54
- }
55
-
56
- require_once(WCL_PLUGIN_DIR . '/admin/includes/compatibility.php');
57
- require_once(WCL_PLUGIN_DIR . '/admin/boot.php');
58
  }
59
-
60
- $this->setModules();
61
-
62
- if( is_admin() ) {
63
- $this->initActivation();
64
- }
65
-
66
- $this->setAddons();
67
-
68
- $this->globalScripts();
69
-
70
- add_action('plugins_loaded', array($this, 'pluginsLoaded'));
71
  }
72
-
73
- public static function app()
74
- {
75
- return self::$app;
 
76
  }
77
-
78
- protected function initActivation()
79
- {
80
- include_once(WCL_PLUGIN_DIR . '/admin/activation.php');
81
- $this->registerActivation('WCL_Activation');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
83
-
84
- protected function setModules()
85
- {
86
- $this->load(array(
87
- array('libs/factory/bootstrap', 'factory_bootstrap_409', 'admin'),
88
- array('libs/factory/forms', 'factory_forms_410', 'admin'),
89
- array('libs/factory/pages', 'factory_pages_410', 'admin'),
90
- array('libs/factory/notices', 'factory_notices_407', 'admin'),
91
- array('libs/factory/clearfy', 'factory_clearfy_206', 'all')
92
- ));
93
  }
94
-
95
- public function setAddons()
96
- {
97
- $addons = array();
98
-
99
- if( $this->isActivateComponent('html_minify') && !defined('WHTM_PLUGIN_ACTIVE') ) {
100
- $addons['html_minify'] = array(
101
- 'WHTM_Plugin',
102
- WCL_PLUGIN_DIR . '/components/html-minify/html-minify.php'
103
- );
104
- }
105
-
106
- if( $this->isActivateComponent('minify_and_combine') && !defined('WMAC_PLUGIN_ACTIVE') ) {
107
- $addons['minify_and_combine'] = array(
108
- 'WMAC_Plugin',
109
- WCL_PLUGIN_DIR . '/components/minify-and-combine/minify-and-combine.php'
110
- );
111
- }
112
-
113
- // This module is for Cyrillic users only, for other users it should be disabled
114
- if( $this->isActivateComponent('cyrlitera') && !defined('WCTR_PLUGIN_ACTIVE') ) {
115
- $addons['cyrlitera'] = array(
116
- 'WCTR_Plugin',
117
- WCL_PLUGIN_DIR . '/components/cyrlitera/cyrlitera.php'
118
- );
119
- }
120
-
121
- if( $this->isActivateComponent('disable_notices') && !defined('WDN_PLUGIN_ACTIVE') ) {
122
- $addons['disable_admin_notices'] = array(
123
- 'WDN_Plugin',
124
- WCL_PLUGIN_DIR . '/components/disable-admin-notices/disable-admin-notices.php'
125
- );
126
- }
127
-
128
- if( $this->isActivateComponent('updates_manager') && !defined('WUPM_PLUGIN_ACTIVE') ) {
129
- $addons['updates_manager'] = array(
130
- 'WUPM_Plugin',
131
- WCL_PLUGIN_DIR . '/components/updates-manager/webcraftic-updates-manager.php'
132
- );
133
- }
134
-
135
- if( $this->isActivateComponent('comments_tools') && !defined('WCM_PLUGIN_ACTIVE') ) {
136
- $addons['comments_plus'] = array(
137
- 'WCM_Plugin',
138
- WCL_PLUGIN_DIR . '/components/comments-plus/comments-plus.php'
139
- );
140
- }
141
-
142
- if( $this->isActivateComponent('assets_manager') && !defined('WGZ_PLUGIN_ACTIVE') ) {
143
- $addons['assets_manager'] = array(
144
- 'WGZ_Plugin',
145
- WCL_PLUGIN_DIR . '/components/assets-manager/gonzales.php'
146
- );
147
- }
148
-
149
- if( $this->isActivateComponent('ga_cache') && !defined('WGA_PLUGIN_ACTIVE') ) {
150
- $addons['ga_cache'] = array(
151
- 'WGA_Plugin',
152
- WCL_PLUGIN_DIR . '/components/ga-cache/simple_google_analytics.php'
153
- );
154
- }
155
-
156
- /**
157
- * Include plugin components
158
- */
159
-
160
- require_once(WCL_PLUGIN_DIR . '/includes/classes/class.package.php');
161
-
162
- if( !defined('WCL_PLUGIN_DEBUG') || !WCL_PLUGIN_DEBUG ) {
163
-
164
- $package = WCL_Package::instance();
165
- $package_addons = $package->getActivedAddons();
166
-
167
- if( !empty($package_addons) ) {
168
- $incompatible_addons = array();
169
-
170
- foreach($package_addons as $addon_slug => $addon) {
171
- $base_dir = $addon[1];
172
-
173
- if( !empty($base_dir) && file_exists($base_dir) ) {
174
- $addon_info = get_file_data($base_dir, array(
175
- 'Name' => 'Plugin Name',
176
- //'Version' => 'Version',
177
- 'FrameworkVersion' => 'Framework Version',
178
- ), 'plugin');
179
-
180
- if( !isset($addon_info['FrameworkVersion']) || (rtrim(trim($addon_info['FrameworkVersion'])) != 'FACTORY_409_VERSION') ) {
181
- $incompatible_addons[$addon_slug] = array(
182
- 'title' => $addon_info['Name']
183
- );
184
- } else {
185
- $addons[$addon_slug] = $addon;
186
- }
187
- }
188
- }
189
- if( !empty($incompatible_addons) ) {
190
- add_filter('wbcr_factory_notices_407_list', function ($notices, $plugin_name) use ($incompatible_addons) {
191
- if( $plugin_name != WCL_Plugin::app()->getPluginName() ) {
192
- return $notices;
193
- }
194
-
195
- $notice_text = '<p>' . __('Some components of Clearfy were suspended', 'clearfy') . ':</p><ul style="padding-left:30px; list-style: circle">';
196
- foreach($incompatible_addons as $addon) {
197
- $notice_text .= '<li>' . sprintf(__('Component %s is not compatible with the current version of the plugin Clearfy, you must update the component to the latest version.', 'clearfy'), $addon['title']) . '</li>';
198
- }
199
- $update_components_url = wp_nonce_url($this->getPluginPageUrl('components', array('action' => 'force-update-components')), 'force_update_componetns');
200
- $notice_text .= '</ul><p><a href="' . $update_components_url . '" class="button">' . __('Click here to update the components', 'clearfy') . '</a></p>';
201
-
202
- $notices[] = array(
203
- 'id' => 'clearfy_component_is_not_compatibility',
204
- 'type' => 'error',
205
- 'dismissible' => false,
206
- 'dismiss_expires' => 0,
207
- 'text' => $notice_text
208
  );
209
-
210
- return apply_filters('wbcr_clearfy_admin_notices', $notices);
211
- }, 10, 2);
212
  }
213
  }
214
- //$addons = array_merge($addons, $package_addons);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  }
216
-
217
- $this->loadAddons($addons);
218
  }
219
-
220
- private function registerPages()
221
- {
222
- $this->registerPage('WCL_QuickStartPage', WCL_PLUGIN_DIR . '/admin/pages/quick-start.php');
223
- $this->registerPage('WCL_AdvancedPage', WCL_PLUGIN_DIR . '/admin/pages/advanced.php');
224
- $this->registerPage('WCL_PerformancePage', WCL_PLUGIN_DIR . '/admin/pages/performance.php');
225
- $this->registerPage('WCL_PerformanceGooglePage', WCL_PLUGIN_DIR . '/admin/pages/performance-google.php');
226
- $this->registerPage('WCL_ComponentsPage', WCL_PLUGIN_DIR . '/admin/pages/components.php');
227
- $this->registerPage('WCL_SeoPage', WCL_PLUGIN_DIR . '/admin/pages/seo.php');
228
- $this->registerPage('WCL_DoublePagesPage', WCL_PLUGIN_DIR . '/admin/pages/seo-double-pages.php');
229
- $this->registerPage('WCL_DefencePage', WCL_PLUGIN_DIR . '/admin/pages/defence.php');
230
- $this->registerPage('WCL_LicensePage', WCL_PLUGIN_DIR . '/admin/pages/license.php');
231
-
232
- if( $this->isActivateComponent('widget_tools') ) {
233
- $this->registerPage('WCL_WidgetsPage', WCL_PLUGIN_DIR . '/admin/pages/widgets.php');
 
 
 
 
 
 
 
 
234
  }
235
-
236
- $this->registerPage('WCL_ClearfySettingsPage', WCL_PLUGIN_DIR . '/admin/pages/clearfy-settings.php');
237
-
238
- if( !defined('WIO_PLUGIN_ACTIVE') ) {
239
- $this->registerPage('WCL_ImageOptimizationPage', WCL_PLUGIN_DIR . '/admin/pages/image-optimization.php');
240
  }
241
-
242
- if( !defined('WHLP_PLUGIN_ACTIVE') ) {
243
- $this->registerPage('WCL_HideLoginPage', WCL_PLUGIN_DIR . '/admin/pages/hide-login-page.php');
244
  }
 
 
245
  }
246
-
247
- private function globalScripts()
248
- {
249
- require_once(WCL_PLUGIN_DIR . '/includes/boot.php');
250
-
251
- require_once(WCL_PLUGIN_DIR . '/includes/classes/class.configurate-performance.php');
252
- require_once(WCL_PLUGIN_DIR . '/includes/classes/class.configurate-google-performance.php');
253
- require_once(WCL_PLUGIN_DIR . '/includes/classes/class.configurate-privacy.php');
254
- require_once(WCL_PLUGIN_DIR . '/includes/classes/class.configurate-security.php');
255
- require_once(WCL_PLUGIN_DIR . '/includes/classes/class.configurate-seo.php');
256
-
257
- new WCL_ConfigPerformance($this);
258
- new WCL_ConfigGooglePerformance($this);
259
- new WCL_ConfigPrivacy($this);
260
- new WCL_ConfigSecurity($this);
261
- new WCL_ConfigSeo($this);
 
 
 
 
 
 
 
262
  }
263
-
264
- public function pluginsLoaded()
265
- {
266
- $this->setTextDomain('clearfy', WCL_PLUGIN_DIR);
267
-
268
- // todo: проверить страницы, могут ли они быть вызываны позже
269
- if( is_admin() ) {
270
- $this->registerPages();
271
- }
272
-
273
- require_once(WCL_PLUGIN_DIR . '/includes/classes/class.configurate-advanced.php');
274
- new WCL_ConfigAdvanced($this);
 
 
 
 
 
 
 
 
 
 
275
  }
276
-
277
- /**
278
- * @return bool
279
- */
280
- public function currentUserCan()
281
- {
282
- $permission = $this->isNetworkActive() ? 'manage_network' : 'manage_options';
283
-
284
- return current_user_can($permission);
285
  }
286
-
287
- /**
288
- * @param string $component_name
289
- * @return bool
290
- * @throws Exception
291
- */
292
- public function isActivateComponent($component_name)
293
- {
294
- if( !is_string($component_name) ) {
295
- throw new Exception('Attribute component_name must be is string');
296
- }
297
-
298
- $deactivate_components = $this->getPopulateOption('deactive_preinstall_components', array());
299
-
300
- if( !is_array($deactivate_components) ) {
301
- $deactivate_components = array();
302
- }
303
-
304
- if( $deactivate_components && in_array($component_name, $deactivate_components) ) {
305
- return false;
306
- }
307
-
308
- return true;
309
  }
310
-
311
- /**
312
- * @param string $component_name
313
- * @return bool
314
- * @throws Exception
315
- */
316
- public function deactivateComponent($component_name)
317
- {
318
- if( !$this->isActivateComponent($component_name) ) {
319
- return true;
320
- }
321
-
322
- do_action('wbcr_clearfy_pre_deactivate_component', $component_name);
323
-
324
- $deactivate_components = $this->getPopulateOption('deactive_preinstall_components', array());
325
-
326
- if( !empty($deactivate_components) && is_array($deactivate_components) ) {
327
- $deactivate_components[] = $component_name;
328
- } else {
329
- $deactivate_components = array();
330
- $deactivate_components[] = $component_name;
331
- }
332
-
333
- $this->updatePopulateOption('deactive_preinstall_components', $deactivate_components);
334
-
335
- do_action('wbcr_clearfy_deactivated_component', $component_name);
336
-
337
  return true;
338
  }
339
-
340
- /**
341
- * @param string $component_name
342
- * @return bool
343
- * @throws Exception
344
- */
345
- public function activateComponent($component_name)
346
- {
347
- if( $this->isActivateComponent($component_name) ) {
348
- return true;
349
- }
350
-
351
- do_action('wbcr_clearfy_pre_activate_component', $component_name);
352
-
353
- $deactivate_components = $this->getPopulateOption('deactive_preinstall_components', array());
354
-
355
- if( !empty($deactivate_components) && is_array($deactivate_components) ) {
356
- $index = array_search($component_name, $deactivate_components);
357
- unset($deactivate_components[$index]);
358
- }
359
-
360
- if( empty($deactivate_components) ) {
361
- $this->deletePopulateOption('deactive_preinstall_components');
362
- } else {
363
- $this->updatePopulateOption('deactive_preinstall_components', $deactivate_components);
364
- }
365
-
366
- //do_action('wbcr/clearfy/activated_component', $component_name);
367
-
368
- return true;
369
  }
370
-
371
- /**
372
- * Allows you to get a button to install the plugin component
373
- *
374
- * @param $component_type
375
- * @param $slug
376
- * @return WCL_InstallPluginsButton
377
- */
378
- public function getInstallComponentsButton($component_type, $slug)
379
- {
380
- require_once WCL_PLUGIN_DIR . '/admin/includes/classes/class.install-plugins-button.php';
381
-
382
- return new WCL_InstallPluginsButton($component_type, $slug);
 
 
 
383
  }
384
-
385
- /**
386
- * Allows you to get a button to delete the plugin component
387
- *
388
- * @param $component_type
389
- * @param $slug
390
- * @return WCL_InstallPluginsButton
391
- */
392
- public function getDeleteComponentsButton($component_type, $slug)
393
- {
394
- require_once WCL_PLUGIN_DIR . '/admin/includes/classes/class.install-plugins-button.php';
395
- require_once WCL_PLUGIN_DIR . '/admin/includes/classes/class.delete-plugins-button.php';
396
-
397
- return new WCL_DeletePluginsButton($component_type, $slug);
398
  }
399
-
400
- /**
401
- * Возвращает класс для работы с лицензией
402
- *
403
- * @return WCL_Licensing
404
- */
405
- public function getLicense()
406
- {
407
- return WCL_Licensing::instance();
408
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  }
 
1
  <?php
2
+ /**
3
+ * Clearfy core class
4
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
5
+ * @copyright (c) 19.02.2018, Webcraftic
6
+ * @version 1.0
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ class WCL_Plugin extends Wbcr_Factory409_Plugin {
15
+
16
  /**
17
+ * @var WCL_Plugin
 
 
 
18
  */
19
+ private static $app;
20
+
21
+ public function __construct( $plugin_path, $data ) {
22
+ self::$app = $this;
23
+
24
+ parent::__construct( $plugin_path, $data );
25
+
26
+ // Freemius
27
+ require_once( WCL_PLUGIN_DIR . '/includes/freemius/class.storage.php' );
28
+
29
+ require_once( WCL_PLUGIN_DIR . '/includes/freemius/entities/class.wcl-fs-entity.php' );
30
+ require_once( WCL_PLUGIN_DIR . '/includes/freemius/entities/class.wcl-fs-scope-entity.php' );
31
+ require_once( WCL_PLUGIN_DIR . '/includes/freemius/entities/class.wcl-fs-user.php' );
32
+ require_once( WCL_PLUGIN_DIR . '/includes/freemius/entities/class.wcl-fs-site.php' );
33
+ require_once( WCL_PLUGIN_DIR . '/includes/freemius/entities/class.wcl-fs-plugin-license.php' );
34
+
35
+ require_once( WCL_PLUGIN_DIR . '/includes/freemius/sdk/FreemiusWordPress.php' );
36
+
37
+ require_once( WCL_PLUGIN_DIR . '/includes/classes/exceptions/class.license-exception.php' );
38
+ require_once( WCL_PLUGIN_DIR . '/includes/classes/class.licensing.php' );
39
+ require_once( WCL_PLUGIN_DIR . '/includes/classes/class.package.php' );
40
+
41
+ if ( is_admin() ) {
42
+ require_once( WCL_PLUGIN_DIR . '/admin/includes/classes/class.option.php' );
43
+ require_once( WCL_PLUGIN_DIR . '/admin/includes/classes/class.group.php' );
44
+
45
+ require_once( WCL_PLUGIN_DIR . '/admin/activation.php' );
46
+
47
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
48
+ require( WCL_PLUGIN_DIR . '/admin/ajax/configurate.php' );
49
+ require( WCL_PLUGIN_DIR . '/admin/ajax/import-settings.php' );
50
+ require( WCL_PLUGIN_DIR . '/admin/ajax/install-addons.php' );
51
+ require( WCL_PLUGIN_DIR . '/admin/ajax/update-package.php' );
52
+ require( WCL_PLUGIN_DIR . '/admin/ajax/check-license.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
+
55
+ require_once( WCL_PLUGIN_DIR . '/admin/includes/compatibility.php' );
56
+ require_once( WCL_PLUGIN_DIR . '/admin/boot.php' );
 
 
 
 
 
 
 
 
 
57
  }
58
+
59
+ $this->setModules();
60
+
61
+ if ( is_admin() ) {
62
+ $this->initActivation();
63
  }
64
+
65
+ $this->setAddons();
66
+
67
+ $this->globalScripts();
68
+
69
+ add_action( 'plugins_loaded', array( $this, 'pluginsLoaded' ) );
70
+ }
71
+
72
+ public static function app() {
73
+ return self::$app;
74
+ }
75
+
76
+ protected function initActivation() {
77
+ include_once( WCL_PLUGIN_DIR . '/admin/activation.php' );
78
+ $this->registerActivation( 'WCL_Activation' );
79
+ }
80
+
81
+ protected function setModules() {
82
+ $this->load( array(
83
+ array( 'libs/factory/bootstrap', 'factory_bootstrap_409', 'admin' ),
84
+ array( 'libs/factory/forms', 'factory_forms_410', 'admin' ),
85
+ array( 'libs/factory/pages', 'factory_pages_410', 'admin' ),
86
+ array( 'libs/factory/notices', 'factory_notices_407', 'admin' ),
87
+ array( 'libs/factory/clearfy', 'factory_clearfy_206', 'all' )
88
+ ) );
89
+ }
90
+
91
+ public function setAddons() {
92
+ $addons = array();
93
+
94
+ if ( $this->isActivateComponent( 'html_minify' ) && ! defined( 'WHTM_PLUGIN_ACTIVE' ) ) {
95
+ $addons['html_minify'] = array(
96
+ 'WHTM_Plugin',
97
+ WCL_PLUGIN_DIR . '/components/html-minify/html-minify.php'
98
+ );
99
  }
100
+
101
+ if ( $this->isActivateComponent( 'minify_and_combine' ) && ! defined( 'WMAC_PLUGIN_ACTIVE' ) ) {
102
+ $addons['minify_and_combine'] = array(
103
+ 'WMAC_Plugin',
104
+ WCL_PLUGIN_DIR . '/components/minify-and-combine/minify-and-combine.php'
105
+ );
 
 
 
 
106
  }
107
+
108
+ // This module is for Cyrillic users only, for other users it should be disabled
109
+ if ( $this->isActivateComponent( 'cyrlitera' ) && ! defined( 'WCTR_PLUGIN_ACTIVE' ) ) {
110
+ $addons['cyrlitera'] = array(
111
+ 'WCTR_Plugin',
112
+ WCL_PLUGIN_DIR . '/components/cyrlitera/cyrlitera.php'
113
+ );
114
+ }
115
+
116
+ if ( $this->isActivateComponent( 'disable_notices' ) && ! defined( 'WDN_PLUGIN_ACTIVE' ) ) {
117
+ $addons['disable_admin_notices'] = array(
118
+ 'WDN_Plugin',
119
+ WCL_PLUGIN_DIR . '/components/disable-admin-notices/disable-admin-notices.php'
120
+ );
121
+ }
122
+
123
+ if ( $this->isActivateComponent( 'updates_manager' ) && ! defined( 'WUPM_PLUGIN_ACTIVE' ) ) {
124
+ $addons['updates_manager'] = array(
125
+ 'WUPM_Plugin',
126
+ WCL_PLUGIN_DIR . '/components/updates-manager/webcraftic-updates-manager.php'
127
+ );
128
+ }
129
+
130
+ if ( $this->isActivateComponent( 'comments_tools' ) && ! defined( 'WCM_PLUGIN_ACTIVE' ) ) {
131
+ $addons['comments_plus'] = array(
132
+ 'WCM_Plugin',
133
+ WCL_PLUGIN_DIR . '/components/comments-plus/comments-plus.php'
134
+ );
135
+ }
136
+
137
+ if ( $this->isActivateComponent( 'assets_manager' ) && ! defined( 'WGZ_PLUGIN_ACTIVE' ) ) {
138
+ $addons['assets_manager'] = array(
139
+ 'WGZ_Plugin',
140
+ WCL_PLUGIN_DIR . '/components/assets-manager/gonzales.php'
141
+ );
142
+ }
143
+
144
+ if ( $this->isActivateComponent( 'ga_cache' ) && ! defined( 'WGA_PLUGIN_ACTIVE' ) ) {
145
+ $addons['ga_cache'] = array(
146
+ 'WGA_Plugin',
147
+ WCL_PLUGIN_DIR . '/components/ga-cache/simple_google_analytics.php'
148
+ );
149
+ }
150
+
151
+ /**
152
+ * Include plugin components
153
+ */
154
+
155
+ require_once( WCL_PLUGIN_DIR . '/includes/classes/class.package.php' );
156
+
157
+ if ( ! defined( 'WCL_PLUGIN_DEBUG' ) || ! WCL_PLUGIN_DEBUG ) {
158
+
159
+ $package = WCL_Package::instance();
160
+ $package_addons = $package->getActivedAddons();
161
+
162
+ if ( ! empty( $package_addons ) ) {
163
+ $incompatible_addons = array();
164
+
165
+ foreach ( $package_addons as $addon_slug => $addon ) {
166
+ $base_dir = $addon[1];
167
+
168
+ if ( ! empty( $base_dir ) && file_exists( $base_dir ) ) {
169
+ $addon_info = get_file_data( $base_dir, array(
170
+ 'Name' => 'Plugin Name',
171
+ //'Version' => 'Version',
172
+ 'FrameworkVersion' => 'Framework Version',
173
+ ), 'plugin' );
174
+
175
+ if ( ! isset( $addon_info['FrameworkVersion'] ) || ( rtrim( trim( $addon_info['FrameworkVersion'] ) ) != 'FACTORY_409_VERSION' ) ) {
176
+ $incompatible_addons[ $addon_slug ] = array(
177
+ 'title' => $addon_info['Name']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  );
179
+ } else {
180
+ $addons[ $addon_slug ] = $addon;
181
+ }
182
  }
183
  }
184
+ if ( ! empty( $incompatible_addons ) ) {
185
+ add_filter( 'wbcr_factory_notices_407_list', function ( $notices, $plugin_name ) use ( $incompatible_addons ) {
186
+ if ( $plugin_name != WCL_Plugin::app()->getPluginName() ) {
187
+ return $notices;
188
+ }
189
+
190
+ $notice_text = '<p>' . __( 'Some components of Clearfy were suspended', 'clearfy' ) . ':</p><ul style="padding-left:30px; list-style: circle">';
191
+ foreach ( $incompatible_addons as $addon ) {
192
+ $notice_text .= '<li>' . sprintf( __( 'Component %s is not compatible with the current version of the plugin Clearfy, you must update the component to the latest version.', 'clearfy' ), $addon['title'] ) . '</li>';
193
+ }
194
+ $update_components_url = wp_nonce_url( $this->getPluginPageUrl( 'components', array( 'action' => 'force-update-components' ) ), 'force_update_componetns' );
195
+ $notice_text .= '</ul><p><a href="' . $update_components_url . '" class="button">' . __( 'Click here to update the components', 'clearfy' ) . '</a></p>';
196
+
197
+ $notices[] = array(
198
+ 'id' => 'clearfy_component_is_not_compatibility',
199
+ 'type' => 'error',
200
+ 'dismissible' => false,
201
+ 'dismiss_expires' => 0,
202
+ 'text' => $notice_text
203
+ );
204
+
205
+ return apply_filters( 'wbcr_clearfy_admin_notices', $notices );
206
+ }, 10, 2 );
207
+ }
208
  }
209
+ //$addons = array_merge($addons, $package_addons);
 
210
  }
211
+
212
+ $this->loadAddons( $addons );
213
+ }
214
+
215
+ /**
216
+ * Register pages for wp admin
217
+ *
218
+ * @throws Exception
219
+ */
220
+ private function registerPages() {
221
+ try {
222
+ $this->registerPage( 'WCL_QuickStartPage', WCL_PLUGIN_DIR . '/admin/pages/quick-start.php' );
223
+ $this->registerPage( 'WCL_AdvancedPage', WCL_PLUGIN_DIR . '/admin/pages/advanced.php' );
224
+ $this->registerPage( 'WCL_PerformancePage', WCL_PLUGIN_DIR . '/admin/pages/performance.php' );
225
+ $this->registerPage( 'WCL_PerformanceGooglePage', WCL_PLUGIN_DIR . '/admin/pages/performance-google.php' );
226
+ $this->registerPage( 'WCL_ComponentsPage', WCL_PLUGIN_DIR . '/admin/pages/components.php' );
227
+ $this->registerPage( 'WCL_SeoPage', WCL_PLUGIN_DIR . '/admin/pages/seo.php' );
228
+ $this->registerPage( 'WCL_DoublePagesPage', WCL_PLUGIN_DIR . '/admin/pages/seo-double-pages.php' );
229
+ $this->registerPage( 'WCL_DefencePage', WCL_PLUGIN_DIR . '/admin/pages/defence.php' );
230
+ $this->registerPage( 'WCL_LicensePage', WCL_PLUGIN_DIR . '/admin/pages/license.php' );
231
+
232
+ if ( $this->isActivateComponent( 'widget_tools' ) ) {
233
+ $this->registerPage( 'WCL_WidgetsPage', WCL_PLUGIN_DIR . '/admin/pages/widgets.php' );
234
  }
235
+
236
+ $this->registerPage( 'WCL_ClearfySettingsPage', WCL_PLUGIN_DIR . '/admin/pages/clearfy-settings.php' );
237
+
238
+ if ( ! defined( 'WIO_PLUGIN_ACTIVE' ) ) {
239
+ $this->registerPage( 'WCL_ImageOptimizationPage', WCL_PLUGIN_DIR . '/admin/pages/image-optimization.php' );
240
  }
241
+
242
+ if ( ! defined( 'WHLP_PLUGIN_ACTIVE' ) ) {
243
+ $this->registerPage( 'WCL_HideLoginPage', WCL_PLUGIN_DIR . '/admin/pages/hide-login-page.php' );
244
  }
245
+ } catch( Exception $e ) {
246
+ throw new Exception( $e->getMessage() );
247
  }
248
+ }
249
+
250
+ private function globalScripts() {
251
+ require_once( WCL_PLUGIN_DIR . '/includes/boot.php' );
252
+
253
+ require_once( WCL_PLUGIN_DIR . '/includes/classes/class.configurate-performance.php' );
254
+ require_once( WCL_PLUGIN_DIR . '/includes/classes/class.configurate-google-performance.php' );
255
+ require_once( WCL_PLUGIN_DIR . '/includes/classes/class.configurate-privacy.php' );
256
+ require_once( WCL_PLUGIN_DIR . '/includes/classes/class.configurate-security.php' );
257
+ require_once( WCL_PLUGIN_DIR . '/includes/classes/class.configurate-seo.php' );
258
+
259
+ new WCL_ConfigPerformance( $this );
260
+ new WCL_ConfigGooglePerformance( $this );
261
+ new WCL_ConfigPrivacy( $this );
262
+ new WCL_ConfigSecurity( $this );
263
+ new WCL_ConfigSeo( $this );
264
+ }
265
+
266
+ public function pluginsLoaded() {
267
+ $this->setTextDomain( 'clearfy', WCL_PLUGIN_DIR );
268
+
269
+ if ( is_admin() ) {
270
+ $this->registerPages();
271
  }
272
+
273
+ require_once( WCL_PLUGIN_DIR . '/includes/classes/class.configurate-advanced.php' );
274
+ new WCL_ConfigAdvanced( $this );
275
+ }
276
+
277
+ /**
278
+ * @return bool
279
+ */
280
+ public function currentUserCan() {
281
+ $permission = $this->isNetworkActive() ? 'manage_network' : 'manage_options';
282
+
283
+ return current_user_can( $permission );
284
+ }
285
+
286
+ /**
287
+ * @param string $component_name
288
+ *
289
+ * @return bool
290
+ */
291
+ public function isActivateComponent( $component_name ) {
292
+ if ( ! is_string( $component_name ) ) {
293
+ return false;
294
  }
295
+
296
+ $deactivate_components = $this->getPopulateOption( 'deactive_preinstall_components', array() );
297
+
298
+ if ( ! is_array( $deactivate_components ) ) {
299
+ $deactivate_components = array();
 
 
 
 
300
  }
301
+
302
+ if ( $deactivate_components && in_array( $component_name, $deactivate_components ) ) {
303
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  }
305
+
306
+ return true;
307
+ }
308
+
309
+ /**
310
+ * @param string $component_name
311
+ *
312
+ * @return bool
313
+ */
314
+ public function deactivateComponent( $component_name ) {
315
+ if ( ! $this->isActivateComponent( $component_name ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  return true;
317
  }
318
+
319
+ do_action( 'wbcr_clearfy_pre_deactivate_component', $component_name );
320
+
321
+ $deactivate_components = $this->getPopulateOption( 'deactive_preinstall_components', array() );
322
+
323
+ if ( ! empty( $deactivate_components ) && is_array( $deactivate_components ) ) {
324
+ $deactivate_components[] = $component_name;
325
+ } else {
326
+ $deactivate_components = array();
327
+ $deactivate_components[] = $component_name;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  }
329
+
330
+ $this->updatePopulateOption( 'deactive_preinstall_components', $deactivate_components );
331
+
332
+ do_action( 'wbcr_clearfy_deactivated_component', $component_name );
333
+
334
+ return true;
335
+ }
336
+
337
+ /**
338
+ * @param string $component_name
339
+ *
340
+ * @return bool
341
+ */
342
+ public function activateComponent( $component_name ) {
343
+ if ( $this->isActivateComponent( $component_name ) ) {
344
+ return true;
345
  }
346
+
347
+ do_action( 'wbcr_clearfy_pre_activate_component', $component_name );
348
+
349
+ $deactivate_components = $this->getPopulateOption( 'deactive_preinstall_components', array() );
350
+
351
+ if ( ! empty( $deactivate_components ) && is_array( $deactivate_components ) ) {
352
+ $index = array_search( $component_name, $deactivate_components );
353
+ unset( $deactivate_components[ $index ] );
 
 
 
 
 
 
354
  }
355
+
356
+ if ( empty( $deactivate_components ) ) {
357
+ $this->deletePopulateOption( 'deactive_preinstall_components' );
358
+ } else {
359
+ $this->updatePopulateOption( 'deactive_preinstall_components', $deactivate_components );
 
 
 
 
360
  }
361
+
362
+ //do_action('wbcr/clearfy/activated_component', $component_name);
363
+
364
+ return true;
365
+ }
366
+
367
+ /**
368
+ * Allows you to get a button to install the plugin component
369
+ *
370
+ * @param $component_type
371
+ * @param $slug
372
+ *
373
+ * @return WCL_InstallPluginsButton
374
+ */
375
+ public function getInstallComponentsButton( $component_type, $slug ) {
376
+ require_once WCL_PLUGIN_DIR . '/admin/includes/classes/class.install-plugins-button.php';
377
+
378
+ return new WCL_InstallPluginsButton( $component_type, $slug );
379
+ }
380
+
381
+ /**
382
+ * Allows you to get a button to delete the plugin component
383
+ *
384
+ * @param $component_type
385
+ * @param $slug
386
+ *
387
+ * @return WCL_InstallPluginsButton
388
+ */
389
+ public function getDeleteComponentsButton( $component_type, $slug ) {
390
+ require_once WCL_PLUGIN_DIR . '/admin/includes/classes/class.install-plugins-button.php';
391
+ require_once WCL_PLUGIN_DIR . '/admin/includes/classes/class.delete-plugins-button.php';
392
+
393
+ return new WCL_DeletePluginsButton( $component_type, $slug );
394
+ }
395
+
396
+ /**
397
+ * Возвращает класс для работы с лицензией
398
+ *
399
+ * @return WCL_Licensing
400
+ */
401
+ public function getLicense() {
402
+ return WCL_Licensing::instance();
403
  }
404
+ }
includes/classes/class.configurate-performance.php CHANGED
@@ -1,512 +1,485 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /**
3
- * This class configures the code cleanup settings
4
- * @author Webcraftic <wordpress.webraftic@gmail.com>
5
- * @copyright (c) 2017 Webraftic Ltd
6
- * @version 1.0
7
  */
8
-
9
- // Exit if accessed directly
10
- if( !defined('ABSPATH') ) {
11
- exit;
12
  }
13
 
14
- class WCL_ConfigPerformance extends Wbcr_FactoryClearfy206_Configurate {
15
-
16
- /**
17
- * @param WCL_Plugin $plugin
18
- */
19
- public function __construct(WCL_Plugin $plugin)
20
- {
21
- parent::__construct($plugin);
22
-
23
- $this->plugin = $plugin;
 
 
 
 
 
24
  }
25
 
26
- public function registerActionsAndFilters()
27
- {
28
- if( $this->getPopulateOption('disable_emoji') ) {
29
- add_action('init', array($this, 'disableEmojis'));
30
  }
31
 
32
- if( $this->getPopulateOption('remove_jquery_migrate') && !is_admin() ) {
33
- add_filter('wp_default_scripts', array($this, 'removeJqueryMigrate'));
34
  }
35
 
36
- if( $this->getPopulateOption('disable_embeds') ) {
37
- add_action('init', array($this, 'disableEmbeds'));
38
  }
39
 
40
- if( $this->getPopulateOption('disable_json_rest_api') ) {
41
- $this->removeRestApi();
42
  }
43
 
44
- if( !is_admin() ) {
45
- if( $this->getPopulateOption('disable_feed') ) {
46
- $this->disableFeed();
47
- }
48
-
49
- if( $this->getPopulateOption('disable_dashicons') ) {
50
- add_action('wp_print_styles', array($this, 'disableDashicons'), -1);
51
- }
52
-
53
- if( $this->getPopulateOption('remove_xfn_link') ) {
54
- add_action('wp_loaded', array($this, 'htmlCompressor'));
55
- }
56
-
57
- if( $this->getPopulateOption('remove_recent_comments_style') ) {
58
- add_action('widgets_init', array($this, 'removeRecentCommentsStyle'));
59
- }
60
-
61
- /**
62
- * Priority set to 9999. Higher numbers correspond with later execution.
63
- * Hook into the style loader and remove the version information.
64
- */
65
-
66
- if( $this->getPopulateOption('remove_style_version') ) {
67
- add_filter('style_loader_src', array($this, 'hideWordpressVersionInScript'), 9999, 2);
68
- }
69
-
70
- /**
71
- * Hook into the script loader and remove the version information.
72
- */
73
-
74
- if( $this->getPopulateOption('remove_js_version') ) {
75
- add_filter('script_loader_src', array($this, 'hideWordpressVersionInScript'), 9999, 2);
76
- }
77
-
78
- $this->remove_tags_from_head();
79
- }
80
- }
81
-
82
-
83
- /**
84
- * Remove wp version from any enqueued scripts
85
- *
86
- * @param string $target_url
87
- * @return string
88
- */
89
- public function hideWordpressVersionInScript($src, $handle)
90
- {
91
- if( is_user_logged_in() and $this->getPopulateOption('disable_remove_style_version_for_auth_users', false) ) {
92
- return $src;
93
  }
94
- $filename_arr = explode('?', basename($src));
95
- $exclude_file_list = $this->getPopulateOption('remove_version_exclude', '');
96
- $exclude_files_arr = array_map('trim', explode(PHP_EOL, $exclude_file_list));
97
-
98
- if( strpos($src, 'ver=') && !in_array(str_replace('?' . $filename_arr[1], '', $src), $exclude_files_arr, true) ) {
99
- $src = remove_query_arg('ver', $src);
 
100
  }
101
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  return $src;
103
  }
104
-
105
- /**
106
- * Disable dashicons for all but the auth user
107
- */
108
- public function disableDashicons()
109
- {
110
- if( !is_admin_bar_showing() && !is_customize_preview() ) {
111
- wp_deregister_style('dashicons');
112
- }
113
  }
114
-
115
- /**
116
- * Disable the emoji's
117
- */
118
- public function disableEmojis()
119
- {
120
- remove_action('wp_head', 'print_emoji_detection_script', 7);
121
- remove_action('admin_print_scripts', 'print_emoji_detection_script');
122
- remove_action('wp_print_styles', 'print_emoji_styles');
123
- remove_action('admin_print_styles', 'print_emoji_styles');
124
- remove_filter('the_content_feed', 'wp_staticize_emoji');
125
- remove_filter('comment_text_rss', 'wp_staticize_emoji');
126
- remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
127
- add_filter('emoji_svg_url', '__return_false');
128
- add_filter('tiny_mce_plugins', array($this, 'disableEmojisTinymce'));
129
- add_filter('wp_resource_hints', array($this, 'disableEmojisRemoveDnsPrefetch'), 10, 2);
130
  }
131
-
132
- /**
133
- * Filter function used to remove the tinymce emoji plugin.
134
- *
135
- * @param array $plugins
136
- * @return array Difference betwen the two arrays
137
- */
138
- function disableEmojisTinymce($plugins)
139
- {
140
- if( is_array($plugins) ) {
141
- return array_diff($plugins, array('wpemoji'));
142
- }
143
-
144
- return array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  }
146
-
147
- /**
148
- * Remove emoji CDN hostname from DNS prefetching hints.
149
- *
150
- * @param array $urls URLs to print for resource hints.
151
- * @param string $relation_type The relation type the URLs are printed for.
152
- * @return array Difference betwen the two arrays.
153
- */
154
- function disableEmojisRemoveDnsPrefetch($urls, $relation_type)
155
- {
156
-
157
- if( 'dns-prefetch' == $relation_type ) {
158
-
159
- // Strip out any URLs referencing the WordPress.org emoji location
160
- $emoji_svg_url_bit = 'https://s.w.org/images/core/emoji/';
161
- foreach($urls as $key => $url) {
162
- if( strpos($url, $emoji_svg_url_bit) !== false ) {
163
- unset($urls[$key]);
164
- }
 
 
165
  }
166
  }
167
-
168
- return $urls;
169
  }
170
-
171
- /**
172
- * Disables the WP REST API for visitors not logged into WordPress.
173
- */
174
- public function removeRestApi()
175
- {
176
- /*
177
- Disable REST API link in HTTP headers
178
- Link: <https://example.com/wp-json/>; rel="https://api.w.org/"
179
- */
180
- remove_action('template_redirect', 'rest_output_link_header', 11);
181
-
182
- /*
183
- Disable REST API links in HTML <head>
184
- <link rel='https://api.w.org/' href='https://example.com/wp-json/' />
185
- */
186
- remove_action('wp_head', 'rest_output_link_wp_head', 10);
187
- remove_action('xmlrpc_rsd_apis', 'rest_output_rsd');
188
-
189
- /*
190
- Disable REST API
191
- */
192
- if( version_compare(get_bloginfo('version'), '4.7', '>=') ) {
193
- add_filter('rest_authentication_errors', array($this, 'disableWpRestApi'));
194
- } else {
195
- // REST API 1.x
196
- add_filter('json_enabled', '__return_false');
197
- add_filter('json_jsonp_enabled', '__return_false');
198
-
199
- // REST API 2.x
200
- add_filter('rest_enabled', '__return_false');
201
- add_filter('rest_jsonp_enabled', '__return_false');
202
- }
203
- }
204
-
205
- public function disableWpRestApi($access)
206
- {
207
- if( !is_user_logged_in() ) {
208
-
209
- $message = apply_filters('disable_wp_rest_api_error', __('REST API restricted to authenticated users.', 'clearfy'));
210
-
211
- return new WP_Error('rest_login_required', $message, array('status' => rest_authorization_required_code()));
212
- }
213
-
214
- return $access;
215
  }
216
-
217
-
218
- // todo: не работает должным образом, проверить
219
- public function removeRecentCommentsStyle()
220
- {
221
- global $wp_widget_factory;
222
 
223
- $widget_recent_comments = isset($wp_widget_factory->widgets['WP_Widget_Recent_Comments'])
224
- ? $wp_widget_factory->widgets['WP_Widget_Recent_Comments']
225
- : null;
226
 
227
- if( !empty($widget_recent_comments) ) {
228
- remove_action('wp_head', array(
229
- $wp_widget_factory->widgets['WP_Widget_Recent_Comments'],
230
- 'recent_comments_style'
231
- ));
232
- }
233
  }
234
 
235
- /**
236
- * Disable feeds
237
- */
238
- public function disableFeed()
239
- {
240
- add_action('wp_loaded', array($this, 'removeFeedLinks'));
241
- add_action('template_redirect', array($this, 'filterFeeds'), 1);
242
- add_filter('bbp_request', array($this, 'filterBbpFeeds'), 9);
243
- }
244
 
 
245
 
246
- public function removeFeedLinks()
247
- {
248
- remove_action('wp_head', 'feed_links', 2);
249
- remove_action('wp_head', 'feed_links_extra', 3);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  }
251
 
252
- public function filterFeeds()
253
- {
254
- if( !is_feed() || is_404() ) {
255
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  }
257
 
258
- $this->disabled_feed_behaviour();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  }
260
-
261
- public function disabled_feed_behaviour()
262
- {
263
- global $wp_rewrite, $wp_query;
 
 
 
 
 
 
 
 
264
 
265
- if( $this->getPopulateOption('disabled_feed_behaviour', 'redirect_301') == 'redirect_404' ) {
266
- $wp_query->is_feed = false;
267
- $wp_query->set_404();
268
- status_header(404);
269
- // Override the xml+rss header set by WP in send_headers
270
- header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
271
- } else {
272
- if( isset($_GET['feed']) ) {
273
- wp_redirect(esc_url_raw(remove_query_arg('feed')), 301);
274
- exit;
275
- }
276
-
277
- if( 'old' !== get_query_var('feed') ) { // WP redirects these anyway, and removing the query var will confuse it thoroughly
278
- set_query_var('feed', '');
279
- }
280
 
281
- redirect_canonical(); // Let WP figure out the appropriate redirect URL.
 
 
282
 
283
- // Still here? redirect_canonical failed to redirect, probably because of a filter. Try the hard way.
284
- $struct = (!is_singular() && is_comment_feed())
285
- ? $wp_rewrite->get_comment_feed_permastruct()
286
- : $wp_rewrite->get_feed_permastruct();
287
-
288
- $struct = preg_quote($struct, '#');
289
- $struct = str_replace('%feed%', '(\w+)?', $struct);
290
- $struct = preg_replace('#/+#', '/', $struct);
291
- $requested_url = (is_ssl()
292
- ? 'https://'
293
- : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
294
 
295
- $new_url = preg_replace('#' . $struct . '/?$#', '', $requested_url);
 
296
 
297
- if( $new_url !== $requested_url ) {
298
- wp_redirect($new_url, 301);
299
- exit;
 
 
 
300
  }
301
- }
302
- }
303
-
304
- /**
305
- * BBPress feed detection sourced from bbp_request_feed_trap() in BBPress Core.
306
- *
307
- * @param array $query_vars
308
- * @return array
309
- */
310
- public function filterBbpFeeds($query_vars)
311
- {
312
- // Looking at a feed
313
- if( isset($query_vars['feed']) ) {
314
 
315
- // Forum/Topic/Reply Feed
316
- if( isset($query_vars['post_type']) ) {
317
-
318
- // Matched post type
319
- $post_type = false;
320
- $post_types = array();
321
-
322
- if( function_exists('bbp_get_forum_post_type') && function_exists('bbp_get_topic_post_type') && function_exists('bbp_get_reply_post_type') ) // Post types to check
323
- {
324
- $post_types = array(
325
- bbp_get_forum_post_type(),
326
- bbp_get_topic_post_type(),
327
- bbp_get_reply_post_type(),
328
- );
329
- }
330
-
331
- // Cast query vars as array outside of foreach loop
332
- $qv_array = (array)$query_vars['post_type'];
333
-
334
- // Check if this query is for a bbPress post type
335
- foreach($post_types as $bbp_pt) {
336
- if( in_array($bbp_pt, $qv_array, true) ) {
337
- $post_type = $bbp_pt;
338
- break;
339
- }
340
- }
341
-
342
- // Looking at a bbPress post type
343
- if( !empty($post_type) ) {
344
- $this->disabled_feed_behaviour();
345
- }
346
  }
347
  }
348
-
349
- // No feed so continue on
350
- return $query_vars;
351
  }
352
 
353
- /**
354
- * Remove unused tags from head
355
- */
356
- public function remove_tags_from_head()
357
- {
358
- /*if( $this->getPopulateOption('remove_dns_prefetch') ) {
359
- remove_action('wp_head', 'wp_resource_hints', 2);
360
- }*/
361
-
362
- if( $this->getPopulateOption('remove_rsd_link') ) {
363
- remove_action('wp_head', 'rsd_link');
364
- }
365
-
366
- if( $this->getPopulateOption('remove_wlw_link') ) {
367
- remove_action('wp_head', 'wlwmanifest_link');
368
- }
369
-
370
- if( $this->getPopulateOption('remove_adjacent_posts_link') ) {
371
- remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
372
- remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
373
- }
374
-
375
- if( $this->getPopulateOption('remove_shortlink_link') ) {
376
- remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
377
- remove_action('template_redirect', 'wp_shortlink_header', 11, 0);
378
- }
379
-
380
- if( $this->getPopulateOption('remove_xfn_link') ) {
381
- add_filter('avf_profile_head_tag', array($this, 'removeXfnLink'));
382
- }
383
  }
384
-
385
- /**
386
- * For more information about XFN relationships and examples concerning their use, see the
387
- *
388
- * http://gmpg.org/xfn/
389
- * @return bool
390
- */
391
- public function removeXfnLink()
392
- {
393
- return false;
394
  }
395
-
396
- /**
397
- * Remove jQuery Migrate
398
- *
399
- * @param WP_Scripts $scripts
400
- */
401
- public function removeJqueryMigrate(&$scripts)
402
- {
403
- $scripts->remove('jquery');
404
- $scripts->add('jquery', false, array('jquery-core'), '1.12.4');
405
  }
406
 
407
- // Disable Embeds
408
- public function disableEmbeds()
409
- {
410
- global $wp, $wp_embed;
411
-
412
- $wp->public_query_vars = array_diff($wp->public_query_vars, array('embed'));
413
- remove_filter('the_content', array($wp_embed, 'autoembed'), 8);
414
-
415
- // Remove content feed filter
416
- remove_filter('the_content_feed', '_oembed_filter_feed_content');
417
-
418
- // Abort embed libraries loading
419
- remove_action('plugins_loaded', 'wp_maybe_load_embeds', 0);
420
-
421
- // No auto-embedding support
422
- add_filter('pre_option_embed_autourls', '__return_false');
423
-
424
- // Avoid oEmbed auto discovery
425
- add_filter('embed_oembed_discover', '__return_false');
426
-
427
- // Remove REST API related hooks
428
- remove_action('rest_api_init', 'wp_oembed_register_route');
429
- remove_filter('rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10);
430
-
431
- // Remove header actions
432
- remove_action('wp_head', 'wp_oembed_add_discovery_links');
433
- remove_action('wp_head', 'wp_oembed_add_host_js');
434
-
435
- remove_action('embed_head', 'enqueue_embed_scripts', 1);
436
- remove_action('embed_head', 'print_emoji_detection_script');
437
- remove_action('embed_head', 'print_embed_styles');
438
- remove_action('embed_head', 'wp_print_head_scripts', 20);
439
- remove_action('embed_head', 'wp_print_styles', 20);
440
- remove_action('embed_head', 'wp_no_robots');
441
- remove_action('embed_head', 'rel_canonical');
442
- remove_action('embed_head', 'locale_stylesheet', 30);
443
-
444
- remove_action('embed_content_meta', 'print_embed_comments_button');
445
- remove_action('embed_content_meta', 'print_embed_sharing_button');
446
-
447
- remove_action('embed_footer', 'print_embed_sharing_dialog');
448
- remove_action('embed_footer', 'print_embed_scripts');
449
- remove_action('embed_footer', 'wp_print_footer_scripts', 20);
450
-
451
- remove_filter('excerpt_more', 'wp_embed_excerpt_more', 20);
452
- remove_filter('the_excerpt_embed', 'wptexturize');
453
- remove_filter('the_excerpt_embed', 'convert_chars');
454
- remove_filter('the_excerpt_embed', 'wpautop');
455
- remove_filter('the_excerpt_embed', 'shortcode_unautop');
456
- remove_filter('the_excerpt_embed', 'wp_embed_excerpt_attachment');
457
-
458
- // Remove data and results filters
459
- remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10);
460
- remove_filter('oembed_response_data', 'get_oembed_response_data_rich', 10);
461
- remove_filter('pre_oembed_result', 'wp_filter_pre_oembed_result', 10);
462
-
463
- // WooCommerce embeds in short description
464
- remove_filter('woocommerce_short_description', 'wc_do_oembeds');
465
-
466
- add_filter('tiny_mce_plugins', array($this, 'disableEmbedsTinyMcePlugin'));
467
- add_filter('rewrite_rules_array', array($this, 'disableEmbedsRewrites'));
468
-
469
- wp_deregister_script('wp-embed');
470
  }
471
 
472
- public function disableEmbedsTinyMcePlugin($plugins)
473
- {
474
- return array_diff($plugins, array('wpembed', 'wpview'));
475
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
476
 
477
- public function disableEmbedsRewrites($rules)
478
- {
479
- $new_rules = array();
480
- foreach($rules as $rule => $rewrite) {
481
- if( false !== ($pos = strpos($rewrite, '?')) ) {
482
- $params = explode('&', substr($rewrite, $pos + 1));
483
- if( in_array('embed=true', $params) ) {
484
- continue;
485
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  }
487
- $new_rules[$rule] = $rewrite;
488
  }
489
-
490
- return $new_rules;
491
  }
492
 
493
- public function htmlCompressor()
494
- {
495
- ob_start(array($this, 'htmlCompressorMain'));
496
- }
497
-
498
- public function htmlCompressorMain($content)
499
- {
500
- $old_content = $content;
501
-
502
- if( $this->getPopulateOption('remove_xfn_link') ) {
503
- $content = preg_replace('/<link[^>]+href=(?:\'|")https?:\/\/gmpg.org\/xfn\/11(?:\'|")(?:[^>]+)?>/', '', $content);
504
-
505
- if( empty($content) ) {
506
- $content = $old_content;
507
- }
508
  }
509
-
510
- return $content;
511
  }
 
 
512
  }
 
1
  <?php
2
+ /**
3
+ * This class configures the code cleanup settings
4
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
5
+ * @copyright (c) 2017 Webraftic Ltd
6
+ * @version 1.0
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ class WCL_ConfigPerformance extends Wbcr_FactoryClearfy206_Configurate {
15
+
16
  /**
17
+ * @param WCL_Plugin $plugin
 
 
 
18
  */
19
+ public function __construct( WCL_Plugin $plugin ) {
20
+ parent::__construct( $plugin );
21
+
22
+ $this->plugin = $plugin;
23
  }
24
 
25
+ public function registerActionsAndFilters() {
26
+ if ( $this->getPopulateOption( 'disable_emoji' ) ) {
27
+ add_action( 'init', array( $this, 'disableEmojis' ) );
28
+ }
29
+
30
+ if ( $this->getPopulateOption( 'remove_jquery_migrate' ) && ! is_admin() ) {
31
+ add_filter( 'wp_default_scripts', array( $this, 'removeJqueryMigrate' ) );
32
+ }
33
+
34
+ if ( $this->getPopulateOption( 'disable_embeds' ) ) {
35
+ add_action( 'init', array( $this, 'disableEmbeds' ) );
36
+ }
37
+
38
+ if ( $this->getPopulateOption( 'disable_json_rest_api' ) ) {
39
+ $this->removeRestApi();
40
  }
41
 
42
+ if ( ! is_admin() ) {
43
+ if ( $this->getPopulateOption( 'disable_feed' ) ) {
44
+ $this->disableFeed();
 
45
  }
46
 
47
+ if ( $this->getPopulateOption( 'disable_dashicons' ) ) {
48
+ add_action( 'wp_print_styles', array( $this, 'disableDashicons' ), - 1 );
49
  }
50
 
51
+ if ( $this->getPopulateOption( 'remove_xfn_link' ) ) {
52
+ add_action( 'wp_loaded', array( $this, 'htmlCompressor' ) );
53
  }
54
 
55
+ if ( $this->getPopulateOption( 'remove_recent_comments_style' ) ) {
56
+ add_action( 'widgets_init', array( $this, 'removeRecentCommentsStyle' ) );
57
  }
58
 
59
+ /**
60
+ * Priority set to 9999. Higher numbers correspond with later execution.
61
+ * Hook into the style loader and remove the version information.
62
+ */
63
+
64
+ if ( $this->getPopulateOption( 'remove_style_version' ) ) {
65
+ add_filter( 'style_loader_src', array( $this, 'hideWordpressVersionInScript' ), 9999, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
+
68
+ /**
69
+ * Hook into the script loader and remove the version information.
70
+ */
71
+
72
+ if ( $this->getPopulateOption( 'remove_js_version' ) ) {
73
+ add_filter( 'script_loader_src', array( $this, 'hideWordpressVersionInScript' ), 9999, 2 );
74
  }
75
+
76
+ $this->remove_tags_from_head();
77
+ }
78
+ }
79
+
80
+
81
+ /**
82
+ * Remove wp version from any enqueued scripts
83
+ *
84
+ * @param string $target_url
85
+ *
86
+ * @return string
87
+ */
88
+ public function hideWordpressVersionInScript( $src, $handle ) {
89
+ if ( is_user_logged_in() and $this->getPopulateOption( 'disable_remove_style_version_for_auth_users', false ) ) {
90
  return $src;
91
  }
92
+ $filename_arr = explode( '?', basename( $src ) );
93
+ $exclude_file_list = $this->getPopulateOption( 'remove_version_exclude', '' );
94
+ $exclude_files_arr = array_map( 'trim', explode( PHP_EOL, $exclude_file_list ) );
95
+
96
+ if ( strpos( $src, 'ver=' ) && ! in_array( str_replace( '?' . $filename_arr[1], '', $src ), $exclude_files_arr, true ) ) {
97
+ $src = remove_query_arg( 'ver', $src );
 
 
 
98
  }
99
+
100
+ return $src;
101
+ }
102
+
103
+ /**
104
+ * Disable dashicons for all but the auth user
105
+ */
106
+ public function disableDashicons() {
107
+ if ( ! is_admin_bar_showing() && ! is_customize_preview() ) {
108
+ wp_deregister_style( 'dashicons' );
 
 
 
 
 
 
109
  }
110
+ }
111
+
112
+ /**
113
+ * Disable the emoji's
114
+ */
115
+ public function disableEmojis() {
116
+ remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
117
+ remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
118
+ remove_action( 'wp_print_styles', 'print_emoji_styles' );
119
+ remove_action( 'admin_print_styles', 'print_emoji_styles' );
120
+ remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
121
+ remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
122
+ remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
123
+ add_filter( 'emoji_svg_url', '__return_false' );
124
+ add_filter( 'tiny_mce_plugins', array( $this, 'disableEmojisTinymce' ) );
125
+ add_filter( 'wp_resource_hints', array( $this, 'disableEmojisRemoveDnsPrefetch' ), 10, 2 );
126
+ }
127
+
128
+ /**
129
+ * Filter function used to remove the tinymce emoji plugin.
130
+ *
131
+ * @param array $plugins
132
+ *
133
+ * @return array Difference betwen the two arrays
134
+ */
135
+ function disableEmojisTinymce( $plugins ) {
136
+ if ( is_array( $plugins ) ) {
137
+ return array_diff( $plugins, array( 'wpemoji' ) );
138
  }
139
+
140
+ return array();
141
+ }
142
+
143
+ /**
144
+ * Remove emoji CDN hostname from DNS prefetching hints.
145
+ *
146
+ * @param array $urls URLs to print for resource hints.
147
+ * @param string $relation_type The relation type the URLs are printed for.
148
+ *
149
+ * @return array Difference betwen the two arrays.
150
+ */
151
+ function disableEmojisRemoveDnsPrefetch( $urls, $relation_type ) {
152
+
153
+ if ( 'dns-prefetch' == $relation_type ) {
154
+
155
+ // Strip out any URLs referencing the WordPress.org emoji location
156
+ $emoji_svg_url_bit = 'https://s.w.org/images/core/emoji/';
157
+ foreach ( $urls as $key => $url ) {
158
+ if ( strpos( $url, $emoji_svg_url_bit ) !== false ) {
159
+ unset( $urls[ $key ] );
160
  }
161
  }
 
 
162
  }
163
+
164
+ return $urls;
165
+ }
166
+
167
+ /**
168
+ * Disables the WP REST API for visitors not logged into WordPress.
169
+ */
170
+ public function removeRestApi() {
171
+ /*
172
+ Disable REST API link in HTTP headers
173
+ Link: <https://example.com/wp-json/>; rel="https://api.w.org/"
174
+ */
175
+ remove_action( 'template_redirect', 'rest_output_link_header', 11 );
176
+
177
+ /*
178
+ Disable REST API links in HTML <head>
179
+ <link rel='https://api.w.org/' href='https://example.com/wp-json/' />
180
+ */
181
+ remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
182
+ remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' );
183
+
184
+ /*
185
+ Disable REST API
186
+ */
187
+ if ( version_compare( get_bloginfo( 'version' ), '4.7', '>=' ) ) {
188
+ add_filter( 'rest_authentication_errors', array( $this, 'disableWpRestApi' ) );
189
+ } else {
190
+ // REST API 1.x
191
+ add_filter( 'json_enabled', '__return_false' );
192
+ add_filter( 'json_jsonp_enabled', '__return_false' );
193
+
194
+ // REST API 2.x
195
+ add_filter( 'rest_enabled', '__return_false' );
196
+ add_filter( 'rest_jsonp_enabled', '__return_false' );
 
 
 
 
 
 
 
 
 
 
 
197
  }
198
+ }
199
+
200
+ public function disableWpRestApi( $access ) {
201
+ if ( ! is_user_logged_in() ) {
 
 
202
 
203
+ $message = apply_filters( 'disable_wp_rest_api_error', __( 'REST API restricted to authenticated users.', 'clearfy' ) );
 
 
204
 
205
+ return new WP_Error( 'rest_login_required', $message, array( 'status' => rest_authorization_required_code() ) );
 
 
 
 
 
206
  }
207
 
208
+ return $access;
209
+ }
210
+
211
+
212
+ // todo: не работает должным образом, проверить
213
+ public function removeRecentCommentsStyle() {
214
+ global $wp_widget_factory;
 
 
215
 
216
+ $widget_recent_comments = isset( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'] ) ? $wp_widget_factory->widgets['WP_Widget_Recent_Comments'] : null;
217
 
218
+ if ( ! empty( $widget_recent_comments ) ) {
219
+ remove_action( 'wp_head', array(
220
+ $wp_widget_factory->widgets['WP_Widget_Recent_Comments'],
221
+ 'recent_comments_style'
222
+ ) );
223
+ }
224
+ }
225
+
226
+ /**
227
+ * Disable feeds
228
+ */
229
+ public function disableFeed() {
230
+ add_action( 'wp_loaded', array( $this, 'removeFeedLinks' ) );
231
+ add_action( 'template_redirect', array( $this, 'filterFeeds' ), 1 );
232
+ add_filter( 'bbp_request', array( $this, 'filterBbpFeeds' ), 9 );
233
+ }
234
+
235
+
236
+ public function removeFeedLinks() {
237
+ remove_action( 'wp_head', 'feed_links', 2 );
238
+ remove_action( 'wp_head', 'feed_links_extra', 3 );
239
+ }
240
+
241
+ public function filterFeeds() {
242
+ if ( ! is_feed() || is_404() ) {
243
+ return;
244
  }
245
 
246
+ $this->disabled_feed_behaviour();
247
+ }
248
+
249
+ public function disabled_feed_behaviour() {
250
+ global $wp_rewrite, $wp_query;
251
+
252
+ if ( $this->getPopulateOption( 'disabled_feed_behaviour', 'redirect_301' ) == 'redirect_404' ) {
253
+ $wp_query->is_feed = false;
254
+ $wp_query->set_404();
255
+ status_header( 404 );
256
+ // Override the xml+rss header set by WP in send_headers
257
+ header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
258
+ } else {
259
+ if ( isset( $_GET['feed'] ) ) {
260
+ wp_redirect( esc_url_raw( remove_query_arg( 'feed' ) ), 301 );
261
+ exit;
262
+ }
263
+
264
+ if ( 'old' !== get_query_var( 'feed' ) ) { // WP redirects these anyway, and removing the query var will confuse it thoroughly
265
+ set_query_var( 'feed', '' );
266
  }
267
 
268
+ redirect_canonical(); // Let WP figure out the appropriate redirect URL.
269
+
270
+ // Still here? redirect_canonical failed to redirect, probably because of a filter. Try the hard way.
271
+ $struct = ( ! is_singular() && is_comment_feed() ) ? $wp_rewrite->get_comment_feed_permastruct() : $wp_rewrite->get_feed_permastruct();
272
+
273
+ $struct = preg_quote( $struct, '#' );
274
+ $struct = str_replace( '%feed%', '(\w+)?', $struct );
275
+ $struct = preg_replace( '#/+#', '/', $struct );
276
+ $requested_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
277
+
278
+ $new_url = preg_replace( '#' . $struct . '/?$#', '', $requested_url );
279
+
280
+ if ( $new_url !== $requested_url ) {
281
+ wp_redirect( $new_url, 301 );
282
+ exit;
283
+ }
284
  }
285
+ }
286
+
287
+ /**
288
+ * BBPress feed detection sourced from bbp_request_feed_trap() in BBPress Core.
289
+ *
290
+ * @param array $query_vars
291
+ *
292
+ * @return array
293
+ */
294
+ public function filterBbpFeeds( $query_vars ) {
295
+ // Looking at a feed
296
+ if ( isset( $query_vars['feed'] ) ) {
297
 
298
+ // Forum/Topic/Reply Feed
299
+ if ( isset( $query_vars['post_type'] ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
300
 
301
+ // Matched post type
302
+ $post_type = false;
303
+ $post_types = array();
304
 
305
+ if ( function_exists( 'bbp_get_forum_post_type' ) && function_exists( 'bbp_get_topic_post_type' ) && function_exists( 'bbp_get_reply_post_type' ) ) // Post types to check
306
+ {
307
+ $post_types = array(
308
+ bbp_get_forum_post_type(),
309
+ bbp_get_topic_post_type(),
310
+ bbp_get_reply_post_type(),
311
+ );
312
+ }
 
 
 
313
 
314
+ // Cast query vars as array outside of foreach loop
315
+ $qv_array = (array) $query_vars['post_type'];
316
 
317
+ // Check if this query is for a bbPress post type
318
+ foreach ( $post_types as $bbp_pt ) {
319
+ if ( in_array( $bbp_pt, $qv_array, true ) ) {
320
+ $post_type = $bbp_pt;
321
+ break;
322
+ }
323
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
324
 
325
+ // Looking at a bbPress post type
326
+ if ( ! empty( $post_type ) ) {
327
+ $this->disabled_feed_behaviour();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  }
329
  }
 
 
 
330
  }
331
 
332
+ // No feed so continue on
333
+ return $query_vars;
334
+ }
335
+
336
+ /**
337
+ * Remove unused tags from head
338
+ */
339
+ public function remove_tags_from_head() {
340
+ /*if( $this->getPopulateOption('remove_dns_prefetch') ) {
341
+ remove_action('wp_head', 'wp_resource_hints', 2);
342
+ }*/
343
+
344
+ if ( $this->getPopulateOption( 'remove_rsd_link' ) ) {
345
+ remove_action( 'wp_head', 'rsd_link' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
  }
347
+
348
+ if ( $this->getPopulateOption( 'remove_wlw_link' ) ) {
349
+ remove_action( 'wp_head', 'wlwmanifest_link' );
 
 
 
 
 
 
 
350
  }
351
+
352
+ if ( $this->getPopulateOption( 'remove_adjacent_posts_link' ) ) {
353
+ remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 );
354
+ remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
 
 
 
 
 
 
355
  }
356
 
357
+ if ( $this->getPopulateOption( 'remove_shortlink_link' ) ) {
358
+ remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
359
+ remove_action( 'template_redirect', 'wp_shortlink_header', 11, 0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  }
361
 
362
+ if ( $this->getPopulateOption( 'remove_xfn_link' ) ) {
363
+ add_filter( 'avf_profile_head_tag', array( $this, 'removeXfnLink' ) );
 
364
  }
365
+ }
366
+
367
+ /**
368
+ * For more information about XFN relationships and examples concerning their use, see the
369
+ *
370
+ * http://gmpg.org/xfn/
371
+ * @return bool
372
+ */
373
+ public function removeXfnLink() {
374
+ return false;
375
+ }
376
+
377
+ /**
378
+ * Remove jQuery Migrate
379
+ *
380
+ * @param WP_Scripts $scripts
381
+ */
382
+ public function removeJqueryMigrate( &$scripts ) {
383
+ $scripts->remove( 'jquery' );
384
+ $scripts->add( 'jquery', false, array( 'jquery-core' ), '1.12.4' );
385
+ }
386
+
387
+ // Disable Embeds
388
+ public function disableEmbeds() {
389
+ global $wp, $wp_embed;
390
 
391
+ $wp->public_query_vars = array_diff( $wp->public_query_vars, array( 'embed' ) );
392
+ remove_filter( 'the_content', array( $wp_embed, 'autoembed' ), 8 );
393
+
394
+ // Remove content feed filter
395
+ remove_filter( 'the_content_feed', '_oembed_filter_feed_content' );
396
+
397
+ // Abort embed libraries loading
398
+ remove_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 );
399
+
400
+ // No auto-embedding support
401
+ add_filter( 'pre_option_embed_autourls', '__return_false' );
402
+
403
+ // Avoid oEmbed auto discovery
404
+ add_filter( 'embed_oembed_discover', '__return_false' );
405
+
406
+ // Remove REST API related hooks
407
+ remove_action( 'rest_api_init', 'wp_oembed_register_route' );
408
+ remove_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10 );
409
+
410
+ // Remove header actions
411
+ remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
412
+ remove_action( 'wp_head', 'wp_oembed_add_host_js' );
413
+
414
+ remove_action( 'embed_head', 'enqueue_embed_scripts', 1 );
415
+ remove_action( 'embed_head', 'print_emoji_detection_script' );
416
+ remove_action( 'embed_head', 'print_embed_styles' );
417
+ remove_action( 'embed_head', 'wp_print_head_scripts', 20 );
418
+ remove_action( 'embed_head', 'wp_print_styles', 20 );
419
+ remove_action( 'embed_head', 'wp_no_robots' );
420
+ remove_action( 'embed_head', 'rel_canonical' );
421
+ remove_action( 'embed_head', 'locale_stylesheet', 30 );
422
+
423
+ remove_action( 'embed_content_meta', 'print_embed_comments_button' );
424
+ remove_action( 'embed_content_meta', 'print_embed_sharing_button' );
425
+
426
+ remove_action( 'embed_footer', 'print_embed_sharing_dialog' );
427
+ remove_action( 'embed_footer', 'print_embed_scripts' );
428
+ remove_action( 'embed_footer', 'wp_print_footer_scripts', 20 );
429
+
430
+ remove_filter( 'excerpt_more', 'wp_embed_excerpt_more', 20 );
431
+ remove_filter( 'the_excerpt_embed', 'wptexturize' );
432
+ remove_filter( 'the_excerpt_embed', 'convert_chars' );
433
+ remove_filter( 'the_excerpt_embed', 'wpautop' );
434
+ remove_filter( 'the_excerpt_embed', 'shortcode_unautop' );
435
+ remove_filter( 'the_excerpt_embed', 'wp_embed_excerpt_attachment' );
436
+
437
+ // Remove data and results filters
438
+ remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
439
+ remove_filter( 'oembed_response_data', 'get_oembed_response_data_rich', 10 );
440
+ remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 );
441
+
442
+ // WooCommerce embeds in short description
443
+ remove_filter( 'woocommerce_short_description', 'wc_do_oembeds' );
444
+
445
+ add_filter( 'tiny_mce_plugins', array( $this, 'disableEmbedsTinyMcePlugin' ) );
446
+ add_filter( 'rewrite_rules_array', array( $this, 'disableEmbedsRewrites' ) );
447
+ }
448
+
449
+ public function disableEmbedsTinyMcePlugin( $plugins ) {
450
+ return array_diff( $plugins, array( 'wpembed', 'wpview' ) );
451
+ }
452
+
453
+ public function disableEmbedsRewrites( $rules ) {
454
+ $new_rules = array();
455
+ foreach ( $rules as $rule => $rewrite ) {
456
+ if ( false !== ( $pos = strpos( $rewrite, '?' ) ) ) {
457
+ $params = explode( '&', substr( $rewrite, $pos + 1 ) );
458
+ if ( in_array( 'embed=true', $params ) ) {
459
+ continue;
460
  }
 
461
  }
462
+ $new_rules[ $rule ] = $rewrite;
 
463
  }
464
 
465
+ return $new_rules;
466
+ }
467
+
468
+ public function htmlCompressor() {
469
+ ob_start( array( $this, 'htmlCompressorMain' ) );
470
+ }
471
+
472
+ public function htmlCompressorMain( $content ) {
473
+ $old_content = $content;
474
+
475
+ if ( $this->getPopulateOption( 'remove_xfn_link' ) ) {
476
+ $content = preg_replace( '/<link[^>]+href=(?:\'|")https?:\/\/gmpg.org\/xfn\/11(?:\'|")(?:[^>]+)?>/', '', $content );
477
+
478
+ if ( empty( $content ) ) {
479
+ $content = $old_content;
480
  }
 
 
481
  }
482
+
483
+ return $content;
484
  }
485
+ }
includes/classes/class.configurate-privacy.php CHANGED
@@ -1,67 +1,79 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  /**
4
- * This class configures the code cleanup settings
5
- * @author Webcraftic <wordpress.webraftic@gmail.com>
6
- * @copyright (c) 2017 Webraftic Ltd
7
- * @version 1.0
8
  */
9
-
10
- // Exit if accessed directly
11
- if( !defined('ABSPATH') ) {
12
- exit;
13
  }
14
-
15
- class WCL_ConfigPrivacy extends Wbcr_FactoryClearfy206_Configurate {
16
-
17
- /**
18
- * @param WCL_Plugin $plugin
19
- */
20
- public function __construct(WCL_Plugin $plugin)
21
- {
22
- parent::__construct($plugin);
23
-
24
- $this->plugin = $plugin;
25
- }
26
-
27
- public function registerActionsAndFilters()
28
- {
29
- if( !is_admin() ) {
30
- if( $this->getPopulateOption('remove_meta_generator') ) {
31
- remove_action('wp_head', 'wp_generator');
32
-
33
- if( class_exists('WooCommerce') ) {
34
- remove_action('wp_head', 'woo_version');
35
- }
36
-
37
- if( class_exists('SitePress') ) {
38
- global $sitepress;
39
- remove_action('wp_head', array($sitepress, 'meta_generator_tag'));
40
- }
41
-
42
- add_filter('the_generator', '__return_empty_string');
43
  }
44
-
45
- if( $this->getPopulateOption('remove_html_comments') ) {
46
- add_action('wp_loaded', array($this, 'removeHtmlComments'));
 
47
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
  }
50
-
51
-
52
- public function removeHtmlComments()
53
- {
54
- ob_start(array($this, 'removeHtmlCommentsMain'));
55
- }
56
-
57
- /**
58
- * !ngg_resource - can not be deleted, otherwise the plugin nextgen gallery will not work
59
- * @param string $data
60
- * @return mixed
61
- */
62
- public function removeHtmlCommentsMain($data)
63
- {
64
- //CLRF-166 issue fix bug with noindex (\s?\/?noindex)
65
- return preg_replace('#<!--(?!<!|\s?ngg_resource|\s?\/?noindex)[^\[>].*?-->#s', '', $data);
66
- }
67
- }
 
1
  <?php
2
+
3
+ /**
4
+ * This class configures the code cleanup settings
5
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
6
+ * @copyright (c) 2017 Webraftic Ltd
7
+ * @version 1.0
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ class WCL_ConfigPrivacy extends Wbcr_FactoryClearfy206_Configurate {
16
 
17
  /**
18
+ * @param WCL_Plugin $plugin
 
 
 
19
  */
20
+ public function __construct( WCL_Plugin $plugin ) {
21
+ parent::__construct( $plugin );
22
+
23
+ $this->plugin = $plugin;
24
  }
25
+
26
+ public function registerActionsAndFilters() {
27
+ if ( ! is_admin() ) {
28
+ if ( $this->getPopulateOption( 'remove_meta_generator' ) ) {
29
+ remove_action( 'wp_head', 'wp_generator' );
30
+
31
+ if ( class_exists( 'WooCommerce' ) ) {
32
+ remove_action( 'wp_head', 'woo_version' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  }
34
+
35
+ if ( class_exists( 'SitePress' ) ) {
36
+ global $sitepress;
37
+ remove_action( 'wp_head', array( $sitepress, 'meta_generator_tag' ) );
38
  }
39
+
40
+ add_filter( 'the_generator', '__return_empty_string' );
41
+
42
+ // Replace <meta .* name="generator"> like tags
43
+ // which may contain versioning of
44
+ add_action( 'wp_head', function () {
45
+ ob_start( function ( $content ) {
46
+ $raw_content = $content;
47
+ $content = preg_replace( '/<meta.*name="generator".*?\/>/m', '', $content );
48
+ if ( empty( $content ) ) {
49
+ return $raw_content;
50
+ }
51
+
52
+ return $content;
53
+ } );
54
+ }, 0, 0 );
55
+ }
56
+
57
+ if ( $this->getPopulateOption( 'remove_html_comments' ) ) {
58
+ add_action( 'wp_loaded', array( $this, 'removeHtmlComments' ) );
59
  }
60
  }
61
+ }
62
+
63
+
64
+ public function removeHtmlComments() {
65
+ ob_start( array( $this, 'removeHtmlCommentsMain' ) );
66
+ }
67
+
68
+ /**
69
+ * !ngg_resource - can not be deleted, otherwise the plugin nextgen gallery will not work
70
+ *
71
+ * @param string $data
72
+ *
73
+ * @return mixed
74
+ */
75
+ public function removeHtmlCommentsMain( $data ) {
76
+ //CLRF-166 issue fix bug with noindex (\s?\/?noindex)
77
+ return preg_replace( '#<!--(?!<!|\s?ngg_resource|\s?\/?noindex)[^\[>].*?-->#s', '', $data );
78
+ }
79
+ }
includes/classes/class.licensing.php CHANGED
@@ -1,646 +1,615 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /**
3
- * Класс для работы с системой лицензирования
4
- * @author Webcraftic <jokerov@gmail.com>
5
- * @copyright (c) 2018 Webraftic Ltd
6
- * @version 1.0
7
  */
8
-
9
- // Exit if accessed directly
10
- if( !defined('ABSPATH') ) {
11
- exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  }
13
-
14
- class WCL_Licensing {
15
-
16
- /**
17
- * @var int номер плагина в сервисе freemius
18
- */
19
- private $plugin_id;
20
-
21
- /**
22
- * @var string приватный ключ плагина
23
- */
24
- private $plugin_public_key;
25
-
26
- /**
27
- * @var string slug плагина
28
- */
29
- private $plugin_slug;
30
-
31
- /**
32
- * @var string install_url - url для установки аддонов фримиус
33
- */
34
- //private $install_url = 'https://clearfy.pro/zip/zip.php';
35
-
36
- /**
37
- * @var WCL_Licensing
38
- */
39
- private static $_instance;
40
-
41
- /**
42
- * @var array хранилище данных лицензии
43
- */
44
- private $_storage = array();
45
-
46
- /**
47
- * @var WCL_FreemiusWPApi
48
- */
49
- private $_user_api;
50
-
51
- /**
52
- * @var WCL_FreemiusWPApi
53
- */
54
- private $_site_api;
55
-
56
- /**
57
- * Получение системы лицензирования
58
- *
59
- * @return WCL_Licensing
60
- */
61
- static function instance()
62
- {
63
- if( !isset(self::$_instance) ) {
64
- self::$_instance = new WCL_Licensing;
65
- }
66
-
67
- return self::$_instance;
68
- }
69
-
70
- /**
71
- * Инициализация системы лицензирования
72
- *
73
- */
74
- private function __construct()
75
- {
76
- // для того, чтобы постоянно не менять настройки фримиус. Константы определяются в конфиге
77
- $this->plugin_id = defined('WBCR_CLR_LICENSING_ID') ? WBCR_CLR_LICENSING_ID : WCL_Plugin::app()->getPluginInfoAttr('freemius_plugin_id');
78
- $this->plugin_public_key = defined('WBCR_CLR_LICENSING_KEY') ? WBCR_CLR_LICENSING_KEY : WCL_Plugin::app()->getPluginInfoAttr('freemius_public_key');
79
- $this->plugin_slug = defined('WBCR_CLR_LICENSING_SLUG') ? WBCR_CLR_LICENSING_SLUG : WCL_Plugin::app()->getPluginInfoAttr('freemius_plugin_slug');
80
-
81
- $this->_storage = new WCL_Licensing_Storage;
82
  }
83
-
84
 
85
- /**
86
- * Возвращает объект хранилища
87
- *
88
- * @return WCL_Licensing_Storage
89
- */
90
- public function getStorage()
91
- {
92
- return $this->_storage;
93
- }
94
-
95
- /**
96
- * Возвращает объект api плагина
97
- *
98
- * @return WCL_FreemiusWPApi
99
- */
100
- public function getPluginApi()
101
- {
102
- return new WCL_FreemiusWPApi('plugin', // scope
103
- $this->plugin_id, // element_id
104
- $this->plugin_public_key, //public key
105
- $this->plugin_public_key, false);
106
- }
107
-
108
- /**
109
- * Возвращает объект api аддона
110
- *
111
- * @return WCL_FreemiusWPApi
112
- */
113
- public function getAddonApi($addon)
114
- {
115
- return new WCL_FreemiusWPApi('plugin', // scope
116
- $addon->id, // element_id
117
- $addon->public_key, //public key
118
- false, false);
119
- }
120
-
121
- /**
122
- * Возвращает объект api инсталла(сайта)
123
- *
124
- * @return WCL_FreemiusWPApi
125
- */
126
- public function getSiteApi()
127
- {
128
- if( isset($this->_site_api) ) {
129
- return $this->_site_api;
130
- }
131
- $site = $this->_storage->get('site');
132
- $this->_site_api = new WCL_FreemiusWPApi('install', // scope
133
- $site->id, // element_id
134
- $site->public_key, //public key
135
- $site->secret_key, false);
136
-
137
- return $this->_site_api;
138
- }
139
-
140
- /**
141
- * Возвращает объект api юзера
142
- *
143
- * @return WCL_FreemiusWPApi
144
- */
145
- public function getUserApi()
146
- {
147
- if( isset($this->_user_api) ) {
148
- return $this->_user_api;
149
- }
150
- $user = $this->_storage->get('user');
151
- $this->_user_api = new WCL_FreemiusWPApi('user', // scope
152
- $user->id, // element_id
153
- $user->public_key, //public key
154
- $user->secret_key, false);
155
-
156
- return $this->_user_api;
157
  }
158
-
159
- /**
160
- * Деактивирует текущую лицензию
161
- */
162
- public function deactivate()
163
- {
164
- $site = $this->_storage->get('site');
165
- $current_license = $this->_storage->get('license');
166
-
167
- $api_install = $this->getSiteApi();
168
- $api_user = $this->getUserApi();
169
-
170
- $api_install->Api('/licenses/' . $current_license->id . '.json?license_key=' . $current_license->secret_key, 'DELETE');
171
- $api_user->Api('/plugins/' . $this->plugin_id . '/installs.json?ids=' . $site->id, 'DELETE');
172
-
173
- $this->_storage->delete('site');
174
- $this->_storage->delete('license');
175
- $this->_storage->save();
176
-
177
- $this->_user_api = null;
178
- $this->_site_api = null;
179
-
180
- if( wp_next_scheduled('wbcr_clearfy_license_autosync') ) {
181
- wp_clear_scheduled_hook('wbcr_clearfy_license_autosync');
182
- }
183
  }
184
 
185
- /**
186
- * Деактивирует текущую лицензию
187
- *
188
- * @return bool
189
- */
190
- public function uninstall()
191
- {
192
- $this->deactivate();
193
-
194
- return true;
195
  }
196
 
197
- /**
198
- * Синхронизирует данные текущей лицензии
199
- *
200
- * @return bool
201
- */
202
- public function sync()
203
- {
204
- $site = $this->_storage->get('site');
205
- $current_license = $this->_storage->get('license');
206
-
207
- $api_install = $this->getSiteApi();
208
- $api_user = $this->getUserApi();
209
-
210
- $license = $api_install->Api('/licenses/' . $current_license->id . '.json?license_key=' . urlencode($current_license->secret_key), 'GET');
211
- $install = $api_user->Api('/plugins/' . $this->plugin_id . '/installs.json?ids=' . $site->id, 'GET');
212
-
213
- if( $install->installs[0]->license_id !== $current_license->id ) {
214
- $this->uninstall();
215
-
216
- return true;
217
- }
218
-
219
- $subscriptions = $api_install->Api('/licenses/' . $current_license->id . '/subscriptions.json', 'GET');
220
- $plan = $api_user->Api('/plugins/' . $this->plugin_id . '/plans/' . $current_license->plan_id . '.json', 'GET');
221
- $current_license->plan_title = $plan->title;
222
-
223
- if( isset($subscriptions->subscriptions) and isset($subscriptions->subscriptions[0]) ) {
224
- if( !is_null($subscriptions->subscriptions[0]->next_payment) ) {
225
- $current_license->billing_cycle = $subscriptions->subscriptions[0]->billing_cycle;
226
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  }
228
-
229
- $current_license->sync($license);
230
- $this->_storage->set('license', $current_license);
231
- $this->_storage->save();
232
-
233
- $this->getAddons(true); // обновляем список аддонов
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
 
235
  return true;
236
  }
237
-
238
- /**
239
- * Отписывается от платной подписики на обновления
240
- *
241
- * @return WP_Error
242
- */
243
- public function unsubscribe()
244
- {
245
- $current_license = $this->_storage->get('license');
246
- $api_install = $this->getSiteApi();
247
-
248
- $subscriptions = $api_install->Api('/licenses/' . $current_license->id . '/subscriptions.json', 'GET');
249
-
250
- if( isset($subscriptions->subscriptions) and isset($subscriptions->subscriptions[0]) ) {
251
- $api_install->Api('downgrade.json', 'PUT');
252
- $current_license->billing_cycle = null;
253
- $this->_storage->set('license', $current_license);
254
- $this->_storage->save();
255
- }
256
-
257
- return true;
258
  }
259
 
260
- /**
261
- * Активирует лицензию
262
- *
263
- * @param string $license_key лицензионный ключ
264
- * @return bool
265
- */
266
- public function activate($license_key)
267
- {
268
- $current_license = $this->_storage->get('license');
269
-
270
- if( isset($current_license->id) ) {
271
- if( $current_license->secret_key == $license_key ) {
272
- $this->sync();
273
-
274
- return true;
275
- }
276
- $this->deactivate();
277
- }
278
-
279
- $url = 'https://wp.freemius.com/action/service/user/install/';
280
- $unique_id = md5(get_site_url() . SECURE_AUTH_KEY);
281
- $request_body = array(
282
- 'plugin_slug' => $this->plugin_slug,
283
- 'plugin_id' => $this->plugin_id,
284
- 'plugin_public_key' => $this->plugin_public_key,
285
- 'plugin_version' => WCL_Plugin::app()->getPluginVersion(),
286
- 'is_active' => true,
287
- 'is_premium' => true,
288
- 'format' => 'json',
289
- 'is_disconnected' => false,
290
- 'license_key' => $license_key,
291
- 'site_url' => get_home_url(), //site_uid
292
- 'site_uid' => $unique_id,
293
- 'language' => get_bloginfo('language'),
294
- 'charset' => get_bloginfo('charset'),
295
- 'platform_version' => get_bloginfo('version'),
296
- 'sdk_version' => '2.1.1',
297
- 'programming_language_version' => phpversion(),
298
- );
299
- $responce = wp_remote_post($url, array(
300
- 'body' => $request_body,
301
- 'timeout' => 15,
302
- ));
303
- if( is_wp_error($responce) ) {
304
- return new WP_Error('alert-danger', $responce->get_error_message());
305
- }
306
- if( isset($responce['response']['code']) and $responce['response']['code'] == 403 ) {
307
- return new WP_Error('alert-danger', 'http error');
308
- }
309
-
310
- $responce_data = json_decode($responce['body']);
311
- if( isset($responce_data->error) ) {
312
- return new WP_Error('alert-danger', $responce_data->error);
313
- }
314
- $user = new WCL_FS_User($responce_data);
315
- $site = new WCL_FS_Site($responce_data);
316
-
317
- $this->_storage->set('user', $user);
318
- $this->_storage->set('site', $site);
319
-
320
- $api_user = $this->getUserApi();
321
- $api_install = $this->getSiteApi();
322
-
323
- $user_licensies = $api_user->Api('/plugins/' . $this->plugin_id . '/licenses.json', 'GET');
324
-
325
- foreach($user_licensies->licenses as $user_license) {
326
- if( $user_license->secret_key == $license_key ) {
327
- $current_license = new WCL_FS_Plugin_License($user_license);
328
- }
329
- }
330
-
331
- $plan = $api_user->Api('/plugins/' . $this->plugin_id . '/plans/' . $current_license->plan_id . '.json', 'GET');
332
-
333
- $subscriptions = $api_install->Api('/licenses/' . $current_license->id . '/subscriptions.json', 'GET');
334
-
335
- $current_license->plan_title = $plan->title;
336
-
337
- if( isset($subscriptions->subscriptions) and isset($subscriptions->subscriptions[0]) ) {
338
  $current_license->billing_cycle = $subscriptions->subscriptions[0]->billing_cycle;
339
  }
340
-
341
- $this->_storage->set('license', $current_license);
342
- $this->_storage->save();
343
-
344
- if( !wp_next_scheduled('wbcr_clearfy_license_autosync') ) {
345
- wp_schedule_event(time(), 'twicedaily', 'wbcr_clearfy_license_autosync');
346
- }
347
-
348
- return true;
349
  }
350
 
351
- /**
352
- * Проверяет, не истекла ли текущая лицензия
353
- * @return bool
354
- */
355
- public function isLicenseValid()
356
- {
357
- $current_license = $this->_storage->get('license');
358
- if( !$current_license ) {
359
- return false;
360
- }
361
-
362
- return $current_license->is_valid();
 
 
 
 
 
 
 
 
 
 
 
363
  }
364
 
365
- /**
366
- * Получает аддоны плагина. Кеширует на день
367
- *
368
- * @param bool $flush_cache сбрасывает кеш
369
- * @return stdClass объект ответа с аддонами
370
- */
371
-
372
- public function getAddons($flush_cache = false)
373
- {
374
- $addons = WCL_Plugin::app()->getPopulateOption('freemius_addons', array());
375
- $addons_last_update = WCL_Plugin::app()->getPopulateOption('freemius_addons_last_update', 0);
376
 
377
- $next_update = $addons_last_update + DAY_IN_SECONDS;
378
-
379
- if( ($flush_cache or date('U') > $next_update) || defined('WCL_PLUGIN_FREEMIUS_DEBUG') && WCL_PLUGIN_FREEMIUS_DEBUG ) {
380
- $api_plugin = $this->getPluginApi();
381
- $addons = $api_plugin->Api('/addons.json?enriched=true');
382
- WCL_Plugin::app()->updatePopulateOption('freemius_addons_last_update', date('U'));
383
- if( $addons and isset($addons->plugins) ) {
384
- WCL_Plugin::app()->updatePopulateOption('freemius_addons', $addons);
385
- }
386
- }
387
-
388
- return $addons;
389
- }
390
-
391
- public function getAddonData($slug)
392
- {
393
- $freemius_addons_data = $this->getAddons();
394
- $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption('freemius_activated_addons', array());
395
- if( isset($freemius_addons_data->plugins) ) {
396
- foreach($freemius_addons_data->plugins as $freemius_addon) {
397
- if( $freemius_addon->slug == $slug ) {
398
- $addon_data = array(
399
- 'addon' => $freemius_addon,
400
- 'slug' => $freemius_addon->slug,
401
- 'is_actived' => in_array($freemius_addon->slug, $freemius_activated_addons) ? true : false,
402
- 'is_free' => $freemius_addon->free_releases_count ? true : false,
403
- 'url' => isset($freemius_addon->info) ? $freemius_addon->info->url : '#',
404
- );
405
-
406
- return $addon_data;
407
- }
408
- }
409
- }
410
-
411
- return false;
412
  }
413
 
414
- public function isActivePaidAddons()
415
- {
416
- $freemius_addons_data = $this->getAddons();
417
- $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption('freemius_activated_addons', array());
418
- if( isset($freemius_addons_data->plugins) ) {
419
- foreach($freemius_addons_data->plugins as $freemius_addon) {
420
- if( !$freemius_addon->free_releases_count ) {
421
- if( in_array($freemius_addon->slug, $freemius_activated_addons) ) {
422
- return true;
423
- }
424
- }
 
 
 
 
 
 
 
425
  }
426
  }
427
-
428
- return false;
429
  }
430
 
431
- /**
432
- * Возвращает данные аддона, полученные с сервиса фримиус
433
- *
434
- * @param string $slug слаг аддона
435
- * @return stdClass объект с описанием аддона или false
436
- */
437
- public function getFreemiusAddonData($slug)
438
- {
439
- $addons = $this->getAddons();
440
- foreach($addons->plugins as $addon) {
441
- if( $addon->slug == $slug ) {
442
- return $addon;
443
- }
444
- }
445
-
446
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
  }
448
 
449
- public function getAddonCurrentVersion($slug)
450
- {
451
- $package_plugin = WCL_Package::instance();
452
- $addon = $package_plugin->getAddon($slug);
453
- if( $addon ) {
454
- return $addon['current_version'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
455
  }
456
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
  return false;
458
  }
459
 
460
- /**
461
- * Устанавливает аддон с сервиса фримиус
462
- *
463
- * @param string $slug слаг аддона
464
- * @return bool
465
- */
466
-
467
- public function installAddon($slug)
468
- {
469
- /*
470
- $installed_addons = WCL_Plugin::app()->getPopulateOption( 'freemius_installed_addons', array() );
471
- if ( in_array( $slug, $installed_addons ) ) {
472
- return new WP_Error( 'addon_exist', 'Аддон уже установлен' );
473
-
474
- }
475
- $installed_addons[] = $slug;
476
-
477
- $components_dir = WCL_PLUGIN_DIR . '/components/';
478
- $tmp_file = $components_dir . date('U') . '.zip';
479
-
480
- $current_license = $this->_storage->get('license');
481
- $site = $this->_storage->get('site');
482
- $addons = $this->getAddons();
483
-
484
- $license_key = $current_license->secret_key;
485
- $license_id = $current_license->id;
486
- $install_id = $site->id;
487
- $addon_id = 0;
488
 
489
- foreach($addons->plugins as $freemius_addon) {
490
- if( $freemius_addon->slug == $slug ) {
491
- $addon_id = $freemius_addon->id;
492
- }
493
- }
494
- $url = $this->install_url . '?install_id=' . $install_id . '&addon_id=' . $addon_id . '&license_id=' . $license_id . '&license_key=' . urlencode($license_key);
495
- $zip = file_get_contents($url);
496
- file_put_contents($tmp_file, $zip);
497
 
498
- global $wp_filesystem;
499
- if( !$wp_filesystem ) {
500
- if( !function_exists('WP_Filesystem') ) {
501
- require_once(ABSPATH . 'wp-admin/includes/file.php');
502
- }
503
- WP_Filesystem();
504
  }
505
- $unzipped = unzip_file($tmp_file, $components_dir);
506
- unlink($tmp_file);
507
- if( $unzipped ) {
508
- // удаляем папку libs если она есть
509
- $addon_dir = $components_dir . $slug . '/';
510
- if( !is_dir($addon_dir) ) {
511
- $addon_dir = $components_dir . $slug . '-premium/';
512
- }
513
- $libs_dir = $addon_dir . 'libs/';
514
- if( is_dir($addon_dir) and is_dir($libs_dir) ) {
515
- $wp_filesystem->rmdir($libs_dir, true);
 
 
 
 
 
 
 
 
 
516
  }
517
- WCL_Plugin::app()->updatePopulateOption('freemius_installed_addons', $installed_addons);
518
- } else {
519
- return false;
520
  }
521
-
522
- */
523
-
524
- return true;
525
  }
526
 
527
- /**
528
- * Устанавливает аддон
529
- *
530
- * @param string $slug слаг аддона
531
- * @return bool
532
- */
533
-
534
- public function deleteAddon($slug)
535
- {
536
- $installed_addons = WCL_Plugin::app()->getPopulateOption('freemius_installed_addons', array());
537
- if( in_array($slug, $installed_addons) ) {
538
- /*
539
- foreach( $installed_addons as $key => $addon ) {
540
-
541
- if( $slug == $addon ) {
542
- unset($installed_addons[$key]);
543
- global $wp_filesystem;
544
- if( !$wp_filesystem ) {
545
- if( !function_exists('WP_Filesystem') ) {
546
- require_once(ABSPATH . 'wp-admin/includes/file.php');
547
- }
548
- WP_Filesystem();
549
- }
550
- $addon_dir = WCL_PLUGIN_DIR . '/components/' . $slug . '/';
551
- if( !is_dir($addon_dir) ) {
552
- $addon_dir = WCL_PLUGIN_DIR . '/components/' . $slug . '-premium/';
553
- }
554
- if( is_dir($addon_dir) ) {
555
- $wp_filesystem->rmdir($addon_dir, true);
556
- }
557
  }
558
  }
559
-
560
- */
561
- $this->deactivateAddon($slug);
562
- WCL_Plugin::app()->updatePopulateOption('freemius_installed_addons', $installed_addons);
563
  }
564
-
565
- return true;
566
  }
567
 
568
- /**
569
- * Активирует аддон
570
- *
571
- * @param string $slug слаг аддона
572
- * @return bool
573
- */
574
-
575
- public function activateAddon($slug)
576
- {
577
- $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption('freemius_activated_addons', array());
578
-
579
- if( !in_array($slug, $freemius_activated_addons) ) {
580
- $freemius_activated_addons[] = $slug;
 
 
581
  }
582
-
583
- $freemius_activated_addons = $this->filteringExistsAddons($freemius_activated_addons);
584
-
585
- //$component_info = $this->getFreemiusAddonData( $slug );
586
- do_action('wbcr_clearfy_pre_activate_component', $slug);
587
-
588
- WCL_Plugin::app()->updatePopulateOption('freemius_activated_addons', $freemius_activated_addons);
589
-
590
- //do_action( 'wbcr/clearfy/activated_component', $slug);
591
-
592
- return true;
593
  }
594
 
595
- /**
596
- * Деактивирует аддон
597
- *
598
- * @param string $slug слаг аддона
599
- * @return bool
600
- */
601
-
602
- public function deactivateAddon($slug)
603
- {
604
- $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption('freemius_activated_addons', array());
605
-
606
- if( in_array($slug, $freemius_activated_addons) ) {
607
- foreach($freemius_activated_addons as $key => $component) {
608
- if( $component == $slug ) {
609
- unset($freemius_activated_addons[$key]);
610
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
611
  }
612
  }
613
-
614
- //$component_info = $this->getFreemiusAddonData( $slug );
615
- do_action('wbcr_clearfy_pre_deactivate_component', $slug);
616
-
617
- WCL_Plugin::app()->updatePopulateOption('freemius_activated_addons', $freemius_activated_addons);
618
-
619
- do_action('wbcr_clearfy_deactivated_component', $slug);
620
-
621
- return true;
622
  }
623
 
624
- /**
625
- * Фильтрует активированные аддоны
626
- * Фильтрация нужна для того, чтобы в активированных аддонах были только те, что есть в сервисе фримиус
627
- * Старые аддоны отфильтруются и не попадут на сборку
628
- *
629
- * @param array $freemius_activated_addons активированные аддоны
630
- * @return array $freemius_activated_addons_filtered
631
- */
632
- public function filteringExistsAddons($freemius_activated_addons)
633
- {
634
- $freemius_addons = $this->getAddons();
635
- $freemius_activated_addons_filtered = array();
636
- foreach($freemius_addons->plugins as $addon) {
637
- if( in_array($addon->slug, $freemius_activated_addons) ) {
638
- $freemius_activated_addons_filtered[] = $addon->slug;
639
- }
 
 
 
 
 
 
 
 
 
640
  }
641
-
642
- return $freemius_activated_addons_filtered;
643
  }
 
 
644
  }
 
645
 
646
 
1
  <?php
2
+ /**
3
+ * Class for working with the licensing system
4
+ *
5
+ * @author Webcraftic
6
+ * Developed: Evgeniy Jokerov <jokerov@gmail.com>, Edited: Alex Kovalev <alex.kovalevv@gmail.com>
7
+ * @copyright (c) 2018 Webraftic Ltd
8
+ * @version 1.0
9
+ */
10
+
11
+ // Exit if accessed directly
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+
16
+ class WCL_Licensing {
17
+
18
  /**
19
+ * @var int plugin number in the freemius service
 
 
 
20
  */
21
+ private $plugin_id;
22
+
23
+ /**
24
+ * @var string plugin private key
25
+ */
26
+ private $plugin_public_key;
27
+
28
+ /**
29
+ * @var string plugin slug
30
+ */
31
+ private $plugin_slug;
32
+
33
+ /**
34
+ * @var string install_url - url to install addons freemius
35
+ */
36
+ //private $install_url = 'https://clearfy.pro/zip/zip.php';
37
+
38
+ /**
39
+ * @var WCL_Licensing
40
+ */
41
+ private static $_instance;
42
+
43
+ /**
44
+ * @var array license data store
45
+ */
46
+ private $storage = array();
47
+
48
+ /**
49
+ * @var WCL_FreemiusWPApi
50
+ */
51
+ private $user_api;
52
+
53
+ /**
54
+ * @var WCL_FreemiusWPApi
55
+ */
56
+ private $site_api;
57
+
58
+ /**
59
+ * Getting a licensing system
60
+ *
61
+ * @return WCL_Licensing
62
+ */
63
+ static function instance() {
64
+ if ( ! isset( self::$_instance ) ) {
65
+ self::$_instance = new WCL_Licensing;
66
+ }
67
+
68
+ return self::$_instance;
69
  }
70
+
71
+ /**
72
+ * Initialization of the licensing system
73
+ *
74
+ */
75
+ private function __construct() {
76
+
77
+ $this->plugin_id = defined( 'WBCR_CLR_LICENSING_ID' ) ? WBCR_CLR_LICENSING_ID : WCL_Plugin::app()->getPluginInfoAttr( 'freemius_plugin_id' );
78
+ $this->plugin_public_key = defined( 'WBCR_CLR_LICENSING_KEY' ) ? WBCR_CLR_LICENSING_KEY : WCL_Plugin::app()->getPluginInfoAttr( 'freemius_public_key' );
79
+ $this->plugin_slug = defined( 'WBCR_CLR_LICENSING_SLUG' ) ? WBCR_CLR_LICENSING_SLUG : WCL_Plugin::app()->getPluginInfoAttr( 'freemius_plugin_slug' );
80
+
81
+ $this->storage = new WCL_Licensing_Storage;
82
+ }
83
+
84
+
85
+ /**
86
+ * Returns a storage object
87
+ *
88
+ * @return WCL_Licensing_Storage
89
+ */
90
+ public function getStorage() {
91
+ return $this->storage;
92
+ }
93
+
94
+ /**
95
+ * Returns the plugin api object
96
+ *
97
+ * @return WCL_FreemiusWPApi
98
+ */
99
+ public function getPluginApi() {
100
+ return new WCL_FreemiusWPApi( 'plugin', // scope
101
+ $this->plugin_id, // element_id
102
+ $this->plugin_public_key, //public key
103
+ $this->plugin_public_key, false );
104
+ }
105
+
106
+ /**
107
+ * Returns addi api object
108
+ *
109
+ * @return WCL_FreemiusWPApi
110
+ */
111
+ public function getAddonApi( $addon ) {
112
+ return new WCL_FreemiusWPApi( 'plugin', // scope
113
+ $addon->id, // element_id
114
+ $addon->public_key, //public key
115
+ false, false );
116
+ }
117
+
118
+ /**
119
+ * Returns the api object of the installer
120
+ *
121
+ * @return WCL_FreemiusWPApi
122
+ * @throws \WCL\LicenseException
123
+ */
124
+ public function getSiteApi() {
125
+
126
+ if ( isset( $this->site_api ) ) {
127
+ return $this->site_api;
 
 
 
 
 
 
 
 
 
 
 
128
  }
 
129
 
130
+ $site = $this->storage->getSite();
131
+
132
+ if ( ! $site || empty( $site ) ) {
133
+ $this->storage->flush();
134
+ throw new WCL\LicenseException( 'Information about the site does not exist.' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  }
136
+
137
+ $this->site_api = new WCL_FreemiusWPApi( 'install', // scope
138
+ $site->site_id, // element_id
139
+ $site->public_key, //public key
140
+ $site->secret_key, false );
141
+
142
+ return $this->site_api;
143
+ }
144
+
145
+ /**
146
+ * Returns the user api object
147
+ *
148
+ * @return WCL_FreemiusWPApi
149
+ * @throws \WCL\LicenseException
150
+ */
151
+ public function getUserApi() {
152
+ if ( isset( $this->user_api ) ) {
153
+ return $this->user_api;
 
 
 
 
 
 
 
154
  }
155
 
156
+ $user = $this->storage->getUser();
157
+
158
+ if ( ! $user || empty( $user ) ) {
159
+ $this->storage->flush();
160
+ throw new WCL\LicenseException( 'Information about the user does not exist.' );
 
 
 
 
 
161
  }
162
 
163
+ $this->user_api = new WCL_FreemiusWPApi( 'user', // scope
164
+ $user->id, // element_id
165
+ $user->public_key, //public key
166
+ $user->secret_key, false );
167
+
168
+ return $this->user_api;
169
+ }
170
+
171
+ /**
172
+ * Deactivates current license
173
+ *
174
+ * @throws \WCL\LicenseException
175
+ * @return bool
176
+ */
177
+ public function deactivate() {
178
+ $site = $this->storage->getSite();
179
+ $current_license = $this->storage->getLicense();
180
+
181
+ if ( ! $current_license || empty( $current_license->id ) ) {
182
+ return false;
183
+ }
184
+
185
+ $license = $this->getSiteApi()->Api( '/licenses/' . $current_license->id . '.json?license_key=' . $current_license->secret_key, 'DELETE' );
186
+
187
+ if ( isset( $license->error ) ) {
188
+ throw new WCL\LicenseException( $license->error->message );
189
+ }
190
+
191
+ $install = $this->getUserApi()->Api( '/plugins/' . $this->plugin_id . '/installs.json?ids=' . $site->site_id, 'DELETE' );
192
+
193
+ if ( isset( $install->error ) ) {
194
+ throw new WCL\LicenseException( $install->error->message );
195
+ }
196
+
197
+ $this->storage->flush();
198
+
199
+ $this->user_api = null;
200
+ $this->site_api = null;
201
+
202
+ if ( wp_next_scheduled( 'wbcr_clearfy_license_autosync' ) ) {
203
+ wp_clear_scheduled_hook( 'wbcr_clearfy_license_autosync' );
204
+ }
205
+
206
+ return true;
207
+ }
208
+
209
+ /**
210
+ * @return bool
211
+ * @throws \WCL\LicenseException
212
+ */
213
+ public function uninstall() {
214
+ try {
215
+ if ( ! $this->deactivate() ) {
216
+ return false;
217
  }
218
+ } catch( WCL\LicenseException $e ) {
219
+ throw new WCL\LicenseException( $e->getMessage() );
220
+ }
221
+
222
+ return true;
223
+ }
224
+
225
+ /**
226
+ * Synchronizes current license data
227
+ *
228
+ * @return bool
229
+ * @throws \WCL\LicenseException
230
+ */
231
+ public function sync() {
232
+ $current_license = $this->storage->getLicense();
233
+
234
+ if ( ! $current_license || empty( $current_license->id ) ) {
235
+ return false;
236
+ }
237
+
238
+ $site = $this->storage->getSite();
239
+
240
+ $api_install = $this->getSiteApi();
241
+ $api_user = $this->getUserApi();
242
+
243
+ $license = $api_install->Api( '/licenses/' . $current_license->id . '.json?license_key=' . urlencode( $current_license->secret_key ), 'GET' );
244
+
245
+ if ( isset( $license->error ) ) {
246
+ throw new WCL\LicenseException( $license->error->message );
247
+ }
248
+
249
+ $install = $api_user->Api( '/plugins/' . $this->plugin_id . '/installs.json?ids=' . $site->site_id, 'GET' );
250
+
251
+ if ( isset( $install->error ) ) {
252
+ throw new WCL\LicenseException( $install->error->message );
253
+ }
254
+
255
+ if ( $install->installs[0]->license_id !== $current_license->id ) {
256
+ $this->uninstall();
257
 
258
  return true;
259
  }
260
+
261
+ $subscriptions = $api_install->Api( '/licenses/' . $current_license->id . '/subscriptions.json', 'GET' );
262
+
263
+ if ( isset( $subscriptions->error ) ) {
264
+ throw new WCL\LicenseException( $subscriptions->error->message );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  }
266
 
267
+ $plan = $api_user->Api( '/plugins/' . $this->plugin_id . '/plans/' . $current_license->plan_id . '.json', 'GET' );
268
+
269
+ if ( isset( $plan->error ) ) {
270
+ throw new WCL\LicenseException( $plan->error->message );
271
+ }
272
+
273
+ $current_license->plan_title = $plan->title;
274
+
275
+ if ( isset( $subscriptions->subscriptions ) and isset( $subscriptions->subscriptions[0] ) ) {
276
+ if ( ! is_null( $subscriptions->subscriptions[0]->next_payment ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  $current_license->billing_cycle = $subscriptions->subscriptions[0]->billing_cycle;
278
  }
 
 
 
 
 
 
 
 
 
279
  }
280
 
281
+ $current_license->sync( $license );
282
+
283
+ $this->storage->setLicense( $current_license );
284
+ $this->storage->save();
285
+
286
+ $this->getAddons( true );
287
+
288
+ return true;
289
+ }
290
+
291
+ /**
292
+ * Unsubscribes from a paid subscription to updates
293
+ *
294
+ * @return bool
295
+ * @throws \WCL\LicenseException
296
+ */
297
+ public function unsubscribe() {
298
+ $current_license = $this->storage->getLicense();
299
+
300
+ try {
301
+ $api_install = $this->getSiteApi();
302
+ } catch( WCL\LicenseException $e ) {
303
+ throw new WCL\LicenseException( $e->getMessage() );
304
  }
305
 
306
+ $subscriptions = $api_install->Api( '/licenses/' . $current_license->id . '/subscriptions.json', 'GET' );
307
+
308
+ if ( isset( $subscriptions->subscriptions ) and isset( $subscriptions->subscriptions[0] ) ) {
309
+ $api_install->Api( 'downgrade.json', 'PUT' );
310
+ $current_license->billing_cycle = null;
 
 
 
 
 
 
311
 
312
+ $this->storage->setLicense( $current_license );
313
+ $this->storage->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  }
315
 
316
+ return true;
317
+ }
318
+
319
+ /**
320
+ * Activates the license
321
+ *
322
+ * @param string $license_key license key
323
+ *
324
+ * @return bool
325
+ * @throws WCL\LicenseException
326
+ */
327
+ public function activate( $license_key ) {
328
+ $current_license = $this->storage->getLicense();
329
+
330
+ if ( $current_license && ! empty( $current_license->secret_key ) ) {
331
+ if ( $current_license->secret_key == $license_key ) {
332
+ if ( $this->sync() ) {
333
+ return true;
334
  }
335
  }
336
+ $this->deactivate();
 
337
  }
338
 
339
+ $url = 'https://wp.freemius.com/action/service/user/install/';
340
+ $unique_id = md5( get_site_url() . SECURE_AUTH_KEY );
341
+ $request_body = array(
342
+ 'plugin_slug' => $this->plugin_slug,
343
+ 'plugin_id' => $this->plugin_id,
344
+ 'plugin_public_key' => $this->plugin_public_key,
345
+ 'plugin_version' => WCL_Plugin::app()->getPluginVersion(),
346
+ 'is_active' => true,
347
+ 'is_premium' => true,
348
+ 'format' => 'json',
349
+ 'is_disconnected' => false,
350
+ 'license_key' => $license_key,
351
+ 'site_url' => get_home_url(), //site_uid
352
+ 'site_uid' => $unique_id,
353
+ 'language' => get_bloginfo( 'language' ),
354
+ 'charset' => get_bloginfo( 'charset' ),
355
+ 'platform_version' => get_bloginfo( 'version' ),
356
+ 'sdk_version' => '2.1.1',
357
+ 'programming_language_version' => phpversion(),
358
+ );
359
+
360
+ $responce = wp_remote_post( $url, array(
361
+ 'body' => $request_body,
362
+ 'timeout' => 15,
363
+ ) );
364
+
365
+ if ( is_wp_error( $responce ) ) {
366
+ throw new WCL\LicenseException( $responce->get_error_message(), 'alert-danger' );
367
+ }
368
+
369
+ if ( isset( $responce['response']['code'] ) and $responce['response']['code'] == 403 ) {
370
+ throw new WCL\LicenseException( 'Freemius 403 error.', 'alert-danger' );
371
  }
372
 
373
+ $responce_data = json_decode( $responce['body'] );
374
+
375
+ if ( isset( $responce_data->error ) ) {
376
+ throw new WCL\LicenseException( $responce_data->error );
377
+ }
378
+
379
+ $user = new WCL_FS_User( $responce_data );
380
+ $site = new WCL_FS_Site( $responce_data );
381
+
382
+ $this->storage->setUser( $user );
383
+ $this->storage->setSite( $site );
384
+
385
+ $api_user = $this->getUserApi();
386
+ $api_install = $this->getSiteApi();
387
+
388
+ $user_licensies = $api_user->Api( '/plugins/' . $this->plugin_id . '/licenses.json', 'GET' );
389
+
390
+ if ( isset( $user_licensies->error ) ) {
391
+ throw new WCL\LicenseException( $user_licensies->error->message );
392
+ }
393
+
394
+ foreach ( $user_licensies->licenses as $user_license ) {
395
+ if ( $user_license->secret_key == $license_key ) {
396
+ $current_license = new WCL_FS_Plugin_License( $user_license );
397
  }
398
+ }
399
+
400
+ if ( ! $current_license ) {
401
+ throw new WCL\LicenseException( 'Unknown error. The license key is not registered for the current user.' );
402
+ }
403
+
404
+ $plan = $api_user->Api( '/plugins/' . $this->plugin_id . '/plans/' . $current_license->plan_id . '.json', 'GET' );
405
+
406
+ if ( isset( $plan->error ) ) {
407
+ throw new WCL\LicenseException( $plan->error->message );
408
+ }
409
+
410
+ $subscriptions = $api_install->Api( '/licenses/' . $current_license->id . '/subscriptions.json', 'GET' );
411
+
412
+ if ( isset( $subscriptions->error ) ) {
413
+ throw new WCL\LicenseException( $subscriptions->error->message );
414
+ }
415
+
416
+ $current_license->plan_title = $plan->title;
417
+
418
+ if ( isset( $subscriptions->subscriptions ) and isset( $subscriptions->subscriptions[0] ) ) {
419
+ $current_license->billing_cycle = $subscriptions->subscriptions[0]->billing_cycle;
420
+ }
421
+
422
+ $this->storage->setLicense( $current_license );
423
+ $this->storage->save();
424
+
425
+ if ( ! wp_next_scheduled( 'wbcr_clearfy_license_autosync' ) ) {
426
+ wp_schedule_event( time(), 'twicedaily', 'wbcr_clearfy_license_autosync' );
427
+ }
428
+
429
+ return true;
430
+ }
431
+
432
+ /**
433
+ * Checks if current license has expired
434
+ * @return bool
435
+ */
436
+ public function isLicenseValid() {
437
+ $current_license = $this->storage->getLicense();
438
+
439
+ if ( ! $current_license || ! isset( $current_license->id ) ) {
440
  return false;
441
  }
442
 
443
+ return $current_license->is_valid();
444
+ }
445
+
446
+ /**
447
+ * Gets plugin addons. Caches for a day
448
+ *
449
+ * @param bool $flush_cache if true, creates a request to bypass the cache
450
+ *
451
+ * @return stdClass addons list
452
+ */
453
+
454
+ public function getAddons( $flush_cache = false ) {
455
+ $addons = WCL_Plugin::app()->getPopulateOption( 'freemius_addons', array() );
456
+ $addons_last_update = WCL_Plugin::app()->getPopulateOption( 'freemius_addons_last_update', 0 );
457
+
458
+ $next_update = $addons_last_update + DAY_IN_SECONDS;
459
+
460
+ if ( ( $flush_cache or date( 'U' ) > $next_update ) || defined( 'WCL_PLUGIN_FREEMIUS_DEBUG' ) && WCL_PLUGIN_FREEMIUS_DEBUG ) {
461
+ $api_plugin = $this->getPluginApi();
462
+ $addons = $api_plugin->Api( '/addons.json?enriched=true' );
 
 
 
 
 
 
 
 
463
 
464
+ WCL_Plugin::app()->updatePopulateOption( 'freemius_addons_last_update', date( 'U' ) );
 
 
 
 
 
 
 
465
 
466
+ if ( $addons and isset( $addons->plugins ) ) {
467
+ WCL_Plugin::app()->updatePopulateOption( 'freemius_addons', $addons );
 
 
 
 
468
  }
469
+ }
470
+
471
+ return $addons;
472
+ }
473
+
474
+ public function getAddonData( $slug ) {
475
+ $freemius_addons_data = $this->getAddons();
476
+ $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption( 'freemius_activated_addons', array() );
477
+ if ( isset( $freemius_addons_data->plugins ) ) {
478
+ foreach ( $freemius_addons_data->plugins as $freemius_addon ) {
479
+ if ( $freemius_addon->slug == $slug ) {
480
+ $addon_data = array(
481
+ 'addon' => $freemius_addon,
482
+ 'slug' => $freemius_addon->slug,
483
+ 'is_actived' => in_array( $freemius_addon->slug, $freemius_activated_addons ) ? true : false,
484
+ 'is_free' => $freemius_addon->free_releases_count ? true : false,
485
+ 'url' => isset( $freemius_addon->info ) ? $freemius_addon->info->url : '#',
486
+ );
487
+
488
+ return $addon_data;
489
  }
 
 
 
490
  }
 
 
 
 
491
  }
492
 
493
+ return false;
494
+ }
495
+
496
+ public function isActivePaidAddons() {
497
+ $freemius_addons_data = $this->getAddons();
498
+ $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption( 'freemius_activated_addons', array() );
499
+ if ( isset( $freemius_addons_data->plugins ) ) {
500
+ foreach ( $freemius_addons_data->plugins as $freemius_addon ) {
501
+ if ( ! $freemius_addon->free_releases_count ) {
502
+ if ( in_array( $freemius_addon->slug, $freemius_activated_addons ) ) {
503
+ return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  }
505
  }
 
 
 
 
506
  }
 
 
507
  }
508
 
509
+ return false;
510
+ }
511
+
512
+ /**
513
+ * Returns addon data received from freemus service
514
+ *
515
+ * @param string $slug addon slug
516
+ *
517
+ * @return stdClass|bool object with addon description or false
518
+ */
519
+ public function getFreemiusAddonData( $slug ) {
520
+ $addons = $this->getAddons();
521
+ foreach ( $addons->plugins as $addon ) {
522
+ if ( $addon->slug == $slug ) {
523
+ return $addon;
524
  }
 
 
 
 
 
 
 
 
 
 
 
525
  }
526
 
527
+ return false;
528
+ }
529
+
530
+ public function getAddonCurrentVersion( $slug ) {
531
+ $package_plugin = WCL_Package::instance();
532
+ $addon = $package_plugin->getAddon( $slug );
533
+ if ( $addon ) {
534
+ return $addon['current_version'];
535
+ }
536
+
537
+ return false;
538
+ }
539
+
540
+ /**
541
+ * Activates addon
542
+ *
543
+ * @param string $slug addon slug
544
+ *
545
+ * @return bool
546
+ */
547
+
548
+ public function activateAddon( $slug ) {
549
+ $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption( 'freemius_activated_addons', array() );
550
+
551
+ if ( ! in_array( $slug, $freemius_activated_addons ) ) {
552
+ $freemius_activated_addons[] = $slug;
553
+ }
554
+
555
+ $freemius_activated_addons = $this->filteringExistsAddons( $freemius_activated_addons );
556
+
557
+ do_action( 'wbcr_clearfy_pre_activate_component', $slug );
558
+
559
+ WCL_Plugin::app()->updatePopulateOption( 'freemius_activated_addons', $freemius_activated_addons );
560
+
561
+ return true;
562
+ }
563
+
564
+ /**
565
+ * Deactivates addon
566
+ *
567
+ * @param string $slug add-on slug
568
+ *
569
+ * @return bool
570
+ */
571
+
572
+ public function deactivateAddon( $slug ) {
573
+ $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption( 'freemius_activated_addons', array() );
574
+
575
+ if ( in_array( $slug, $freemius_activated_addons ) ) {
576
+ foreach ( $freemius_activated_addons as $key => $component ) {
577
+ if ( $component == $slug ) {
578
+ unset( $freemius_activated_addons[ $key ] );
579
  }
580
  }
 
 
 
 
 
 
 
 
 
581
  }
582
 
583
+ do_action( 'wbcr_clearfy_pre_deactivate_component', $slug );
584
+
585
+ WCL_Plugin::app()->updatePopulateOption( 'freemius_activated_addons', $freemius_activated_addons );
586
+
587
+ do_action( 'wbcr_clearfy_deactivated_component', $slug );
588
+
589
+ return true;
590
+ }
591
+
592
+ /**
593
+ * Filters activated add-ons
594
+ * Filtering is needed to ensure that in activated add-ons there are only those that are in the service of Freemius
595
+ * Old add-ons will be filtered and will not fall on the assembly.
596
+ *
597
+ * @param array $freemius_activated_addons активированные аддоны
598
+ *
599
+ * @return array $freemius_activated_addons_filtered
600
+ */
601
+ public function filteringExistsAddons( $freemius_activated_addons ) {
602
+ $freemius_addons = $this->getAddons();
603
+ $freemius_activated_addons_filtered = array();
604
+
605
+ foreach ( $freemius_addons->plugins as $addon ) {
606
+ if ( in_array( $addon->slug, $freemius_activated_addons ) ) {
607
+ $freemius_activated_addons_filtered[] = $addon->slug;
608
  }
 
 
609
  }
610
+
611
+ return $freemius_activated_addons_filtered;
612
  }
613
+ }
614
 
615
 
includes/classes/class.package.php CHANGED
@@ -1,328 +1,310 @@
1
  <?php
2
 
3
- class WCL_Package {
4
-
5
- private static $instance = null;
6
- private $packages = array();
7
-
8
- private $is_need_update_addons = false;
9
-
10
- private $plugin_slug = 'clearfy-package';
11
-
12
- private $plugin_dir = 'clearfy_package';
13
-
14
- private $plugin_basename = ''; // заполняется в конструкторе
15
-
16
- private $builder_url = 'https://clearfy.pro/package/';
17
-
18
- public static function instance()
19
- {
20
- if( null === self::$instance ) {
21
- self::$instance = new self();
22
- }
23
-
24
- return self::$instance;
25
  }
26
-
27
- private function __clone()
28
- {
 
 
 
 
 
 
 
 
29
  }
30
-
31
- private function __construct()
32
- {
33
- $this->plugin_basename = $this->plugin_dir . '/' . $this->plugin_slug . '.php';
34
- if( !function_exists('is_plugin_active_for_network') ) {
35
- require_once(ABSPATH . '/wp-admin/includes/plugin.php');
36
- }
 
 
 
 
 
37
  }
38
-
39
- public function info()
40
- {
41
- return array(
42
- 'plugin_basename' => $this->plugin_basename,
43
- 'plugin_slug' => $this->plugin_basename,
44
- );
45
  }
46
-
47
- public function add($packages = array())
48
- {
49
- if( !$packages ) {
50
- return false;
51
- }
52
- foreach($packages as $package) {
53
- $key = $package['slug'];
54
- $this->packages[$key] = $package;
 
 
55
  }
56
  }
57
-
58
- public function getAll()
59
- {
60
- return $this->packages;
 
 
 
61
  }
62
-
63
- public function getSlugs()
64
- {
65
- $slugs = array();
66
- if( $this->packages ) {
67
- foreach($this->packages as $package) {
68
- $slugs[] = $package['slug'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  }
70
  }
71
-
72
- return $slugs;
73
- }
74
-
75
- public function getAddon($slug)
76
- {
77
- if( isset($this->packages[$slug]) ) {
78
- return $this->packages[$slug];
79
  }
80
-
81
- return false;
82
- }
83
-
84
- public function isActive()
85
- {
86
- return is_plugin_active($this->plugin_basename);
87
  }
88
-
89
- public function isInstalled()
90
- {
91
- if( file_exists(WP_PLUGIN_DIR . '/' . $this->plugin_basename) ) {
92
- return true;
 
 
 
 
 
 
93
  }
94
-
95
- return false;
96
- }
97
-
98
- /**
99
- * Метод проверяет, нужно ли обновлять сами аддоны
100
- *
101
- * @return bool
102
- */
103
- public function isNeedUpdateAddons()
104
- {
105
- return $this->is_need_update_addons;
106
  }
107
-
108
- /**
109
- * Метод проверяет, нужно ли обновлять весь пакет в целом.
110
- * Пакет может быть обновлен по двум причинам:
111
- * 1) Активирован аддон, которого ещё нет в пакете(или пакет не установлен)
112
- * 2) Для аддонов проявились новые версии
113
- *
114
- * @return bool
115
- */
116
- public function isNeedUpdate()
117
- {
118
- $need_update_package = false;
119
- $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption('freemius_activated_addons', array());
120
-
121
- if( $this->isActive() ) {
122
- // если плагин clearfy-package установлен, то проверяем в нём наличие фримиус аддонов
123
- $addons = $this->getAll();
124
- $licensing = WCL_Licensing::instance();
125
- $freemius_addons_data = $licensing->getAddons();
126
- foreach($freemius_activated_addons as $freemius_active_addon) {
127
- if( isset($addons[$freemius_active_addon]) ) {
128
- // проверяем, актуальна ли версия аддона
129
- foreach($freemius_addons_data->plugins as $freemius_addon) {
130
- if( $freemius_addon->slug != $freemius_active_addon ) {
131
- continue;
132
- }
133
- // если во фримиусе не указана версия, то делаем её равной текущей версии аддона. Для того, чтобы уведомление об обновлении вечно не висело.
134
- $actual_version = isset($freemius_addon->info) ? $freemius_addon->info->selling_point_0 : '';
135
- if( !$actual_version ) {
136
- $actual_version = $addons[$freemius_active_addon]['current_version'];
137
- }
138
- if( version_compare($actual_version, $addons[$freemius_active_addon]['current_version'], '>') ) {
139
- $this->is_need_update_addons = true;
140
- $need_update_package = true;
141
- }
142
- }
143
- } else {
144
- $need_update_package = true;
145
- }
146
- }
147
  } else {
148
- // если плагин clearfy-package НЕ установлен, то любая активация фримиус аддона требует обновления пакета
149
- if( count($freemius_activated_addons) ) {
150
- $need_update_package = true;
151
- }
152
  }
153
-
154
- return $need_update_package;
155
  }
156
-
157
- public function active()
158
- {
159
- // если плагин установлен и не активирован, то активируем
160
- if( $this->isInstalled() and !$this->isActive() ) {
161
- if( WCL_Plugin::app()->isNetworkActive() ) {
162
- activate_plugin($this->plugin_basename, '', true);
163
- } else {
164
- activate_plugin($this->plugin_basename);
 
 
 
165
  }
166
  }
167
  }
168
-
169
- public function deactive()
170
- {
171
- // если плагин установлен и не активирован, то активируем
172
- if( $this->isInstalled() and $this->isActive() ) {
173
- if( WCL_Plugin::app()->isNetworkActive() ) {
174
- deactivate_plugins($this->plugin_basename, false, true);
175
- } else {
176
- deactivate_plugins($this->plugin_basename);
177
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
 
179
  }
180
-
181
- public function downloadUrl()
182
- {
183
- $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption('freemius_activated_addons', array());
184
- $licensing = WCL_Licensing::instance();
185
- $package_slugs = array();
186
-
187
- if( $this->isActive() ) {
188
- $package_slugs = $this->getSlugs();
189
- foreach($freemius_activated_addons as $freemius_addon) {
190
- if( !in_array($freemius_addon, $package_slugs) ) {
191
- $package_slugs[] = $freemius_addon;
192
- }
193
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  }
195
- if( !$package_slugs ) {
196
- $package_slugs = $freemius_activated_addons;
 
197
  }
198
- //$package_slugs[] = 'test-addon'; // для тестирования ошибки. Сборщик не отдаст архив
199
- $url = $this->builder_url . 'assembly-package.php?addons=' . join(',', $package_slugs);
200
- if( $licensing->isLicenseValid() ) {
201
- $storage = $licensing->getStorage();
202
- $license = $storage->get('license');
203
- $site = $storage->get('site');
204
- $license_id = isset($license->id) ? $license->id : '';
205
- $license_key = isset($license->secret_key) ? $license->secret_key : '';
206
- $install_id = isset($site->id) ? $site->id : '';
207
- $url .= '&license_id=' . $license_id . '&license_key=' . urlencode($license_key) . '&install_id=' . $install_id;
208
  }
209
-
210
- return $url;
211
  }
212
-
213
- /**
214
- * @return array|bool|false|WP_Error
215
- * @throws Exception
216
- */
217
- public function update()
218
- {
219
- global $wp_filesystem;
220
-
221
- if( !WCL_Plugin::app()->currentUserCan() ) {
222
- return new WP_Error('addon_install_error', __('Sorry, you are not allowed to install plugins on this site.'));
223
- }
224
-
225
- $url = $this->downloadUrl();
226
-
227
- if( !$wp_filesystem ) {
228
- if( !function_exists('WP_Filesystem') ) {
229
- require_once(ABSPATH . 'wp-admin/includes/file.php');
230
- }
231
- WP_Filesystem();
232
- }
233
-
234
- if( !WP_Filesystem(false, WP_PLUGIN_DIR) ) {
235
- throw new Exception('You are not allowed to edt folders/files on this site');
236
  } else {
237
- ob_start();
238
-
239
- require_once(ABSPATH . 'wp-admin/includes/file.php');
240
- require_once(ABSPATH . 'wp-admin/includes/misc.php');
241
- require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
242
- require_once(WCL_PLUGIN_DIR . '/admin/includes/classes/class.upgrader-skin.php');
243
- require_once(WCL_PLUGIN_DIR . '/admin/includes/classes/class.upgrader.php');
244
-
245
- add_filter('async_update_translation', '__return_false', 1);
246
-
247
- $upgrader = new WCL_Plugin_Upgrader(new WCL_Upgrader_Skin);
248
-
249
- if( $this->isInstalled() ) {
250
- $result = $upgrader->run(array(
251
- 'package' => $url,
252
- 'destination' => WP_PLUGIN_DIR,
253
- 'clear_destination' => true,
254
- 'clear_working' => true,
255
- 'hook_extra' => array(
256
- 'plugin' => $this->plugin_basename,
257
- 'type' => 'plugin',
258
- 'action' => 'update',
259
- ),
260
- ));
261
- } else {
262
- $result = $upgrader->install($url);
263
- }
264
-
265
- if( is_wp_error($result) ) {
266
- return $result;
267
- }
268
-
269
- $this->active();
270
-
271
- ob_end_clean();
272
-
273
- if( null === $result ) {
274
- return new WP_Error('addon_install_error', 'An unknown error occurred during the delivery of the component package. Please report this problem to our support team <b>wordpress.webraftic@gmail.com</b>'); // пока думаю как получать сообщение об ошибке с сервера
275
- }
276
-
277
- return $result;
278
  }
 
 
 
 
 
279
  }
280
-
281
- public function getUpdateNotice()
282
- {
283
- $need_update_package = $this->isNeedUpdate();
284
- $message = '';
285
- if( $need_update_package ) {
286
- if( $this->isNeedUpdateAddons() ) {
287
- // доступны обновления компонентов
288
- $message = __('Updates are available for one of the components. Please, update your current package of components to the newest version.', 'clearfy');
289
- } else {
290
- // нужно обновить весь пакет
291
- $message = __('You’ve changed the component configuration. For the further work, please, update the current package of components!', 'clearfy');
292
- }
293
- //$message .= ' <a href="'.admin_url('admin-ajax.php?action=wbcr-clearfy-update-package&_wpnonce=' . wp_create_nonce( 'package' )).'">' . __( 'Update', 'clearfy' ) . '</a>';
294
-
295
- $message .= ' <button class="wbcr-clr-update-package button button-default" type="button" data-wpnonce="' . wp_create_nonce('package') . '" data-loading="' . __('Update in progress...', 'clearfy') . '">' . __('Update now', 'clearfy') . '</button>';
296
-
297
- return $message;
298
  }
299
-
300
- return false;
301
- }
302
-
303
- public function getActivedAddons()
304
- {
305
- $addons = array();
306
- if( $this->isInstalled() ) {
307
- $package_dir = WP_PLUGIN_DIR . '/' . $this->plugin_dir;
308
- $package_config = $package_dir . '/config.php';
309
- if( file_exists($package_config) ) {
310
- $packages = require($package_config);
311
- $this->add($packages);
312
- }
313
- if( $this->packages ) {
314
- $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption('freemius_activated_addons', array());
315
- foreach($this->packages as $addon) {
316
- if( in_array($addon['slug'], $freemius_activated_addons) ) {
317
- $addons[$addon['slug']] = array(
318
- $addon['class_name'],
319
- $package_dir . '/components/' . $addon['base_dir']
320
- );
321
- }
322
  }
323
  }
324
  }
325
-
326
- return $addons;
327
  }
 
 
328
  }
 
1
  <?php
2
 
3
+ class WCL_Package {
4
+
5
+ private static $instance = null;
6
+ private $packages = array();
7
+
8
+ private $is_need_update_addons = false;
9
+
10
+ private $plugin_slug = 'clearfy-package';
11
+
12
+ private $plugin_dir = 'clearfy_package';
13
+
14
+ private $plugin_basename = ''; // заполняется в конструкторе
15
+
16
+ private $builder_url = 'https://clearfy.pro/package/';
17
+
18
+ public static function instance() {
19
+ if ( null === self::$instance ) {
20
+ self::$instance = new self();
 
 
 
 
21
  }
22
+
23
+ return self::$instance;
24
+ }
25
+
26
+ private function __clone() {
27
+ }
28
+
29
+ private function __construct() {
30
+ $this->plugin_basename = $this->plugin_dir . '/' . $this->plugin_slug . '.php';
31
+ if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
32
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
33
  }
34
+ }
35
+
36
+ public function info() {
37
+ return array(
38
+ 'plugin_basename' => $this->plugin_basename,
39
+ 'plugin_slug' => $this->plugin_basename,
40
+ );
41
+ }
42
+
43
+ public function add( $packages = array() ) {
44
+ if ( ! $packages ) {
45
+ return false;
46
  }
47
+ foreach ( $packages as $package ) {
48
+ $key = $package['slug'];
49
+ $this->packages[ $key ] = $package;
 
 
 
 
50
  }
51
+ }
52
+
53
+ public function getAll() {
54
+ return $this->packages;
55
+ }
56
+
57
+ public function getSlugs() {
58
+ $slugs = array();
59
+ if ( $this->packages ) {
60
+ foreach ( $this->packages as $package ) {
61
+ $slugs[] = $package['slug'];
62
  }
63
  }
64
+
65
+ return $slugs;
66
+ }
67
+
68
+ public function getAddon( $slug ) {
69
+ if ( isset( $this->packages[ $slug ] ) ) {
70
+ return $this->packages[ $slug ];
71
  }
72
+
73
+ return false;
74
+ }
75
+
76
+ public function isActive() {
77
+ return is_plugin_active( $this->plugin_basename );
78
+ }
79
+
80
+ public function isInstalled() {
81
+ if ( file_exists( WP_PLUGIN_DIR . '/' . $this->plugin_basename ) ) {
82
+ return true;
83
+ }
84
+
85
+ return false;
86
+ }
87
+
88
+ /**
89
+ * Метод проверяет, нужно ли обновлять сами аддоны
90
+ *
91
+ * @return bool
92
+ */
93
+ public function isNeedUpdateAddons() {
94
+ return $this->is_need_update_addons;
95
+ }
96
+
97
+ /**
98
+ * Метод проверяет, нужно ли обновлять весь пакет в целом.
99
+ * Пакет может быть обновлен по двум причинам:
100
+ * 1) Активирован аддон, которого ещё нет в пакете(или пакет не установлен)
101
+ * 2) Для аддонов проявились новые версии
102
+ *
103
+ * @return bool
104
+ */
105
+ public function isNeedUpdate() {
106
+ $need_update_package = false;
107
+ $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption( 'freemius_activated_addons', array() );
108
+
109
+ if ( $this->isActive() ) {
110
+ // если плагин clearfy-package установлен, то проверяем в нём наличие фримиус аддонов
111
+ $addons = $this->getAll();
112
+ $licensing = WCL_Licensing::instance();
113
+ $freemius_addons_data = $licensing->getAddons();
114
+ foreach ( $freemius_activated_addons as $freemius_active_addon ) {
115
+ if ( isset( $addons[ $freemius_active_addon ] ) ) {
116
+ // проверяем, актуальна ли версия аддона
117
+ foreach ( $freemius_addons_data->plugins as $freemius_addon ) {
118
+ if ( $freemius_addon->slug != $freemius_active_addon ) {
119
+ continue;
120
+ }
121
+ // если во фримиусе не указана версия, то делаем её равной текущей версии аддона. Для того, чтобы уведомление об обновлении вечно не висело.
122
+ $actual_version = isset( $freemius_addon->info ) ? $freemius_addon->info->selling_point_0 : '';
123
+ if ( ! $actual_version ) {
124
+ $actual_version = $addons[ $freemius_active_addon ]['current_version'];
125
+ }
126
+ if ( version_compare( $actual_version, $addons[ $freemius_active_addon ]['current_version'], '>' ) ) {
127
+ $this->is_need_update_addons = true;
128
+ $need_update_package = true;
129
+ }
130
+ }
131
+ } else {
132
+ $need_update_package = true;
133
  }
134
  }
135
+ } else {
136
+ // если плагин clearfy-package НЕ установлен, то любая активация фримиус аддона требует обновления пакета
137
+ if ( count( $freemius_activated_addons ) ) {
138
+ $need_update_package = true;
 
 
 
 
139
  }
 
 
 
 
 
 
 
140
  }
141
+
142
+ return $need_update_package;
143
+ }
144
+
145
+ public function active() {
146
+ // если плагин установлен и не активирован, то активируем
147
+ if ( $this->isInstalled() and ! $this->isActive() ) {
148
+ if ( WCL_Plugin::app()->isNetworkActive() ) {
149
+ activate_plugin( $this->plugin_basename, '', true );
150
+ } else {
151
+ activate_plugin( $this->plugin_basename );
152
  }
 
 
 
 
 
 
 
 
 
 
 
 
153
  }
154
+ }
155
+
156
+ public function deactive() {
157
+ // если плагин установлен и не активирован, то активируем
158
+ if ( $this->isInstalled() and $this->isActive() ) {
159
+ if ( WCL_Plugin::app()->isNetworkActive() ) {
160
+ deactivate_plugins( $this->plugin_basename, false, true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  } else {
162
+ deactivate_plugins( $this->plugin_basename );
 
 
 
163
  }
 
 
164
  }
165
+ }
166
+
167
+ public function downloadUrl() {
168
+ $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption( 'freemius_activated_addons', array() );
169
+ $licensing = WCL_Licensing::instance();
170
+ $package_slugs = array();
171
+
172
+ if ( $this->isActive() ) {
173
+ $package_slugs = $this->getSlugs();
174
+ foreach ( $freemius_activated_addons as $freemius_addon ) {
175
+ if ( ! in_array( $freemius_addon, $package_slugs ) ) {
176
+ $package_slugs[] = $freemius_addon;
177
  }
178
  }
179
  }
180
+ if ( ! $package_slugs ) {
181
+ $package_slugs = $freemius_activated_addons;
182
+ }
183
+ //$package_slugs[] = 'test-addon'; // для тестирования ошибки. Сборщик не отдаст архив
184
+ $url = $this->builder_url . 'assembly-package.php?addons=' . join( ',', $package_slugs );
185
+ if ( $licensing->isLicenseValid() ) {
186
+ $storage = $licensing->getStorage();
187
+ $license = $storage->getLicense();
188
+ $site = $storage->getSite();
189
+ $license_id = isset( $license->id ) ? $license->id : '';
190
+ $license_key = isset( $license->secret_key ) ? $license->secret_key : '';
191
+ $install_id = isset( $site->site_id ) ? $site->site_id : '';
192
+ $url .= '&license_id=' . $license_id . '&license_key=' . urlencode( $license_key ) . '&install_id=' . $install_id;
193
+ }
194
+
195
+ return $url;
196
+ }
197
+
198
+ /**
199
+ * @return array|bool|false|WP_Error
200
+ * @throws Exception
201
+ */
202
+ public function update() {
203
+ global $wp_filesystem;
204
+
205
+ if ( ! WCL_Plugin::app()->currentUserCan() ) {
206
+ return new WP_Error( 'addon_install_error', __( 'Sorry, you are not allowed to install plugins on this site.' ) );
207
+ }
208
+
209
+ $url = $this->downloadUrl();
210
+
211
+ if ( ! $wp_filesystem ) {
212
+ if ( ! function_exists( 'WP_Filesystem' ) ) {
213
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
214
  }
215
+ WP_Filesystem();
216
  }
217
+
218
+ if ( ! WP_Filesystem( false, WP_PLUGIN_DIR ) ) {
219
+ throw new Exception( 'You are not allowed to edt folders/files on this site' );
220
+ } else {
221
+ ob_start();
222
+
223
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
224
+ require_once( ABSPATH . 'wp-admin/includes/misc.php' );
225
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
226
+ require_once( WCL_PLUGIN_DIR . '/admin/includes/classes/class.upgrader-skin.php' );
227
+ require_once( WCL_PLUGIN_DIR . '/admin/includes/classes/class.upgrader.php' );
228
+
229
+ add_filter( 'async_update_translation', '__return_false', 1 );
230
+
231
+ $upgrader = new WCL_Plugin_Upgrader( new WCL_Upgrader_Skin );
232
+
233
+ if ( $this->isInstalled() ) {
234
+ $result = $upgrader->run( array(
235
+ 'package' => $url,
236
+ 'destination' => WP_PLUGIN_DIR,
237
+ 'clear_destination' => true,
238
+ 'clear_working' => true,
239
+ 'hook_extra' => array(
240
+ 'plugin' => $this->plugin_basename,
241
+ 'type' => 'plugin',
242
+ 'action' => 'update',
243
+ ),
244
+ ) );
245
+ } else {
246
+ $result = $upgrader->install( $url );
247
  }
248
+
249
+ if ( is_wp_error( $result ) ) {
250
+ return $result;
251
  }
252
+
253
+ $this->active();
254
+
255
+ ob_end_clean();
256
+
257
+ if ( null === $result ) {
258
+ return new WP_Error( 'addon_install_error', 'An unknown error occurred during the delivery of the component package. Please report this problem to our support team <b>wordpress.webraftic@gmail.com</b>' ); // пока думаю как получать сообщение об ошибке с сервера
 
 
 
259
  }
260
+
261
+ return $result;
262
  }
263
+ }
264
+
265
+ public function getUpdateNotice() {
266
+ $need_update_package = $this->isNeedUpdate();
267
+ $message = '';
268
+ if ( $need_update_package ) {
269
+ if ( $this->isNeedUpdateAddons() ) {
270
+ // доступны обновления компонентов
271
+ $message = __( 'Updates are available for one of the components. Please, update your current package of components to the newest version.', 'clearfy' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  } else {
273
+ // нужно обновить весь пакет
274
+ $message = __( 'You’ve changed the component configuration. For the further work, please, update the current package of components!', 'clearfy' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  }
276
+ //$message .= ' <a href="'.admin_url('admin-ajax.php?action=wbcr-clearfy-update-package&_wpnonce=' . wp_create_nonce( 'package' )).'">' . __( 'Update', 'clearfy' ) . '</a>';
277
+
278
+ $message .= ' <button class="wbcr-clr-update-package button button-default" type="button" data-wpnonce="' . wp_create_nonce( 'package' ) . '" data-loading="' . __( 'Update in progress...', 'clearfy' ) . '">' . __( 'Update now', 'clearfy' ) . '</button>';
279
+
280
+ return $message;
281
  }
282
+
283
+ return false;
284
+ }
285
+
286
+ public function getActivedAddons() {
287
+ $addons = array();
288
+ if ( $this->isInstalled() ) {
289
+ $package_dir = WP_PLUGIN_DIR . '/' . $this->plugin_dir;
290
+ $package_config = $package_dir . '/config.php';
291
+ if ( file_exists( $package_config ) ) {
292
+ $packages = require( $package_config );
293
+ $this->add( $packages );
 
 
 
 
 
 
294
  }
295
+ if ( $this->packages ) {
296
+ $freemius_activated_addons = WCL_Plugin::app()->getPopulateOption( 'freemius_activated_addons', array() );
297
+ foreach ( $this->packages as $addon ) {
298
+ if ( in_array( $addon['slug'], $freemius_activated_addons ) ) {
299
+ $addons[ $addon['slug'] ] = array(
300
+ $addon['class_name'],
301
+ $package_dir . '/components/' . $addon['base_dir']
302
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  }
304
  }
305
  }
 
 
306
  }
307
+
308
+ return $addons;
309
  }
310
+ }
includes/classes/exceptions/class.license-exception.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * License exception
4
+ * @author Webcraftic <wordpress.webraftic@gmail.com>
5
+ * @copyright (c) 2017 Webraftic Ltd
6
+ * @version 1.0
7
+ */
8
+
9
+ namespace WCL;
10
+
11
+ use Exception;
12
+
13
+ // Exit if accessed directly
14
+ if ( ! defined( 'ABSPATH' ) ) {
15
+ exit;
16
+ }
17
+
18
+
19
+ class LicenseException extends Exception {
20
+
21
+ }
includes/classes/exceptions/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
includes/classes/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
includes/freemius/class.storage.php CHANGED
@@ -1,93 +1,195 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  /**
4
- * Класс работы с данными лицензирования
5
- * @author Webcraftic <jokerov@gmail.com>
6
- * @copyright (c) 2018 Webraftic Ltd
7
- * @version 1.0
8
  */
9
-
10
- // Exit if accessed directly
11
- if( ! defined( 'ABSPATH' ) ) {
12
- exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
-
15
- class WCL_Licensing_Storage {
16
-
17
- /**
18
- * @var WCL_Licensing_Storage
19
- */
20
- private $_storage = array();
21
-
22
- /**
23
- * Инициализация системы хранения данных
24
- *
25
- */
26
- public function __construct() {
27
- $this->load();
28
- }
29
 
30
- /**
31
- * Загрузка данных из хранилища
32
- *
33
- */
34
- public function load() {
35
- $this->_storage = WCL_Plugin::app()->getPopulateOption( 'license_storage', false );
36
-
37
- if ( isset( $this->_storage['user']->id ) and $this->_storage['user']->id ) {
38
- $this->_storage['user'] = new WCL_FS_User( $this->_storage['user'] );
39
  }
40
- if ( isset( $this->_storage['site']->id ) and $this->_storage['site']->id ) {
41
- $this->_storage['site'] = new WCL_FS_Site( $this->_storage['site'] );
42
  }
43
- if ( isset( $this->_storage['license']->id ) and $this->_storage['license']->id ) {
44
- $this->_storage['license'] = new WCL_FS_Plugin_License( $this->_storage['license'] );
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
 
 
46
  }
47
 
48
- /**
49
- * Сохранение данных
50
- *
51
- */
52
- public function save() {
53
- WCL_Plugin::app()->updatePopulateOption( 'license_storage', $this->_storage );
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
 
56
- /**
57
- * Получает элемент хранилища по его имени
58
- *
59
- * @param string $property ключ
60
- * @return mixed
61
- */
62
- public function get( $property ) {
63
- if ( isset( $this->_storage[ $property ] ) ) {
64
- return $this->_storage[ $property ];
 
 
 
 
 
65
  }
66
- return false;
 
67
  }
68
 
69
- public function getAll() {
70
- return $this->_storage;
 
 
 
 
 
 
 
 
 
 
 
71
  }
 
 
 
 
 
 
 
 
 
72
 
73
- /**
74
- * Устанавливает значение для элемента хранилища
75
- *
76
- * @param string $property ключ
77
- * @param string $value значение
78
- */
79
- public function set( $property, $value ) {
80
- $this->_storage[ $property ] = $value;
81
  }
 
 
 
 
 
 
 
 
 
82
 
83
- /**
84
- * Удаляет значение их хранилища
85
- *
86
- * @param string $property ключ
87
- */
88
- public function delete( $property ) {
89
- if ( isset( $this->_storage[ $property ] ) ) {
90
- $this->_storage[ $property ] = false;
91
- }
92
  }
93
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+
3
+ /**
4
+ * Licensing Data Class
5
+ * @author Webcraftic <jokerov@gmail.com>
6
+ * @copyright (c) 2018 Webraftic Ltd
7
+ * @version 1.0
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ class WCL_Licensing_Storage {
16
 
17
  /**
18
+ * @var array
 
 
 
19
  */
20
+ private $license = array();
21
+
22
+ /**
23
+ * @var array
24
+ */
25
+ private $user = array();
26
+
27
+ /**
28
+ * @var array
29
+ */
30
+ private $site = array();
31
+
32
+ /**
33
+ * Storage Initialization
34
+ *
35
+ */
36
+ public function __construct() {
37
+ $this->load();
38
  }
39
+
40
+ /**
41
+ * Loading data from storage
42
+ *
43
+ */
44
+ public function load() {
45
+ $new_license_storage = WCL_Plugin::app()->getPopulateOption( 'license', false );
 
 
 
 
 
 
 
 
46
 
47
+ if ( is_array( $new_license_storage ) ) {
48
+ if ( isset( $new_license_storage['user'] ) && ! empty( $new_license_storage['user'] ) ) {
49
+ $this->user = $new_license_storage['user'];
50
+ }
51
+ if ( isset( $new_license_storage['site'] ) && ! empty( $new_license_storage['site'] ) ) {
52
+ $this->site = $new_license_storage['site'];
 
 
 
53
  }
54
+ if ( isset( $new_license_storage['license'] ) && ! empty( $new_license_storage['license'] ) ) {
55
+ $this->license = $new_license_storage['license'];
56
  }
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Get site license info
62
+ *
63
+ * @return WCL_FS_Plugin_License|null
64
+ */
65
+ public function getLicense() {
66
+ if ( isset( $this->license ) && ! empty( $this->license ) ) {
67
+ $license = new stdClass;
68
+
69
+ foreach ( $this->license as $key => $prop ) {
70
+ $license->$key = $prop;
71
  }
72
+
73
+ return new WCL_FS_Plugin_License( $license );
74
  }
75
 
76
+ return null;
77
+ }
78
+
79
+ /**
80
+ * Get site info
81
+ *
82
+ * @return WCL_FS_Site|null
83
+ */
84
+ public function getSite() {
85
+ if ( isset( $this->site ) && ! empty( $this->site ) ) {
86
+ $site = new stdClass;
87
+
88
+ foreach ( $this->site as $key => $prop ) {
89
+ $site->$key = $prop;
90
+ }
91
+
92
+ return new WCL_FS_Site( $site );
93
  }
94
 
95
+ return null;
96
+ }
97
+
98
+ /**
99
+ * Get user info
100
+ *
101
+ * @return WCL_FS_User|null
102
+ */
103
+ public function getUser() {
104
+ if ( isset( $this->user ) && ! empty( $this->user ) ) {
105
+ $user = new stdClass;
106
+
107
+ foreach ( $this->user as $key => $prop ) {
108
+ $user->$key = $prop;
109
  }
110
+
111
+ return new WCL_FS_User( $user );
112
  }
113
 
114
+ return null;
115
+ }
116
+
117
+ /**
118
+ * Set user attrs
119
+ *
120
+ * @param WCL_FS_User $user
121
+ */
122
+ public function setUser( WCL_FS_User $user ) {
123
+ $available_attrs = get_object_vars( $user );
124
+
125
+ foreach ( $available_attrs as $attr => $value ) {
126
+ $this->user[ $attr ] = $user->$attr;
127
  }
128
+ }
129
+
130
+ /**
131
+ * Set site attrs
132
+ *
133
+ * @param WCL_FS_Site $site
134
+ */
135
+ public function setSite( WCL_FS_Site $site ) {
136
+ $available_attrs = get_object_vars( $site );
137
 
138
+ foreach ( $available_attrs as $attr => $value ) {
139
+ $this->site[ $attr ] = $site->$attr;
 
 
 
 
 
 
140
  }
141
+ }
142
+
143
+ /**
144
+ * Sets license attrs
145
+ *
146
+ * @param WCL_FS_Plugin_License $license
147
+ */
148
+ public function setLicense( WCL_FS_Plugin_License $license ) {
149
+ $available_attrs = get_object_vars( $license );
150
 
151
+ foreach ( $available_attrs as $attr => $value ) {
152
+ $this->license[ $attr ] = $license->$attr;
 
 
 
 
 
 
 
153
  }
154
  }
155
+
156
+ /**
157
+ * Removes the value of their repository.
158
+ *
159
+ * @param string $property available properties user, site, license
160
+ *
161
+ * @return bool
162
+ */
163
+ public function delete( $property ) {
164
+ if ( empty( $property ) || ! in_array( $property, array( 'user', 'site', 'license' ) ) ) {
165
+ return false;
166
+ }
167
+
168
+ $this->$property = array();
169
+
170
+ return true;
171
+ }
172
+
173
+ /**
174
+ * Сlears all license data from storage
175
+ */
176
+ public function flush() {
177
+ $this->delete( 'site' );
178
+ $this->delete( 'license' );
179
+ $this->delete( 'user' );
180
+ $this->save();
181
+ }
182
+
183
+ /**
184
+ * Saving data
185
+ */
186
+ public function save() {
187
+ //WCL_Plugin::app()->updatePopulateOption( 'licensestorage', $this->storage );
188
+
189
+ WCL_Plugin::app()->updatePopulateOption( 'license', array(
190
+ 'user' => $this->user,
191
+ 'site' => $this->site,
192
+ 'license' => $this->license
193
+ ) );
194
+ }
195
+ }
includes/freemius/entities/class.wcl-fs-entity.php CHANGED
@@ -1,164 +1,162 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
- * @since 1.0.3
7
  */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  /**
14
- * Get object's public variables.
15
- *
16
  * @author Vova Feldman (@svovaf)
17
- * @since 1.0.0
18
  *
19
- * @param object $object
 
20
  *
21
- * @return array
22
  */
23
- function wcl_fs_get_object_public_vars( $object ) {
24
- return get_object_vars( $object );
 
 
 
 
 
 
 
 
25
  }
26
 
 
 
27
  /**
28
- * Класс для работы с записями freemius
29
- * @author Webcraftic <jokerov@gmail.com>
30
- * @copyright (c) 2018 Webraftic Ltd
31
- * @version 1.0
 
 
 
 
 
32
  */
33
- class WCL_FS_Entity {
34
- /**
35
- * @var number
36
- */
37
- public $id;
38
- /**
39
- * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
40
- */
41
- public $updated;
42
- /**
43
- * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
44
- */
45
- public $created;
46
-
47
- /**
48
- * @param bool|object $entity
49
- */
50
- public function __construct( $entity = false ) {
51
- if ( ! ( $entity instanceof stdClass ) && ! ( $entity instanceof WCL_FS_Entity ) ) {
52
- return;
53
- }
54
-
55
- $props = wcl_fs_get_object_public_vars( $this );
56
-
57
- foreach ( $props as $key => $def_value ) {
58
- $this->{$key} = isset( $entity->{$key} ) ? $entity->{$key} : $def_value;
59
- }
60
  }
61
 
62
- public function populate( $data ) {
63
- $props = wcl_fs_get_object_public_vars( $this );
64
- foreach ( $props as $key => $def_value ) {
65
- $this->{$key} = isset( $data[ $key ] ) ? $data[ $key ] : $def_value;
66
- }
67
- }
68
 
69
- public function toArray() {
70
- return wcl_fs_get_object_public_vars( $this );
71
- }
72
-
73
- static function get_type() {
74
- return 'type';
75
- }
76
-
77
- /**
78
- * @author Vova Feldman (@svovaf)
79
- * @since 1.0.6
80
- *
81
- * @param FS_Entity $entity1
82
- * @param FS_Entity $entity2
83
- *
84
- * @return bool
85
- */
86
- static function equals( $entity1, $entity2 ) {
87
- if ( is_null( $entity1 ) && is_null( $entity2 ) ) {
88
- return true;
89
- } else if ( is_object( $entity1 ) && is_object( $entity2 ) ) {
90
- return ( $entity1->id == $entity2->id );
91
- } else if ( is_object( $entity1 ) ) {
92
- return is_null( $entity1->id );
93
- } else {
94
- return is_null( $entity2->id );
95
  }
96
- }
97
-
98
- private $_is_updated = false;
99
-
100
- /**
101
- * Update object property.
102
- *
103
- * @author Vova Feldman (@svovaf)
104
- * @since 1.0.9
105
- *
106
- * @param string|array[string]mixed $key
107
- * @param string|bool $val
108
- *
109
- * @return bool
110
- */
111
- function update( $key, $val = false ) {
112
- if ( ! is_array( $key ) ) {
113
- $key = array( $key => $val );
114
- }
115
-
116
- $is_updated = false;
117
-
118
- foreach ( $key as $k => $v ) {
119
- if ( $this->{$k} === $v ) {
120
- continue;
121
- }
122
-
123
- if ( ( is_string( $this->{$k} ) && is_numeric( $v ) ||
124
- ( is_numeric( $this->{$k} ) && is_string( $v ) ) ) &&
125
- $this->{$k} == $v
126
- ) {
127
- continue;
128
- }
129
-
130
- // Update value.
131
- $this->{$k} = $v;
132
-
133
- $is_updated = true;
134
  }
135
-
136
- $this->_is_updated = $is_updated;
137
-
138
- return $is_updated;
139
- }
140
-
141
- /**
142
- * Checks if entity was updated.
143
- *
144
- * @author Vova Feldman (@svovaf)
145
- * @since 1.0.9
146
- *
147
- * @return bool
148
- */
149
- function is_updated() {
150
- return $this->_is_updated;
151
- }
152
-
153
- /**
154
- * @param $id
155
- *
156
- * @author Vova Feldman (@svovaf)
157
- * @since 1.1.2
158
- *
159
- * @return bool
160
- */
161
- static function is_valid_id($id){
162
- return is_numeric($id);
163
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  }
 
1
  <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * Get object's public variables.
15
+ *
16
+ * @author Vova Feldman (@svovaf)
17
+ * @since 1.0.0
18
+ *
19
+ * @param object $object
20
+ *
21
+ * @return array
22
+ */
23
+ function wcl_fs_get_object_public_vars( $object ) {
24
+ return get_object_vars( $object );
25
+ }
26
+
27
+ /**
28
+ * Класс для работы с записями freemius
29
+ * @author Webcraftic <jokerov@gmail.com>
30
+ * @copyright (c) 2018 Webraftic Ltd
31
+ * @version 1.0
32
+ */
33
+ class WCL_FS_Entity {
34
+
35
  /**
36
+ * @var number
 
 
 
37
  */
38
+ public $id;
39
+ /**
40
+ * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
41
+ */
42
+ public $updated;
43
+ /**
44
+ * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
45
+ */
46
+ public $created;
47
+
48
+ /**
49
+ * @param bool|object $entity
50
+ */
51
+ public function __construct( $entity = false ) {
52
+ if ( ! ( $entity instanceof stdClass ) && ! ( $entity instanceof WCL_FS_Entity ) ) {
53
+ return;
54
+ }
55
+
56
+ $props = wcl_fs_get_object_public_vars( $this );
57
+
58
+ foreach ( $props as $key => $def_value ) {
59
+ $this->{$key} = isset( $entity->{$key} ) ? $entity->{$key} : $def_value;
60
+ }
61
  }
62
+
63
+ public function populate( $data ) {
64
+ $props = wcl_fs_get_object_public_vars( $this );
65
+ foreach ( $props as $key => $def_value ) {
66
+ $this->{$key} = isset( $data[ $key ] ) ? $data[ $key ] : $def_value;
67
+ }
68
+ }
69
+
70
+ public function toArray() {
71
+ return wcl_fs_get_object_public_vars( $this );
72
+ }
73
+
74
+ static function get_type() {
75
+ return 'type';
76
+ }
77
+
78
  /**
 
 
79
  * @author Vova Feldman (@svovaf)
80
+ * @since 1.0.6
81
  *
82
+ * @param WCL_FS_Entity $entity1
83
+ * @param WCL_FS_Entity $entity2
84
  *
85
+ * @return bool
86
  */
87
+ static function equals( $entity1, $entity2 ) {
88
+ if ( is_null( $entity1 ) && is_null( $entity2 ) ) {
89
+ return true;
90
+ } else if ( is_object( $entity1 ) && is_object( $entity2 ) ) {
91
+ return ( $entity1->id == $entity2->id );
92
+ } else if ( is_object( $entity1 ) ) {
93
+ return is_null( $entity1->id );
94
+ } else {
95
+ return is_null( $entity2->id );
96
+ }
97
  }
98
 
99
+ private $_is_updated = false;
100
+
101
  /**
102
+ * Update object property.
103
+ *
104
+ * @author Vova Feldman (@svovaf)
105
+ * @since 1.0.9
106
+ *
107
+ * @param string|array[string]mixed $key
108
+ * @param string|bool $val
109
+ *
110
+ * @return bool
111
  */
112
+ function update( $key, $val = false ) {
113
+ if ( ! is_array( $key ) ) {
114
+ $key = array( $key => $val );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  }
116
 
117
+ $is_updated = false;
 
 
 
 
 
118
 
119
+ foreach ( $key as $k => $v ) {
120
+ if ( $this->{$k} === $v ) {
121
+ continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  }
123
+
124
+ if ( ( is_string( $this->{$k} ) && is_numeric( $v ) || ( is_numeric( $this->{$k} ) && is_string( $v ) ) ) && $this->{$k} == $v ) {
125
+ continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  }
127
+
128
+ // Update value.
129
+ $this->{$k} = $v;
130
+
131
+ $is_updated = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  }
133
+
134
+ $this->_is_updated = $is_updated;
135
+
136
+ return $is_updated;
137
+ }
138
+
139
+ /**
140
+ * Checks if entity was updated.
141
+ *
142
+ * @author Vova Feldman (@svovaf)
143
+ * @since 1.0.9
144
+ *
145
+ * @return bool
146
+ */
147
+ function is_updated() {
148
+ return $this->_is_updated;
149
+ }
150
+
151
+ /**
152
+ * @param $id
153
+ *
154
+ * @author Vova Feldman (@svovaf)
155
+ * @since 1.1.2
156
+ *
157
+ * @return bool
158
+ */
159
+ static function is_valid_id( $id ) {
160
+ return is_numeric( $id );
161
  }
162
+ }
includes/freemius/entities/class.wcl-fs-plugin-license.php CHANGED
@@ -1,296 +1,332 @@
1
  <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
- * @since 1.0.5
7
- */
8
 
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
 
13
- /**
14
- * Класс для хранения данных лицензии
15
- * @author Webcraftic <jokerov@gmail.com>
16
- * @copyright (c) 2018 Webraftic Ltd
17
- * @version 1.0
 
 
 
 
 
 
 
18
  */
19
- class WCL_FS_Plugin_License extends WCL_FS_Entity {
20
-
21
- #region Properties
22
-
23
- /**
24
- * @var number
25
- */
26
- public $plugin_id;
27
- /**
28
- * @var number
29
- */
30
- public $user_id;
31
- /**
32
- * @var number
33
- */
34
- public $plan_id;
35
-
36
- public $plan_title;
37
-
38
- public $billing_cycle;
39
- /**
40
- * @var number
41
- */
42
- public $pricing_id;
43
- /**
44
- * @var int|null
45
- */
46
- public $quota;
47
- /**
48
- * @var int
49
- */
50
- public $activated;
51
- /**
52
- * @var int
53
- */
54
- public $activated_local;
55
- /**
56
- * @var string
57
- */
58
- public $expiration;
59
- /**
60
- * @var string
61
- */
62
- public $secret_key;
63
- /**
64
- * @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same
65
- * license.
66
- */
67
- public $is_free_localhost;
68
- /**
69
- * @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only
70
- * block updates and support.
71
- */
72
- public $is_block_features;
73
- /**
74
- * @var bool
75
- */
76
- public $is_cancelled;
77
-
78
- #endregion Properties
79
-
80
- /**
81
- * @param stdClass|bool $license
82
- */
83
- function __construct( $license = false ) {
84
- parent::__construct( $license );
85
- }
86
-
87
- /**
88
- * Get entity type.
89
- *
90
- * @return string
91
- */
92
- static function get_type() {
93
- return 'license';
94
- }
95
-
96
- /**
97
- * Check how many site activations left.
98
- *
99
- * @author Vova Feldman (@svovaf)
100
- * @since 1.0.5
101
- *
102
- * @return int
103
- */
104
- function left() {
105
- if ( ! $this->is_active() || $this->is_expired() ) {
106
- return 0;
107
- }
108
-
109
- if ( $this->is_unlimited() ) {
110
- return 999;
111
- }
112
-
113
- return ( $this->quota - $this->activated - ( $this->is_free_localhost ? 0 : $this->activated_local ) );
114
- }
115
-
116
- /**
117
- * Check if single site license.
118
- *
119
- * @author Vova Feldman (@svovaf)
120
- * @since 1.1.8.1
121
- *
122
- * @return bool
123
- */
124
- function is_single_site() {
125
- return ( is_numeric( $this->quota ) && 1 == $this->quota );
126
- }
127
-
128
- /**
129
- * @author Vova Feldman (@svovaf)
130
- * @since 1.0.5
131
- *
132
- * @return bool
133
- */
134
- function is_expired() {
135
- return ! $this->is_lifetime() && ( strtotime( $this->expiration ) < date('U') );
136
- }
137
-
138
- /**
139
- * Check if license is not expired.
140
- *
141
- * @author Vova Feldman (@svovaf)
142
- * @since 1.2.1
143
- *
144
- * @return bool
145
- */
146
- function is_valid() {
147
- return ! $this->is_expired();
148
- }
149
-
150
- /**
151
- * @author Vova Feldman (@svovaf)
152
- * @since 1.0.6
153
- *
154
- * @return bool
155
- */
156
- function is_lifetime() {
157
- return is_null( $this->expiration );
158
- }
159
-
160
- /**
161
- * @author Vova Feldman (@svovaf)
162
- * @since 1.2.0
163
- *
164
- * @return bool
165
- */
166
- function is_unlimited() {
167
- return is_null( $this->quota );
168
- }
169
-
170
- /**
171
- * Check if license is fully utilized.
172
- *
173
- * @author Vova Feldman (@svovaf)
174
- * @since 1.0.6
175
- *
176
- * @param bool|null $is_localhost
177
- *
178
- * @return bool
179
- */
180
- function is_utilized( $is_localhost = null ) {
181
- if ( is_null( $is_localhost ) ) {
182
- $is_localhost = false; // была WP_FS__IS_LOCALHOST_FOR_SERVER
183
- }
184
-
185
- if ( $this->is_unlimited() ) {
186
- return false;
187
- }
188
-
189
- return ! ( $this->is_free_localhost && $is_localhost ) &&
190
- ( $this->quota <= $this->activated + ( $this->is_free_localhost ? 0 : $this->activated_local ) );
191
- }
192
-
193
- /**
194
- * Check if license can be activated.
195
- *
196
- * @author Vova Feldman (@svovaf)
197
- * @since 2.0.0
198
- *
199
- * @param bool|null $is_localhost
200
- *
201
- * @return bool
202
- */
203
- function can_activate( $is_localhost = null ) {
204
- return ! $this->is_utilized( $is_localhost ) && $this->is_features_enabled();
205
- }
206
-
207
- /**
208
- * Check if license can be activated on a given number of production and localhost sites.
209
- *
210
- * @author Vova Feldman (@svovaf)
211
- * @since 2.0.0
212
- *
213
- * @param int $production_count
214
- * @param int $localhost_count
215
- *
216
- * @return bool
217
- */
218
- function can_activate_bulk( $production_count, $localhost_count ) {
219
- if ( $this->is_unlimited() ) {
220
- return true;
221
- }
222
-
223
- /**
224
- * For simplicity, the logic will work as following: when given X sites to activate the license on, if it's
225
- * possible to activate on ALL of them, do the activation. If it's not possible to activate on ALL of them,
226
- * do NOT activate on any of them.
227
- */
228
- return ( $this->quota >= $this->activated + $production_count + ( $this->is_free_localhost ? 0 : $this->activated_local + $localhost_count ) );
229
- }
230
-
231
- /**
232
- * @author Vova Feldman (@svovaf)
233
- * @since 1.2.1
234
- *
235
- * @return bool
236
- */
237
- function is_active() {
238
- return ( ! $this->is_cancelled );
239
- }
240
-
241
- /**
242
- * Check if license's plan features are enabled.
243
- *
244
- * - Either if plan not expired
245
- * - If expired, based on the configuration to block features or not.
246
- *
247
- * @author Vova Feldman (@svovaf)
248
- * @since 1.0.6
249
- *
250
- * @return bool
251
- */
252
- function is_features_enabled() {
253
- return $this->is_active() && ( ! $this->is_block_features || ! $this->is_expired() );
254
- }
255
-
256
- /**
257
- * Subscription considered to be new without any payments
258
- * if the license expires in less than 24 hours
259
- * from the license creation.
260
- *
261
- * @author Vova Feldman (@svovaf)
262
- * @since 1.0.9
263
- *
264
- * @return bool
265
- */
266
- function is_first_payment_pending() {
267
- return ( 86400 >= strtotime( $this->expiration ) - strtotime( $this->created ) );
268
- }
269
-
270
- /**
271
- * @return int
272
- */
273
- function total_activations() {
274
- return ( $this->activated + $this->activated_local );
275
- }
276
-
277
- public function remainingDays() {
278
- if ( $this->is_lifetime() ) {
279
- return 999;
280
- }
281
- $remaining = strtotime( $this->expiration ) - date('U');
282
- $days_remaining = floor( $remaining / 86400 );
283
- return $days_remaining;
284
  }
285
 
286
- public function sync( $actual_license_data ) {
287
- $props = wcl_fs_get_object_public_vars( $this );
288
-
289
- foreach ( $props as $key => $def_value ) {
290
- $this->{$key} = isset( $actual_license_data->{$key} ) ? $actual_license_data->{$key} : $def_value;
291
- }
292
- if ( isset( $actual_license_data->expiration ) and is_null( $actual_license_data->expiration ) ) {
293
- $this->expiration = null;
294
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  }
296
- }
 
1
  <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
+ * @since 1.0.5
7
+ */
8
 
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
 
13
+ /**
14
+ * Класс для хранения данных лицензии
15
+ * @author Webcraftic <jokerov@gmail.com>
16
+ * @copyright (c) 2018 Webraftic Ltd
17
+ * @version 1.0
18
+ */
19
+ class WCL_FS_Plugin_License extends WCL_FS_Entity {
20
+
21
+ #region Properties
22
+
23
+ /**
24
+ * @var number
25
  */
26
+ public $id;
27
+
28
+ /**
29
+ * @var string
30
+ */
31
+ public $public_key;
32
+
33
+ /**
34
+ * @var string
35
+ */
36
+ public $secret_key;
37
+
38
+ /**
39
+ * @var number
40
+ */
41
+ public $plugin_id;
42
+
43
+ /**
44
+ * @var number
45
+ */
46
+ public $user_id;
47
+ /**
48
+ * @var number
49
+ */
50
+ public $plan_id;
51
+
52
+ /**
53
+ * @var string
54
+ */
55
+ public $plan_title;
56
+
57
+ /**
58
+ * @var number
59
+ */
60
+ public $billing_cycle;
61
+
62
+ /**
63
+ * @var number
64
+ */
65
+ public $pricing_id;
66
+
67
+ /**
68
+ * @var int|null
69
+ */
70
+ public $quota;
71
+
72
+ /**
73
+ * @var int
74
+ */
75
+ public $activated;
76
+ /**
77
+ * @var int
78
+ */
79
+ public $activated_local;
80
+
81
+ /**
82
+ * @var string
83
+ */
84
+ public $expiration;
85
+
86
+ /**
87
+ * @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same
88
+ * license.
89
+ */
90
+ public $is_free_localhost;
91
+
92
+ /**
93
+ * @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only
94
+ * block updates and support.
95
+ */
96
+ public $is_block_features;
97
+
98
+ /**
99
+ * @var bool
100
+ */
101
+ public $is_cancelled;
102
+
103
+ /**
104
+ * @var int
105
+ */
106
+ public $environment;
107
+
108
+ /**
109
+ * @var int
110
+ */
111
+ public $source;
112
+
113
+
114
+ #endregion Properties
115
+
116
+ /**
117
+ * @param stdClass|bool $license
118
+ */
119
+ function __construct( $license = false ) {
120
+ parent::__construct( $license );
121
+ }
122
+
123
+ /**
124
+ * Get entity type.
125
+ *
126
+ * @return string
127
+ */
128
+ static function get_type() {
129
+ return 'license';
130
+ }
131
+
132
+ /**
133
+ * Check how many site activations left.
134
+ *
135
+ * @author Vova Feldman (@svovaf)
136
+ * @since 1.0.5
137
+ *
138
+ * @return int
139
+ */
140
+ function left() {
141
+ if ( ! $this->is_active() || $this->is_expired() ) {
142
+ return 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
144
 
145
+ if ( $this->is_unlimited() ) {
146
+ return 999;
147
+ }
148
+
149
+ return ( $this->quota - $this->activated - ( $this->is_free_localhost ? 0 : $this->activated_local ) );
150
+ }
151
+
152
+ /**
153
+ * Check if single site license.
154
+ *
155
+ * @author Vova Feldman (@svovaf)
156
+ * @since 1.1.8.1
157
+ *
158
+ * @return bool
159
+ */
160
+ function is_single_site() {
161
+ return ( is_numeric( $this->quota ) && 1 == $this->quota );
162
+ }
163
+
164
+ /**
165
+ * @author Vova Feldman (@svovaf)
166
+ * @since 1.0.5
167
+ *
168
+ * @return bool
169
+ */
170
+ function is_expired() {
171
+ return ! $this->is_lifetime() && ( strtotime( $this->expiration ) < date( 'U' ) );
172
+ }
173
+
174
+ /**
175
+ * Check if license is not expired.
176
+ *
177
+ * @author Vova Feldman (@svovaf)
178
+ * @since 1.2.1
179
+ *
180
+ * @return bool
181
+ */
182
+ function is_valid() {
183
+ return ! $this->is_expired();
184
+ }
185
+
186
+ /**
187
+ * @author Vova Feldman (@svovaf)
188
+ * @since 1.0.6
189
+ *
190
+ * @return bool
191
+ */
192
+ function is_lifetime() {
193
+ return is_null( $this->expiration );
194
+ }
195
+
196
+ /**
197
+ * @author Vova Feldman (@svovaf)
198
+ * @since 1.2.0
199
+ *
200
+ * @return bool
201
+ */
202
+ function is_unlimited() {
203
+ return is_null( $this->quota );
204
+ }
205
+
206
+ /**
207
+ * Check if license is fully utilized.
208
+ *
209
+ * @author Vova Feldman (@svovaf)
210
+ * @since 1.0.6
211
+ *
212
+ * @param bool|null $is_localhost
213
+ *
214
+ * @return bool
215
+ */
216
+ function is_utilized( $is_localhost = null ) {
217
+ if ( is_null( $is_localhost ) ) {
218
+ $is_localhost = false; // была WP_FS__IS_LOCALHOST_FOR_SERVER
219
+ }
220
+
221
+ if ( $this->is_unlimited() ) {
222
+ return false;
223
+ }
224
+
225
+ return ! ( $this->is_free_localhost && $is_localhost ) && ( $this->quota <= $this->activated + ( $this->is_free_localhost ? 0 : $this->activated_local ) );
226
+ }
227
+
228
+ /**
229
+ * Check if license can be activated.
230
+ *
231
+ * @author Vova Feldman (@svovaf)
232
+ * @since 2.0.0
233
+ *
234
+ * @param bool|null $is_localhost
235
+ *
236
+ * @return bool
237
+ */
238
+ function can_activate( $is_localhost = null ) {
239
+ return ! $this->is_utilized( $is_localhost ) && $this->is_features_enabled();
240
+ }
241
+
242
+ /**
243
+ * Check if license can be activated on a given number of production and localhost sites.
244
+ *
245
+ * @author Vova Feldman (@svovaf)
246
+ * @since 2.0.0
247
+ *
248
+ * @param int $production_count
249
+ * @param int $localhost_count
250
+ *
251
+ * @return bool
252
+ */
253
+ function can_activate_bulk( $production_count, $localhost_count ) {
254
+ if ( $this->is_unlimited() ) {
255
+ return true;
256
+ }
257
+
258
+ /**
259
+ * For simplicity, the logic will work as following: when given X sites to activate the license on, if it's
260
+ * possible to activate on ALL of them, do the activation. If it's not possible to activate on ALL of them,
261
+ * do NOT activate on any of them.
262
+ */
263
+ return ( $this->quota >= $this->activated + $production_count + ( $this->is_free_localhost ? 0 : $this->activated_local + $localhost_count ) );
264
+ }
265
+
266
+ /**
267
+ * @author Vova Feldman (@svovaf)
268
+ * @since 1.2.1
269
+ *
270
+ * @return bool
271
+ */
272
+ function is_active() {
273
+ return ( ! $this->is_cancelled );
274
+ }
275
+
276
+ /**
277
+ * Check if license's plan features are enabled.
278
+ *
279
+ * - Either if plan not expired
280
+ * - If expired, based on the configuration to block features or not.
281
+ *
282
+ * @author Vova Feldman (@svovaf)
283
+ * @since 1.0.6
284
+ *
285
+ * @return bool
286
+ */
287
+ function is_features_enabled() {
288
+ return $this->is_active() && ( ! $this->is_block_features || ! $this->is_expired() );
289
+ }
290
+
291
+ /**
292
+ * Subscription considered to be new without any payments
293
+ * if the license expires in less than 24 hours
294
+ * from the license creation.
295
+ *
296
+ * @author Vova Feldman (@svovaf)
297
+ * @since 1.0.9
298
+ *
299
+ * @return bool
300
+ */
301
+ function is_first_payment_pending() {
302
+ return ( 86400 >= strtotime( $this->expiration ) - strtotime( $this->created ) );
303
+ }
304
+
305
+ /**
306
+ * @return int
307
+ */
308
+ function total_activations() {
309
+ return ( $this->activated + $this->activated_local );
310
+ }
311
+
312
+ public function remainingDays() {
313
+ if ( $this->is_lifetime() ) {
314
+ return 999;
315
+ }
316
+ $remaining = strtotime( $this->expiration ) - date( 'U' );
317
+ $days_remaining = floor( $remaining / 86400 );
318
+
319
+ return $days_remaining;
320
+ }
321
+
322
+ public function sync( $actual_license_data ) {
323
+ $props = wcl_fs_get_object_public_vars( $this );
324
+
325
+ foreach ( $props as $key => $def_value ) {
326
+ $this->{$key} = isset( $actual_license_data->{$key} ) ? $actual_license_data->{$key} : $def_value;
327
+ }
328
+ if ( isset( $actual_license_data->expiration ) and is_null( $actual_license_data->expiration ) ) {
329
+ $this->expiration = null;
330
  }
331
+ }
332
+ }
includes/freemius/entities/class.wcl-fs-scope-entity.php CHANGED
@@ -1,29 +1,30 @@
1
  <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
- * @since 1.0.4
7
- */
8
 
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
 
13
- class WCL_FS_ScopeEntity extends WCL_FS_Entity {
14
- /**
15
- * @var string
16
- */
17
- public $public_key;
18
- /**
19
- * @var string
20
- */
21
- public $secret_key;
22
-
23
- /**
24
- * @param bool|stdClass $scope_entity
25
- */
26
- function __construct( $scope_entity = false ) {
27
- parent::__construct( $scope_entity );
28
- }
29
  }
 
1
  <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
+ * @since 1.0.4
7
+ */
8
 
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
 
13
+ class WCL_FS_ScopeEntity extends WCL_FS_Entity {
14
+
15
+ /**
16
+ * @var string
17
+ */
18
+ public $public_key;
19
+ /**
20
+ * @var string
21
+ */
22
+ public $secret_key;
23
+
24
+ /**
25
+ * @param bool|stdClass $scope_entity
26
+ */
27
+ function __construct( $scope_entity = false ) {
28
+ parent::__construct( $scope_entity );
29
  }
30
+ }
includes/freemius/entities/class.wcl-fs-site.php CHANGED
@@ -1,240 +1,151 @@
1
  <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
- * @since 1.0.3
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
 
 
 
 
 
 
 
 
12
 
13
  /**
14
- * Класс для хранения данных инсталла(сайта) freemius
15
- * @author Webcraftic <jokerov@gmail.com>
16
- * @copyright (c) 2018 Webraftic Ltd
17
- * @version 1.0
18
- */
19
- class WCL_FS_Site extends WCL_FS_ScopeEntity {
20
- /**
21
- * @var number
22
- */
23
- public $site_id;
24
- /**
25
- * @var number
26
- */
27
- public $plugin_id;
28
- /**
29
- * @var number
30
- */
31
- public $user_id;
32
- /**
33
- * @var string
34
- */
35
- public $title;
36
- /**
37
- * @var string
38
- */
39
- public $url;
40
- /**
41
- * @var string
42
- */
43
- public $version;
44
- /**
45
- * @var string E.g. en-GB
46
- */
47
- public $language;
48
- /**
49
- * @var string E.g. UTF-8
50
- */
51
- public $charset;
52
- /**
53
- * @var string Platform version (e.g WordPress version).
54
- */
55
- public $platform_version;
56
- /**
57
- * Freemius SDK version
58
- *
59
- * @author Leo Fajardo (@leorw)
60
- * @since 1.2.2
61
- *
62
- * @var string SDK version (e.g.: 1.2.2)
63
- */
64
- public $sdk_version;
65
- /**
66
- * @var string Programming language version (e.g PHP version).
67
- */
68
- public $programming_language_version;
69
- /**
70
- * @var number|null
71
- */
72
- public $plan_id;
73
- /**
74
- * @var number|null
75
- */
76
- public $license_id;
77
- /**
78
- * @var number|null
79
- */
80
- public $trial_plan_id;
81
- /**
82
- * @var string|null
83
- */
84
- public $trial_ends;
85
- /**
86
- * @since 1.0.9
87
- *
88
- * @var bool
89
- */
90
- public $is_premium = false;
91
- /**
92
- * @author Leo Fajardo (@leorw)
93
- *
94
- * @since 1.2.1.5
95
- *
96
- * @var bool
97
- */
98
- public $is_disconnected = false;
99
- /**
100
- * @since 2.0.0
101
- *
102
- * @var bool
103
- */
104
- public $is_active = true;
105
- /**
106
- * @since 2.0.0
107
- *
108
- * @var bool
109
- */
110
- public $is_uninstalled = false;
111
-
112
- /**
113
- * @param stdClass|bool $site
114
- */
115
- function __construct( $site = false ) {
116
- parent::__construct( $site );
117
-
118
- if ( is_object( $site ) and isset( $site->plan_id ) ) {
119
- $this->plan_id = $site->plan_id;
120
- }
121
-
122
- if ( ! is_bool( $this->is_disconnected ) ) {
123
- $this->is_disconnected = false;
124
- }
125
-
126
- $props = wcl_fs_get_object_public_vars( $this );
127
-
128
- foreach ( $props as $key => $def_value ) {
129
- $this->{$key} = isset( $site->{ 'install_' . $key } ) ? $site->{ 'install_' . $key } : $def_value;
130
- }
131
- if ( isset ( $site->install_id ) ) {
132
- $this->site_id = $site->install_id;
133
- }
134
- }
135
-
136
- static function get_type() {
137
- return 'install';
138
- }
139
-
140
- /**
141
- * @author Vova Feldman (@svovaf)
142
- * @since 2.0.0
143
- *
144
- * @param string $url
145
- *
146
- * @return bool
147
- */
148
- static function is_localhost_by_address( $url ) {
149
- if ( false !== strpos( $url, '127.0.0.1' ) ||
150
- false !== strpos( $url, 'localhost' )
151
- ) {
152
- return true;
153
- }
154
-
155
- if ( ! fs_starts_with( $url, 'http' ) ) {
156
- $url = 'http://' . $url;
157
- }
158
-
159
- $url_parts = parse_url( $url );
160
-
161
- $subdomain = $url_parts['host'];
162
-
163
- return (
164
- // Starts with.
165
- fs_starts_with( $subdomain, 'local.' ) ||
166
- fs_starts_with( $subdomain, 'dev.' ) ||
167
- fs_starts_with( $subdomain, 'test.' ) ||
168
- fs_starts_with( $subdomain, 'staging.' ) ||
169
-
170
- // Ends with.
171
- fs_ends_with( $subdomain, '.dev' ) ||
172
- fs_ends_with( $subdomain, '.test' ) ||
173
- fs_ends_with( $subdomain, '.staging' ) ||
174
- fs_ends_with( $subdomain, '.local' ) ||
175
- fs_ends_with( $subdomain, '.example' ) ||
176
- fs_ends_with( $subdomain, '.invalid' ) ||
177
- // GoDaddy test/dev.
178
- fs_ends_with( $subdomain, '.myftpupload.com' ) ||
179
- // ngrok tunneling.
180
- fs_ends_with( $subdomain, '.ngrok.io' ) ||
181
- // SiteGround staging.
182
- fs_starts_with( $subdomain, 'staging' ) ||
183
- // WPEngine staging.
184
- fs_ends_with( $subdomain, '.staging.wpengine.com' ) ||
185
- // Pantheon
186
- ( fs_ends_with($subdomain, 'pantheonsite.io') &&
187
- (fs_starts_with($subdomain, 'test-') || fs_starts_with($subdomain, 'dev-'))) ||
188
- // Cloudways
189
- fs_ends_with( $subdomain, '.cloudwaysapps.com' )
190
- );
191
- }
192
-
193
- function is_localhost() {
194
- return ( WP_FS__IS_LOCALHOST_FOR_SERVER || self::is_localhost_by_address( $this->url ) );
195
- }
196
-
197
- /**
198
- * Check if site in trial.
199
- *
200
- * @author Vova Feldman (@svovaf)
201
- * @since 1.0.9
202
- *
203
- * @return bool
204
- */
205
- function is_trial() {
206
- return is_numeric( $this->trial_plan_id ) && ( strtotime( $this->trial_ends ) > WP_FS__SCRIPT_START_TIME );
207
- }
208
-
209
- /**
210
- * Check if user already utilized the trial with the current install.
211
- *
212
- * @author Vova Feldman (@svovaf)
213
- * @since 1.0.9
214
- *
215
- * @return bool
216
- */
217
- function is_trial_utilized() {
218
- return is_numeric( $this->trial_plan_id );
219
- }
220
-
221
- /**
222
- * @author Vova Feldman (@svovaf)
223
- * @since 2.0.0
224
- *
225
- * @return bool
226
- */
227
- function is_tracking_allowed() {
228
- return ( true !== $this->is_disconnected );
229
- }
230
-
231
- /**
232
- * @author Vova Feldman (@svovaf)
233
- * @since 2.0.0
234
- *
235
- * @return bool
236
- */
237
- function is_tracking_prohibited() {
238
- return ! $this->is_tracking_allowed();
239
- }
240
- }
1
  <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * Класс для хранения данных инсталла(сайта) freemius
15
+ * @author Webcraftic <jokerov@gmail.com>
16
+ * @copyright (c) 2018 Webraftic Ltd
17
+ * @version 1.0
18
+ */
19
+ class WCL_FS_Site extends WCL_FS_ScopeEntity {
20
 
21
  /**
22
+ * @var number
23
+ */
24
+ public $site_id;
25
+
26
+ /**
27
+ * @var string
28
+ */
29
+ public $public_key;
30
+
31
+ /**
32
+ * @var string
33
+ */
34
+ public $secret_key;
35
+
36
+ /**
37
+ * @var number
38
+ */
39
+ public $plugin_id;
40
+ /**
41
+ * @var number
42
+ */
43
+ public $user_id;
44
+ /**
45
+ * @var string
46
+ */
47
+ public $title;
48
+ /**
49
+ * @var string
50
+ */
51
+ public $url;
52
+ /**
53
+ * @var string
54
+ */
55
+ public $version;
56
+ /**
57
+ * @var string E.g. en-GB
58
+ */
59
+ public $language;
60
+ /**
61
+ * @var string E.g. UTF-8
62
+ */
63
+ public $charset;
64
+ /**
65
+ * @var string Platform version (e.g WordPress version).
66
+ */
67
+ public $platform_version;
68
+ /**
69
+ * Freemius SDK version
70
+ *
71
+ * @author Leo Fajardo (@leorw)
72
+ * @since 1.2.2
73
+ *
74
+ * @var string SDK version (e.g.: 1.2.2)
75
+ */
76
+ public $sdk_version;
77
+ /**
78
+ * @var string Programming language version (e.g PHP version).
79
+ */
80
+ public $programming_language_version;
81
+ /**
82
+ * @var number|null
83
+ */
84
+ public $plan_id;
85
+ /**
86
+ * @var number|null
87
+ */
88
+ public $license_id;
89
+ /**
90
+ * @var number|null
91
+ */
92
+ public $trial_plan_id;
93
+ /**
94
+ * @var string|null
95
+ */
96
+ public $trial_ends;
97
+ /**
98
+ * @since 1.0.9
99
+ *
100
+ * @var bool
101
+ */
102
+ public $is_premium = false;
103
+ /**
104
+ * @author Leo Fajardo (@leorw)
105
+ *
106
+ * @since 1.2.1.5
107
+ *
108
+ * @var bool
109
+ */
110
+ public $is_disconnected = false;
111
+ /**
112
+ * @since 2.0.0
113
+ *
114
+ * @var bool
115
+ */
116
+ public $is_active = true;
117
+ /**
118
+ * @since 2.0.0
119
+ *
120
+ * @var bool
121
+ */
122
+ public $is_uninstalled = false;
123
+
124
+ /**
125
+ * @param stdClass|bool $site
126
+ */
127
+ function __construct( $site = false ) {
128
+ parent::__construct( $site );
129
+
130
+ if ( is_object( $site ) and isset( $site->plan_id ) ) {
131
+ $this->plan_id = $site->plan_id;
132
+ }
133
+
134
+ if ( ! is_bool( $this->is_disconnected ) ) {
135
+ $this->is_disconnected = false;
136
+ }
137
+
138
+ $props = wcl_fs_get_object_public_vars( $this );
139
+
140
+ foreach ( $props as $key => $def_value ) {
141
+ $this->{$key} = isset( $site->{'install_' . $key} ) ? $site->{'install_' . $key} : $def_value;
142
+ }
143
+ if ( isset ( $site->install_id ) ) {
144
+ $this->site_id = $site->install_id;
145
+ }
146
+ }
147
+
148
+ static function get_type() {
149
+ return 'install';
150
+ }
151
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/freemius/entities/class.wcl-fs-user.php CHANGED
@@ -1,71 +1,85 @@
1
  <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
- * @since 1.0.3
7
- */
8
 
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
 
 
 
 
 
 
 
 
 
13
  /**
14
- * Класс для хранения данных пользователя с freemius
15
- * @author Webcraftic <jokerov@gmail.com>
16
- * @copyright (c) 2018 Webraftic Ltd
17
- * @version 1.0
18
  */
19
- class WCL_FS_User extends WCL_FS_ScopeEntity {
20
-
21
- /**
22
- * @var string
23
- */
24
- public $email;
25
- /**
26
- * @var string
27
- */
28
- public $first;
29
- /**
30
- * @var string
31
- */
32
- public $last;
33
- /**
34
- * @var bool
35
- */
36
- public $is_verified;
37
- /**
38
- * @var string|null
39
- */
40
- public $customer_id;
41
- /**
42
- * @var float
43
- */
44
- public $gross;
45
-
46
-
47
- /**
48
- * @param object|bool $user
49
- */
50
- public function __construct( $user = false ) {
51
- parent::__construct( $user );
52
- $props = wcl_fs_get_object_public_vars( $this );
53
-
54
- foreach ( $props as $key => $def_value ) {
55
- $this->{$key} = isset( $user->{ 'user_' . $key } ) ? $user->{ 'user_' . $key } : $def_value;
56
- }
57
- }
58
-
59
- public function get_name() {
60
- return trim( ucfirst( trim( is_string( $this->first ) ? $this->first : '' ) ) . ' ' . ucfirst( trim( is_string( $this->last ) ? $this->last : '' ) ) );
61
- }
62
-
63
- public function is_verified() {
64
- return ( isset( $this->is_verified ) && true === $this->is_verified );
65
- }
66
-
67
- static function get_type() {
68
- return 'user';
69
- }
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  }
 
1
  <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
+ * @since 1.0.3
7
+ */
8
 
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
 
13
+ /**
14
+ * Класс для хранения данных пользователя с freemius
15
+ * @author Webcraftic <jokerov@gmail.com>
16
+ * @copyright (c) 2018 Webraftic Ltd
17
+ * @version 1.0
18
+ */
19
+ class WCL_FS_User extends WCL_FS_ScopeEntity {
20
+
21
  /**
22
+ * @var int
 
 
 
23
  */
24
+ public $id;
25
+
26
+ /**
27
+ * @var string
28
+ */
29
+ public $public_key;
30
+
31
+ /**
32
+ * @var string
33
+ */
34
+ public $secret_key;
35
+
36
+ /**
37
+ * @var string
38
+ */
39
+ public $email;
40
+ /**
41
+ * @var string
42
+ */
43
+ public $first;
44
+ /**
45
+ * @var string
46
+ */
47
+ public $last;
48
+ /**
49
+ * @var bool
50
+ */
51
+ public $is_verified;
52
+ /**
53
+ * @var string|null
54
+ */
55
+ public $customer_id;
56
+ /**
57
+ * @var float
58
+ */
59
+ public $gross;
60
+
61
+
62
+ /**
63
+ * @param object|bool $user
64
+ */
65
+ public function __construct( $user = false ) {
66
+ parent::__construct( $user );
67
+ $props = wcl_fs_get_object_public_vars( $this );
 
 
 
 
 
 
 
68
 
69
+ foreach ( $props as $key => $def_value ) {
70
+ $this->{$key} = isset( $user->{'user_' . $key} ) ? $user->{'user_' . $key} : $def_value;
71
+ }
72
+ }
73
+
74
+ public function get_name() {
75
+ return trim( ucfirst( trim( is_string( $this->first ) ? $this->first : '' ) ) . ' ' . ucfirst( trim( is_string( $this->last ) ? $this->last : '' ) ) );
76
+ }
77
+
78
+ public function is_verified() {
79
+ return ( isset( $this->is_verified ) && true === $this->is_verified );
80
+ }
81
+
82
+ static function get_type() {
83
+ return 'user';
84
  }
85
+ }
includes/freemius/entities/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
includes/freemius/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
includes/freemius/sdk/Exceptions/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
includes/freemius/sdk/FreemiusBase.php CHANGED
@@ -1,204 +1,196 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /**
3
- * Copyright 2014 Freemius, Inc.
4
- *
5
- * Licensed under the GPL v2 (the "License"); you may
6
- * not use this file except in compliance with the License. You may obtain
7
- * a copy of the License at
8
- *
9
- * http://choosealicense.com/licenses/gpl-v2/
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations
15
- * under the License.
16
  */
17
-
18
- define('WCL_FS_API__VERSION', '1');
19
- define('WCL_FS_SDK__PATH', dirname(__FILE__));
20
- define('WCL_FS_SDK__EXCEPTIONS_PATH', WCL_FS_SDK__PATH . '/Exceptions/');
21
-
22
- if (!function_exists('json_decode'))
23
- throw new Exception('Freemius needs the JSON PHP extension.');
24
-
25
- // Include all exception files.
26
- $exceptions = array(
27
- 'Exception',
28
- 'InvalidArgumentException',
29
- 'ArgumentNotExistException',
30
- 'EmptyArgumentException',
31
- 'OAuthException'
32
- );
33
-
34
- foreach ($exceptions as $e)
35
- require WCL_FS_SDK__EXCEPTIONS_PATH . $e . '.php';
36
-
37
- abstract class WCL_Freemius_Api_Base
38
- {
39
- const VERSION = '1.0.4';
40
- const FORMAT = 'json';
41
-
42
- protected $_id;
43
- protected $_public;
44
- protected $_secret;
45
- protected $_scope;
46
- protected $_sandbox;
47
-
48
- /**
49
- * @param string $pScope 'app', 'developer', 'user' or 'install'.
50
- * @param number $pID Element's id.
51
- * @param string $pPublic Public key.
52
- * @param string $pSecret Element's secret key.
53
- * @param bool $pSandbox Whether or not to run API in sandbox mode.
54
- */
55
- public function Init($pScope, $pID, $pPublic, $pSecret, $pSandbox = false)
56
- {
57
- $this->_id = $pID;
58
- $this->_public = $pPublic;
59
- $this->_secret = $pSecret;
60
- $this->_scope = $pScope;
61
- $this->_sandbox = $pSandbox;
62
- }
63
-
64
- public function IsSandbox()
65
- {
66
- return $this->_sandbox;
67
- }
68
-
69
- function CanonizePath($pPath)
70
- {
71
- $pPath = trim($pPath, '/');
72
- $query_pos = strpos($pPath, '?');
73
- $query = '';
74
-
75
- if (false !== $query_pos) {
76
- $query = substr($pPath, $query_pos);
77
- $pPath = substr($pPath, 0, $query_pos);
78
- }
79
-
80
- // Trim '.json' suffix.
81
- $format_length = strlen('.' . self::FORMAT);
82
- $start = $format_length * (-1); //negative
83
- if (substr(strtolower($pPath), $start) === ('.' . self::FORMAT))
84
- $pPath = substr($pPath, 0, strlen($pPath) - $format_length);
85
-
86
- switch ($this->_scope) {
87
- case 'app':
88
- $base = '/apps/' . $this->_id;
89
- break;
90
- case 'developer':
91
- $base = '/developers/' . $this->_id;
92
- break;
93
- case 'user':
94
- $base = '/users/' . $this->_id;
95
- break;
96
- case 'plugin':
97
- $base = '/plugins/' . $this->_id;
98
- break;
99
- case 'install':
100
- $base = '/installs/' . $this->_id;
101
- break;
102
- default:
103
- throw new WCL_Freemius_Exception('Scope not implemented.');
104
- }
105
-
106
- return '/v' . WCL_FS_API__VERSION . $base .
107
- (!empty($pPath) ? '/' : '') . $pPath .
108
- ((false === strpos($pPath, '.')) ? '.' . self::FORMAT : '') . $query;
109
- }
110
-
111
- abstract function MakeRequest($pCanonizedPath, $pMethod = 'GET', $pParams = array(), $pFileParams = array());
112
-
113
- private function _Api($pPath, $pMethod = 'GET', $pParams = array(), $pFileParams = array())
114
- {
115
- $pMethod = strtoupper($pMethod);
116
-
117
- try {
118
- $result = $this->MakeRequest($pPath, $pMethod, $pParams, $pFileParams);
119
- }
120
- catch (WCL_Freemius_Exception $e)
121
- {
122
- // Map to error object.
123
- $result = json_encode($e->getResult());
124
- } catch (Exception $e) {
125
- // Map to error object.
126
- $result = json_encode(array(
127
- 'error' => array(
128
- 'type' => 'Unknown',
129
- 'message' => $e->getMessage() . ' (' . $e->getFile() . ': ' . $e->getLine() . ')',
130
- 'code' => 'unknown',
131
- 'http' => 402
132
- )
133
- ));
134
- }
135
-
136
- $decoded = null;
137
- if ( ! is_object( $result ) ) {
138
- $decoded = json_decode($result);
139
- }
140
-
141
- return (null === $decoded) ? $result : $decoded;
142
- }
143
-
144
- /**
145
- * @return bool True if successful connectivity to the API endpoint using ping.json endpoint.
146
- */
147
- public function Test()
148
- {
149
- $pong = $this->_Api('/v' . WCL_FS_API__VERSION . '/ping.json');
150
-
151
- return (is_object($pong) && isset($pong->api) && 'pong' === $pong->api);
152
  }
153
-
154
- /**
155
- * Find clock diff between current server to API server.
156
- *
157
- * @since 1.0.2
158
- * @return int Clock diff in seconds.
159
- */
160
- public function FindClockDiff()
161
- {
162
- $time = time();
163
- $pong = $this->_Api('/v' . WCL_FS_API__VERSION . '/ping.json');
164
- return ($time - strtotime($pong->timestamp));
165
  }
166
-
167
- public function Api($pPath, $pMethod = 'GET', $pParams = array(), $pFileParams = array())
168
- {
169
- return $this->_Api($this->CanonizePath($pPath), $pMethod, $pParams, $pFileParams);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  }
171
-
172
- /**
173
- * Base64 encoding that does not need to be urlencode()ed.
174
- * Exactly the same as base64_encode except it uses
175
- * - instead of +
176
- * _ instead of /
177
- * No padded =
178
- *
179
- * @param string $input base64UrlEncoded string
180
- * @return string
181
- */
182
- protected static function Base64UrlDecode($input)
183
- {
184
- return base64_decode(strtr($input, '-_', '+/'));
 
 
 
 
 
 
 
 
 
 
185
  }
186
-
187
- /**
188
- * Base64 encoding that does not need to be urlencode()ed.
189
- * Exactly the same as base64_encode except it uses
190
- * - instead of +
191
- * _ instead of /
192
- *
193
- * @param string $input string
194
- * @return string base64Url encoded string
195
- */
196
- protected static function Base64UrlEncode($input)
197
- {
198
- $str = strtr(base64_encode($input), '+/', '-_');
199
- $str = str_replace('=', '', $str);
200
-
201
- return $str;
202
  }
203
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  }
 
1
  <?php
2
+ /**
3
+ * Copyright 2014 Freemius, Inc.
4
+ *
5
+ * Licensed under the GPL v2 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://choosealicense.com/licenses/gpl-v2/
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ */
17
+
18
+ define( 'WCL_FS_API__VERSION', '1' );
19
+ define( 'WCL_FS_SDK__PATH', dirname( __FILE__ ) );
20
+ define( 'WCL_FS_SDK__EXCEPTIONS_PATH', WCL_FS_SDK__PATH . '/Exceptions/' );
21
+
22
+ if ( ! function_exists( 'json_decode' ) ) {
23
+ throw new Exception( 'Freemius needs the JSON PHP extension.' );
24
+ }
25
+
26
+ // Include all exception files.
27
+ $exceptions = array(
28
+ 'Exception',
29
+ 'InvalidArgumentException',
30
+ 'ArgumentNotExistException',
31
+ 'EmptyArgumentException',
32
+ 'OAuthException'
33
+ );
34
+
35
+ foreach ( $exceptions as $e ) {
36
+ require WCL_FS_SDK__EXCEPTIONS_PATH . $e . '.php';
37
+ }
38
+
39
+ abstract class WCL_Freemius_Api_Base {
40
+
41
+ const VERSION = '1.0.4';
42
+ const FORMAT = 'json';
43
+
44
+ protected $_id;
45
+ protected $_public;
46
+ protected $_secret;
47
+ protected $_scope;
48
+ protected $_sandbox;
49
+
50
  /**
51
+ * @param string $pScope 'app', 'developer', 'user' or 'install'.
52
+ * @param number $pID Element's id.
53
+ * @param string $pPublic Public key.
54
+ * @param string $pSecret Element's secret key.
55
+ * @param bool $pSandbox Whether or not to run API in sandbox mode.
 
 
 
 
 
 
 
 
56
  */
57
+ public function Init( $pScope, $pID, $pPublic, $pSecret, $pSandbox = false ) {
58
+ $this->_id = $pID;
59
+ $this->_public = $pPublic;
60
+ $this->_secret = $pSecret;
61
+ $this->_scope = $pScope;
62
+ $this->_sandbox = $pSandbox;
63
+ }
64
+
65
+ public function IsSandbox() {
66
+ return $this->_sandbox;
67
+ }
68
+
69
+ function CanonizePath( $pPath ) {
70
+ $pPath = trim( $pPath, '/' );
71
+ $query_pos = strpos( $pPath, '?' );
72
+ $query = '';
73
+
74
+ if ( false !== $query_pos ) {
75
+ $query = substr( $pPath, $query_pos );
76
+ $pPath = substr( $pPath, 0, $query_pos );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
+
79
+ // Trim '.json' suffix.
80
+ $format_length = strlen( '.' . self::FORMAT );
81
+ $start = $format_length * ( - 1 ); //negative
82
+ if ( substr( strtolower( $pPath ), $start ) === ( '.' . self::FORMAT ) ) {
83
+ $pPath = substr( $pPath, 0, strlen( $pPath ) - $format_length );
 
 
 
 
 
 
84
  }
85
+
86
+ switch ( $this->_scope ) {
87
+ case 'app':
88
+ $base = '/apps/' . $this->_id;
89
+ break;
90
+ case 'developer':
91
+ $base = '/developers/' . $this->_id;
92
+ break;
93
+ case 'user':
94
+ $base = '/users/' . $this->_id;
95
+ break;
96
+ case 'plugin':
97
+ $base = '/plugins/' . $this->_id;
98
+ break;
99
+ case 'install':
100
+ $base = '/installs/' . $this->_id;
101
+ break;
102
+ default:
103
+ throw new WCL_Freemius_Exception( 'Scope not implemented.' );
104
  }
105
+
106
+ return '/v' . WCL_FS_API__VERSION . $base . ( ! empty( $pPath ) ? '/' : '' ) . $pPath . ( ( false === strpos( $pPath, '.' ) ) ? '.' . self::FORMAT : '' ) . $query;
107
+ }
108
+
109
+ abstract function MakeRequest( $pCanonizedPath, $pMethod = 'GET', $pParams = array(), $pFileParams = array() );
110
+
111
+ private function _Api( $pPath, $pMethod = 'GET', $pParams = array(), $pFileParams = array() ) {
112
+ $pMethod = strtoupper( $pMethod );
113
+
114
+ try {
115
+ $result = $this->MakeRequest( $pPath, $pMethod, $pParams, $pFileParams );
116
+ } catch( WCL_Freemius_Exception $e ) {
117
+ // Map to error object.
118
+ $result = json_encode( $e->getResult() );
119
+ } catch( Exception $e ) {
120
+ // Map to error object.
121
+ $result = json_encode( array(
122
+ 'error' => array(
123
+ 'type' => 'Unknown',
124
+ 'message' => $e->getMessage() . ' (' . $e->getFile() . ': ' . $e->getLine() . ')',
125
+ 'code' => 'unknown',
126
+ 'http' => 402
127
+ )
128
+ ) );
129
  }
130
+
131
+ $decoded = null;
132
+ if ( ! is_object( $result ) ) {
133
+ $decoded = json_decode( $result );
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
135
+
136
+ return ( null === $decoded ) ? $result : $decoded;
137
+ }
138
+
139
+ /**
140
+ * @return bool True if successful connectivity to the API endpoint using ping.json endpoint.
141
+ */
142
+ public function Test() {
143
+ $pong = $this->_Api( '/v' . WCL_FS_API__VERSION . '/ping.json' );
144
+
145
+ return ( is_object( $pong ) && isset( $pong->api ) && 'pong' === $pong->api );
146
+ }
147
+
148
+ /**
149
+ * Find clock diff between current server to API server.
150
+ *
151
+ * @since 1.0.2
152
+ * @return int Clock diff in seconds.
153
+ */
154
+ public function FindClockDiff() {
155
+ $time = time();
156
+ $pong = $this->_Api( '/v' . WCL_FS_API__VERSION . '/ping.json' );
157
+
158
+ return ( $time - strtotime( $pong->timestamp ) );
159
+ }
160
+
161
+ public function Api( $pPath, $pMethod = 'GET', $pParams = array(), $pFileParams = array() ) {
162
+ return $this->_Api( $this->CanonizePath( $pPath ), $pMethod, $pParams, $pFileParams );
163
+ }
164
+
165
+ /**
166
+ * Base64 encoding that does not need to be urlencode()ed.
167
+ * Exactly the same as base64_encode except it uses
168
+ * - instead of +
169
+ * _ instead of /
170
+ * No padded =
171
+ *
172
+ * @param string $input base64UrlEncoded string
173
+ *
174
+ * @return string
175
+ */
176
+ protected static function Base64UrlDecode( $input ) {
177
+ return base64_decode( strtr( $input, '-_', '+/' ) );
178
+ }
179
+
180
+ /**
181
+ * Base64 encoding that does not need to be urlencode()ed.
182
+ * Exactly the same as base64_encode except it uses
183
+ * - instead of +
184
+ * _ instead of /
185
+ *
186
+ * @param string $input string
187
+ *
188
+ * @return string base64Url encoded string
189
+ */
190
+ protected static function Base64UrlEncode( $input ) {
191
+ $str = strtr( base64_encode( $input ), '+/', '-_' );
192
+ $str = str_replace( '=', '', $str );
193
+
194
+ return $str;
195
  }
196
+ }
includes/freemius/sdk/FreemiusWordPress.php CHANGED
@@ -1,704 +1,659 @@
1
  <?php
2
- /**
3
- * Copyright 2016 Freemius, Inc.
4
- *
5
- * Licensed under the GPL v2 (the "License"); you may
6
- * not use this file except in compliance with the License. You may obtain
7
- * a copy of the License at
8
- *
9
- * http://choosealicense.com/licenses/gpl-v2/
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations
15
- * under the License.
16
- */
17
-
18
- require_once dirname( __FILE__ ) . '/FreemiusBase.php';
19
-
20
- if ( ! defined( 'WCL_FS_SDK__USER_AGENT' ) ) {
21
- define( 'WCL_FS_SDK__USER_AGENT', 'fs-php-' . WCL_Freemius_Api_Base::VERSION );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
 
23
 
24
- if ( ! defined( 'WCL_FS_SDK__SIMULATE_NO_CURL' ) ) {
25
- define( 'WCL_FS_SDK__SIMULATE_NO_CURL', false );
26
- }
27
 
28
- if ( ! defined( 'WCL_FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
29
- define( 'WCL_FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
30
- }
31
 
32
- if ( ! defined( 'WCL_FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
33
- define( 'WCL_FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
34
- }
35
 
36
- if ( ! defined( 'WCL_FS_SDK__HAS_CURL' ) ) {
37
- if ( WCL_FS_SDK__SIMULATE_NO_CURL ) {
38
- define( 'WCL_FS_SDK__HAS_CURL', false );
39
- } else {
40
- $curl_required_methods = array(
41
- 'curl_version',
42
- 'curl_exec',
43
- 'curl_init',
44
- 'curl_close',
45
- 'curl_setopt',
46
- 'curl_setopt_array',
47
- 'curl_error',
48
- );
49
 
50
- $has_curl = true;
51
- foreach ( $curl_required_methods as $m ) {
52
- if ( ! function_exists( $m ) ) {
53
- $has_curl = false;
54
- break;
55
- }
56
- }
57
 
58
- define( 'WCL_FS_SDK__HAS_CURL', $has_curl );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
 
 
60
  }
61
-
62
- $curl_version = WCL_FS_SDK__HAS_CURL ?
63
- curl_version() :
64
- array( 'version' => '7.37' );
65
-
66
- if ( ! defined( 'WCL_FS_API__PROTOCOL' ) ) {
67
- define( 'WCL_FS_API__PROTOCOL', version_compare( $curl_version['version'], '7.37', '>=' ) ? 'https' : 'http' );
 
 
68
  }
69
-
70
- if ( ! defined( 'WCL_FS_API__LOGGER_ON' ) ) {
71
- define( 'WCL_FS_API__LOGGER_ON', false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
-
74
- if ( ! defined( 'WCL_FS_API__ADDRESS' ) ) {
75
- define( 'WCL_FS_API__ADDRESS', '://api.freemius.com' );
 
 
 
 
 
 
 
 
 
76
  }
77
- if ( ! defined( 'WCL_FS_API__SANDBOX_ADDRESS' ) ) {
78
- define( 'WCL_FS_API__SANDBOX_ADDRESS', '://sandbox-api.freemius.com' );
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
-
81
- if ( class_exists( 'WCL_FreemiusWPApi' ) ) {
82
- return;
 
 
 
 
 
83
  }
84
-
85
- class WCL_FreemiusWPApi extends WCL_Freemius_Api_Base {
86
- private static $_logger = array();
87
-
88
- /**
89
- * @param string $pScope 'app', 'developer', 'user' or 'install'.
90
- * @param number $pID Element's id.
91
- * @param string $pPublic Public key.
92
- * @param string|bool $pSecret Element's secret key.
93
- * @param bool $pSandbox Whether or not to run API in sandbox mode.
94
- */
95
- public function __construct( $pScope, $pID, $pPublic, $pSecret = false, $pSandbox = false ) {
96
- // If secret key not provided, use public key encryption.
97
- if ( is_bool( $pSecret ) ) {
98
- $pSecret = $pPublic;
99
- }
100
-
101
- parent::Init( $pScope, $pID, $pPublic, $pSecret, $pSandbox );
102
- }
103
-
104
- public static function GetUrl( $pCanonizedPath = '', $pIsSandbox = false ) {
105
- $address = ( $pIsSandbox ? WCL_FS_API__SANDBOX_ADDRESS : WCL_FS_API__ADDRESS );
106
-
107
- if ( ':' === $address[0] ) {
108
- $address = self::$_protocol . $address;
109
- }
110
-
111
- return $address . $pCanonizedPath;
112
  }
113
-
114
- #----------------------------------------------------------------------------------
115
- #region Servers Clock Diff
116
- #----------------------------------------------------------------------------------
117
-
118
- /**
119
- * @var int Clock diff in seconds between current server to API server.
120
- */
121
- private static $_clock_diff = 0;
122
-
123
- /**
124
- * Set clock diff for all API calls.
125
- *
126
- * @since 1.0.3
127
- *
128
- * @param $pSeconds
129
- */
130
- public static function SetClockDiff( $pSeconds ) {
131
- self::$_clock_diff = $pSeconds;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  }
133
-
134
- /**
135
- * Find clock diff between current server to API server.
136
- *
137
- * @since 1.0.2
138
- * @return int Clock diff in seconds.
139
- */
140
- public function FindClockDiff() {
141
- $time = time();
142
- $pong = self::Ping();
143
-
144
- return ( $time - strtotime( $pong->timestamp ) );
 
 
 
 
 
 
 
 
145
  }
146
-
147
- #endregion
148
-
149
- /**
150
- * @var string http or https
151
- */
152
- private static $_protocol = WCL_FS_API__PROTOCOL;
153
-
154
- /**
155
- * Set API connection protocol.
156
- *
157
- * @since 1.0.4
158
- */
159
- public static function SetHttp() {
160
- self::$_protocol = 'http';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  }
162
-
163
- /**
164
- * @since 1.0.4
165
- *
166
- * @return bool
167
- */
168
- public static function IsHttps() {
169
- return ( 'https' === self::$_protocol );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  }
171
-
172
- /**
173
- * Sign request with the following HTTP headers:
174
- * Content-MD5: MD5(HTTP Request body)
175
- * Date: Current date (i.e Sat, 14 Feb 2016 20:24:46 +0000)
176
- * Authorization: FS {scope_entity_id}:{scope_entity_public_key}:base64encode(sha256(string_to_sign,
177
- * {scope_entity_secret_key}))
178
- *
179
- * @param string $pResourceUrl
180
- * @param array $pWPRemoteArgs
181
- *
182
- * @return array
183
- */
184
- function SignRequest( $pResourceUrl, $pWPRemoteArgs ) {
185
- $auth = $this->GenerateAuthorizationParams(
186
- $pResourceUrl,
187
- $pWPRemoteArgs['method'],
188
- ! empty( $pWPRemoteArgs['body'] ) ? $pWPRemoteArgs['body'] : ''
189
  );
190
-
191
- $pWPRemoteArgs['headers']['Date'] = $auth['date'];
192
- $pWPRemoteArgs['headers']['Authorization'] = $auth['authorization'];
193
-
194
- if ( ! empty( $auth['content_md5'] ) ) {
195
- $pWPRemoteArgs['headers']['Content-MD5'] = $auth['content_md5'];
196
- }
197
-
198
- return $pWPRemoteArgs;
199
  }
200
-
201
- /**
202
- * Generate Authorization request headers:
203
- *
204
- * Content-MD5: MD5(HTTP Request body)
205
- * Date: Current date (i.e Sat, 14 Feb 2016 20:24:46 +0000)
206
- * Authorization: FS {scope_entity_id}:{scope_entity_public_key}:base64encode(sha256(string_to_sign,
207
- * {scope_entity_secret_key}))
208
- *
209
- * @author Vova Feldman
210
- *
211
- * @param string $pResourceUrl
212
- * @param string $pMethod
213
- * @param string $pPostParams
214
- *
215
- * @return array
216
- * @throws WCL_Freemius_Exception
217
- */
218
- function GenerateAuthorizationParams(
219
- $pResourceUrl,
220
- $pMethod = 'GET',
221
- $pPostParams = ''
222
- ) {
223
- $pMethod = strtoupper( $pMethod );
224
-
225
- $eol = "\n";
226
- $content_md5 = '';
227
- $content_type = '';
228
- $now = ( time() - self::$_clock_diff );
229
- $date = date( 'r', $now );
230
-
231
- if ( in_array( $pMethod, array( 'POST', 'PUT' ) ) && ! empty( $pPostParams ) ) {
232
- $content_md5 = md5( $pPostParams );
233
- $content_type = 'application/json';
234
- }
235
-
236
- $string_to_sign = implode( $eol, array(
237
- $pMethod,
238
- $content_md5,
239
- $content_type,
240
- $date,
241
- $pResourceUrl
242
- ) );
243
-
244
- // If secret and public keys are identical, it means that
245
- // the signature uses public key hash encoding.
246
- $auth_type = ( $this->_secret !== $this->_public ) ? 'FS' : 'FSP';
247
-
248
- $auth = array(
249
- 'date' => $date,
250
- 'authorization' => $auth_type . ' ' . $this->_id . ':' .
251
- $this->_public . ':' .
252
- self::Base64UrlEncode( hash_hmac(
253
- 'sha256', $string_to_sign, $this->_secret
254
- ) )
255
- );
256
-
257
- if ( ! empty( $content_md5 ) ) {
258
- $auth['content_md5'] = $content_md5;
259
- }
260
-
261
- return $auth;
262
  }
263
-
264
- /**
265
- * Get API request URL signed via query string.
266
- *
267
- * @since 1.2.3 Stopped using http_build_query(). Instead, use urlencode(). In some environments the encoding of http_build_query() can generate a URL that once used with a redirect, the `&` querystring separator is escaped to `&amp;` which breaks the URL (Added by @svovaf).
268
- *
269
- * @param string $pPath
270
- *
271
- * @throws WCL_Freemius_Exception
272
- *
273
- * @return string
274
- */
275
- function GetSignedUrl( $pPath ) {
276
- $resource = explode( '?', $this->CanonizePath( $pPath ) );
277
- $pResourceUrl = $resource[0];
278
-
279
- $auth = $this->GenerateAuthorizationParams( $pResourceUrl );
280
-
281
- return Freemius_Api_WordPress::GetUrl(
282
- $pResourceUrl . '?' .
283
- ( 1 < count( $resource ) && ! empty( $resource[1] ) ? $resource[1] . '&' : '' ) .
284
- 'authorization=' . urlencode( $auth['authorization'] ) .
285
- '&auth_date=' . urlencode( $auth['date'] )
286
- , $this->_sandbox );
287
- }
288
-
289
- /**
290
- * @author Vova Feldman
291
- *
292
- * @param string $pUrl
293
- * @param array $pWPRemoteArgs
294
- *
295
- * @return mixed
296
- */
297
- private static function ExecuteRequest( $pUrl, &$pWPRemoteArgs ) {
298
- $start = microtime( true );
299
-
300
- $response = wp_remote_request( $pUrl, $pWPRemoteArgs );
301
-
302
- if ( WCL_FS_API__LOGGER_ON ) {
303
- $end = microtime( true );
304
-
305
- $has_body = ( isset( $pWPRemoteArgs['body'] ) && ! empty( $pWPRemoteArgs['body'] ) );
306
- $is_http_error = is_wp_error( $response );
307
-
308
- self::$_logger[] = array(
309
- 'id' => count( self::$_logger ),
310
- 'start' => $start,
311
- 'end' => $end,
312
- 'total' => ( $end - $start ),
313
- 'method' => $pWPRemoteArgs['method'],
314
- 'path' => $pUrl,
315
- 'body' => $has_body ? $pWPRemoteArgs['body'] : null,
316
- 'result' => ! $is_http_error ?
317
- $response['body'] :
318
- json_encode( $response->get_error_messages() ),
319
- 'code' => ! $is_http_error ? $response['response']['code'] : null,
320
- 'backtrace' => debug_backtrace(),
321
- );
322
  }
323
-
324
- return $response;
325
  }
326
-
327
- /**
328
- * @return array
329
- */
330
- static function GetLogger() {
331
- return self::$_logger;
 
 
 
332
  }
333
-
334
- /**
335
- * @param string $pCanonizedPath
336
- * @param string $pMethod
337
- * @param array $pParams
338
- * @param null|array $pWPRemoteArgs
339
- * @param bool $pIsSandbox
340
- * @param null|callable $pBeforeExecutionFunction
341
- *
342
- * @return object[]|object|null
343
- *
344
- * @throws \WCL_Freemius_Exception
345
- */
346
- private static function MakeStaticRequest(
347
- $pCanonizedPath,
348
- $pMethod = 'GET',
349
- $pParams = array(),
350
- $pWPRemoteArgs = null,
351
- $pIsSandbox = false,
352
- $pBeforeExecutionFunction = null
353
- ) {
354
- // Connectivity errors simulation.
355
- if ( WCL_FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
356
- self::ThrowCloudFlareDDoSException();
357
- } else if ( WCL_FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
358
- self::ThrowSquidAclException();
359
- }
360
-
361
- if ( empty( $pWPRemoteArgs ) ) {
362
- $user_agent = 'Freemius/WordPress-SDK/' . WCL_Freemius_Api_Base::VERSION . '; ' .
363
- home_url();
364
-
365
- $pWPRemoteArgs = array(
366
- 'method' => strtoupper( $pMethod ),
367
- 'connect_timeout' => 10,
368
- 'timeout' => 60,
369
- 'follow_redirects' => true,
370
- 'redirection' => 5,
371
- 'user-agent' => $user_agent,
372
- 'blocking' => true,
373
- );
374
- }
375
-
376
- if ( ! isset( $pWPRemoteArgs['headers'] ) ||
377
- ! is_array( $pWPRemoteArgs['headers'] )
378
- ) {
379
- $pWPRemoteArgs['headers'] = array();
380
- }
381
-
382
- if ( in_array( $pMethod, array( 'POST', 'PUT' ) ) ) {
383
- if ( is_array( $pParams ) && 0 < count( $pParams ) ) {
384
- $pWPRemoteArgs['headers']['Content-type'] = 'application/json';
385
- $pWPRemoteArgs['body'] = json_encode( $pParams );
386
- }
387
- }
388
-
389
- $request_url = self::GetUrl( $pCanonizedPath, $pIsSandbox );
390
-
391
- $resource = explode( '?', $pCanonizedPath );
392
-
393
- if ( WCL_FS_SDK__HAS_CURL ) {
394
- // Disable the 'Expect: 100-continue' behaviour. This causes cURL to wait
395
- // for 2 seconds if the server does not support this header.
396
- $pWPRemoteArgs['headers']['Expect'] = '';
397
- }
398
-
399
- if ( 'https' === substr( strtolower( $request_url ), 0, 5 ) ) {
400
- $pWPRemoteArgs['sslverify'] = false;
401
- }
402
-
403
- if ( false !== $pBeforeExecutionFunction &&
404
- is_callable( $pBeforeExecutionFunction )
405
- ) {
406
- $pWPRemoteArgs = call_user_func( $pBeforeExecutionFunction, $resource[0], $pWPRemoteArgs );
407
- }
408
-
409
- $result = self::ExecuteRequest( $request_url, $pWPRemoteArgs );
410
-
411
- if ( is_wp_error( $result ) ) {
412
  /**
413
- * @var WP_Error $result
 
 
 
 
414
  */
415
- if ( self::IsCurlError( $result ) ) {
 
 
416
  /**
417
- * With dual stacked DNS responses, it's possible for a server to
418
- * have IPv6 enabled but not have IPv6 connectivity. If this is
419
- * the case, cURL will try IPv4 first and if that fails, then it will
420
- * fall back to IPv6 and the error EHOSTUNREACH is returned by the
421
- * operating system.
422
  */
423
- $matches = array();
424
- $regex = '/Failed to connect to ([^:].*): Network is unreachable/';
425
- if ( preg_match( $regex, $result->get_error_message( 'http_request_failed' ), $matches ) ) {
426
- /**
427
- * Validate IP before calling `inet_pton()` to avoid PHP un-catchable warning.
428
- * @author Vova Feldman (@svovaf)
429
- */
430
- if ( filter_var( $matches[1], FILTER_VALIDATE_IP ) ) {
431
- if ( strlen( inet_pton( $matches[1] ) ) === 16 ) {
432
- // error_log('Invalid IPv6 configuration on server, Please disable or get native IPv6 on your server.');
433
- // Hook to an action triggered just before cURL is executed to resolve the IP version to v4.
434
- add_action( 'http_api_curl', 'Freemius_Api_WordPress::CurlResolveToIPv4', 10, 1 );
435
-
436
- // Re-run request.
437
- $result = self::ExecuteRequest( $request_url, $pWPRemoteArgs );
438
- }
439
  }
440
  }
441
  }
442
-
443
- if ( is_wp_error( $result ) ) {
444
- self::ThrowWPRemoteException( $result );
445
- }
446
  }
447
-
448
- $response_body = $result['body'];
449
-
450
- if ( empty( $response_body ) ) {
451
- return null;
452
- }
453
-
454
- $decoded = json_decode( $response_body );
455
-
456
- if ( is_null( $decoded ) ) {
457
- if ( preg_match( '/Please turn JavaScript on/i', $response_body ) &&
458
- preg_match( '/text\/javascript/', $response_body )
459
- ) {
460
- self::ThrowCloudFlareDDoSException( $response_body );
461
- } else if ( preg_match( '/Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect./', $response_body ) &&
462
- preg_match( '/squid/', $response_body )
463
- ) {
464
- self::ThrowSquidAclException( $response_body );
465
- } else {
466
- $decoded = (object) array(
467
- 'error' => (object) array(
468
- 'type' => 'Unknown',
469
- 'message' => $response_body,
470
- 'code' => 'unknown',
471
- 'http' => 402
472
- )
473
- );
474
- }
475
  }
476
-
477
- return $decoded;
478
  }
479
-
480
-
481
- /**
482
- * Makes an HTTP request. This method can be overridden by subclasses if
483
- * developers want to do fancier things or use something other than wp_remote_request()
484
- * to make the request.
485
- *
486
- * @param string $pCanonizedPath The URL to make the request to
487
- * @param string $pMethod HTTP method
488
- * @param array $pParams The parameters to use for the POST body
489
- * @param null|array $pWPRemoteArgs wp_remote_request options.
490
- *
491
- * @return object[]|object|null
492
- *
493
- * @throws WCL_Freemius_Exception
494
- */
495
- public function MakeRequest(
496
- $pCanonizedPath,
497
- $pMethod = 'GET',
498
- $pParams = array(),
499
- $pWPRemoteArgs = null
500
- ) {
501
- $resource = explode( '?', $pCanonizedPath );
502
-
503
- // Only sign request if not ping.json connectivity test.
504
- $sign_request = ( '/v1/ping.json' !== strtolower( substr( $resource[0], - strlen( '/v1/ping.json' ) ) ) );
505
-
506
- return self::MakeStaticRequest(
507
- $pCanonizedPath,
508
- $pMethod,
509
- $pParams,
510
- $pWPRemoteArgs,
511
- $this->_sandbox,
512
- $sign_request ? array( &$this, 'SignRequest' ) : null
513
- );
514
- }
515
-
516
- /**
517
- * Sets CURLOPT_IPRESOLVE to CURL_IPRESOLVE_V4 for cURL-Handle provided as parameter
518
- *
519
- * @param resource $handle A cURL handle returned by curl_init()
520
- *
521
- * @return resource $handle A cURL handle returned by curl_init() with CURLOPT_IPRESOLVE set to
522
- * CURL_IPRESOLVE_V4
523
- *
524
- * @link https://gist.github.com/golderweb/3a2aaec2d56125cc004e
525
- */
526
- static function CurlResolveToIPv4( $handle ) {
527
- curl_setopt( $handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
528
-
529
- return $handle;
530
- }
531
-
532
- #----------------------------------------------------------------------------------
533
- #region Connectivity Test
534
- #----------------------------------------------------------------------------------
535
-
536
- /**
537
- * If successful connectivity to the API endpoint using ping.json endpoint.
538
- *
539
- * - OR -
540
- *
541
- * Validate if ping result object is valid.
542
- *
543
- * @param mixed $pPong
544
- *
545
- * @return bool
546
- */
547
- public function Test( $pPong = null ) {
548
- $pong = is_null( $pPong ) ?
549
- self::Ping() :
550
- $pPong;
551
-
552
- return (
553
- is_object( $pong ) &&
554
- isset( $pong->api ) &&
555
- 'pong' === $pong->api
556
- );
557
  }
558
-
559
- /**
560
- * Ping API to test connectivity.
561
- *
562
- * @return object
563
- */
564
- public static function Ping() {
565
- try {
566
- $result = self::MakeStaticRequest( '/v' . WCL_FS_API__VERSION . '/ping.json' );
567
- } catch ( WCL_Freemius_Exception $e ) {
568
- // Map to error object.
569
- $result = (object) $e->getResult();
570
- } catch ( Exception $e ) {
571
- // Map to error object.
572
- $result = (object) array(
573
- 'error' => array(
574
  'type' => 'Unknown',
575
- 'message' => $e->getMessage() . ' (' . $e->getFile() . ': ' . $e->getLine() . ')',
576
  'code' => 'unknown',
577
  'http' => 402
578
  )
579
  );
580
  }
581
-
582
- return $result;
583
  }
584
-
585
- #endregion
586
-
587
- #----------------------------------------------------------------------------------
588
- #region Connectivity Exceptions
589
- #----------------------------------------------------------------------------------
590
-
591
- /**
592
- * @param \WP_Error $pError
593
- *
594
- * @return bool
595
- */
596
- private static function IsCurlError( WP_Error $pError ) {
597
- $message = $pError->get_error_message( 'http_request_failed' );
598
-
599
- return ( 0 === strpos( $message, 'cURL' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
600
  }
601
-
602
- /**
603
- * @param WP_Error $pError
604
- *
605
- * @throws WCL_Freemius_Exception
606
- */
607
- private static function ThrowWPRemoteException( WP_Error $pError ) {
608
- if ( self::IsCurlError( $pError ) ) {
609
- $message = $pError->get_error_message( 'http_request_failed' );
610
-
611
- #region Check if there are any missing cURL methods.
612
-
613
- $curl_required_methods = array(
614
- 'curl_version',
615
- 'curl_exec',
616
- 'curl_init',
617
- 'curl_close',
618
- 'curl_setopt',
619
- 'curl_setopt_array',
620
- 'curl_error',
621
- );
622
-
623
- // Find all missing methods.
624
- $missing_methods = array();
625
- foreach ( $curl_required_methods as $m ) {
626
- if ( ! function_exists( $m ) ) {
627
- $missing_methods[] = $m;
628
- }
629
- }
630
-
631
- if ( ! empty( $missing_methods ) ) {
632
- throw new WCL_Freemius_Exception( array(
633
- 'error' => (object) array(
634
- 'type' => 'cUrlMissing',
635
- 'message' => $message,
636
- 'code' => 'curl_missing',
637
- 'http' => 402
638
- ),
639
- 'missing_methods' => $missing_methods,
640
- ) );
 
 
 
 
 
 
 
641
  }
642
-
643
- #endregion
644
-
645
- // cURL error - "cURL error {{errno}}: {{error}}".
646
- $parts = explode( ':', substr( $message, strlen( 'cURL error ' ) ), 2 );
647
-
648
- $code = ( 0 < count( $parts ) ) ? $parts[0] : 'http_request_failed';
649
- $message = ( 1 < count( $parts ) ) ? $parts[1] : $message;
650
-
651
- $e = new WCL_Freemius_Exception( array(
652
- 'error' => array(
653
- 'code' => $code,
654
  'message' => $message,
655
- 'type' => 'CurlException',
656
- ),
657
- ) );
658
- } else {
659
- $e = new WCL_Freemius_Exception( array(
660
- 'error' => array(
661
- 'code' => $pError->get_error_code(),
662
- 'message' => $pError->get_error_message(),
663
- 'type' => 'WPRemoteException',
664
  ),
 
665
  ) );
666
  }
667
-
668
- throw $e;
669
- }
670
-
671
- /**
672
- * @param string $pResult
673
- *
674
- * @throws WCL_Freemius_Exception
675
- */
676
- private static function ThrowCloudFlareDDoSException( $pResult = '' ) {
677
- throw new WCL_Freemius_Exception( array(
678
- 'error' => (object) array(
679
- 'type' => 'CloudFlareDDoSProtection',
680
- 'message' => $pResult,
681
- 'code' => 'cloudflare_ddos_protection',
682
- 'http' => 402
683
- )
684
  ) );
685
- }
686
-
687
- /**
688
- * @param string $pResult
689
- *
690
- * @throws WCL_Freemius_Exception
691
- */
692
- private static function ThrowSquidAclException( $pResult = '' ) {
693
- throw new WCL_Freemius_Exception( array(
694
- 'error' => (object) array(
695
- 'type' => 'SquidCacheBlock',
696
- 'message' => $pResult,
697
- 'code' => 'squid_cache_block',
698
- 'http' => 402
699
- )
700
  ) );
701
  }
702
-
703
- #endregion
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704
  }
 
 
 
1
  <?php
2
+ /**
3
+ * Copyright 2016 Freemius, Inc.
4
+ *
5
+ * Licensed under the GPL v2 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://choosealicense.com/licenses/gpl-v2/
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ */
17
+
18
+ require_once dirname( __FILE__ ) . '/FreemiusBase.php';
19
+
20
+ if ( ! defined( 'WCL_FS_SDK__USER_AGENT' ) ) {
21
+ define( 'WCL_FS_SDK__USER_AGENT', 'fs-php-' . WCL_Freemius_Api_Base::VERSION );
22
+ }
23
+
24
+ if ( ! defined( 'WCL_FS_SDK__SIMULATE_NO_CURL' ) ) {
25
+ define( 'WCL_FS_SDK__SIMULATE_NO_CURL', false );
26
+ }
27
+
28
+ if ( ! defined( 'WCL_FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
29
+ define( 'WCL_FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
30
+ }
31
+
32
+ if ( ! defined( 'WCL_FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
33
+ define( 'WCL_FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
34
+ }
35
+
36
+ if ( ! defined( 'WCL_FS_SDK__HAS_CURL' ) ) {
37
+ if ( WCL_FS_SDK__SIMULATE_NO_CURL ) {
38
+ define( 'WCL_FS_SDK__HAS_CURL', false );
39
+ } else {
40
+ $curl_required_methods = array(
41
+ 'curl_version',
42
+ 'curl_exec',
43
+ 'curl_init',
44
+ 'curl_close',
45
+ 'curl_setopt',
46
+ 'curl_setopt_array',
47
+ 'curl_error',
48
+ );
49
+
50
+ $has_curl = true;
51
+ foreach ( $curl_required_methods as $m ) {
52
+ if ( ! function_exists( $m ) ) {
53
+ $has_curl = false;
54
+ break;
55
+ }
56
+ }
57
+
58
+ define( 'WCL_FS_SDK__HAS_CURL', $has_curl );
59
  }
60
+ }
61
 
62
+ $curl_version = WCL_FS_SDK__HAS_CURL ? curl_version() : array( 'version' => '7.37' );
 
 
63
 
64
+ if ( ! defined( 'WCL_FS_API__PROTOCOL' ) ) {
65
+ define( 'WCL_FS_API__PROTOCOL', version_compare( $curl_version['version'], '7.37', '>=' ) ? 'https' : 'http' );
66
+ }
67
 
68
+ if ( ! defined( 'WCL_FS_API__LOGGER_ON' ) ) {
69
+ define( 'WCL_FS_API__LOGGER_ON', false );
70
+ }
71
 
72
+ if ( ! defined( 'WCL_FS_API__ADDRESS' ) ) {
73
+ define( 'WCL_FS_API__ADDRESS', '://api.freemius.com' );
74
+ }
75
+ if ( ! defined( 'WCL_FS_API__SANDBOX_ADDRESS' ) ) {
76
+ define( 'WCL_FS_API__SANDBOX_ADDRESS', '://sandbox-api.freemius.com' );
77
+ }
 
 
 
 
 
 
 
78
 
79
+ if ( class_exists( 'WCL_FreemiusWPApi' ) ) {
80
+ return;
81
+ }
 
 
 
 
82
 
83
+ class WCL_FreemiusWPApi extends WCL_Freemius_Api_Base {
84
+
85
+ private static $_logger = array();
86
+
87
+ /**
88
+ * @param string $pScope 'app', 'developer', 'user' or 'install'.
89
+ * @param number $pID Element's id.
90
+ * @param string $pPublic Public key.
91
+ * @param string|bool $pSecret Element's secret key.
92
+ * @param bool $pSandbox Whether or not to run API in sandbox mode.
93
+ */
94
+ public function __construct( $pScope, $pID, $pPublic, $pSecret = false, $pSandbox = false ) {
95
+ // If secret key not provided, use public key encryption.
96
+ if ( is_bool( $pSecret ) ) {
97
+ $pSecret = $pPublic;
98
  }
99
+
100
+ parent::Init( $pScope, $pID, $pPublic, $pSecret, $pSandbox );
101
  }
102
+
103
+ public static function GetUrl( $pCanonizedPath = '', $pIsSandbox = false ) {
104
+ $address = ( $pIsSandbox ? WCL_FS_API__SANDBOX_ADDRESS : WCL_FS_API__ADDRESS );
105
+
106
+ if ( ':' === $address[0] ) {
107
+ $address = self::$_protocol . $address;
108
+ }
109
+
110
+ return $address . $pCanonizedPath;
111
  }
112
+
113
+ #----------------------------------------------------------------------------------
114
+ #region Servers Clock Diff
115
+ #----------------------------------------------------------------------------------
116
+
117
+ /**
118
+ * @var int Clock diff in seconds between current server to API server.
119
+ */
120
+ private static $_clock_diff = 0;
121
+
122
+ /**
123
+ * Set clock diff for all API calls.
124
+ *
125
+ * @since 1.0.3
126
+ *
127
+ * @param $pSeconds
128
+ */
129
+ public static function SetClockDiff( $pSeconds ) {
130
+ self::$_clock_diff = $pSeconds;
131
  }
132
+
133
+ /**
134
+ * Find clock diff between current server to API server.
135
+ *
136
+ * @since 1.0.2
137
+ * @return int Clock diff in seconds.
138
+ */
139
+ public function FindClockDiff() {
140
+ $time = time();
141
+ $pong = self::Ping();
142
+
143
+ return ( $time - strtotime( $pong->timestamp ) );
144
  }
145
+
146
+ #endregion
147
+
148
+ /**
149
+ * @var string http or https
150
+ */
151
+ private static $_protocol = WCL_FS_API__PROTOCOL;
152
+
153
+ /**
154
+ * Set API connection protocol.
155
+ *
156
+ * @since 1.0.4
157
+ */
158
+ public static function SetHttp() {
159
+ self::$_protocol = 'http';
160
  }
161
+
162
+ /**
163
+ * @since 1.0.4
164
+ *
165
+ * @return bool
166
+ */
167
+ public static function IsHttps() {
168
+ return ( 'https' === self::$_protocol );
169
  }
170
+
171
+ /**
172
+ * Sign request with the following HTTP headers:
173
+ * Content-MD5: MD5(HTTP Request body)
174
+ * Date: Current date (i.e Sat, 14 Feb 2016 20:24:46 +0000)
175
+ * Authorization: FS {scope_entity_id}:{scope_entity_public_key}:base64encode(sha256(string_to_sign,
176
+ * {scope_entity_secret_key}))
177
+ *
178
+ * @param string $pResourceUrl
179
+ * @param array $pWPRemoteArgs
180
+ *
181
+ * @return array
182
+ */
183
+ function SignRequest( $pResourceUrl, $pWPRemoteArgs ) {
184
+ $auth = $this->GenerateAuthorizationParams( $pResourceUrl, $pWPRemoteArgs['method'], ! empty( $pWPRemoteArgs['body'] ) ? $pWPRemoteArgs['body'] : '' );
185
+
186
+ $pWPRemoteArgs['headers']['Date'] = $auth['date'];
187
+ $pWPRemoteArgs['headers']['Authorization'] = $auth['authorization'];
188
+
189
+ if ( ! empty( $auth['content_md5'] ) ) {
190
+ $pWPRemoteArgs['headers']['Content-MD5'] = $auth['content_md5'];
 
 
 
 
 
 
 
191
  }
192
+
193
+ return $pWPRemoteArgs;
194
+ }
195
+
196
+ /**
197
+ * Generate Authorization request headers:
198
+ *
199
+ * Content-MD5: MD5(HTTP Request body)
200
+ * Date: Current date (i.e Sat, 14 Feb 2016 20:24:46 +0000)
201
+ * Authorization: FS {scope_entity_id}:{scope_entity_public_key}:base64encode(sha256(string_to_sign,
202
+ * {scope_entity_secret_key}))
203
+ *
204
+ * @author Vova Feldman
205
+ *
206
+ * @param string $pResourceUrl
207
+ * @param string $pMethod
208
+ * @param string $pPostParams
209
+ *
210
+ * @return array
211
+ * @throws WCL_Freemius_Exception
212
+ */
213
+ function GenerateAuthorizationParams(
214
+ $pResourceUrl, $pMethod = 'GET', $pPostParams = ''
215
+ ) {
216
+ $pMethod = strtoupper( $pMethod );
217
+
218
+ $eol = "\n";
219
+ $content_md5 = '';
220
+ $content_type = '';
221
+ $now = ( time() - self::$_clock_diff );
222
+ $date = date( 'r', $now );
223
+
224
+ if ( in_array( $pMethod, array( 'POST', 'PUT' ) ) && ! empty( $pPostParams ) ) {
225
+ $content_md5 = md5( $pPostParams );
226
+ $content_type = 'application/json';
227
  }
228
+
229
+ $string_to_sign = implode( $eol, array(
230
+ $pMethod,
231
+ $content_md5,
232
+ $content_type,
233
+ $date,
234
+ $pResourceUrl
235
+ ) );
236
+
237
+ // If secret and public keys are identical, it means that
238
+ // the signature uses public key hash encoding.
239
+ $auth_type = ( $this->_secret !== $this->_public ) ? 'FS' : 'FSP';
240
+
241
+ $auth = array(
242
+ 'date' => $date,
243
+ 'authorization' => $auth_type . ' ' . $this->_id . ':' . $this->_public . ':' . self::Base64UrlEncode( hash_hmac( 'sha256', $string_to_sign, $this->_secret ) )
244
+ );
245
+
246
+ if ( ! empty( $content_md5 ) ) {
247
+ $auth['content_md5'] = $content_md5;
248
  }
249
+
250
+ return $auth;
251
+ }
252
+
253
+ /**
254
+ * Get API request URL signed via query string.
255
+ *
256
+ * @since 1.2.3 Stopped using http_build_query(). Instead, use urlencode(). In some environments the encoding of http_build_query() can generate a URL that once used with a redirect, the `&` querystring separator is escaped to `&amp;` which breaks the URL (Added by @svovaf).
257
+ *
258
+ * @param string $pPath
259
+ *
260
+ * @throws WCL_Freemius_Exception
261
+ *
262
+ * @return string
263
+ */
264
+ function GetSignedUrl( $pPath ) {
265
+ $resource = explode( '?', $this->CanonizePath( $pPath ) );
266
+ $pResourceUrl = $resource[0];
267
+
268
+ $auth = $this->GenerateAuthorizationParams( $pResourceUrl );
269
+
270
+ return Freemius_Api_WordPress::GetUrl( $pResourceUrl . '?' . ( 1 < count( $resource ) && ! empty( $resource[1] ) ? $resource[1] . '&' : '' ) . 'authorization=' . urlencode( $auth['authorization'] ) . '&auth_date=' . urlencode( $auth['date'] ), $this->_sandbox );
271
+ }
272
+
273
+ /**
274
+ * @author Vova Feldman
275
+ *
276
+ * @param string $pUrl
277
+ * @param array $pWPRemoteArgs
278
+ *
279
+ * @return mixed
280
+ */
281
+ private static function ExecuteRequest( $pUrl, &$pWPRemoteArgs ) {
282
+ $start = microtime( true );
283
+
284
+ $response = wp_remote_request( $pUrl, $pWPRemoteArgs );
285
+
286
+ if ( WCL_FS_API__LOGGER_ON ) {
287
+ $end = microtime( true );
288
+
289
+ $has_body = ( isset( $pWPRemoteArgs['body'] ) && ! empty( $pWPRemoteArgs['body'] ) );
290
+ $is_http_error = is_wp_error( $response );
291
+
292
+ self::$_logger[] = array(
293
+ 'id' => count( self::$_logger ),
294
+ 'start' => $start,
295
+ 'end' => $end,
296
+ 'total' => ( $end - $start ),
297
+ 'method' => $pWPRemoteArgs['method'],
298
+ 'path' => $pUrl,
299
+ 'body' => $has_body ? $pWPRemoteArgs['body'] : null,
300
+ 'result' => ! $is_http_error ? $response['body'] : json_encode( $response->get_error_messages() ),
301
+ 'code' => ! $is_http_error ? $response['response']['code'] : null,
302
+ 'backtrace' => debug_backtrace(),
303
+ );
304
  }
305
+
306
+ return $response;
307
+ }
308
+
309
+ /**
310
+ * @return array
311
+ */
312
+ static function GetLogger() {
313
+ return self::$_logger;
314
+ }
315
+
316
+ /**
317
+ * @param string $pCanonizedPath
318
+ * @param string $pMethod
319
+ * @param array $pParams
320
+ * @param null|array $pWPRemoteArgs
321
+ * @param bool $pIsSandbox
322
+ * @param null|callable $pBeforeExecutionFunction
323
+ *
324
+ * @return object[]|object|null
325
+ *
326
+ * @throws \WCL_Freemius_Exception
327
+ */
328
+ private static function MakeStaticRequest(
329
+ $pCanonizedPath, $pMethod = 'GET', $pParams = array(), $pWPRemoteArgs = null, $pIsSandbox = false, $pBeforeExecutionFunction = null
330
+ ) {
331
+ // Connectivity errors simulation.
332
+ if ( WCL_FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
333
+ self::ThrowCloudFlareDDoSException();
334
+ } else if ( WCL_FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
335
+ self::ThrowSquidAclException();
336
  }
337
+
338
+ if ( empty( $pWPRemoteArgs ) ) {
339
+ $user_agent = 'Freemius/WordPress-SDK/' . WCL_Freemius_Api_Base::VERSION . '; ' . home_url();
340
+
341
+ $pWPRemoteArgs = array(
342
+ 'method' => strtoupper( $pMethod ),
343
+ 'connect_timeout' => 10,
344
+ 'timeout' => 60,
345
+ 'follow_redirects' => true,
346
+ 'redirection' => 5,
347
+ 'user-agent' => $user_agent,
348
+ 'blocking' => true,
 
 
 
 
 
 
349
  );
 
 
 
 
 
 
 
 
 
350
  }
351
+
352
+ if ( ! isset( $pWPRemoteArgs['headers'] ) || ! is_array( $pWPRemoteArgs['headers'] ) ) {
353
+ $pWPRemoteArgs['headers'] = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
  }
355
+
356
+ if ( in_array( $pMethod, array( 'POST', 'PUT' ) ) ) {
357
+ if ( is_array( $pParams ) && 0 < count( $pParams ) ) {
358
+ $pWPRemoteArgs['headers']['Content-type'] = 'application/json';
359
+ $pWPRemoteArgs['body'] = json_encode( $pParams );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  }
 
 
361
  }
362
+
363
+ $request_url = self::GetUrl( $pCanonizedPath, $pIsSandbox );
364
+
365
+ $resource = explode( '?', $pCanonizedPath );
366
+
367
+ if ( WCL_FS_SDK__HAS_CURL ) {
368
+ // Disable the 'Expect: 100-continue' behaviour. This causes cURL to wait
369
+ // for 2 seconds if the server does not support this header.
370
+ $pWPRemoteArgs['headers']['Expect'] = '';
371
  }
372
+
373
+ if ( 'https' === substr( strtolower( $request_url ), 0, 5 ) ) {
374
+ $pWPRemoteArgs['sslverify'] = false;
375
+ }
376
+
377
+ if ( false !== $pBeforeExecutionFunction && is_callable( $pBeforeExecutionFunction ) ) {
378
+ $pWPRemoteArgs = call_user_func( $pBeforeExecutionFunction, $resource[0], $pWPRemoteArgs );
379
+ }
380
+
381
+ $result = self::ExecuteRequest( $request_url, $pWPRemoteArgs );
382
+
383
+ if ( is_wp_error( $result ) ) {
384
+ /**
385
+ * @var WP_Error $result
386
+ */
387
+ if ( self::IsCurlError( $result ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  /**
389
+ * With dual stacked DNS responses, it's possible for a server to
390
+ * have IPv6 enabled but not have IPv6 connectivity. If this is
391
+ * the case, cURL will try IPv4 first and if that fails, then it will
392
+ * fall back to IPv6 and the error EHOSTUNREACH is returned by the
393
+ * operating system.
394
  */
395
+ $matches = array();
396
+ $regex = '/Failed to connect to ([^:].*): Network is unreachable/';
397
+ if ( preg_match( $regex, $result->get_error_message( 'http_request_failed' ), $matches ) ) {
398
  /**
399
+ * Validate IP before calling `inet_pton()` to avoid PHP un-catchable warning.
400
+ * @author Vova Feldman (@svovaf)
 
 
 
401
  */
402
+ if ( filter_var( $matches[1], FILTER_VALIDATE_IP ) ) {
403
+ if ( strlen( inet_pton( $matches[1] ) ) === 16 ) {
404
+ // error_log('Invalid IPv6 configuration on server, Please disable or get native IPv6 on your server.');
405
+ // Hook to an action triggered just before cURL is executed to resolve the IP version to v4.
406
+ add_action( 'http_api_curl', 'Freemius_Api_WordPress::CurlResolveToIPv4', 10, 1 );
407
+
408
+ // Re-run request.
409
+ $result = self::ExecuteRequest( $request_url, $pWPRemoteArgs );
 
 
 
 
 
 
 
 
410
  }
411
  }
412
  }
 
 
 
 
413
  }
414
+
415
+ if ( is_wp_error( $result ) ) {
416
+ self::ThrowWPRemoteException( $result );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
  }
 
 
418
  }
419
+
420
+ $response_body = $result['body'];
421
+
422
+ if ( empty( $response_body ) ) {
423
+ return null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
  }
425
+
426
+ $decoded = json_decode( $response_body );
427
+
428
+ if ( is_null( $decoded ) ) {
429
+ if ( preg_match( '/Please turn JavaScript on/i', $response_body ) && preg_match( '/text\/javascript/', $response_body ) ) {
430
+ self::ThrowCloudFlareDDoSException( $response_body );
431
+ } else if ( preg_match( '/Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect./', $response_body ) && preg_match( '/squid/', $response_body ) ) {
432
+ self::ThrowSquidAclException( $response_body );
433
+ } else {
434
+ $decoded = (object) array(
435
+ 'error' => (object) array(
 
 
 
 
 
436
  'type' => 'Unknown',
437
+ 'message' => $response_body,
438
  'code' => 'unknown',
439
  'http' => 402
440
  )
441
  );
442
  }
 
 
443
  }
444
+
445
+ return $decoded;
446
+ }
447
+
448
+
449
+ /**
450
+ * Makes an HTTP request. This method can be overridden by subclasses if
451
+ * developers want to do fancier things or use something other than wp_remote_request()
452
+ * to make the request.
453
+ *
454
+ * @param string $pCanonizedPath The URL to make the request to
455
+ * @param string $pMethod HTTP method
456
+ * @param array $pParams The parameters to use for the POST body
457
+ * @param null|array $pWPRemoteArgs wp_remote_request options.
458
+ *
459
+ * @return object[]|object|null
460
+ *
461
+ * @throws WCL_Freemius_Exception
462
+ */
463
+ public function MakeRequest(
464
+ $pCanonizedPath, $pMethod = 'GET', $pParams = array(), $pWPRemoteArgs = null
465
+ ) {
466
+ $resource = explode( '?', $pCanonizedPath );
467
+
468
+ // Only sign request if not ping.json connectivity test.
469
+ $sign_request = ( '/v1/ping.json' !== strtolower( substr( $resource[0], - strlen( '/v1/ping.json' ) ) ) );
470
+
471
+ return self::MakeStaticRequest( $pCanonizedPath, $pMethod, $pParams, $pWPRemoteArgs, $this->_sandbox, $sign_request ? array(
472
+ &$this,
473
+ 'SignRequest'
474
+ ) : null );
475
+ }
476
+
477
+ /**
478
+ * Sets CURLOPT_IPRESOLVE to CURL_IPRESOLVE_V4 for cURL-Handle provided as parameter
479
+ *
480
+ * @param resource $handle A cURL handle returned by curl_init()
481
+ *
482
+ * @return resource $handle A cURL handle returned by curl_init() with CURLOPT_IPRESOLVE set to
483
+ * CURL_IPRESOLVE_V4
484
+ *
485
+ * @link https://gist.github.com/golderweb/3a2aaec2d56125cc004e
486
+ */
487
+ static function CurlResolveToIPv4( $handle ) {
488
+ curl_setopt( $handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
489
+
490
+ return $handle;
491
+ }
492
+
493
+ #----------------------------------------------------------------------------------
494
+ #region Connectivity Test
495
+ #----------------------------------------------------------------------------------
496
+
497
+ /**
498
+ * If successful connectivity to the API endpoint using ping.json endpoint.
499
+ *
500
+ * - OR -
501
+ *
502
+ * Validate if ping result object is valid.
503
+ *
504
+ * @param mixed $pPong
505
+ *
506
+ * @return bool
507
+ */
508
+ public function Test( $pPong = null ) {
509
+ $pong = is_null( $pPong ) ? self::Ping() : $pPong;
510
+
511
+ return ( is_object( $pong ) && isset( $pong->api ) && 'pong' === $pong->api );
512
+ }
513
+
514
+ /**
515
+ * Ping API to test connectivity.
516
+ *
517
+ * @return object
518
+ */
519
+ public static function Ping() {
520
+ try {
521
+ $result = self::MakeStaticRequest( '/v' . WCL_FS_API__VERSION . '/ping.json' );
522
+ } catch( WCL_Freemius_Exception $e ) {
523
+ // Map to error object.
524
+ $result = (object) $e->getResult();
525
+ } catch( Exception $e ) {
526
+ // Map to error object.
527
+ $result = (object) array(
528
+ 'error' => array(
529
+ 'type' => 'Unknown',
530
+ 'message' => $e->getMessage() . ' (' . $e->getFile() . ': ' . $e->getLine() . ')',
531
+ 'code' => 'unknown',
532
+ 'http' => 402
533
+ )
534
+ );
535
  }
536
+
537
+ return $result;
538
+ }
539
+
540
+ #endregion
541
+
542
+ #----------------------------------------------------------------------------------
543
+ #region Connectivity Exceptions
544
+ #----------------------------------------------------------------------------------
545
+
546
+ /**
547
+ * @param \WP_Error $pError
548
+ *
549
+ * @return bool
550
+ */
551
+ private static function IsCurlError( WP_Error $pError ) {
552
+ $message = $pError->get_error_message( 'http_request_failed' );
553
+
554
+ return ( 0 === strpos( $message, 'cURL' ) );
555
+ }
556
+
557
+ /**
558
+ * @param WP_Error $pError
559
+ *
560
+ * @throws WCL_Freemius_Exception
561
+ */
562
+ private static function ThrowWPRemoteException( WP_Error $pError ) {
563
+ if ( self::IsCurlError( $pError ) ) {
564
+ $message = $pError->get_error_message( 'http_request_failed' );
565
+
566
+ #region Check if there are any missing cURL methods.
567
+
568
+ $curl_required_methods = array(
569
+ 'curl_version',
570
+ 'curl_exec',
571
+ 'curl_init',
572
+ 'curl_close',
573
+ 'curl_setopt',
574
+ 'curl_setopt_array',
575
+ 'curl_error',
576
+ );
577
+
578
+ // Find all missing methods.
579
+ $missing_methods = array();
580
+ foreach ( $curl_required_methods as $m ) {
581
+ if ( ! function_exists( $m ) ) {
582
+ $missing_methods[] = $m;
583
  }
584
+ }
585
+
586
+ if ( ! empty( $missing_methods ) ) {
587
+ throw new WCL_Freemius_Exception( array(
588
+ 'error' => (object) array(
589
+ 'type' => 'cUrlMissing',
 
 
 
 
 
 
590
  'message' => $message,
591
+ 'code' => 'curl_missing',
592
+ 'http' => 402
 
 
 
 
 
 
 
593
  ),
594
+ 'missing_methods' => $missing_methods,
595
  ) );
596
  }
597
+
598
+ #endregion
599
+
600
+ // cURL error - "cURL error {{errno}}: {{error}}".
601
+ $parts = explode( ':', substr( $message, strlen( 'cURL error ' ) ), 2 );
602
+
603
+ $code = ( 0 < count( $parts ) ) ? $parts[0] : 'http_request_failed';
604
+ $message = ( 1 < count( $parts ) ) ? $parts[1] : $message;
605
+
606
+ $e = new WCL_Freemius_Exception( array(
607
+ 'error' => array(
608
+ 'code' => $code,
609
+ 'message' => $message,
610
+ 'type' => 'CurlException',
611
+ ),
 
 
612
  ) );
613
+ } else {
614
+ $e = new WCL_Freemius_Exception( array(
615
+ 'error' => array(
616
+ 'code' => $pError->get_error_code(),
617
+ 'message' => $pError->get_error_message(),
618
+ 'type' => 'WPRemoteException',
619
+ ),
 
 
 
 
 
 
 
 
620
  ) );
621
  }
622
+
623
+ throw $e;
624
+ }
625
+
626
+ /**
627
+ * @param string $pResult
628
+ *
629
+ * @throws WCL_Freemius_Exception
630
+ */
631
+ private static function ThrowCloudFlareDDoSException( $pResult = '' ) {
632
+ throw new WCL_Freemius_Exception( array(
633
+ 'error' => (object) array(
634
+ 'type' => 'CloudFlareDDoSProtection',
635
+ 'message' => $pResult,
636
+ 'code' => 'cloudflare_ddos_protection',
637
+ 'http' => 402
638
+ )
639
+ ) );
640
+ }
641
+
642
+ /**
643
+ * @param string $pResult
644
+ *
645
+ * @throws WCL_Freemius_Exception
646
+ */
647
+ private static function ThrowSquidAclException( $pResult = '' ) {
648
+ throw new WCL_Freemius_Exception( array(
649
+ 'error' => (object) array(
650
+ 'type' => 'SquidCacheBlock',
651
+ 'message' => $pResult,
652
+ 'code' => 'squid_cache_block',
653
+ 'http' => 402
654
+ )
655
+ ) );
656
  }
657
+
658
+ #endregion
659
+ }
includes/freemius/sdk/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
includes/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
languages/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
libs/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
readme.txt CHANGED
@@ -15,6 +15,16 @@ Optimize and tweak WordPress by disable unused features. Improve performance, SE
15
 
16
  Thousands of users already optimized their WordPress sites with **Clearfy plugin**. It’s multipurpose and free tool with tons of settings. Combine it with other plugins and you’ll get better optimized and secure WordPress website.
17
 
 
 
 
 
 
 
 
 
 
 
18
  ### Optimize SEO and SPEED of your website in 5 minutes ###
19
  1. **Clear website code from trash;**
20
  2. **Eliminate the WordPress vulnerabilities;**
@@ -238,6 +248,17 @@ Of course! To do this, email us your wishes with address, which you will find in
238
 
239
 
240
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
241
  = 1.4.6 =
242
  * Fixed: Bug when license activated [Call to undefined function mime_content_type].
243
  * Fixed: Disable comments component: [Uncaught Error: Class 'WCTR_Plugin' not found].
@@ -246,7 +267,7 @@ Of course! To do this, email us your wishes with address, which you will find in
246
  * Fixed: Update manager component: [Warning: Invalid argument supplied].
247
 
248
  = 1.4.5 =
249
- * Fixed: Update manager component: [Undefined index: clearfy]
250
 
251
  = 1.4.4 =
252
  * Fixed: Added compatibility with ithemes sync
15
 
16
  Thousands of users already optimized their WordPress sites with **Clearfy plugin**. It’s multipurpose and free tool with tons of settings. Combine it with other plugins and you’ll get better optimized and secure WordPress website.
17
 
18
+ #### NEED SUPPORT, WE GOT YOU COVERED ####
19
+ We provide free support for this plugin. If you are pushed with a problem, just create a new ticket. We will definitely help you!
20
+
21
+ 1. **[Get starting free support](https://clearfy.pro/support/?utm_source=wordpress.org&utm_campaign=wbcr_clearfy&utm_content=repo_description)**
22
+ 4. **[Hot support](https://clearfy.pro/hot-support/?utm_source=wordpress.org&utm_campaign=wbcr_clearfy&utm_content=repo_description)** - Any user can contact us. You can use it only if you find a php error in plugin, get a white screen, or want to report a vulnerability.
23
+
24
+ #### ADDITIONAL RESOURCES ####
25
+ 1. **[Youtube channel](https://www.youtube.com/channel/UCxOg4XzLe5kX1bP2YP4TTfQ)**
26
+ 2. **[Telegram](https://t.me/webcraftic)**
27
+
28
  ### Optimize SEO and SPEED of your website in 5 minutes ###
29
  1. **Clear website code from trash;**
30
  2. **Eliminate the WordPress vulnerabilities;**
248
 
249
 
250
  == Changelog ==
251
+ = 1.5.0 =
252
+ * Fixed: Bug when disabling embeds, in Wordpress 5.0 did not work editor gutenberg
253
+ = 1.4.9 =
254
+ * Fixed: Bug with Woocommerce Memberships
255
+ * Fixed: Bug with License manager
256
+ * Fixed: [Cyrlitera component]: when using transliteration on frontend, duplicate pages were created.
257
+ * Fixed: [Update manager component]: no longer disables plugin update checking.
258
+ * Fixed: [Update manager component]: inverted switches to disable auto-updates.
259
+ * Fixed: [Update manager component]: removed the "Update Manager" button on the plugin and themes page.
260
+ * Fixed: Bug with wbcr_factory_409_imppage_after_form_save: you will no longer see the PHP notification.
261
+
262
  = 1.4.6 =
263
  * Fixed: Bug when license activated [Call to undefined function mime_content_type].
264
  * Fixed: Disable comments component: [Uncaught Error: Class 'WCTR_Plugin' not found].
267
  * Fixed: Update manager component: [Warning: Invalid argument supplied].
268
 
269
  = 1.4.5 =
270
+ * Fixed: Update manager: [Undefined index: clearfy]
271
 
272
  = 1.4.4 =
273
  * Fixed: Added compatibility with ithemes sync
templates/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
uninstall.php CHANGED
@@ -1,75 +1,85 @@
1
  <?php
2
 
3
- // if uninstall.php is not called by WordPress, die
4
- if( !defined('WP_UNINSTALL_PLUGIN') ) {
5
- die;
6
- }
7
 
8
- // remove plugin options
9
- global $wpdb;
10
 
11
- require_once ABSPATH . '/wp-admin/includes/plugin.php';
12
 
13
- /**
14
- * Удаление кеша и опций
15
- */
16
- function uninstall()
17
- {
18
- // remove plugin options
19
- global $wpdb;
20
 
21
- $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name = 'factory_plugin_activated_wbcr_clearfy';");
22
- $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wbcr-clearfy_%';");
23
- $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wbcr_clearfy_%';");
24
- $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wbcr_wp_term_%';");
25
- $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE meta_key='wbcr_wp_old_slug';");
26
 
27
- $dismissed_pointers = explode(',', get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true));
28
 
29
- if( in_array('wbcr_clearfy_settings_pointer_1_4_2', $dismissed_pointers) ) {
30
- $key = array_search('wbcr_clearfy_settings_pointer_1_4_2', $dismissed_pointers);
31
- if( isset($dismissed_pointers[$key]) ) {
32
- unset($dismissed_pointers[$key]);
33
- if( !empty($dismissed_pointers) ) {
34
- update_user_meta(get_current_user_id(), 'dismissed_wp_pointers', implode(',', $dismissed_pointers));
35
- } else {
36
- delete_user_meta(get_current_user_id(), 'dismissed_wp_pointers');
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
  }
40
  }
41
-
42
- if( is_multisite() ) {
43
- global $wpdb, $wp_version;
44
-
45
- $wpdb->query("DELETE FROM {$wpdb->sitemeta} WHERE meta_key LIKE 'wbcr_clearfy_%';");
46
-
47
- $blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
48
-
49
- if( !empty($blogs) ) {
50
- foreach($blogs as $id) {
51
-
52
- switch_to_blog($id);
53
-
54
- uninstall();
55
-
56
- restore_current_blog();
57
- }
58
  }
59
- } else {
60
- uninstall();
61
  }
 
 
 
62
 
63
- $package_plugin_basename = 'clearfy_package/clearfy-package.php';
64
 
65
- if( is_plugin_active($package_plugin_basename) ) {
66
- if( is_multisite() && is_plugin_active_for_network($package_plugin_basename) ) {
67
- deactivate_plugins($package_plugin_basename, false, true);
68
- } else {
69
- deactivate_plugins($package_plugin_basename);
70
- }
71
  }
 
72
 
73
- delete_plugins(array($package_plugin_basename));
74
 
75
- //todo: добавить функции очистки для компонентов
1
  <?php
2
 
3
+ // if uninstall.php is not called by WordPress, die
4
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
5
+ die;
6
+ }
7
 
8
+ global $wpdb;
 
9
 
10
+ $can_unistall = false;
11
 
12
+ if ( is_multisite() ) {
13
+ $can_unistall = get_site_option( 'wbcr_clearfy_complete_uninstall' );
14
+ } else {
15
+ $can_unistall = get_option( 'wbcr_clearfy_complete_uninstall' );
16
+ }
 
 
17
 
18
+ if ( ! $can_unistall ) {
19
+ return;
20
+ }
 
 
21
 
22
+ require_once ABSPATH . '/wp-admin/includes/plugin.php';
23
 
24
+ /**
25
+ * Удаление кеша и опций
26
+ */
27
+ function uninstall() {
28
+ // remove plugin options
29
+ global $wpdb;
30
+
31
+ $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name = 'factory_plugin_activated_wbcr_clearfy';" );
32
+ $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wbcr-clearfy_%';" );
33
+ $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wbcr_clearfy_%';" );
34
+ $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wbcr_wp_term_%';" );
35
+ $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key='wbcr_wp_old_slug';" );
36
+
37
+ $dismissed_pointers = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
38
+
39
+ if ( in_array( 'wbcr_clearfy_settings_pointer_1_4_2', $dismissed_pointers ) ) {
40
+ $key = array_search( 'wbcr_clearfy_settings_pointer_1_4_2', $dismissed_pointers );
41
+ if ( isset( $dismissed_pointers[ $key ] ) ) {
42
+ unset( $dismissed_pointers[ $key ] );
43
+ if ( ! empty( $dismissed_pointers ) ) {
44
+ update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', implode( ',', $dismissed_pointers ) );
45
+ } else {
46
+ delete_user_meta( get_current_user_id(), 'dismissed_wp_pointers' );
47
  }
48
  }
49
  }
50
+ }
51
+
52
+ if ( is_multisite() ) {
53
+ global $wpdb, $wp_version;
54
+
55
+ $wpdb->query( "DELETE FROM {$wpdb->sitemeta} WHERE meta_key LIKE 'wbcr_clearfy_%';" );
56
+
57
+ $blogs = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
58
+
59
+ if ( ! empty( $blogs ) ) {
60
+ foreach ( $blogs as $id ) {
61
+
62
+ switch_to_blog( $id );
63
+
64
+ uninstall();
65
+
66
+ restore_current_blog();
67
  }
 
 
68
  }
69
+ } else {
70
+ uninstall();
71
+ }
72
 
73
+ $package_plugin_basename = 'clearfy_package/clearfy-package.php';
74
 
75
+ if ( is_plugin_active( $package_plugin_basename ) ) {
76
+ if ( is_multisite() && is_plugin_active_for_network( $package_plugin_basename ) ) {
77
+ deactivate_plugins( $package_plugin_basename, false, true );
78
+ } else {
79
+ deactivate_plugins( $package_plugin_basename );
 
80
  }
81
+ }
82
 
83
+ delete_plugins( array( $package_plugin_basename ) );
84
 
85
+ //todo: добавить функции очистки для компонентов
updates/010409.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php #comp-page builds: premium
2
+
3
+ /**
4
+ * Updates for altering the table used to store statistics data.
5
+ * Adds new columns and renames existing ones in order to add support for the new social buttons.
6
+ */
7
+ class WCLUpdate010409 extends Wbcr_Factory409_Update {
8
+
9
+ public function install() {
10
+ require_once( WCL_PLUGIN_DIR . '/includes/freemius/class.storage.php' );
11
+
12
+ $old_license_storage = WCL_Plugin::app()->getPopulateOption( 'license_storage', false );
13
+ $storage = new WCL_Licensing_Storage();
14
+
15
+ if ( $old_license_storage ) {
16
+ if ( isset( $old_license_storage['user'] ) && $old_license_storage['user'] instanceof WCL_FS_User ) {
17
+ $storage->setUser( $old_license_storage['user'] );
18
+ }
19
+ if ( isset( $old_license_storage['site'] ) && $old_license_storage['site'] instanceof WCL_FS_Site ) {
20
+ $storage->setSite( $old_license_storage['site'] );
21
+ }
22
+ if ( isset( $old_license_storage['license'] ) && $old_license_storage['license'] instanceof WCL_FS_Plugin_License ) {
23
+ $storage->setLicense( $old_license_storage['license'] );
24
+ }
25
+
26
+ $storage->save();
27
+
28
+ WCL_Plugin::app()->deletePopulateOption( 'license_storage' );
29
+ }
30
+ }
31
+ }
updates/index.php CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.