Page Templater For Elementor - Version 1.2.1

Version Description

  • 2017-10-11
Download this release

Release Info

Developer themeisle
Plugin Icon wp plugin Page Templater For Elementor
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2.0 to 1.2.1

Files changed (41) hide show
  1. CHANGELOG.md +6 -4
  2. assets/custom.css +12 -12
  3. assets/custom.js +18 -12
  4. assets/settings.php +3 -3
  5. custom-posttype-class.php +7 -7
  6. elementemplater-class.php +2 -2
  7. elementemplator.php +37 -3
  8. inc/class-tgm-plugin-activation.php +3855 -0
  9. inc/custom-posttype-class.php +7 -7
  10. inc/elementemplater-functions.php +2 -2
  11. inc/settings.php +3 -3
  12. readme.md +6 -1
  13. readme.txt +6 -1
  14. vendor/autoload.php +7 -0
  15. vendor/codeinwp/themeisle-sdk/LICENSE +674 -0
  16. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-feedback-deactivate.php +470 -0
  17. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-feedback-factory.php +50 -0
  18. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-feedback-review.php +209 -0
  19. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-feedback-translate.php +966 -0
  20. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-feedback.php +90 -0
  21. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-licenser.php +710 -0
  22. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-loader.php +93 -0
  23. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-logger.php +218 -0
  24. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-notification-manager.php +105 -0
  25. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-product.php +555 -0
  26. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-rollback.php +223 -0
  27. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-widget-dashboard-blog.php +383 -0
  28. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-widget.php +50 -0
  29. vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-widgets-factory.php +37 -0
  30. vendor/codeinwp/themeisle-sdk/composer.json +24 -0
  31. vendor/codeinwp/themeisle-sdk/index.php +5 -0
  32. vendor/codeinwp/themeisle-sdk/load.php +35 -0
  33. vendor/codeinwp/themeisle-sdk/start.php +37 -0
  34. vendor/composer/ClassLoader.php +413 -0
  35. vendor/composer/LICENSE +21 -0
  36. vendor/composer/autoload_classmap.php +9 -0
  37. vendor/composer/autoload_files.php +10 -0
  38. vendor/composer/autoload_namespaces.php +9 -0
  39. vendor/composer/autoload_psr4.php +9 -0
  40. vendor/composer/autoload_real.php +59 -0
  41. vendor/composer/installed.json +45 -0
CHANGELOG.md CHANGED
@@ -1,9 +1,11 @@
1
 
2
- ### v1.2.0 - 2017-09-29
3
  **Changes:**
4
- * Added Themeisle SDK.
5
- * Added Continuous Integration.
6
- * Changed contributors.
 
 
7
 
8
  ### v1.2.0 - 2017-09-29
9
  **Changes:**
1
 
2
+ ### v1.2.1 - 2017-11-16
3
  **Changes:**
4
+ * Tested up to 4.9
5
+
6
+ ### v1.2.1 - 2017-10-11
7
+ **Changes:**
8
+ * Added Recommendation for Elementor Addons & Widgets.
9
 
10
  ### v1.2.0 - 2017-09-29
11
  **Changes:**
assets/custom.css CHANGED
@@ -22,9 +22,9 @@
22
 
23
  .elementor-widget-wp-widget-nav_menu {
24
  clear: both;
25
- display: block;
26
  width: 100%;
27
-
28
  }
29
 
30
  .elementor-widget-wp-widget-nav_menu h5 {
@@ -54,7 +54,7 @@
54
  padding-bottom: 0.25em;
55
  padding-top: 0.25em;
56
  }
57
-
58
  .anchor-menu {
59
  left: 0;
60
  position: absolute;
@@ -63,7 +63,7 @@
63
  z-index: 3;
64
  transition: transform 0.2s;
65
  }
66
-
67
  .anchor-menu-fixed.elementor-widget-wp-widget-nav_menu,
68
  .site-header-hidden.elementor-widget-wp-widget-nav_menu {
69
  position: fixed;
@@ -73,7 +73,7 @@
73
  }
74
 
75
  .anchor-menu-fixed.anchor-menu,
76
- .anchor-menu-fixed.elementor-widget-wp-widget-nav_menu {
77
  -webkit-animation: header-down 0.2s ease-in;
78
  animation: header-down 0.2s ease-in;
79
  -webkit-transform: translate(0);
@@ -81,7 +81,7 @@
81
  }
82
 
83
  .site-header-hidden.anchor-menu,
84
- .site-header-hidden.elementor-widget-wp-widget-nav_menu {
85
  -webkit-animation: header-up 0.5s ease-in;
86
  animation: header-up 0.5s ease-in;
87
  -webkit-transform: translate(-100%);
@@ -89,9 +89,9 @@
89
  }
90
 
91
  .admin-bar .anchor-menu-fixed.anchor-menu,
92
- .admin-bar .anchor-menu-fixed.elementor-widget-wp-widget-nav_menu {
93
  top: 32px;
94
- }
95
 
96
  @-webkit-keyframes header-down {
97
  from {
@@ -132,7 +132,7 @@
132
  transform: translate(0, -100%);
133
  }
134
  }
135
-
136
  .elementor-widget-wp-widget-nav_menu {
137
  width: 100%;
138
  }
@@ -161,15 +161,15 @@
161
  }
162
 
163
  .elementor-widget-wp-widget-nav_menu a:hover,
164
- .elementor-widget-wp-widget-nav_menu a:focus {
165
  color: #999;
166
  }
167
-
168
  .anchor-menu-fixed.elementor-widget-wp-widget-nav_menu h5 {
169
  text-align: right;
170
  margin-left: 3.5%;
171
  }
172
-
173
  .anchor-menu-fixed.elementor-widget-wp-widget-nav_menu ul {
174
  float: left;
175
  padding-right: 3.5%;
22
 
23
  .elementor-widget-wp-widget-nav_menu {
24
  clear: both;
25
+ display: block;
26
  width: 100%;
27
+
28
  }
29
 
30
  .elementor-widget-wp-widget-nav_menu h5 {
54
  padding-bottom: 0.25em;
55
  padding-top: 0.25em;
56
  }
57
+
58
  .anchor-menu {
59
  left: 0;
60
  position: absolute;
63
  z-index: 3;
64
  transition: transform 0.2s;
65
  }
66
+
67
  .anchor-menu-fixed.elementor-widget-wp-widget-nav_menu,
68
  .site-header-hidden.elementor-widget-wp-widget-nav_menu {
69
  position: fixed;
73
  }
74
 
75
  .anchor-menu-fixed.anchor-menu,
76
+ .anchor-menu-fixed.elementor-widget-wp-widget-nav_menu {
77
  -webkit-animation: header-down 0.2s ease-in;
78
  animation: header-down 0.2s ease-in;
79
  -webkit-transform: translate(0);
81
  }
82
 
83
  .site-header-hidden.anchor-menu,
84
+ .site-header-hidden.elementor-widget-wp-widget-nav_menu {
85
  -webkit-animation: header-up 0.5s ease-in;
86
  animation: header-up 0.5s ease-in;
87
  -webkit-transform: translate(-100%);
89
  }
90
 
91
  .admin-bar .anchor-menu-fixed.anchor-menu,
92
+ .admin-bar .anchor-menu-fixed.elementor-widget-wp-widget-nav_menu {
93
  top: 32px;
94
+ }
95
 
96
  @-webkit-keyframes header-down {
97
  from {
132
  transform: translate(0, -100%);
133
  }
134
  }
135
+
136
  .elementor-widget-wp-widget-nav_menu {
137
  width: 100%;
138
  }
161
  }
162
 
163
  .elementor-widget-wp-widget-nav_menu a:hover,
164
+ .elementor-widget-wp-widget-nav_menu a:focus {
165
  color: #999;
166
  }
167
+
168
  .anchor-menu-fixed.elementor-widget-wp-widget-nav_menu h5 {
169
  text-align: right;
170
  margin-left: 3.5%;
171
  }
172
+
173
  .anchor-menu-fixed.elementor-widget-wp-widget-nav_menu ul {
174
  float: left;
175
  padding-right: 3.5%;
assets/custom.js CHANGED
@@ -1,14 +1,20 @@
1
- jQuery( document ).ready( function( $ ) {
 
2
 
3
- $(function () {
4
- var nav = $('.elementor-widget-wp-widget-nav_menu');
5
- $(window).scroll(function () {
6
- if ($(this).scrollTop() > 85) {
7
- nav.addClass('anchor-menu-fixed anchor-menu');
8
- } else {
9
- nav.removeClass('anchor-menu-fixed anchor-menu');
10
- }
11
- });
12
- });
 
 
 
 
13
 
14
- });
 
1
+ jQuery( document ).ready(
2
+ function( $ ) {
3
 
4
+ $(
5
+ function () {
6
+ var nav = $( '.elementor-widget-wp-widget-nav_menu' );
7
+ $( window ).scroll(
8
+ function () {
9
+ if ($( this ).scrollTop() > 85) {
10
+ nav.addClass( 'anchor-menu-fixed anchor-menu' );
11
+ } else {
12
+ nav.removeClass( 'anchor-menu-fixed anchor-menu' );
13
+ }
14
+ }
15
+ );
16
+ }
17
+ );
18
 
19
+ }
20
+ );
assets/settings.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  $tcp_options = get_option( 'elcpt_options' );
3
- $tcp_pts = isset( $tcp_options['objects'] ) ? $tcp_options['objects'] : array();
4
  ?>
5
 
6
  <div class="wrap">
@@ -9,7 +9,7 @@ $tcp_pts = isset( $tcp_options['objects'] ) ? $tcp_options['objects'] : array();
9
  <?php if ( isset( $_GET['msg'] ) ) : ?>
10
  <div id="message" class="updated below-h2">
11
  <?php if ( $_GET['msg'] == 'update' ) : ?>
12
- <p><?php _e( 'Settings Updated.','elementor-templater' ); ?></p>
13
  <?php endif; ?>
14
  </div>
15
  <?php endif; ?>
@@ -33,7 +33,7 @@ $tcp_pts = isset( $tcp_options['objects'] ) ? $tcp_options['objects'] : array();
33
  <?php
34
  $post_types = get_post_types(
35
  array(
36
- 'public' => true,
37
  ), 'objects'
38
  );
39
 
1
  <?php
2
  $tcp_options = get_option( 'elcpt_options' );
3
+ $tcp_pts = isset( $tcp_options['objects'] ) ? $tcp_options['objects'] : array();
4
  ?>
5
 
6
  <div class="wrap">
9
  <?php if ( isset( $_GET['msg'] ) ) : ?>
10
  <div id="message" class="updated below-h2">
11
  <?php if ( $_GET['msg'] == 'update' ) : ?>
12
+ <p><?php _e( 'Settings Updated.', 'elementor-templater' ); ?></p>
13
  <?php endif; ?>
14
  </div>
15
  <?php endif; ?>
33
  <?php
34
  $post_types = get_post_types(
35
  array(
36
+ 'public' => true,
37
  ), 'objects'
38
  );
39
 
custom-posttype-class.php CHANGED
@@ -45,8 +45,8 @@ class EL_CustomTemplates {
45
  function elcpt_post_template( $post ) {
46
  $this->post_ID = $post->ID;
47
 
48
- $template_vars = array();
49
- $templates = $this->elcpt_get_post_templates();
50
  $custom_template = $this->elcpt_get_custom_post_template();
51
 
52
  if ( $templates ) { ?>
@@ -79,9 +79,9 @@ class EL_CustomTemplates {
79
  }
80
 
81
  function elcpt_get_post_templates() {
82
- $theme = wp_get_theme();
83
  $post_templates = array();
84
- $files = (array) $theme->get_files( 'php', 1 );
85
  foreach ( $files as $file => $full_path ) {
86
  $headers = @get_file_data( $full_path, array( 'Post Template Name' => 'Post Template Name' ) );
87
  if ( empty( $headers['Post Template Name'] ) ) {
@@ -112,8 +112,8 @@ class EL_CustomTemplates {
112
  }
113
 
114
  $this->post_ID = $post_ID;
115
- $template = (string) @ $_POST['custom_post_template'];
116
- $template = stripslashes_deep( $template );
117
  $this->elcpt_set_custom_post_template( $template );
118
  }
119
 
@@ -154,7 +154,7 @@ class EL_CustomTemplates {
154
  }
155
 
156
  check_admin_referer( 'nonce_elcpt' );
157
- $input_options = array();
158
  $input_options['objects'] = isset( $_POST['objects'] ) ? $_POST['objects'] : '';
159
  update_option( 'elcpt_options', $input_options );
160
  wp_redirect( 'options-general.php?page=elcpt-settings&msg=update' );
45
  function elcpt_post_template( $post ) {
46
  $this->post_ID = $post->ID;
47
 
48
+ $template_vars = array();
49
+ $templates = $this->elcpt_get_post_templates();
50
  $custom_template = $this->elcpt_get_custom_post_template();
51
 
52
  if ( $templates ) { ?>
79
  }
80
 
81
  function elcpt_get_post_templates() {
82
+ $theme = wp_get_theme();
83
  $post_templates = array();
84
+ $files = (array) $theme->get_files( 'php', 1 );
85
  foreach ( $files as $file => $full_path ) {
86
  $headers = @get_file_data( $full_path, array( 'Post Template Name' => 'Post Template Name' ) );
87
  if ( empty( $headers['Post Template Name'] ) ) {
112
  }
113
 
114
  $this->post_ID = $post_ID;
115
+ $template = (string) @ $_POST['custom_post_template'];
116
+ $template = stripslashes_deep( $template );
117
  $this->elcpt_set_custom_post_template( $template );
118
  }
119
 
154
  }
155
 
156
  check_admin_referer( 'nonce_elcpt' );
157
+ $input_options = array();
158
  $input_options['objects'] = isset( $_POST['objects'] ) ? $_POST['objects'] : '';
159
  update_option( 'elcpt_options', $input_options );
160
  wp_redirect( 'options-general.php?page=elcpt-settings&msg=update' );
elementemplater-class.php CHANGED
@@ -100,7 +100,7 @@ class ElemenTemplater {
100
  }
101
 
102
  // New cache, therefore remove the old one
103
- wp_cache_delete( $cache_key , 'themes' );
104
 
105
  // Now add our template to the list of templates by merging our templates
106
  // with the existing templates array from the cache.
@@ -171,7 +171,7 @@ class ElemenTemplater {
171
  * @return void
172
  */
173
  public function elementemplater_styles() {
174
- $theme = get_option( 'template' );
175
  $filename = plugin_dir_path( __FILE__ ) . 'inc/themes/' . $theme . '.php';
176
  if ( file_exists( $filename ) ) {
177
  include_once( $filename );
100
  }
101
 
102
  // New cache, therefore remove the old one
103
+ wp_cache_delete( $cache_key, 'themes' );
104
 
105
  // Now add our template to the list of templates by merging our templates
106
  // with the existing templates array from the cache.
171
  * @return void
172
  */
173
  public function elementemplater_styles() {
174
+ $theme = get_option( 'template' );
175
  $filename = plugin_dir_path( __FILE__ ) . 'inc/themes/' . $theme . '.php';
176
  if ( file_exists( $filename ) ) {
177
  include_once( $filename );
elementemplator.php CHANGED
@@ -3,11 +3,11 @@
3
  * Plugin Name: Page Templater For Elementor
4
  * Plugin URI: https://themeisle.com/
5
  * Description: A helper plugin for users of Elementor Pagebuilder. Adds 2 new templates for complete full width experience while using the page builder - support for a number of popular themes is built-in.
6
- * Version: 1.2.0
7
  * Author: ThemeIsle
8
  * Author URI: https://themeisle.com/
9
  * Requires at least: 4.4
10
- * Tested up to: 4.8
11
  *
12
  * Requires License: no
13
  * WordPress Available: yes
@@ -22,7 +22,7 @@ if ( ! defined( 'WPINC' ) ) {
22
  ------------------------------------------ */
23
 
24
  /* Set plugin version constant. */
25
- define( 'ET_VERSION', '1.2.0' );
26
 
27
  /* Set constant path to the plugin directory. */
28
  define( 'ET_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
@@ -41,6 +41,40 @@ if ( version_compare( floatval( $GLOBALS['wp_version'] ), '4.7', '<' ) ) { // 4.
41
  /* Template Functions */
42
  require_once( ET_PATH . 'inc/elementemplater-functions.php' );
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  /* Require vendor file. */
45
  $vendor_file = ET_PATH . 'vendor/autoload.php';
46
  if ( is_readable( $vendor_file ) ) {
3
  * Plugin Name: Page Templater For Elementor
4
  * Plugin URI: https://themeisle.com/
5
  * Description: A helper plugin for users of Elementor Pagebuilder. Adds 2 new templates for complete full width experience while using the page builder - support for a number of popular themes is built-in.
6
+ * Version: 1.2.1
7
  * Author: ThemeIsle
8
  * Author URI: https://themeisle.com/
9
  * Requires at least: 4.4
10
+ * Tested up to: 4.9
11
  *
12
  * Requires License: no
13
  * WordPress Available: yes
22
  ------------------------------------------ */
23
 
24
  /* Set plugin version constant. */
25
+ define( 'ET_VERSION', '1.2.1' );
26
 
27
  /* Set constant path to the plugin directory. */
28
  define( 'ET_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
41
  /* Template Functions */
42
  require_once( ET_PATH . 'inc/elementemplater-functions.php' );
43
 
44
+ /* Load TGM */
45
+ require_once( ET_PATH . 'inc/class-tgm-plugin-activation.php' );
46
+
47
+ /**
48
+ * Configure TGMPA.
49
+ */
50
+ function elementor_templater_register_required_plugins() {
51
+ $plugins = array(
52
+ array(
53
+ 'name' => 'Elementor Addons & Widgets',
54
+ 'slug' => 'elementor-addon-widgets',
55
+ 'required' => false,
56
+ ),
57
+ );
58
+
59
+ $config = array(
60
+ 'id' => 'elementor-templater',
61
+ 'default_path' => '',
62
+ 'menu' => 'tgmpa-install-plugins',
63
+ 'parent_slug' => 'plugins.php',
64
+ 'capability' => 'manage_options',
65
+ 'has_notices' => true,
66
+ 'dismissable' => true,
67
+ 'dismiss_msg' => '',
68
+ 'is_automatic' => false,
69
+ 'message' => '',
70
+ );
71
+
72
+ tgmpa( $plugins, $config );
73
+ }
74
+
75
+ add_action( 'tgmpa_register', 'elementor_templater_register_required_plugins' );
76
+
77
+
78
  /* Require vendor file. */
79
  $vendor_file = ET_PATH . 'vendor/autoload.php';
80
  if ( is_readable( $vendor_file ) ) {
inc/class-tgm-plugin-activation.php ADDED
@@ -0,0 +1,3855 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin installation and activation for WordPress themes.
4
+ *
5
+ * Please note that this is a drop-in library for a theme or plugin.
6
+ * The authors of this library (Thomas, Gary and Juliette) are NOT responsible
7
+ * for the support of your plugin or theme. Please contact the plugin
8
+ * or theme author for support.
9
+ *
10
+ * @package TGM-Plugin-Activation
11
+ * @version 2.6.1
12
+ * @link http://tgmpluginactivation.com/
13
+ * @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer
14
+ * @copyright Copyright (c) 2011, Thomas Griffin
15
+ * @license GPL-2.0+
16
+ */
17
+
18
+ /*
19
+ Copyright 2011 Thomas Griffin (thomasgriffinmedia.com)
20
+
21
+ This program is free software; you can redistribute it and/or modify
22
+ it under the terms of the GNU General Public License, version 2, as
23
+ published by the Free Software Foundation.
24
+
25
+ This program is distributed in the hope that it will be useful,
26
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
27
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
+ GNU General Public License for more details.
29
+
30
+ You should have received a copy of the GNU General Public License
31
+ along with this program; if not, write to the Free Software
32
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33
+ */
34
+
35
+ if ( ! class_exists( 'TGM_Plugin_Activation' ) ) {
36
+
37
+ /**
38
+ * Automatic plugin installation and activation library.
39
+ *
40
+ * Creates a way to automatically install and activate plugins from within themes.
41
+ * The plugins can be either bundled, downloaded from the WordPress
42
+ * Plugin Repository or downloaded from another external source.
43
+ *
44
+ * @since 1.0.0
45
+ *
46
+ * @package TGM-Plugin-Activation
47
+ * @author Thomas Griffin
48
+ * @author Gary Jones
49
+ */
50
+ class TGM_Plugin_Activation {
51
+ /**
52
+ * TGMPA version number.
53
+ *
54
+ * @since 2.5.0
55
+ *
56
+ * @const string Version number.
57
+ */
58
+ const TGMPA_VERSION = '2.6.1';
59
+
60
+ /**
61
+ * Regular expression to test if a URL is a WP plugin repo URL.
62
+ *
63
+ * @const string Regex.
64
+ *
65
+ * @since 2.5.0
66
+ */
67
+ const WP_REPO_REGEX = '|^http[s]?://wordpress\.org/(?:extend/)?plugins/|';
68
+
69
+ /**
70
+ * Arbitrary regular expression to test if a string starts with a URL.
71
+ *
72
+ * @const string Regex.
73
+ *
74
+ * @since 2.5.0
75
+ */
76
+ const IS_URL_REGEX = '|^http[s]?://|';
77
+
78
+ /**
79
+ * Holds a copy of itself, so it can be referenced by the class name.
80
+ *
81
+ * @since 1.0.0
82
+ *
83
+ * @var TGM_Plugin_Activation
84
+ */
85
+ public static $instance;
86
+
87
+ /**
88
+ * Holds arrays of plugin details.
89
+ *
90
+ * @since 1.0.0
91
+ * @since 2.5.0 the array has the plugin slug as an associative key.
92
+ *
93
+ * @var array
94
+ */
95
+ public $plugins = array();
96
+
97
+ /**
98
+ * Holds arrays of plugin names to use to sort the plugins array.
99
+ *
100
+ * @since 2.5.0
101
+ *
102
+ * @var array
103
+ */
104
+ protected $sort_order = array();
105
+
106
+ /**
107
+ * Whether any plugins have the 'force_activation' setting set to true.
108
+ *
109
+ * @since 2.5.0
110
+ *
111
+ * @var bool
112
+ */
113
+ protected $has_forced_activation = false;
114
+
115
+ /**
116
+ * Whether any plugins have the 'force_deactivation' setting set to true.
117
+ *
118
+ * @since 2.5.0
119
+ *
120
+ * @var bool
121
+ */
122
+ protected $has_forced_deactivation = false;
123
+
124
+ /**
125
+ * Name of the unique ID to hash notices.
126
+ *
127
+ * @since 2.4.0
128
+ *
129
+ * @var string
130
+ */
131
+ public $id = 'tgmpa';
132
+
133
+ /**
134
+ * Name of the query-string argument for the admin page.
135
+ *
136
+ * @since 1.0.0
137
+ *
138
+ * @var string
139
+ */
140
+ protected $menu = 'tgmpa-install-plugins';
141
+
142
+ /**
143
+ * Parent menu file slug.
144
+ *
145
+ * @since 2.5.0
146
+ *
147
+ * @var string
148
+ */
149
+ public $parent_slug = 'themes.php';
150
+
151
+ /**
152
+ * Capability needed to view the plugin installation menu item.
153
+ *
154
+ * @since 2.5.0
155
+ *
156
+ * @var string
157
+ */
158
+ public $capability = 'edit_theme_options';
159
+
160
+ /**
161
+ * Default absolute path to folder containing bundled plugin zip files.
162
+ *
163
+ * @since 2.0.0
164
+ *
165
+ * @var string Absolute path prefix to zip file location for bundled plugins. Default is empty string.
166
+ */
167
+ public $default_path = '';
168
+
169
+ /**
170
+ * Flag to show admin notices or not.
171
+ *
172
+ * @since 2.1.0
173
+ *
174
+ * @var boolean
175
+ */
176
+ public $has_notices = true;
177
+
178
+ /**
179
+ * Flag to determine if the user can dismiss the notice nag.
180
+ *
181
+ * @since 2.4.0
182
+ *
183
+ * @var boolean
184
+ */
185
+ public $dismissable = true;
186
+
187
+ /**
188
+ * Message to be output above nag notice if dismissable is false.
189
+ *
190
+ * @since 2.4.0
191
+ *
192
+ * @var string
193
+ */
194
+ public $dismiss_msg = '';
195
+
196
+ /**
197
+ * Flag to set automatic activation of plugins. Off by default.
198
+ *
199
+ * @since 2.2.0
200
+ *
201
+ * @var boolean
202
+ */
203
+ public $is_automatic = false;
204
+
205
+ /**
206
+ * Optional message to display before the plugins table.
207
+ *
208
+ * @since 2.2.0
209
+ *
210
+ * @var string Message filtered by wp_kses_post(). Default is empty string.
211
+ */
212
+ public $message = '';
213
+
214
+ /**
215
+ * Holds configurable array of strings.
216
+ *
217
+ * Default values are added in the constructor.
218
+ *
219
+ * @since 2.0.0
220
+ *
221
+ * @var array
222
+ */
223
+ public $strings = array();
224
+
225
+ /**
226
+ * Holds the version of WordPress.
227
+ *
228
+ * @since 2.4.0
229
+ *
230
+ * @var int
231
+ */
232
+ public $wp_version;
233
+
234
+ /**
235
+ * Holds the hook name for the admin page.
236
+ *
237
+ * @since 2.5.0
238
+ *
239
+ * @var string
240
+ */
241
+ public $page_hook;
242
+
243
+ /**
244
+ * Adds a reference of this object to $instance, populates default strings,
245
+ * does the tgmpa_init action hook, and hooks in the interactions to init.
246
+ *
247
+ * {@internal This method should be `protected`, but as too many TGMPA implementations
248
+ * haven't upgraded beyond v2.3.6 yet, this gives backward compatibility issues.
249
+ * Reverted back to public for the time being.}}
250
+ *
251
+ * @since 1.0.0
252
+ *
253
+ * @see TGM_Plugin_Activation::init()
254
+ */
255
+ public function __construct() {
256
+ // Set the current WordPress version.
257
+ $this->wp_version = $GLOBALS['wp_version'];
258
+
259
+ // Announce that the class is ready, and pass the object (for advanced use).
260
+ do_action_ref_array( 'tgmpa_init', array( $this ) );
261
+
262
+ /*
263
+ * Load our text domain and allow for overloading the fall-back file.
264
+ *
265
+ * {@internal IMPORTANT! If this code changes, review the regex in the custom TGMPA
266
+ * generator on the website.}}
267
+ */
268
+ add_action( 'init', array( $this, 'load_textdomain' ), 5 );
269
+ add_filter( 'load_textdomain_mofile', array( $this, 'overload_textdomain_mofile' ), 10, 2 );
270
+
271
+ // When the rest of WP has loaded, kick-start the rest of the class.
272
+ add_action( 'init', array( $this, 'init' ) );
273
+ }
274
+
275
+ /**
276
+ * Magic method to (not) set protected properties from outside of this class.
277
+ *
278
+ * {@internal hackedihack... There is a serious bug in v2.3.2 - 2.3.6 where the `menu` property
279
+ * is being assigned rather than tested in a conditional, effectively rendering it useless.
280
+ * This 'hack' prevents this from happening.}}
281
+ *
282
+ * @see https://github.com/TGMPA/TGM-Plugin-Activation/blob/2.3.6/tgm-plugin-activation/class-tgm-plugin-activation.php#L1593
283
+ *
284
+ * @since 2.5.2
285
+ *
286
+ * @param string $name Name of an inaccessible property.
287
+ * @param mixed $value Value to assign to the property.
288
+ * @return void Silently fail to set the property when this is tried from outside of this class context.
289
+ * (Inside this class context, the __set() method if not used as there is direct access.)
290
+ */
291
+ public function __set( $name, $value ) {
292
+ return;
293
+ }
294
+
295
+ /**
296
+ * Magic method to get the value of a protected property outside of this class context.
297
+ *
298
+ * @since 2.5.2
299
+ *
300
+ * @param string $name Name of an inaccessible property.
301
+ * @return mixed The property value.
302
+ */
303
+ public function __get( $name ) {
304
+ return $this->{$name};
305
+ }
306
+
307
+ /**
308
+ * Initialise the interactions between this class and WordPress.
309
+ *
310
+ * Hooks in three new methods for the class: admin_menu, notices and styles.
311
+ *
312
+ * @since 2.0.0
313
+ *
314
+ * @see TGM_Plugin_Activation::admin_menu()
315
+ * @see TGM_Plugin_Activation::notices()
316
+ * @see TGM_Plugin_Activation::styles()
317
+ */
318
+ public function init() {
319
+ /**
320
+ * By default TGMPA only loads on the WP back-end and not in an Ajax call. Using this filter
321
+ * you can overrule that behaviour.
322
+ *
323
+ * @since 2.5.0
324
+ *
325
+ * @param bool $load Whether or not TGMPA should load.
326
+ * Defaults to the return of `is_admin() && ! defined( 'DOING_AJAX' )`.
327
+ */
328
+ if ( true !== apply_filters( 'tgmpa_load', ( is_admin() && ! defined( 'DOING_AJAX' ) ) ) ) {
329
+ return;
330
+ }
331
+
332
+ // Load class strings.
333
+ $this->strings = array(
334
+ 'page_title' => __( 'Install Required Plugins', 'elementor-templater' ),
335
+ 'menu_title' => __( 'Install Plugins', 'elementor-templater' ),
336
+ /* translators: %s: plugin name. */
337
+ 'installing' => __( 'Installing Plugin: %s', 'elementor-templater' ),
338
+ /* translators: %s: plugin name. */
339
+ 'updating' => __( 'Updating Plugin: %s', 'elementor-templater' ),
340
+ 'oops' => __( 'Something went wrong with the plugin API.', 'elementor-templater' ),
341
+ 'notice_can_install_required' => _n_noop(
342
+ /* translators: 1: plugin name(s). */
343
+ 'This theme requires the following plugin: %1$s.',
344
+ 'This theme requires the following plugins: %1$s.',
345
+ 'elementor-templater'
346
+ ),
347
+ 'notice_can_install_recommended' => _n_noop(
348
+ /* translators: 1: plugin name(s). */
349
+ 'This theme recommends the following plugin: %1$s.',
350
+ 'This theme recommends the following plugins: %1$s.',
351
+ 'elementor-templater'
352
+ ),
353
+ 'notice_ask_to_update' => _n_noop(
354
+ /* translators: 1: plugin name(s). */
355
+ 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.',
356
+ 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.',
357
+ 'elementor-templater'
358
+ ),
359
+ 'notice_ask_to_update_maybe' => _n_noop(
360
+ /* translators: 1: plugin name(s). */
361
+ 'There is an update available for: %1$s.',
362
+ 'There are updates available for the following plugins: %1$s.',
363
+ 'elementor-templater'
364
+ ),
365
+ 'notice_can_activate_required' => _n_noop(
366
+ /* translators: 1: plugin name(s). */
367
+ 'The following required plugin is currently inactive: %1$s.',
368
+ 'The following required plugins are currently inactive: %1$s.',
369
+ 'elementor-templater'
370
+ ),
371
+ 'notice_can_activate_recommended' => _n_noop(
372
+ /* translators: 1: plugin name(s). */
373
+ 'The following recommended plugin is currently inactive: %1$s.',
374
+ 'The following recommended plugins are currently inactive: %1$s.',
375
+ 'elementor-templater'
376
+ ),
377
+ 'install_link' => _n_noop(
378
+ 'Begin installing plugin',
379
+ 'Begin installing plugins',
380
+ 'elementor-templater'
381
+ ),
382
+ 'update_link' => _n_noop(
383
+ 'Begin updating plugin',
384
+ 'Begin updating plugins',
385
+ 'elementor-templater'
386
+ ),
387
+ 'activate_link' => _n_noop(
388
+ 'Begin activating plugin',
389
+ 'Begin activating plugins',
390
+ 'elementor-templater'
391
+ ),
392
+ 'return' => __( 'Return to Required Plugins Installer', 'elementor-templater' ),
393
+ 'dashboard' => __( 'Return to the Dashboard', 'elementor-templater' ),
394
+ 'plugin_activated' => __( 'Plugin activated successfully.', 'elementor-templater' ),
395
+ 'activated_successfully' => __( 'The following plugin was activated successfully:', 'elementor-templater' ),
396
+ /* translators: 1: plugin name. */
397
+ 'plugin_already_active' => __( 'No action taken. Plugin %1$s was already active.', 'elementor-templater' ),
398
+ /* translators: 1: plugin name. */
399
+ 'plugin_needs_higher_version' => __( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'elementor-templater' ),
400
+ /* translators: 1: dashboard link. */
401
+ 'complete' => __( 'All plugins installed and activated successfully. %1$s', 'elementor-templater' ),
402
+ 'dismiss' => __( 'Dismiss this notice', 'elementor-templater' ),
403
+ 'notice_cannot_install_activate' => __( 'There are one or more required or recommended plugins to install, update or activate.', 'elementor-templater' ),
404
+ 'contact_admin' => __( 'Please contact the administrator of this site for help.', 'elementor-templater' ),
405
+ );
406
+
407
+ do_action( 'tgmpa_register' );
408
+
409
+ /* After this point, the plugins should be registered and the configuration set. */
410
+
411
+ // Proceed only if we have plugins to handle.
412
+ if ( empty( $this->plugins ) || ! is_array( $this->plugins ) ) {
413
+ return;
414
+ }
415
+
416
+ // Set up the menu and notices if we still have outstanding actions.
417
+ if ( true !== $this->is_tgmpa_complete() ) {
418
+ // Sort the plugins.
419
+ array_multisort( $this->sort_order, SORT_ASC, $this->plugins );
420
+
421
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
422
+ add_action( 'admin_head', array( $this, 'dismiss' ) );
423
+
424
+ // Prevent the normal links from showing underneath a single install/update page.
425
+ add_filter( 'install_plugin_complete_actions', array( $this, 'actions' ) );
426
+ add_filter( 'update_plugin_complete_actions', array( $this, 'actions' ) );
427
+
428
+ if ( $this->has_notices ) {
429
+ add_action( 'admin_notices', array( $this, 'notices' ) );
430
+ add_action( 'admin_init', array( $this, 'admin_init' ), 1 );
431
+ add_action( 'admin_enqueue_scripts', array( $this, 'thickbox' ) );
432
+ }
433
+ }
434
+
435
+ // If needed, filter plugin action links.
436
+ add_action( 'load-plugins.php', array( $this, 'add_plugin_action_link_filters' ), 1 );
437
+
438
+ // Make sure things get reset on switch theme.
439
+ add_action( 'switch_theme', array( $this, 'flush_plugins_cache' ) );
440
+
441
+ if ( $this->has_notices ) {
442
+ add_action( 'switch_theme', array( $this, 'update_dismiss' ) );
443
+ }
444
+
445
+ // Setup the force activation hook.
446
+ if ( true === $this->has_forced_activation ) {
447
+ add_action( 'admin_init', array( $this, 'force_activation' ) );
448
+ }
449
+
450
+ // Setup the force deactivation hook.
451
+ if ( true === $this->has_forced_deactivation ) {
452
+ add_action( 'switch_theme', array( $this, 'force_deactivation' ) );
453
+ }
454
+ }
455
+
456
+ /**
457
+ * Load translations.
458
+ *
459
+ * @since 2.6.0
460
+ *
461
+ * (@internal Uses `load_theme_textdomain()` rather than `load_plugin_textdomain()` to
462
+ * get round the different ways of handling the path and deprecated notices being thrown
463
+ * and such. For plugins, the actual file name will be corrected by a filter.}}
464
+ *
465
+ * {@internal IMPORTANT! If this function changes, review the regex in the custom TGMPA
466
+ * generator on the website.}}
467
+ */
468
+ public function load_textdomain() {
469
+ if ( is_textdomain_loaded( 'tgmpa' ) ) {
470
+ return;
471
+ }
472
+
473
+ if ( false !== strpos( __FILE__, WP_PLUGIN_DIR ) || false !== strpos( __FILE__, WPMU_PLUGIN_DIR ) ) {
474
+ // Plugin, we'll need to adjust the file name.
475
+ add_action( 'load_textdomain_mofile', array( $this, 'correct_plugin_mofile' ), 10, 2 );
476
+ load_theme_textdomain( 'tgmpa', dirname( __FILE__ ) . '/languages' );
477
+ remove_action( 'load_textdomain_mofile', array( $this, 'correct_plugin_mofile' ), 10 );
478
+ } else {
479
+ load_theme_textdomain( 'tgmpa', dirname( __FILE__ ) . '/languages' );
480
+ }
481
+ }
482
+
483
+ /**
484
+ * Correct the .mo file name for (must-use) plugins.
485
+ *
486
+ * Themese use `/path/{locale}.mo` while plugins use `/path/{text-domain}-{locale}.mo`.
487
+ *
488
+ * {@internal IMPORTANT! If this function changes, review the regex in the custom TGMPA
489
+ * generator on the website.}}
490
+ *
491
+ * @since 2.6.0
492
+ *
493
+ * @param string $mofile Full path to the target mofile.
494
+ * @param string $domain The domain for which a language file is being loaded.
495
+ * @return string $mofile
496
+ */
497
+ public function correct_plugin_mofile( $mofile, $domain ) {
498
+ // Exit early if not our domain (just in case).
499
+ if ( 'tgmpa' !== $domain ) {
500
+ return $mofile;
501
+ }
502
+ return preg_replace( '`/([a-z]{2}_[A-Z]{2}.mo)$`', '/tgmpa-$1', $mofile );
503
+ }
504
+
505
+ /**
506
+ * Potentially overload the fall-back translation file for the current language.
507
+ *
508
+ * WP, by default since WP 3.7, will load a local translation first and if none
509
+ * can be found, will try and find a translation in the /wp-content/languages/ directory.
510
+ * As this library is theme/plugin agnostic, translation files for TGMPA can exist both
511
+ * in the WP_LANG_DIR /plugins/ subdirectory as well as in the /themes/ subdirectory.
512
+ *
513
+ * This method makes sure both directories are checked.
514
+ *
515
+ * {@internal IMPORTANT! If this function changes, review the regex in the custom TGMPA
516
+ * generator on the website.}}
517
+ *
518
+ * @since 2.6.0
519
+ *
520
+ * @param string $mofile Full path to the target mofile.
521
+ * @param string $domain The domain for which a language file is being loaded.
522
+ * @return string $mofile
523
+ */
524
+ public function overload_textdomain_mofile( $mofile, $domain ) {
525
+ // Exit early if not our domain, not a WP_LANG_DIR load or if the file exists and is readable.
526
+ if ( 'tgmpa' !== $domain || false === strpos( $mofile, WP_LANG_DIR ) || @is_readable( $mofile ) ) {
527
+ return $mofile;
528
+ }
529
+
530
+ // Current fallback file is not valid, let's try the alternative option.
531
+ if ( false !== strpos( $mofile, '/themes/' ) ) {
532
+ return str_replace( '/themes/', '/plugins/', $mofile );
533
+ } elseif ( false !== strpos( $mofile, '/plugins/' ) ) {
534
+ return str_replace( '/plugins/', '/themes/', $mofile );
535
+ } else {
536
+ return $mofile;
537
+ }
538
+ }
539
+
540
+ /**
541
+ * Hook in plugin action link filters for the WP native plugins page.
542
+ *
543
+ * - Prevent activation of plugins which don't meet the minimum version requirements.
544
+ * - Prevent deactivation of force-activated plugins.
545
+ * - Add update notice if update available.
546
+ *
547
+ * @since 2.5.0
548
+ */
549
+ public function add_plugin_action_link_filters() {
550
+ foreach ( $this->plugins as $slug => $plugin ) {
551
+ if ( false === $this->can_plugin_activate( $slug ) ) {
552
+ add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_activate' ), 20 );
553
+ }
554
+
555
+ if ( true === $plugin['force_activation'] ) {
556
+ add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_deactivate' ), 20 );
557
+ }
558
+
559
+ if ( false !== $this->does_plugin_require_update( $slug ) ) {
560
+ add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_update' ), 20 );
561
+ }
562
+ }
563
+ }
564
+
565
+ /**
566
+ * Remove the 'Activate' link on the WP native plugins page if the plugin does not meet the
567
+ * minimum version requirements.
568
+ *
569
+ * @since 2.5.0
570
+ *
571
+ * @param array $actions Action links.
572
+ * @return array
573
+ */
574
+ public function filter_plugin_action_links_activate( $actions ) {
575
+ unset( $actions['activate'] );
576
+
577
+ return $actions;
578
+ }
579
+
580
+ /**
581
+ * Remove the 'Deactivate' link on the WP native plugins page if the plugin has been set to force activate.
582
+ *
583
+ * @since 2.5.0
584
+ *
585
+ * @param array $actions Action links.
586
+ * @return array
587
+ */
588
+ public function filter_plugin_action_links_deactivate( $actions ) {
589
+ unset( $actions['deactivate'] );
590
+
591
+ return $actions;
592
+ }
593
+
594
+ /**
595
+ * Add a 'Requires update' link on the WP native plugins page if the plugin does not meet the
596
+ * minimum version requirements.
597
+ *
598
+ * @since 2.5.0
599
+ *
600
+ * @param array $actions Action links.
601
+ * @return array
602
+ */
603
+ public function filter_plugin_action_links_update( $actions ) {
604
+ $actions['update'] = sprintf(
605
+ '<a href="%1$s" title="%2$s" class="edit">%3$s</a>',
606
+ esc_url( $this->get_tgmpa_status_url( 'update' ) ),
607
+ esc_attr__( 'This plugin needs to be updated to be compatible with your theme.', 'elementor-templater' ),
608
+ esc_html__( 'Update Required', 'elementor-templater' )
609
+ );
610
+
611
+ return $actions;
612
+ }
613
+
614
+ /**
615
+ * Handles calls to show plugin information via links in the notices.
616
+ *
617
+ * We get the links in the admin notices to point to the TGMPA page, rather
618
+ * than the typical plugin-install.php file, so we can prepare everything
619
+ * beforehand.
620
+ *
621
+ * WP does not make it easy to show the plugin information in the thickbox -
622
+ * here we have to require a file that includes a function that does the
623
+ * main work of displaying it, enqueue some styles, set up some globals and
624
+ * finally call that function before exiting.
625
+ *
626
+ * Down right easy once you know how...
627
+ *
628
+ * Returns early if not the TGMPA page.
629
+ *
630
+ * @since 2.1.0
631
+ *
632
+ * @global string $tab Used as iframe div class names, helps with styling
633
+ * @global string $body_id Used as the iframe body ID, helps with styling
634
+ *
635
+ * @return null Returns early if not the TGMPA page.
636
+ */
637
+ public function admin_init() {
638
+ if ( ! $this->is_tgmpa_page() ) {
639
+ return;
640
+ }
641
+
642
+ if ( isset( $_REQUEST['tab'] ) && 'plugin-information' === $_REQUEST['tab'] ) {
643
+ // Needed for install_plugin_information().
644
+ require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
645
+
646
+ wp_enqueue_style( 'plugin-install' );
647
+
648
+ global $tab, $body_id;
649
+ $body_id = 'plugin-information';
650
+ // @codingStandardsIgnoreStart
651
+ $tab = 'plugin-information';
652
+ // @codingStandardsIgnoreEnd
653
+
654
+ install_plugin_information();
655
+
656
+ exit;
657
+ }
658
+ }
659
+
660
+ /**
661
+ * Enqueue thickbox scripts/styles for plugin info.
662
+ *
663
+ * Thickbox is not automatically included on all admin pages, so we must
664
+ * manually enqueue it for those pages.
665
+ *
666
+ * Thickbox is only loaded if the user has not dismissed the admin
667
+ * notice or if there are any plugins left to install and activate.
668
+ *
669
+ * @since 2.1.0
670
+ */
671
+ public function thickbox() {
672
+ if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) {
673
+ add_thickbox();
674
+ }
675
+ }
676
+
677
+ /**
678
+ * Adds submenu page if there are plugin actions to take.
679
+ *
680
+ * This method adds the submenu page letting users know that a required
681
+ * plugin needs to be installed.
682
+ *
683
+ * This page disappears once the plugin has been installed and activated.
684
+ *
685
+ * @since 1.0.0
686
+ *
687
+ * @see TGM_Plugin_Activation::init()
688
+ * @see TGM_Plugin_Activation::install_plugins_page()
689
+ *
690
+ * @return null Return early if user lacks capability to install a plugin.
691
+ */
692
+ public function admin_menu() {
693
+ // Make sure privileges are correct to see the page.
694
+ if ( ! current_user_can( 'install_plugins' ) ) {
695
+ return;
696
+ }
697
+
698
+ $args = apply_filters(
699
+ 'tgmpa_admin_menu_args',
700
+ array(
701
+ 'parent_slug' => $this->parent_slug, // Parent Menu slug.
702
+ 'page_title' => $this->strings['page_title'], // Page title.
703
+ 'menu_title' => $this->strings['menu_title'], // Menu title.
704
+ 'capability' => $this->capability, // Capability.
705
+ 'menu_slug' => $this->menu, // Menu slug.
706
+ 'function' => array( $this, 'install_plugins_page' ), // Callback.
707
+ )
708
+ );
709
+
710
+ $this->add_admin_menu( $args );
711
+ }
712
+
713
+ /**
714
+ * Add the menu item.
715
+ *
716
+ * {@internal IMPORTANT! If this function changes, review the regex in the custom TGMPA
717
+ * generator on the website.}}
718
+ *
719
+ * @since 2.5.0
720
+ *
721
+ * @param array $args Menu item configuration.
722
+ */
723
+ protected function add_admin_menu( array $args ) {
724
+ if ( has_filter( 'tgmpa_admin_menu_use_add_theme_page' ) ) {
725
+ _deprecated_function( 'The "tgmpa_admin_menu_use_add_theme_page" filter', '2.5.0', esc_html__( 'Set the parent_slug config variable instead.', 'elementor-templater' ) );
726
+ }
727
+
728
+ if ( 'themes.php' === $this->parent_slug ) {
729
+ $this->page_hook = call_user_func( 'add_theme_page', $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] );
730
+ } else {
731
+ $this->page_hook = call_user_func( 'add_submenu_page', $args['parent_slug'], $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] );
732
+ }
733
+ }
734
+
735
+ /**
736
+ * Echoes plugin installation form.
737
+ *
738
+ * This method is the callback for the admin_menu method function.
739
+ * This displays the admin page and form area where the user can select to install and activate the plugin.
740
+ * Aborts early if we're processing a plugin installation action.
741
+ *
742
+ * @since 1.0.0
743
+ *
744
+ * @return null Aborts early if we're processing a plugin installation action.
745
+ */
746
+ public function install_plugins_page() {
747
+ // Store new instance of plugin table in object.
748
+ $plugin_table = new TGMPA_List_Table;
749
+
750
+ // Return early if processing a plugin installation action.
751
+ if ( ( ( 'tgmpa-bulk-install' === $plugin_table->current_action() || 'tgmpa-bulk-update' === $plugin_table->current_action() ) && $plugin_table->process_bulk_actions() ) || $this->do_plugin_install() ) {
752
+ return;
753
+ }
754
+
755
+ // Force refresh of available plugin information so we'll know about manual updates/deletes.
756
+ wp_clean_plugins_cache( false );
757
+
758
+ ?>
759
+ <div class="tgmpa wrap">
760
+ <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
761
+ <?php $plugin_table->prepare_items(); ?>
762
+
763
+ <?php
764
+ if ( ! empty( $this->message ) && is_string( $this->message ) ) {
765
+ echo wp_kses_post( $this->message );
766
+ }
767
+ ?>
768
+ <?php $plugin_table->views(); ?>
769
+
770
+ <form id="tgmpa-plugins" action="" method="post">
771
+ <input type="hidden" name="tgmpa-page" value="<?php echo esc_attr( $this->menu ); ?>" />
772
+ <input type="hidden" name="plugin_status" value="<?php echo esc_attr( $plugin_table->view_context ); ?>" />
773
+ <?php $plugin_table->display(); ?>
774
+ </form>
775
+ </div>
776
+ <?php
777
+ }
778
+
779
+ /**
780
+ * Installs, updates or activates a plugin depending on the action link clicked by the user.
781
+ *
782
+ * Checks the $_GET variable to see which actions have been
783
+ * passed and responds with the appropriate method.
784
+ *
785
+ * Uses WP_Filesystem to process and handle the plugin installation
786
+ * method.
787
+ *
788
+ * @since 1.0.0
789
+ *
790
+ * @uses WP_Filesystem
791
+ * @uses WP_Error
792
+ * @uses WP_Upgrader
793
+ * @uses Plugin_Upgrader
794
+ * @uses Plugin_Installer_Skin
795
+ * @uses Plugin_Upgrader_Skin
796
+ *
797
+ * @return boolean True on success, false on failure.
798
+ */
799
+ protected function do_plugin_install() {
800
+ if ( empty( $_GET['plugin'] ) ) {
801
+ return false;
802
+ }
803
+
804
+ // All plugin information will be stored in an array for processing.
805
+ $slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) );
806
+
807
+ if ( ! isset( $this->plugins[ $slug ] ) ) {
808
+ return false;
809
+ }
810
+
811
+ // Was an install or upgrade action link clicked?
812
+ if ( ( isset( $_GET['tgmpa-install'] ) && 'install-plugin' === $_GET['tgmpa-install'] ) || ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) ) {
813
+
814
+ $install_type = 'install';
815
+ if ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) {
816
+ $install_type = 'update';
817
+ }
818
+
819
+ check_admin_referer( 'tgmpa-' . $install_type, 'tgmpa-nonce' );
820
+
821
+ // Pass necessary information via URL if WP_Filesystem is needed.
822
+ $url = wp_nonce_url(
823
+ add_query_arg(
824
+ array(
825
+ 'plugin' => urlencode( $slug ),
826
+ 'tgmpa-' . $install_type => $install_type . '-plugin',
827
+ ),
828
+ $this->get_tgmpa_url()
829
+ ),
830
+ 'tgmpa-' . $install_type,
831
+ 'tgmpa-nonce'
832
+ );
833
+
834
+ $method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
835
+
836
+ if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, array() ) ) ) {
837
+ return true;
838
+ }
839
+
840
+ if ( ! WP_Filesystem( $creds ) ) {
841
+ request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, array() ); // Setup WP_Filesystem.
842
+ return true;
843
+ }
844
+
845
+ /* If we arrive here, we have the filesystem. */
846
+
847
+ // Prep variables for Plugin_Installer_Skin class.
848
+ $extra = array();
849
+ $extra['slug'] = $slug; // Needed for potentially renaming of directory name.
850
+ $source = $this->get_download_url( $slug );
851
+ $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null;
852
+ $api = ( false !== $api ) ? $api : null;
853
+
854
+ $url = add_query_arg(
855
+ array(
856
+ 'action' => $install_type . '-plugin',
857
+ 'plugin' => urlencode( $slug ),
858
+ ),
859
+ 'update.php'
860
+ );
861
+
862
+ if ( ! class_exists( 'Plugin_Upgrader', false ) ) {
863
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
864
+ }
865
+
866
+ $title = ( 'update' === $install_type ) ? $this->strings['updating'] : $this->strings['installing'];
867
+ $skin_args = array(
868
+ 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload',
869
+ 'title' => sprintf( $title, $this->plugins[ $slug ]['name'] ),
870
+ 'url' => esc_url_raw( $url ),
871
+ 'nonce' => $install_type . '-plugin_' . $slug,
872
+ 'plugin' => '',
873
+ 'api' => $api,
874
+ 'extra' => $extra,
875
+ );
876
+ unset( $title );
877
+
878
+ if ( 'update' === $install_type ) {
879
+ $skin_args['plugin'] = $this->plugins[ $slug ]['file_path'];
880
+ $skin = new Plugin_Upgrader_Skin( $skin_args );
881
+ } else {
882
+ $skin = new Plugin_Installer_Skin( $skin_args );
883
+ }
884
+
885
+ // Create a new instance of Plugin_Upgrader.
886
+ $upgrader = new Plugin_Upgrader( $skin );
887
+
888
+ // Perform the action and install the plugin from the $source urldecode().
889
+ add_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1, 3 );
890
+
891
+ if ( 'update' === $install_type ) {
892
+ // Inject our info into the update transient.
893
+ $to_inject = array( $slug => $this->plugins[ $slug ] );
894
+ $to_inject[ $slug ]['source'] = $source;
895
+ $this->inject_update_info( $to_inject );
896
+
897
+ $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] );
898
+ } else {
899
+ $upgrader->install( $source );
900
+ }
901
+
902
+ remove_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1 );
903
+
904
+ // Make sure we have the correct file path now the plugin is installed/updated.
905
+ $this->populate_file_path( $slug );
906
+
907
+ // Only activate plugins if the config option is set to true and the plugin isn't
908
+ // already active (upgrade).
909
+ if ( $this->is_automatic && ! $this->is_plugin_active( $slug ) ) {
910
+ $plugin_activate = $upgrader->plugin_info(); // Grab the plugin info from the Plugin_Upgrader method.
911
+ if ( false === $this->activate_single_plugin( $plugin_activate, $slug, true ) ) {
912
+ return true; // Finish execution of the function early as we encountered an error.
913
+ }
914
+ }
915
+
916
+ $this->show_tgmpa_version();
917
+
918
+ // Display message based on if all plugins are now active or not.
919
+ if ( $this->is_tgmpa_complete() ) {
920
+ echo '<p>', sprintf( esc_html( $this->strings['complete'] ), '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'elementor-templater' ) . '</a>' ), '</p>';
921
+ echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
922
+ } else {
923
+ echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
924
+ }
925
+
926
+ return true;
927
+ } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) {
928
+ // Activate action link was clicked.
929
+ check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' );
930
+
931
+ if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) {
932
+ return true; // Finish execution of the function early as we encountered an error.
933
+ }
934
+ }
935
+
936
+ return false;
937
+ }
938
+
939
+ /**
940
+ * Inject information into the 'update_plugins' site transient as WP checks that before running an update.
941
+ *
942
+ * @since 2.5.0
943
+ *
944
+ * @param array $plugins The plugin information for the plugins which are to be updated.
945
+ */
946
+ public function inject_update_info( $plugins ) {
947
+ $repo_updates = get_site_transient( 'update_plugins' );
948
+
949
+ if ( ! is_object( $repo_updates ) ) {
950
+ $repo_updates = new stdClass;
951
+ }
952
+
953
+ foreach ( $plugins as $slug => $plugin ) {
954
+ $file_path = $plugin['file_path'];
955
+
956
+ if ( empty( $repo_updates->response[ $file_path ] ) ) {
957
+ $repo_updates->response[ $file_path ] = new stdClass;
958
+ }
959
+
960
+ // We only really need to set package, but let's do all we can in case WP changes something.
961
+ $repo_updates->response[ $file_path ]->slug = $slug;
962
+ $repo_updates->response[ $file_path ]->plugin = $file_path;
963
+ $repo_updates->response[ $file_path ]->new_version = $plugin['version'];
964
+ $repo_updates->response[ $file_path ]->package = $plugin['source'];
965
+ if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) {
966
+ $repo_updates->response[ $file_path ]->url = $plugin['external_url'];
967
+ }
968
+ }
969
+
970
+ set_site_transient( 'update_plugins', $repo_updates );
971
+ }
972
+
973
+ /**
974
+ * Adjust the plugin directory name if necessary.
975
+ *
976
+ * The final destination directory of a plugin is based on the subdirectory name found in the
977
+ * (un)zipped source. In some cases - most notably GitHub repository plugin downloads -, this
978
+ * subdirectory name is not the same as the expected slug and the plugin will not be recognized
979
+ * as installed. This is fixed by adjusting the temporary unzipped source subdirectory name to
980
+ * the expected plugin slug.
981
+ *
982
+ * @since 2.5.0
983
+ *
984
+ * @param string $source Path to upgrade/zip-file-name.tmp/subdirectory/.
985
+ * @param string $remote_source Path to upgrade/zip-file-name.tmp.
986
+ * @param \WP_Upgrader $upgrader Instance of the upgrader which installs the plugin.
987
+ * @return string $source
988
+ */
989
+ public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) {
990
+ if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS['wp_filesystem'] ) ) {
991
+ return $source;
992
+ }
993
+
994
+ // Check for single file plugins.
995
+ $source_files = array_keys( $GLOBALS['wp_filesystem']->dirlist( $remote_source ) );
996
+ if ( 1 === count( $source_files ) && false === $GLOBALS['wp_filesystem']->is_dir( $source ) ) {
997
+ return $source;
998
+ }
999
+
1000
+ // Multi-file plugin, let's see if the directory is correctly named.
1001
+ $desired_slug = '';
1002
+
1003
+ // Figure out what the slug is supposed to be.
1004
+ if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options['extra']['slug'] ) ) {
1005
+ $desired_slug = $upgrader->skin->options['extra']['slug'];
1006
+ } else {
1007
+ // Bulk installer contains less info, so fall back on the info registered here.
1008
+ foreach ( $this->plugins as $slug => $plugin ) {
1009
+ if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) {
1010
+ $desired_slug = $slug;
1011
+ break;
1012
+ }
1013
+ }
1014
+ unset( $slug, $plugin );
1015
+ }
1016
+
1017
+ if ( ! empty( $desired_slug ) ) {
1018
+ $subdir_name = untrailingslashit( str_replace( trailingslashit( $remote_source ), '', $source ) );
1019
+
1020
+ if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) {
1021
+ $from_path = untrailingslashit( $source );
1022
+ $to_path = trailingslashit( $remote_source ) . $desired_slug;
1023
+
1024
+ if ( true === $GLOBALS['wp_filesystem']->move( $from_path, $to_path ) ) {
1025
+ return trailingslashit( $to_path );
1026
+ } else {
1027
+ return new WP_Error( 'rename_failed', esc_html__( 'The remote plugin package does not contain a folder with the desired slug and renaming did not work.', 'elementor-templater' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'elementor-templater' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) );
1028
+ }
1029
+ } elseif ( empty( $subdir_name ) ) {
1030
+ return new WP_Error( 'packaged_wrong', esc_html__( 'The remote plugin package consists of more than one file, but the files are not packaged in a folder.', 'elementor-templater' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'elementor-templater' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) );
1031
+ }
1032
+ }
1033
+
1034
+ return $source;
1035
+ }
1036
+
1037
+ /**
1038
+ * Activate a single plugin and send feedback about the result to the screen.
1039
+ *
1040
+ * @since 2.5.0
1041
+ *
1042
+ * @param string $file_path Path within wp-plugins/ to main plugin file.
1043
+ * @param string $slug Plugin slug.
1044
+ * @param bool $automatic Whether this is an automatic activation after an install. Defaults to false.
1045
+ * This determines the styling of the output messages.
1046
+ * @return bool False if an error was encountered, true otherwise.
1047
+ */
1048
+ protected function activate_single_plugin( $file_path, $slug, $automatic = false ) {
1049
+ if ( $this->can_plugin_activate( $slug ) ) {
1050
+ $activate = activate_plugin( $file_path );
1051
+
1052
+ if ( is_wp_error( $activate ) ) {
1053
+ echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>',
1054
+ '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
1055
+
1056
+ return false; // End it here if there is an error with activation.
1057
+ } else {
1058
+ if ( ! $automatic ) {
1059
+ // Make sure message doesn't display again if bulk activation is performed
1060
+ // immediately after a single activation.
1061
+ if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK.
1062
+ echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>';
1063
+ }
1064
+ } else {
1065
+ // Simpler message layout for use on the plugin install page.
1066
+ echo '<p>', esc_html( $this->strings['plugin_activated'] ), '</p>';
1067
+ }
1068
+ }
1069
+ } elseif ( $this->is_plugin_active( $slug ) ) {
1070
+ // No simpler message format provided as this message should never be encountered
1071
+ // on the plugin install page.
1072
+ echo '<div id="message" class="error"><p>',
1073
+ sprintf(
1074
+ esc_html( $this->strings['plugin_already_active'] ),
1075
+ '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>'
1076
+ ),
1077
+ '</p></div>';
1078
+ } elseif ( $this->does_plugin_require_update( $slug ) ) {
1079
+ if ( ! $automatic ) {
1080
+ // Make sure message doesn't display again if bulk activation is performed
1081
+ // immediately after a single activation.
1082
+ if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK.
1083
+ echo '<div id="message" class="error"><p>',
1084
+ sprintf(
1085
+ esc_html( $this->strings['plugin_needs_higher_version'] ),
1086
+ '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>'
1087
+ ),
1088
+ '</p></div>';
1089
+ }
1090
+ } else {
1091
+ // Simpler message layout for use on the plugin install page.
1092
+ echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>';
1093
+ }
1094
+ }
1095
+
1096
+ return true;
1097
+ }
1098
+
1099
+ /**
1100
+ * Echoes required plugin notice.
1101
+ *
1102
+ * Outputs a message telling users that a specific plugin is required for
1103
+ * their theme. If appropriate, it includes a link to the form page where
1104
+ * users can install and activate the plugin.
1105
+ *
1106
+ * Returns early if we're on the Install page.
1107
+ *
1108
+ * @since 1.0.0
1109
+ *
1110
+ * @global object $current_screen
1111
+ *
1112
+ * @return null Returns early if we're on the Install page.
1113
+ */
1114
+ public function notices() {
1115
+ // Remove nag on the install page / Return early if the nag message has been dismissed or user < author.
1116
+ if ( ( $this->is_tgmpa_page() || $this->is_core_update_page() ) || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) || ! current_user_can( apply_filters( 'tgmpa_show_admin_notice_capability', 'publish_posts' ) ) ) {
1117
+ return;
1118
+ }
1119
+
1120
+ // Store for the plugin slugs by message type.
1121
+ $message = array();
1122
+
1123
+ // Initialize counters used to determine plurality of action link texts.
1124
+ $install_link_count = 0;
1125
+ $update_link_count = 0;
1126
+ $activate_link_count = 0;
1127
+ $total_required_action_count = 0;
1128
+
1129
+ foreach ( $this->plugins as $slug => $plugin ) {
1130
+ if ( $this->is_plugin_active( $slug ) && false === $this->does_plugin_have_update( $slug ) ) {
1131
+ continue;
1132
+ }
1133
+
1134
+ if ( ! $this->is_plugin_installed( $slug ) ) {
1135
+ if ( current_user_can( 'install_plugins' ) ) {
1136
+ $install_link_count++;
1137
+
1138
+ if ( true === $plugin['required'] ) {
1139
+ $message['notice_can_install_required'][] = $slug;
1140
+ } else {
1141
+ $message['notice_can_install_recommended'][] = $slug;
1142
+ }
1143
+ }
1144
+ if ( true === $plugin['required'] ) {
1145
+ $total_required_action_count++;
1146
+ }
1147
+ } else {
1148
+ if ( ! $this->is_plugin_active( $slug ) && $this->can_plugin_activate( $slug ) ) {
1149
+ if ( current_user_can( 'activate_plugins' ) ) {
1150
+ $activate_link_count++;
1151
+
1152
+ if ( true === $plugin['required'] ) {
1153
+ $message['notice_can_activate_required'][] = $slug;
1154
+ } else {
1155
+ $message['notice_can_activate_recommended'][] = $slug;
1156
+ }
1157
+ }
1158
+ if ( true === $plugin['required'] ) {
1159
+ $total_required_action_count++;
1160
+ }
1161
+ }
1162
+
1163
+ if ( $this->does_plugin_require_update( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) {
1164
+
1165
+ if ( current_user_can( 'update_plugins' ) ) {
1166
+ $update_link_count++;
1167
+
1168
+ if ( $this->does_plugin_require_update( $slug ) ) {
1169
+ $message['notice_ask_to_update'][] = $slug;
1170
+ } elseif ( false !== $this->does_plugin_have_update( $slug ) ) {
1171
+ $message['notice_ask_to_update_maybe'][] = $slug;
1172
+ }
1173
+ }
1174
+ if ( true === $plugin['required'] ) {
1175
+ $total_required_action_count++;
1176
+ }
1177
+ }
1178
+ }
1179
+ }
1180
+ unset( $slug, $plugin );
1181
+
1182
+ // If we have notices to display, we move forward.
1183
+ if ( ! empty( $message ) || $total_required_action_count > 0 ) {
1184
+ krsort( $message ); // Sort messages.
1185
+ $rendered = '';
1186
+
1187
+ // As add_settings_error() wraps the final message in a <p> and as the final message can't be
1188
+ // filtered, using <p>'s in our html would render invalid html output.
1189
+ $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>' . "\n";
1190
+
1191
+ if ( ! current_user_can( 'activate_plugins' ) && ! current_user_can( 'install_plugins' ) && ! current_user_can( 'update_plugins' ) ) {
1192
+ $rendered = esc_html( $this->strings['notice_cannot_install_activate'] ) . ' ' . esc_html( $this->strings['contact_admin'] );
1193
+ $rendered .= $this->create_user_action_links_for_notice( 0, 0, 0, $line_template );
1194
+ } else {
1195
+
1196
+ // If dismissable is false and a message is set, output it now.
1197
+ if ( ! $this->dismissable && ! empty( $this->dismiss_msg ) ) {
1198
+ $rendered .= sprintf( $line_template, wp_kses_post( $this->dismiss_msg ) );
1199
+ }
1200
+
1201
+ // Render the individual message lines for the notice.
1202
+ foreach ( $message as $type => $plugin_group ) {
1203
+ $linked_plugins = array();
1204
+
1205
+ // Get the external info link for a plugin if one is available.
1206
+ foreach ( $plugin_group as $plugin_slug ) {
1207
+ $linked_plugins[] = $this->get_info_link( $plugin_slug );
1208
+ }
1209
+ unset( $plugin_slug );
1210
+
1211
+ $count = count( $plugin_group );
1212
+ $linked_plugins = array_map( array( 'TGMPA_Utils', 'wrap_in_em' ), $linked_plugins );
1213
+ $last_plugin = array_pop( $linked_plugins ); // Pop off last name to prep for readability.
1214
+ $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'elementor-templater' ) . ' ' . $last_plugin );
1215
+
1216
+ $rendered .= sprintf(
1217
+ $line_template,
1218
+ sprintf(
1219
+ translate_nooped_plural( $this->strings[ $type ], $count, 'tgmpa' ),
1220
+ $imploded,
1221
+ $count
1222
+ )
1223
+ );
1224
+
1225
+ }
1226
+ unset( $type, $plugin_group, $linked_plugins, $count, $last_plugin, $imploded );
1227
+
1228
+ $rendered .= $this->create_user_action_links_for_notice( $install_link_count, $update_link_count, $activate_link_count, $line_template );
1229
+ }
1230
+
1231
+ // Register the nag messages and prepare them to be processed.
1232
+ add_settings_error( 'tgmpa', 'tgmpa', $rendered, $this->get_admin_notice_class() );
1233
+ }
1234
+
1235
+ // Admin options pages already output settings_errors, so this is to avoid duplication.
1236
+ if ( 'options-general' !== $GLOBALS['current_screen']->parent_base ) {
1237
+ $this->display_settings_errors();
1238
+ }
1239
+ }
1240
+
1241
+ /**
1242
+ * Generate the user action links for the admin notice.
1243
+ *
1244
+ * @since 2.6.0
1245
+ *
1246
+ * @param int $install_count Number of plugins to install.
1247
+ * @param int $update_count Number of plugins to update.
1248
+ * @param int $activate_count Number of plugins to activate.
1249
+ * @param int $line_template Template for the HTML tag to output a line.
1250
+ * @return string Action links.
1251
+ */
1252
+ protected function create_user_action_links_for_notice( $install_count, $update_count, $activate_count, $line_template ) {
1253
+ // Setup action links.
1254
+ $action_links = array(
1255
+ 'install' => '',
1256
+ 'update' => '',
1257
+ 'activate' => '',
1258
+ 'dismiss' => $this->dismissable ? '<a href="' . esc_url( wp_nonce_url( add_query_arg( 'tgmpa-dismiss', 'dismiss_admin_notices' ), 'tgmpa-dismiss-' . get_current_user_id() ) ) . '" class="dismiss-notice" target="_parent">' . esc_html( $this->strings['dismiss'] ) . '</a>' : '',
1259
+ );
1260
+
1261
+ $link_template = '<a href="%2$s">%1$s</a>';
1262
+
1263
+ if ( current_user_can( 'install_plugins' ) ) {
1264
+ if ( $install_count > 0 ) {
1265
+ $action_links['install'] = sprintf(
1266
+ $link_template,
1267
+ translate_nooped_plural( $this->strings['install_link'], $install_count, 'tgmpa' ),
1268
+ esc_url( $this->get_tgmpa_status_url( 'install' ) )
1269
+ );
1270
+ }
1271
+ if ( $update_count > 0 ) {
1272
+ $action_links['update'] = sprintf(
1273
+ $link_template,
1274
+ translate_nooped_plural( $this->strings['update_link'], $update_count, 'tgmpa' ),
1275
+ esc_url( $this->get_tgmpa_status_url( 'update' ) )
1276
+ );
1277
+ }
1278
+ }
1279
+
1280
+ if ( current_user_can( 'activate_plugins' ) && $activate_count > 0 ) {
1281
+ $action_links['activate'] = sprintf(
1282
+ $link_template,
1283
+ translate_nooped_plural( $this->strings['activate_link'], $activate_count, 'tgmpa' ),
1284
+ esc_url( $this->get_tgmpa_status_url( 'activate' ) )
1285
+ );
1286
+ }
1287
+
1288
+ $action_links = apply_filters( 'tgmpa_notice_action_links', $action_links );
1289
+
1290
+ $action_links = array_filter( (array) $action_links ); // Remove any empty array items.
1291
+
1292
+ if ( ! empty( $action_links ) ) {
1293
+ $action_links = sprintf( $line_template, implode( ' | ', $action_links ) );
1294
+ return apply_filters( 'tgmpa_notice_rendered_action_links', $action_links );
1295
+ } else {
1296
+ return '';
1297
+ }
1298
+ }
1299
+
1300
+ /**
1301
+ * Get admin notice class.
1302
+ *
1303
+ * Work around all the changes to the various admin notice classes between WP 4.4 and 3.7
1304
+ * (lowest supported version by TGMPA).
1305
+ *
1306
+ * @since 2.6.0
1307
+ *
1308
+ * @return string
1309
+ */
1310
+ protected function get_admin_notice_class() {
1311
+ if ( ! empty( $this->strings['nag_type'] ) ) {
1312
+ return sanitize_html_class( strtolower( $this->strings['nag_type'] ) );
1313
+ } else {
1314
+ if ( version_compare( $this->wp_version, '4.2', '>=' ) ) {
1315
+ return 'notice-warning';
1316
+ } elseif ( version_compare( $this->wp_version, '4.1', '>=' ) ) {
1317
+ return 'notice';
1318
+ } else {
1319
+ return 'updated';
1320
+ }
1321
+ }
1322
+ }
1323
+
1324
+ /**
1325
+ * Display settings errors and remove those which have been displayed to avoid duplicate messages showing
1326
+ *
1327
+ * @since 2.5.0
1328
+ */
1329
+ protected function display_settings_errors() {
1330
+ global $wp_settings_errors;
1331
+
1332
+ settings_errors( 'tgmpa' );
1333
+
1334
+ foreach ( (array) $wp_settings_errors as $key => $details ) {
1335
+ if ( 'tgmpa' === $details['setting'] ) {
1336
+ unset( $wp_settings_errors[ $key ] );
1337
+ break;
1338
+ }
1339
+ }
1340
+ }
1341
+
1342
+ /**
1343
+ * Register dismissal of admin notices.
1344
+ *
1345
+ * Acts on the dismiss link in the admin nag messages.
1346
+ * If clicked, the admin notice disappears and will no longer be visible to this user.
1347
+ *
1348
+ * @since 2.1.0
1349
+ */
1350
+ public function dismiss() {
1351
+ if ( isset( $_GET['tgmpa-dismiss'] ) && check_admin_referer( 'tgmpa-dismiss-' . get_current_user_id() ) ) {
1352
+ update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, 1 );
1353
+ }
1354
+ }
1355
+
1356
+ /**
1357
+ * Add individual plugin to our collection of plugins.
1358
+ *
1359
+ * If the required keys are not set or the plugin has already
1360
+ * been registered, the plugin is not added.
1361
+ *
1362
+ * @since 2.0.0
1363
+ *
1364
+ * @param array|null $plugin Array of plugin arguments or null if invalid argument.
1365
+ * @return null Return early if incorrect argument.
1366
+ */
1367
+ public function register( $plugin ) {
1368
+ if ( empty( $plugin['slug'] ) || empty( $plugin['name'] ) ) {
1369
+ return;
1370
+ }
1371
+
1372
+ if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) {
1373
+ return;
1374
+ }
1375
+
1376
+ $defaults = array(
1377
+ 'name' => '', // String
1378
+ 'slug' => '', // String
1379
+ 'source' => 'repo', // String
1380
+ 'required' => false, // Boolean
1381
+ 'version' => '', // String
1382
+ 'force_activation' => false, // Boolean
1383
+ 'force_deactivation' => false, // Boolean
1384
+ 'external_url' => '', // String
1385
+ 'is_callable' => '', // String|Array.
1386
+ );
1387
+
1388
+ // Prepare the received data.
1389
+ $plugin = wp_parse_args( $plugin, $defaults );
1390
+
1391
+ // Standardize the received slug.
1392
+ $plugin['slug'] = $this->sanitize_key( $plugin['slug'] );
1393
+
1394
+ // Forgive users for using string versions of booleans or floats for version number.
1395
+ $plugin['version'] = (string) $plugin['version'];
1396
+ $plugin['source'] = empty( $plugin['source'] ) ? 'repo' : $plugin['source'];
1397
+ $plugin['required'] = TGMPA_Utils::validate_bool( $plugin['required'] );
1398
+ $plugin['force_activation'] = TGMPA_Utils::validate_bool( $plugin['force_activation'] );
1399
+ $plugin['force_deactivation'] = TGMPA_Utils::validate_bool( $plugin['force_deactivation'] );
1400
+
1401
+ // Enrich the received data.
1402
+ $plugin['file_path'] = $this->_get_plugin_basename_from_slug( $plugin['slug'] );
1403
+ $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] );
1404
+
1405
+ // Set the class properties.
1406
+ $this->plugins[ $plugin['slug'] ] = $plugin;
1407
+ $this->sort_order[ $plugin['slug'] ] = $plugin['name'];
1408
+
1409
+ // Should we add the force activation hook ?
1410
+ if ( true === $plugin['force_activation'] ) {
1411
+ $this->has_forced_activation = true;
1412
+ }
1413
+
1414
+ // Should we add the force deactivation hook ?
1415
+ if ( true === $plugin['force_deactivation'] ) {
1416
+ $this->has_forced_deactivation = true;
1417
+ }
1418
+ }
1419
+
1420
+ /**
1421
+ * Determine what type of source the plugin comes from.
1422
+ *
1423
+ * @since 2.5.0
1424
+ *
1425
+ * @param string $source The source of the plugin as provided, either empty (= WP repo), a file path
1426
+ * (= bundled) or an external URL.
1427
+ * @return string 'repo', 'external', or 'bundled'
1428
+ */
1429
+ protected function get_plugin_source_type( $source ) {
1430
+ if ( 'repo' === $source || preg_match( self::WP_REPO_REGEX, $source ) ) {
1431
+ return 'repo';
1432
+ } elseif ( preg_match( self::IS_URL_REGEX, $source ) ) {
1433
+ return 'external';
1434
+ } else {
1435
+ return 'bundled';
1436
+ }
1437
+ }
1438
+
1439
+ /**
1440
+ * Sanitizes a string key.
1441
+ *
1442
+ * Near duplicate of WP Core `sanitize_key()`. The difference is that uppercase characters *are*
1443
+ * allowed, so as not to break upgrade paths from non-standard bundled plugins using uppercase
1444
+ * characters in the plugin directory path/slug. Silly them.
1445
+ *
1446
+ * @see https://developer.wordpress.org/reference/hooks/sanitize_key/
1447
+ *
1448
+ * @since 2.5.0
1449
+ *
1450
+ * @param string $key String key.
1451
+ * @return string Sanitized key
1452
+ */
1453
+ public function sanitize_key( $key ) {
1454
+ $raw_key = $key;
1455
+ $key = preg_replace( '`[^A-Za-z0-9_-]`', '', $key );
1456
+
1457
+ /**
1458
+ * Filter a sanitized key string.
1459
+ *
1460
+ * @since 2.5.0
1461
+ *
1462
+ * @param string $key Sanitized key.
1463
+ * @param string $raw_key The key prior to sanitization.
1464
+ */
1465
+ return apply_filters( 'tgmpa_sanitize_key', $key, $raw_key );
1466
+ }
1467
+
1468
+ /**
1469
+ * Amend default configuration settings.
1470
+ *
1471
+ * @since 2.0.0
1472
+ *
1473
+ * @param array $config Array of config options to pass as class properties.
1474
+ */
1475
+ public function config( $config ) {
1476
+ $keys = array(
1477
+ 'id',
1478
+ 'default_path',
1479
+ 'has_notices',
1480
+ 'dismissable',
1481
+ 'dismiss_msg',
1482
+ 'menu',
1483
+ 'parent_slug',
1484
+ 'capability',
1485
+ 'is_automatic',
1486
+ 'message',
1487
+ 'strings',
1488
+ );
1489
+
1490
+ foreach ( $keys as $key ) {
1491
+ if ( isset( $config[ $key ] ) ) {
1492
+ if ( is_array( $config[ $key ] ) ) {
1493
+ $this->$key = array_merge( $this->$key, $config[ $key ] );
1494
+ } else {
1495
+ $this->$key = $config[ $key ];
1496
+ }
1497
+ }
1498
+ }
1499
+ }
1500
+
1501
+ /**
1502
+ * Amend action link after plugin installation.
1503
+ *
1504
+ * @since 2.0.0
1505
+ *
1506
+ * @param array $install_actions Existing array of actions.
1507
+ * @return false|array Amended array of actions.
1508
+ */
1509
+ public function actions( $install_actions ) {
1510
+ // Remove action links on the TGMPA install page.
1511
+ if ( $this->is_tgmpa_page() ) {
1512
+ return false;
1513
+ }
1514
+
1515
+ return $install_actions;
1516
+ }
1517
+
1518
+ /**
1519
+ * Flushes the plugins cache on theme switch to prevent stale entries
1520
+ * from remaining in the plugin table.
1521
+ *
1522
+ * @since 2.4.0
1523
+ *
1524
+ * @param bool $clear_update_cache Optional. Whether to clear the Plugin updates cache.
1525
+ * Parameter added in v2.5.0.
1526
+ */
1527
+ public function flush_plugins_cache( $clear_update_cache = true ) {
1528
+ wp_clean_plugins_cache( $clear_update_cache );
1529
+ }
1530
+
1531
+ /**
1532
+ * Set file_path key for each installed plugin.
1533
+ *
1534
+ * @since 2.1.0
1535
+ *
1536
+ * @param string $plugin_slug Optional. If set, only (re-)populates the file path for that specific plugin.
1537
+ * Parameter added in v2.5.0.
1538
+ */
1539
+ public function populate_file_path( $plugin_slug = '' ) {
1540
+ if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) {
1541
+ $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug );
1542
+ } else {
1543
+ // Add file_path key for all plugins.
1544
+ foreach ( $this->plugins as $slug => $values ) {
1545
+ $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug );
1546
+ }
1547
+ }
1548
+ }
1549
+
1550
+ /**
1551
+ * Helper function to extract the file path of the plugin file from the
1552
+ * plugin slug, if the plugin is installed.
1553
+ *
1554
+ * @since 2.0.0
1555
+ *
1556
+ * @param string $slug Plugin slug (typically folder name) as provided by the developer.
1557
+ * @return string Either file path for plugin if installed, or just the plugin slug.
1558
+ */
1559
+ protected function _get_plugin_basename_from_slug( $slug ) {
1560
+ $keys = array_keys( $this->get_plugins() );
1561
+
1562
+ foreach ( $keys as $key ) {
1563
+ if ( preg_match( '|^' . $slug . '/|', $key ) ) {
1564
+ return $key;
1565
+ }
1566
+ }
1567
+
1568
+ return $slug;
1569
+ }
1570
+
1571
+ /**
1572
+ * Retrieve plugin data, given the plugin name.
1573
+ *
1574
+ * Loops through the registered plugins looking for $name. If it finds it,
1575
+ * it returns the $data from that plugin. Otherwise, returns false.
1576
+ *
1577
+ * @since 2.1.0
1578
+ *
1579
+ * @param string $name Name of the plugin, as it was registered.
1580
+ * @param string $data Optional. Array key of plugin data to return. Default is slug.
1581
+ * @return string|boolean Plugin slug if found, false otherwise.
1582
+ */
1583
+ public function _get_plugin_data_from_name( $name, $data = 'slug' ) {
1584
+ foreach ( $this->plugins as $values ) {
1585
+ if ( $name === $values['name'] && isset( $values[ $data ] ) ) {
1586
+ return $values[ $data ];
1587
+ }
1588
+ }
1589
+
1590
+ return false;
1591
+ }
1592
+
1593
+ /**
1594
+ * Retrieve the download URL for a package.
1595
+ *
1596
+ * @since 2.5.0
1597
+ *
1598
+ * @param string $slug Plugin slug.
1599
+ * @return string Plugin download URL or path to local file or empty string if undetermined.
1600
+ */
1601
+ public function get_download_url( $slug ) {
1602
+ $dl_source = '';
1603
+
1604
+ switch ( $this->plugins[ $slug ]['source_type'] ) {
1605
+ case 'repo':
1606
+ return $this->get_wp_repo_download_url( $slug );
1607
+ case 'external':
1608
+ return $this->plugins[ $slug ]['source'];
1609
+ case 'bundled':
1610
+ return $this->default_path . $this->plugins[ $slug ]['source'];
1611
+ }
1612
+
1613
+ return $dl_source; // Should never happen.
1614
+ }
1615
+
1616
+ /**
1617
+ * Retrieve the download URL for a WP repo package.
1618
+ *
1619
+ * @since 2.5.0
1620
+ *
1621
+ * @param string $slug Plugin slug.
1622
+ * @return string Plugin download URL.
1623
+ */
1624
+ protected function get_wp_repo_download_url( $slug ) {
1625
+ $source = '';
1626
+ $api = $this->get_plugins_api( $slug );
1627
+
1628
+ if ( false !== $api && isset( $api->download_link ) ) {
1629
+ $source = $api->download_link;
1630
+ }
1631
+
1632
+ return $source;
1633
+ }
1634
+
1635
+ /**
1636
+ * Try to grab information from WordPress API.
1637
+ *
1638
+ * @since 2.5.0
1639
+ *
1640
+ * @param string $slug Plugin slug.
1641
+ * @return object Plugins_api response object on success, WP_Error on failure.
1642
+ */
1643
+ protected function get_plugins_api( $slug ) {
1644
+ static $api = array(); // Cache received responses.
1645
+
1646
+ if ( ! isset( $api[ $slug ] ) ) {
1647
+ if ( ! function_exists( 'plugins_api' ) ) {
1648
+ require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
1649
+ }
1650
+
1651
+ $response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) );
1652
+
1653
+ $api[ $slug ] = false;
1654
+
1655
+ if ( is_wp_error( $response ) ) {
1656
+ wp_die( esc_html( $this->strings['oops'] ) );
1657
+ } else {
1658
+ $api[ $slug ] = $response;
1659
+ }
1660
+ }
1661
+
1662
+ return $api[ $slug ];
1663
+ }
1664
+
1665
+ /**
1666
+ * Retrieve a link to a plugin information page.
1667
+ *
1668
+ * @since 2.5.0
1669
+ *
1670
+ * @param string $slug Plugin slug.
1671
+ * @return string Fully formed html link to a plugin information page if available
1672
+ * or the plugin name if not.
1673
+ */
1674
+ public function get_info_link( $slug ) {
1675
+ if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) {
1676
+ $link = sprintf(
1677
+ '<a href="%1$s" target="_blank">%2$s</a>',
1678
+ esc_url( $this->plugins[ $slug ]['external_url'] ),
1679
+ esc_html( $this->plugins[ $slug ]['name'] )
1680
+ );
1681
+ } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) {
1682
+ $url = add_query_arg(
1683
+ array(
1684
+ 'tab' => 'plugin-information',
1685
+ 'plugin' => urlencode( $slug ),
1686
+ 'TB_iframe' => 'true',
1687
+ 'width' => '640',
1688
+ 'height' => '500',
1689
+ ),
1690
+ self_admin_url( 'plugin-install.php' )
1691
+ );
1692
+
1693
+ $link = sprintf(
1694
+ '<a href="%1$s" class="thickbox">%2$s</a>',
1695
+ esc_url( $url ),
1696
+ esc_html( $this->plugins[ $slug ]['name'] )
1697
+ );
1698
+ } else {
1699
+ $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink.
1700
+ }
1701
+
1702
+ return $link;
1703
+ }
1704
+
1705
+ /**
1706
+ * Determine if we're on the TGMPA Install page.
1707
+ *
1708
+ * @since 2.1.0
1709
+ *
1710
+ * @return boolean True when on the TGMPA page, false otherwise.
1711
+ */
1712
+ protected function is_tgmpa_page() {
1713
+ return isset( $_GET['page'] ) && $this->menu === $_GET['page'];
1714
+ }
1715
+
1716
+ /**
1717
+ * Determine if we're on a WP Core installation/upgrade page.
1718
+ *
1719
+ * @since 2.6.0
1720
+ *
1721
+ * @return boolean True when on a WP Core installation/upgrade page, false otherwise.
1722
+ */
1723
+ protected function is_core_update_page() {
1724
+ // Current screen is not always available, most notably on the customizer screen.
1725
+ if ( ! function_exists( 'get_current_screen' ) ) {
1726
+ return false;
1727
+ }
1728
+
1729
+ $screen = get_current_screen();
1730
+
1731
+ if ( 'update-core' === $screen->base ) {
1732
+ // Core update screen.
1733
+ return true;
1734
+ } elseif ( 'plugins' === $screen->base && ! empty( $_POST['action'] ) ) { // WPCS: CSRF ok.
1735
+ // Plugins bulk update screen.
1736
+ return true;
1737
+ } elseif ( 'update' === $screen->base && ! empty( $_POST['action'] ) ) { // WPCS: CSRF ok.
1738
+ // Individual updates (ajax call).
1739
+ return true;
1740
+ }
1741
+
1742
+ return false;
1743
+ }
1744
+
1745
+ /**
1746
+ * Retrieve the URL to the TGMPA Install page.
1747
+ *
1748
+ * I.e. depending on the config settings passed something along the lines of:
1749
+ * http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins
1750
+ *
1751
+ * @since 2.5.0
1752
+ *
1753
+ * @return string Properly encoded URL (not escaped).
1754
+ */
1755
+ public function get_tgmpa_url() {
1756
+ static $url;
1757
+
1758
+ if ( ! isset( $url ) ) {
1759
+ $parent = $this->parent_slug;
1760
+ if ( false === strpos( $parent, '.php' ) ) {
1761
+ $parent = 'admin.php';
1762
+ }
1763
+ $url = add_query_arg(
1764
+ array(
1765
+ 'page' => urlencode( $this->menu ),
1766
+ ),
1767
+ self_admin_url( $parent )
1768
+ );
1769
+ }
1770
+
1771
+ return $url;
1772
+ }
1773
+
1774
+ /**
1775
+ * Retrieve the URL to the TGMPA Install page for a specific plugin status (view).
1776
+ *
1777
+ * I.e. depending on the config settings passed something along the lines of:
1778
+ * http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins&plugin_status=install
1779
+ *
1780
+ * @since 2.5.0
1781
+ *
1782
+ * @param string $status Plugin status - either 'install', 'update' or 'activate'.
1783
+ * @return string Properly encoded URL (not escaped).
1784
+ */
1785
+ public function get_tgmpa_status_url( $status ) {
1786
+ return add_query_arg(
1787
+ array(
1788
+ 'plugin_status' => urlencode( $status ),
1789
+ ),
1790
+ $this->get_tgmpa_url()
1791
+ );
1792
+ }
1793
+
1794
+ /**
1795
+ * Determine whether there are open actions for plugins registered with TGMPA.
1796
+ *
1797
+ * @since 2.5.0
1798
+ *
1799
+ * @return bool True if complete, i.e. no outstanding actions. False otherwise.
1800
+ */
1801
+ public function is_tgmpa_complete() {
1802
+ $complete = true;
1803
+ foreach ( $this->plugins as $slug => $plugin ) {
1804
+ if ( ! $this->is_plugin_active( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) {
1805
+ $complete = false;
1806
+ break;
1807
+ }
1808
+ }
1809
+
1810
+ return $complete;
1811
+ }
1812
+
1813
+ /**
1814
+ * Check if a plugin is installed. Does not take must-use plugins into account.
1815
+ *
1816
+ * @since 2.5.0
1817
+ *
1818
+ * @param string $slug Plugin slug.
1819
+ * @return bool True if installed, false otherwise.
1820
+ */
1821
+ public function is_plugin_installed( $slug ) {
1822
+ $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached).
1823
+
1824
+ return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) );
1825
+ }
1826
+
1827
+ /**
1828
+ * Check if a plugin is active.
1829
+ *
1830
+ * @since 2.5.0
1831
+ *
1832
+ * @param string $slug Plugin slug.
1833
+ * @return bool True if active, false otherwise.
1834
+ */
1835
+ public function is_plugin_active( $slug ) {
1836
+ return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) );
1837
+ }
1838
+
1839
+ /**
1840
+ * Check if a plugin can be updated, i.e. if we have information on the minimum WP version required
1841
+ * available, check whether the current install meets them.
1842
+ *
1843
+ * @since 2.5.0
1844
+ *
1845
+ * @param string $slug Plugin slug.
1846
+ * @return bool True if OK to update, false otherwise.
1847
+ */
1848
+ public function can_plugin_update( $slug ) {
1849
+ // We currently can't get reliable info on non-WP-repo plugins - issue #380.
1850
+ if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
1851
+ return true;
1852
+ }
1853
+
1854
+ $api = $this->get_plugins_api( $slug );
1855
+
1856
+ if ( false !== $api && isset( $api->requires ) ) {
1857
+ return version_compare( $this->wp_version, $api->requires, '>=' );
1858
+ }
1859
+
1860
+ // No usable info received from the plugins API, presume we can update.
1861
+ return true;
1862
+ }
1863
+
1864
+ /**
1865
+ * Check to see if the plugin is 'updatetable', i.e. installed, with an update available
1866
+ * and no WP version requirements blocking it.
1867
+ *
1868
+ * @since 2.6.0
1869
+ *
1870
+ * @param string $slug Plugin slug.
1871
+ * @return bool True if OK to proceed with update, false otherwise.
1872
+ */
1873
+ public function is_plugin_updatetable( $slug ) {
1874
+ if ( ! $this->is_plugin_installed( $slug ) ) {
1875
+ return false;
1876
+ } else {
1877
+ return ( false !== $this->does_plugin_have_update( $slug ) && $this->can_plugin_update( $slug ) );
1878
+ }
1879
+ }
1880
+
1881
+ /**
1882
+ * Check if a plugin can be activated, i.e. is not currently active and meets the minimum
1883
+ * plugin version requirements set in TGMPA (if any).
1884
+ *
1885
+ * @since 2.5.0
1886
+ *
1887
+ * @param string $slug Plugin slug.
1888
+ * @return bool True if OK to activate, false otherwise.
1889
+ */
1890
+ public function can_plugin_activate( $slug ) {
1891
+ return ( ! $this->is_plugin_active( $slug ) && ! $this->does_plugin_require_update( $slug ) );
1892
+ }
1893
+
1894
+ /**
1895
+ * Retrieve the version number of an installed plugin.
1896
+ *
1897
+ * @since 2.5.0
1898
+ *
1899
+ * @param string $slug Plugin slug.
1900
+ * @return string Version number as string or an empty string if the plugin is not installed
1901
+ * or version unknown (plugins which don't comply with the plugin header standard).
1902
+ */
1903
+ public function get_installed_version( $slug ) {
1904
+ $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached).
1905
+
1906
+ if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) {
1907
+ return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'];
1908
+ }
1909
+
1910
+ return '';
1911
+ }
1912
+
1913
+ /**
1914
+ * Check whether a plugin complies with the minimum version requirements.
1915
+ *
1916
+ * @since 2.5.0
1917
+ *
1918
+ * @param string $slug Plugin slug.
1919
+ * @return bool True when a plugin needs to be updated, otherwise false.
1920
+ */
1921
+ public function does_plugin_require_update( $slug ) {
1922
+ $installed_version = $this->get_installed_version( $slug );
1923
+ $minimum_version = $this->plugins[ $slug ]['version'];
1924
+
1925
+ return version_compare( $minimum_version, $installed_version, '>' );
1926
+ }
1927
+
1928
+ /**
1929
+ * Check whether there is an update available for a plugin.
1930
+ *
1931
+ * @since 2.5.0
1932
+ *
1933
+ * @param string $slug Plugin slug.
1934
+ * @return false|string Version number string of the available update or false if no update available.
1935
+ */
1936
+ public function does_plugin_have_update( $slug ) {
1937
+ // Presume bundled and external plugins will point to a package which meets the minimum required version.
1938
+ if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
1939
+ if ( $this->does_plugin_require_update( $slug ) ) {
1940
+ return $this->plugins[ $slug ]['version'];
1941
+ }
1942
+
1943
+ return false;
1944
+ }
1945
+
1946
+ $repo_updates = get_site_transient( 'update_plugins' );
1947
+
1948
+ if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) {
1949
+ return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version;
1950
+ }
1951
+
1952
+ return false;
1953
+ }
1954
+
1955
+ /**
1956
+ * Retrieve potential upgrade notice for a plugin.
1957
+ *
1958
+ * @since 2.5.0
1959
+ *
1960
+ * @param string $slug Plugin slug.
1961
+ * @return string The upgrade notice or an empty string if no message was available or provided.
1962
+ */
1963
+ public function get_upgrade_notice( $slug ) {
1964
+ // We currently can't get reliable info on non-WP-repo plugins - issue #380.
1965
+ if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
1966
+ return '';
1967
+ }
1968
+
1969
+ $repo_updates = get_site_transient( 'update_plugins' );
1970
+
1971
+ if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) {
1972
+ return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice;
1973
+ }
1974
+
1975
+ return '';
1976
+ }
1977
+
1978
+ /**
1979
+ * Wrapper around the core WP get_plugins function, making sure it's actually available.
1980
+ *
1981
+ * @since 2.5.0
1982
+ *
1983
+ * @param string $plugin_folder Optional. Relative path to single plugin folder.
1984
+ * @return array Array of installed plugins with plugin information.
1985
+ */
1986
+ public function get_plugins( $plugin_folder = '' ) {
1987
+ if ( ! function_exists( 'get_plugins' ) ) {
1988
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
1989
+ }
1990
+
1991
+ return get_plugins( $plugin_folder );
1992
+ }
1993
+
1994
+ /**
1995
+ * Delete dismissable nag option when theme is switched.
1996
+ *
1997
+ * This ensures that the user(s) is/are again reminded via nag of required
1998
+ * and/or recommended plugins if they re-activate the theme.
1999
+ *
2000
+ * @since 2.1.1
2001
+ */
2002
+ public function update_dismiss() {
2003
+ delete_metadata( 'user', null, 'tgmpa_dismissed_notice_' . $this->id, null, true );
2004
+ }
2005
+
2006
+ /**
2007
+ * Forces plugin activation if the parameter 'force_activation' is
2008
+ * set to true.
2009
+ *
2010
+ * This allows theme authors to specify certain plugins that must be
2011
+ * active at all times while using the current theme.
2012
+ *
2013
+ * Please take special care when using this parameter as it has the
2014
+ * potential to be harmful if not used correctly. Setting this parameter
2015
+ * to true will not allow the specified plugin to be deactivated unless
2016
+ * the user switches themes.
2017
+ *
2018
+ * @since 2.2.0
2019
+ */
2020
+ public function force_activation() {
2021
+ foreach ( $this->plugins as $slug => $plugin ) {
2022
+ if ( true === $plugin['force_activation'] ) {
2023
+ if ( ! $this->is_plugin_installed( $slug ) ) {
2024
+ // Oops, plugin isn't there so iterate to next condition.
2025
+ continue;
2026
+ } elseif ( $this->can_plugin_activate( $slug ) ) {
2027
+ // There we go, activate the plugin.
2028
+ activate_plugin( $plugin['file_path'] );
2029
+ }
2030
+ }
2031
+ }
2032
+ }
2033
+
2034
+ /**
2035
+ * Forces plugin deactivation if the parameter 'force_deactivation'
2036
+ * is set to true and adds the plugin to the 'recently active' plugins list.
2037
+ *
2038
+ * This allows theme authors to specify certain plugins that must be
2039
+ * deactivated upon switching from the current theme to another.
2040
+ *
2041
+ * Please take special care when using this parameter as it has the
2042
+ * potential to be harmful if not used correctly.
2043
+ *
2044
+ * @since 2.2.0
2045
+ */
2046
+ public function force_deactivation() {
2047
+ $deactivated = array();
2048
+
2049
+ foreach ( $this->plugins as $slug => $plugin ) {
2050
+ /*
2051
+ * Only proceed forward if the parameter is set to true and plugin is active
2052
+ * as a 'normal' (not must-use) plugin.
2053
+ */
2054
+ if ( true === $plugin['force_deactivation'] && is_plugin_active( $plugin['file_path'] ) ) {
2055
+ deactivate_plugins( $plugin['file_path'] );
2056
+ $deactivated[ $plugin['file_path'] ] = time();
2057
+ }
2058
+ }
2059
+
2060
+ if ( ! empty( $deactivated ) ) {
2061
+ update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
2062
+ }
2063
+ }
2064
+
2065
+ /**
2066
+ * Echo the current TGMPA version number to the page.
2067
+ *
2068
+ * @since 2.5.0
2069
+ */
2070
+ public function show_tgmpa_version() {
2071
+ echo '<p style="float: right; padding: 0em 1.5em 0.5em 0;"><strong><small>',
2072
+ esc_html(
2073
+ sprintf(
2074
+ /* translators: %s: version number */
2075
+ __( 'TGMPA v%s', 'elementor-templater' ),
2076
+ self::TGMPA_VERSION
2077
+ )
2078
+ ),
2079
+ '</small></strong></p>';
2080
+ }
2081
+
2082
+ /**
2083
+ * Returns the singleton instance of the class.
2084
+ *
2085
+ * @since 2.4.0
2086
+ *
2087
+ * @return \TGM_Plugin_Activation The TGM_Plugin_Activation object.
2088
+ */
2089
+ public static function get_instance() {
2090
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
2091
+ self::$instance = new self();
2092
+ }
2093
+
2094
+ return self::$instance;
2095
+ }
2096
+ }
2097
+
2098
+ if ( ! function_exists( 'load_tgm_plugin_activation' ) ) {
2099
+ /**
2100
+ * Ensure only one instance of the class is ever invoked.
2101
+ *
2102
+ * @since 2.5.0
2103
+ */
2104
+ function load_tgm_plugin_activation() {
2105
+ $GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance();
2106
+ }
2107
+ }
2108
+
2109
+ if ( did_action( 'plugins_loaded' ) ) {
2110
+ load_tgm_plugin_activation();
2111
+ } else {
2112
+ add_action( 'plugins_loaded', 'load_tgm_plugin_activation' );
2113
+ }
2114
+ }
2115
+
2116
+ if ( ! function_exists( 'tgmpa' ) ) {
2117
+ /**
2118
+ * Helper function to register a collection of required plugins.
2119
+ *
2120
+ * @since 2.0.0
2121
+ * @api
2122
+ *
2123
+ * @param array $plugins An array of plugin arrays.
2124
+ * @param array $config Optional. An array of configuration values.
2125
+ */
2126
+ function tgmpa( $plugins, $config = array() ) {
2127
+ $instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
2128
+
2129
+ foreach ( $plugins as $plugin ) {
2130
+ call_user_func( array( $instance, 'register' ), $plugin );
2131
+ }
2132
+
2133
+ if ( ! empty( $config ) && is_array( $config ) ) {
2134
+ // Send out notices for deprecated arguments passed.
2135
+ if ( isset( $config['notices'] ) ) {
2136
+ _deprecated_argument( __FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.' );
2137
+ if ( ! isset( $config['has_notices'] ) ) {
2138
+ $config['has_notices'] = $config['notices'];
2139
+ }
2140
+ }
2141
+
2142
+ if ( isset( $config['parent_menu_slug'] ) ) {
2143
+ _deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_menu_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' );
2144
+ }
2145
+ if ( isset( $config['parent_url_slug'] ) ) {
2146
+ _deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_url_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' );
2147
+ }
2148
+
2149
+ call_user_func( array( $instance, 'config' ), $config );
2150
+ }
2151
+ }
2152
+ }
2153
+
2154
+ /**
2155
+ * WP_List_Table isn't always available. If it isn't available,
2156
+ * we load it here.
2157
+ *
2158
+ * @since 2.2.0
2159
+ */
2160
+ if ( ! class_exists( 'WP_List_Table' ) ) {
2161
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
2162
+ }
2163
+
2164
+ if ( ! class_exists( 'TGMPA_List_Table' ) ) {
2165
+
2166
+ /**
2167
+ * List table class for handling plugins.
2168
+ *
2169
+ * Extends the WP_List_Table class to provide a future-compatible
2170
+ * way of listing out all required/recommended plugins.
2171
+ *
2172
+ * Gives users an interface similar to the Plugin Administration
2173
+ * area with similar (albeit stripped down) capabilities.
2174
+ *
2175
+ * This class also allows for the bulk install of plugins.
2176
+ *
2177
+ * @since 2.2.0
2178
+ *
2179
+ * @package TGM-Plugin-Activation
2180
+ * @author Thomas Griffin
2181
+ * @author Gary Jones
2182
+ */
2183
+ class TGMPA_List_Table extends WP_List_Table {
2184
+ /**
2185
+ * TGMPA instance.
2186
+ *
2187
+ * @since 2.5.0
2188
+ *
2189
+ * @var object
2190
+ */
2191
+ protected $tgmpa;
2192
+
2193
+ /**
2194
+ * The currently chosen view.
2195
+ *
2196
+ * @since 2.5.0
2197
+ *
2198
+ * @var string One of: 'all', 'install', 'update', 'activate'
2199
+ */
2200
+ public $view_context = 'all';
2201
+
2202
+ /**
2203
+ * The plugin counts for the various views.
2204
+ *
2205
+ * @since 2.5.0
2206
+ *
2207
+ * @var array
2208
+ */
2209
+ protected $view_totals = array(
2210
+ 'all' => 0,
2211
+ 'install' => 0,
2212
+ 'update' => 0,
2213
+ 'activate' => 0,
2214
+ );
2215
+
2216
+ /**
2217
+ * References parent constructor and sets defaults for class.
2218
+ *
2219
+ * @since 2.2.0
2220
+ */
2221
+ public function __construct() {
2222
+ $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
2223
+
2224
+ parent::__construct(
2225
+ array(
2226
+ 'singular' => 'plugin',
2227
+ 'plural' => 'plugins',
2228
+ 'ajax' => false,
2229
+ )
2230
+ );
2231
+
2232
+ if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'install', 'update', 'activate' ), true ) ) {
2233
+ $this->view_context = sanitize_key( $_REQUEST['plugin_status'] );
2234
+ }
2235
+
2236
+ add_filter( 'tgmpa_table_data_items', array( $this, 'sort_table_items' ) );
2237
+ }
2238
+
2239
+ /**
2240
+ * Get a list of CSS classes for the <table> tag.
2241
+ *
2242
+ * Overruled to prevent the 'plural' argument from being added.
2243
+ *
2244
+ * @since 2.5.0
2245
+ *
2246
+ * @return array CSS classnames.
2247
+ */
2248
+ public function get_table_classes() {
2249
+ return array( 'widefat', 'fixed' );
2250
+ }
2251
+
2252
+ /**
2253
+ * Gathers and renames all of our plugin information to be used by WP_List_Table to create our table.
2254
+ *
2255
+ * @since 2.2.0
2256
+ *
2257
+ * @return array $table_data Information for use in table.
2258
+ */
2259
+ protected function _gather_plugin_data() {
2260
+ // Load thickbox for plugin links.
2261
+ $this->tgmpa->admin_init();
2262
+ $this->tgmpa->thickbox();
2263
+
2264
+ // Categorize the plugins which have open actions.
2265
+ $plugins = $this->categorize_plugins_to_views();
2266
+
2267
+ // Set the counts for the view links.
2268
+ $this->set_view_totals( $plugins );
2269
+
2270
+ // Prep variables for use and grab list of all installed plugins.
2271
+ $table_data = array();
2272
+ $i = 0;
2273
+
2274
+ // Redirect to the 'all' view if no plugins were found for the selected view context.
2275
+ if ( empty( $plugins[ $this->view_context ] ) ) {
2276
+ $this->view_context = 'all';
2277
+ }
2278
+
2279
+ foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) {
2280
+ $table_data[ $i ]['sanitized_plugin'] = $plugin['name'];
2281
+ $table_data[ $i ]['slug'] = $slug;
2282
+ $table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>';
2283
+ $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] );
2284
+ $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] );
2285
+ $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug );
2286
+ $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug );
2287
+ $table_data[ $i ]['minimum_version'] = $plugin['version'];
2288
+ $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug );
2289
+
2290
+ // Prep the upgrade notice info.
2291
+ $upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug );
2292
+ if ( ! empty( $upgrade_notice ) ) {
2293
+ $table_data[ $i ]['upgrade_notice'] = $upgrade_notice;
2294
+
2295
+ add_action( "tgmpa_after_plugin_row_{$slug}", array( $this, 'wp_plugin_update_row' ), 10, 2 );
2296
+ }
2297
+
2298
+ $table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin );
2299
+
2300
+ $i++;
2301
+ }
2302
+
2303
+ return $table_data;
2304
+ }
2305
+
2306
+ /**
2307
+ * Categorize the plugins which have open actions into views for the TGMPA page.
2308
+ *
2309
+ * @since 2.5.0
2310
+ */
2311
+ protected function categorize_plugins_to_views() {
2312
+ $plugins = array(
2313
+ 'all' => array(), // Meaning: all plugins which still have open actions.
2314
+ 'install' => array(),
2315
+ 'update' => array(),
2316
+ 'activate' => array(),
2317
+ );
2318
+
2319
+ foreach ( $this->tgmpa->plugins as $slug => $plugin ) {
2320
+ if ( $this->tgmpa->is_plugin_active( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) {
2321
+ // No need to display plugins if they are installed, up-to-date and active.
2322
+ continue;
2323
+ } else {
2324
+ $plugins['all'][ $slug ] = $plugin;
2325
+
2326
+ if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) {
2327
+ $plugins['install'][ $slug ] = $plugin;
2328
+ } else {
2329
+ if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) {
2330
+ $plugins['update'][ $slug ] = $plugin;
2331
+ }
2332
+
2333
+ if ( $this->tgmpa->can_plugin_activate( $slug ) ) {
2334
+ $plugins['activate'][ $slug ] = $plugin;
2335
+ }
2336
+ }
2337
+ }
2338
+ }
2339
+
2340
+ return $plugins;
2341
+ }
2342
+
2343
+ /**
2344
+ * Set the counts for the view links.
2345
+ *
2346
+ * @since 2.5.0
2347
+ *
2348
+ * @param array $plugins Plugins order by view.
2349
+ */
2350
+ protected function set_view_totals( $plugins ) {
2351
+ foreach ( $plugins as $type => $list ) {
2352
+ $this->view_totals[ $type ] = count( $list );
2353
+ }
2354
+ }
2355
+
2356
+ /**
2357
+ * Get the plugin required/recommended text string.
2358
+ *
2359
+ * @since 2.5.0
2360
+ *
2361
+ * @param string $required Plugin required setting.
2362
+ * @return string
2363
+ */
2364
+ protected function get_plugin_advise_type_text( $required ) {
2365
+ if ( true === $required ) {
2366
+ return __( 'Required', 'elementor-templater' );
2367
+ }
2368
+
2369
+ return __( 'Recommended', 'elementor-templater' );
2370
+ }
2371
+
2372
+ /**
2373
+ * Get the plugin source type text string.
2374
+ *
2375
+ * @since 2.5.0
2376
+ *
2377
+ * @param string $type Plugin type.
2378
+ * @return string
2379
+ */
2380
+ protected function get_plugin_source_type_text( $type ) {
2381
+ $string = '';
2382
+
2383
+ switch ( $type ) {
2384
+ case 'repo':
2385
+ $string = __( 'WordPress Repository', 'elementor-templater' );
2386
+ break;
2387
+ case 'external':
2388
+ $string = __( 'External Source', 'elementor-templater' );
2389
+ break;
2390
+ case 'bundled':
2391
+ $string = __( 'Pre-Packaged', 'elementor-templater' );
2392
+ break;
2393
+ }
2394
+
2395
+ return $string;
2396
+ }
2397
+
2398
+ /**
2399
+ * Determine the plugin status message.
2400
+ *
2401
+ * @since 2.5.0
2402
+ *
2403
+ * @param string $slug Plugin slug.
2404
+ * @return string
2405
+ */
2406
+ protected function get_plugin_status_text( $slug ) {
2407
+ if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) {
2408
+ return __( 'Not Installed', 'elementor-templater' );
2409
+ }
2410
+
2411
+ if ( ! $this->tgmpa->is_plugin_active( $slug ) ) {
2412
+ $install_status = __( 'Installed But Not Activated', 'elementor-templater' );
2413
+ } else {
2414
+ $install_status = __( 'Active', 'elementor-templater' );
2415
+ }
2416
+
2417
+ $update_status = '';
2418
+
2419
+ if ( $this->tgmpa->does_plugin_require_update( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) {
2420
+ $update_status = __( 'Required Update not Available', 'elementor-templater' );
2421
+
2422
+ } elseif ( $this->tgmpa->does_plugin_require_update( $slug ) ) {
2423
+ $update_status = __( 'Requires Update', 'elementor-templater' );
2424
+
2425
+ } elseif ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) {
2426
+ $update_status = __( 'Update recommended', 'elementor-templater' );
2427
+ }
2428
+
2429
+ if ( '' === $update_status ) {
2430
+ return $install_status;
2431
+ }
2432
+
2433
+ return sprintf(
2434
+ /* translators: 1: install status, 2: update status */
2435
+ _x( '%1$s, %2$s', 'Install/Update Status', 'elementor-templater' ),
2436
+ $install_status,
2437
+ $update_status
2438
+ );
2439
+ }
2440
+
2441
+ /**
2442
+ * Sort plugins by Required/Recommended type and by alphabetical plugin name within each type.
2443
+ *
2444
+ * @since 2.5.0
2445
+ *
2446
+ * @param array $items Prepared table items.
2447
+ * @return array Sorted table items.
2448
+ */
2449
+ public function sort_table_items( $items ) {
2450
+ $type = array();
2451
+ $name = array();
2452
+
2453
+ foreach ( $items as $i => $plugin ) {
2454
+ $type[ $i ] = $plugin['type']; // Required / recommended.
2455
+ $name[ $i ] = $plugin['sanitized_plugin'];
2456
+ }
2457
+
2458
+ array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items );
2459
+
2460
+ return $items;
2461
+ }
2462
+
2463
+ /**
2464
+ * Get an associative array ( id => link ) of the views available on this table.
2465
+ *
2466
+ * @since 2.5.0
2467
+ *
2468
+ * @return array
2469
+ */
2470
+ public function get_views() {
2471
+ $status_links = array();
2472
+
2473
+ foreach ( $this->view_totals as $type => $count ) {
2474
+ if ( $count < 1 ) {
2475
+ continue;
2476
+ }
2477
+
2478
+ switch ( $type ) {
2479
+ case 'all':
2480
+ /* translators: 1: number of plugins. */
2481
+ $text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins', 'elementor-templater' );
2482
+ break;
2483
+ case 'install':
2484
+ /* translators: 1: number of plugins. */
2485
+ $text = _n( 'To Install <span class="count">(%s)</span>', 'To Install <span class="count">(%s)</span>', $count, 'elementor-templater' );
2486
+ break;
2487
+ case 'update':
2488
+ /* translators: 1: number of plugins. */
2489
+ $text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count, 'elementor-templater' );
2490
+ break;
2491
+ case 'activate':
2492
+ /* translators: 1: number of plugins. */
2493
+ $text = _n( 'To Activate <span class="count">(%s)</span>', 'To Activate <span class="count">(%s)</span>', $count, 'elementor-templater' );
2494
+ break;
2495
+ default:
2496
+ $text = '';
2497
+ break;
2498
+ }
2499
+
2500
+ if ( ! empty( $text ) ) {
2501
+
2502
+ $status_links[ $type ] = sprintf(
2503
+ '<a href="%s"%s>%s</a>',
2504
+ esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ),
2505
+ ( $type === $this->view_context ) ? ' class="current"' : '',
2506
+ sprintf( $text, number_format_i18n( $count ) )
2507
+ );
2508
+ }
2509
+ }
2510
+
2511
+ return $status_links;
2512
+ }
2513
+
2514
+ /**
2515
+ * Create default columns to display important plugin information
2516
+ * like type, action and status.
2517
+ *
2518
+ * @since 2.2.0
2519
+ *
2520
+ * @param array $item Array of item data.
2521
+ * @param string $column_name The name of the column.
2522
+ * @return string
2523
+ */
2524
+ public function column_default( $item, $column_name ) {
2525
+ return $item[ $column_name ];
2526
+ }
2527
+
2528
+ /**
2529
+ * Required for bulk installing.
2530
+ *
2531
+ * Adds a checkbox for each plugin.
2532
+ *
2533
+ * @since 2.2.0
2534
+ *
2535
+ * @param array $item Array of item data.
2536
+ * @return string The input checkbox with all necessary info.
2537
+ */
2538
+ public function column_cb( $item ) {
2539
+ return sprintf(
2540
+ '<input type="checkbox" name="%1$s[]" value="%2$s" id="%3$s" />',
2541
+ esc_attr( $this->_args['singular'] ),
2542
+ esc_attr( $item['slug'] ),
2543
+ esc_attr( $item['sanitized_plugin'] )
2544
+ );
2545
+ }
2546
+
2547
+ /**
2548
+ * Create default title column along with the action links.
2549
+ *
2550
+ * @since 2.2.0
2551
+ *
2552
+ * @param array $item Array of item data.
2553
+ * @return string The plugin name and action links.
2554
+ */
2555
+ public function column_plugin( $item ) {
2556
+ return sprintf(
2557
+ '%1$s %2$s',
2558
+ $item['plugin'],
2559
+ $this->row_actions( $this->get_row_actions( $item ), true )
2560
+ );
2561
+ }
2562
+
2563
+ /**
2564
+ * Create version information column.
2565
+ *
2566
+ * @since 2.5.0
2567
+ *
2568
+ * @param array $item Array of item data.
2569
+ * @return string HTML-formatted version information.
2570
+ */
2571
+ public function column_version( $item ) {
2572
+ $output = array();
2573
+
2574
+ if ( $this->tgmpa->is_plugin_installed( $item['slug'] ) ) {
2575
+ $installed = ! empty( $item['installed_version'] ) ? $item['installed_version'] : _x( 'unknown', 'as in: "version nr unknown"', 'elementor-templater' );
2576
+
2577
+ $color = '';
2578
+ if ( ! empty( $item['minimum_version'] ) && $this->tgmpa->does_plugin_require_update( $item['slug'] ) ) {
2579
+ $color = ' color: #ff0000; font-weight: bold;';
2580
+ }
2581
+
2582
+ $output[] = sprintf(
2583
+ '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Installed version:', 'elementor-templater' ) . '</p>',
2584
+ $color,
2585
+ $installed
2586
+ );
2587
+ }
2588
+
2589
+ if ( ! empty( $item['minimum_version'] ) ) {
2590
+ $output[] = sprintf(
2591
+ '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>' . __( 'Minimum required version:', 'elementor-templater' ) . '</p>',
2592
+ $item['minimum_version']
2593
+ );
2594
+ }
2595
+
2596
+ if ( ! empty( $item['available_version'] ) ) {
2597
+ $color = '';
2598
+ if ( ! empty( $item['minimum_version'] ) && version_compare( $item['available_version'], $item['minimum_version'], '>=' ) ) {
2599
+ $color = ' color: #71C671; font-weight: bold;';
2600
+ }
2601
+
2602
+ $output[] = sprintf(
2603
+ '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Available version:', 'elementor-templater' ) . '</p>',
2604
+ $color,
2605
+ $item['available_version']
2606
+ );
2607
+ }
2608
+
2609
+ if ( empty( $output ) ) {
2610
+ return '&nbsp;'; // Let's not break the table layout.
2611
+ } else {
2612
+ return implode( "\n", $output );
2613
+ }
2614
+ }
2615
+
2616
+ /**
2617
+ * Sets default message within the plugins table if no plugins
2618
+ * are left for interaction.
2619
+ *
2620
+ * Hides the menu item to prevent the user from clicking and
2621
+ * getting a permissions error.
2622
+ *
2623
+ * @since 2.2.0
2624
+ */
2625
+ public function no_items() {
2626
+ echo esc_html__( 'No plugins to install, update or activate.', 'elementor-templater' ) . ' <a href="' . esc_url( self_admin_url() ) . '"> ' . esc_html__( 'Return to the Dashboard', 'elementor-templater' ) . '</a>';
2627
+ echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
2628
+ }
2629
+
2630
+ /**
2631
+ * Output all the column information within the table.
2632
+ *
2633
+ * @since 2.2.0
2634
+ *
2635
+ * @return array $columns The column names.
2636
+ */
2637
+ public function get_columns() {
2638
+ $columns = array(
2639
+ 'cb' => '<input type="checkbox" />',
2640
+ 'plugin' => __( 'Plugin', 'elementor-templater' ),
2641
+ 'source' => __( 'Source', 'elementor-templater' ),
2642
+ 'type' => __( 'Type', 'elementor-templater' ),
2643
+ );
2644
+
2645
+ if ( 'all' === $this->view_context || 'update' === $this->view_context ) {
2646
+ $columns['version'] = __( 'Version', 'elementor-templater' );
2647
+ $columns['status'] = __( 'Status', 'elementor-templater' );
2648
+ }
2649
+
2650
+ return apply_filters( 'tgmpa_table_columns', $columns );
2651
+ }
2652
+
2653
+ /**
2654
+ * Get name of default primary column
2655
+ *
2656
+ * @since 2.5.0 / WP 4.3+ compatibility
2657
+ * @access protected
2658
+ *
2659
+ * @return string
2660
+ */
2661
+ protected function get_default_primary_column_name() {
2662
+ return 'plugin';
2663
+ }
2664
+
2665
+ /**
2666
+ * Get the name of the primary column.
2667
+ *
2668
+ * @since 2.5.0 / WP 4.3+ compatibility
2669
+ * @access protected
2670
+ *
2671
+ * @return string The name of the primary column.
2672
+ */
2673
+ protected function get_primary_column_name() {
2674
+ if ( method_exists( 'WP_List_Table', 'get_primary_column_name' ) ) {
2675
+ return parent::get_primary_column_name();
2676
+ } else {
2677
+ return $this->get_default_primary_column_name();
2678
+ }
2679
+ }
2680
+
2681
+ /**
2682
+ * Get the actions which are relevant for a specific plugin row.
2683
+ *
2684
+ * @since 2.5.0
2685
+ *
2686
+ * @param array $item Array of item data.
2687
+ * @return array Array with relevant action links.
2688
+ */
2689
+ protected function get_row_actions( $item ) {
2690
+ $actions = array();
2691
+ $action_links = array();
2692
+
2693
+ // Display the 'Install' action link if the plugin is not yet available.
2694
+ if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) {
2695
+ /* translators: %2$s: plugin name in screen reader markup */
2696
+ $actions['install'] = __( 'Install %2$s', 'elementor-templater' );
2697
+ } else {
2698
+ // Display the 'Update' action link if an update is available and WP complies with plugin minimum.
2699
+ if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) {
2700
+ /* translators: %2$s: plugin name in screen reader markup */
2701
+ $actions['update'] = __( 'Update %2$s', 'elementor-templater' );
2702
+ }
2703
+
2704
+ // Display the 'Activate' action link, but only if the plugin meets the minimum version.
2705
+ if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) {
2706
+ /* translators: %2$s: plugin name in screen reader markup */
2707
+ $actions['activate'] = __( 'Activate %2$s', 'elementor-templater' );
2708
+ }
2709
+ }
2710
+
2711
+ // Create the actual links.
2712
+ foreach ( $actions as $action => $text ) {
2713
+ $nonce_url = wp_nonce_url(
2714
+ add_query_arg(
2715
+ array(
2716
+ 'plugin' => urlencode( $item['slug'] ),
2717
+ 'tgmpa-' . $action => $action . '-plugin',
2718
+ ),
2719
+ $this->tgmpa->get_tgmpa_url()
2720
+ ),
2721
+ 'tgmpa-' . $action,
2722
+ 'tgmpa-nonce'
2723
+ );
2724
+
2725
+ $action_links[ $action ] = sprintf(
2726
+ '<a href="%1$s">' . esc_html( $text ) . '</a>', // $text contains the second placeholder.
2727
+ esc_url( $nonce_url ),
2728
+ '<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>'
2729
+ );
2730
+ }
2731
+
2732
+ $prefix = ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) ? 'network_admin_' : '';
2733
+ return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item['slug'], $item, $this->view_context );
2734
+ }
2735
+
2736
+ /**
2737
+ * Generates content for a single row of the table.
2738
+ *
2739
+ * @since 2.5.0
2740
+ *
2741
+ * @param object $item The current item.
2742
+ */
2743
+ public function single_row( $item ) {
2744
+ parent::single_row( $item );
2745
+
2746
+ /**
2747
+ * Fires after each specific row in the TGMPA Plugins list table.
2748
+ *
2749
+ * The dynamic portion of the hook name, `$item['slug']`, refers to the slug
2750
+ * for the plugin.
2751
+ *
2752
+ * @since 2.5.0
2753
+ */
2754
+ do_action( "tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context );
2755
+ }
2756
+
2757
+ /**
2758
+ * Show the upgrade notice below a plugin row if there is one.
2759
+ *
2760
+ * @since 2.5.0
2761
+ *
2762
+ * @see /wp-admin/includes/update.php
2763
+ *
2764
+ * @param string $slug Plugin slug.
2765
+ * @param array $item The information available in this table row.
2766
+ * @return null Return early if upgrade notice is empty.
2767
+ */
2768
+ public function wp_plugin_update_row( $slug, $item ) {
2769
+ if ( empty( $item['upgrade_notice'] ) ) {
2770
+ return;
2771
+ }
2772
+
2773
+ echo '
2774
+ <tr class="plugin-update-tr">
2775
+ <td colspan="', absint( $this->get_column_count() ), '" class="plugin-update colspanchange">
2776
+ <div class="update-message">',
2777
+ esc_html__( 'Upgrade message from the plugin author:', 'elementor-templater' ),
2778
+ ' <strong>', wp_kses_data( $item['upgrade_notice'] ), '</strong>
2779
+ </div>
2780
+ </td>
2781
+ </tr>';
2782
+ }
2783
+
2784
+ /**
2785
+ * Extra controls to be displayed between bulk actions and pagination.
2786
+ *
2787
+ * @since 2.5.0
2788
+ *
2789
+ * @param string $which 'top' or 'bottom' table navigation.
2790
+ */
2791
+ public function extra_tablenav( $which ) {
2792
+ if ( 'bottom' === $which ) {
2793
+ $this->tgmpa->show_tgmpa_version();
2794
+ }
2795
+ }
2796
+
2797
+ /**
2798
+ * Defines the bulk actions for handling registered plugins.
2799
+ *
2800
+ * @since 2.2.0
2801
+ *
2802
+ * @return array $actions The bulk actions for the plugin install table.
2803
+ */
2804
+ public function get_bulk_actions() {
2805
+
2806
+ $actions = array();
2807
+
2808
+ if ( 'update' !== $this->view_context && 'activate' !== $this->view_context ) {
2809
+ if ( current_user_can( 'install_plugins' ) ) {
2810
+ $actions['tgmpa-bulk-install'] = __( 'Install', 'elementor-templater' );
2811
+ }
2812
+ }
2813
+
2814
+ if ( 'install' !== $this->view_context ) {
2815
+ if ( current_user_can( 'update_plugins' ) ) {
2816
+ $actions['tgmpa-bulk-update'] = __( 'Update', 'elementor-templater' );
2817
+ }
2818
+ if ( current_user_can( 'activate_plugins' ) ) {
2819
+ $actions['tgmpa-bulk-activate'] = __( 'Activate', 'elementor-templater' );
2820
+ }
2821
+ }
2822
+
2823
+ return $actions;
2824
+ }
2825
+
2826
+ /**
2827
+ * Processes bulk installation and activation actions.
2828
+ *
2829
+ * The bulk installation process looks for the $_POST information and passes that
2830
+ * through if a user has to use WP_Filesystem to enter their credentials.
2831
+ *
2832
+ * @since 2.2.0
2833
+ */
2834
+ public function process_bulk_actions() {
2835
+ // Bulk installation process.
2836
+ if ( 'tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action() ) {
2837
+
2838
+ check_admin_referer( 'bulk-' . $this->_args['plural'] );
2839
+
2840
+ $install_type = 'install';
2841
+ if ( 'tgmpa-bulk-update' === $this->current_action() ) {
2842
+ $install_type = 'update';
2843
+ }
2844
+
2845
+ $plugins_to_install = array();
2846
+
2847
+ // Did user actually select any plugins to install/update ?
2848
+ if ( empty( $_POST['plugin'] ) ) {
2849
+ if ( 'install' === $install_type ) {
2850
+ $message = __( 'No plugins were selected to be installed. No action taken.', 'elementor-templater' );
2851
+ } else {
2852
+ $message = __( 'No plugins were selected to be updated. No action taken.', 'elementor-templater' );
2853
+ }
2854
+
2855
+ echo '<div id="message" class="error"><p>', esc_html( $message ), '</p></div>';
2856
+
2857
+ return false;
2858
+ }
2859
+
2860
+ if ( is_array( $_POST['plugin'] ) ) {
2861
+ $plugins_to_install = (array) $_POST['plugin'];
2862
+ } elseif ( is_string( $_POST['plugin'] ) ) {
2863
+ // Received via Filesystem page - un-flatten array (WP bug #19643).
2864
+ $plugins_to_install = explode( ',', $_POST['plugin'] );
2865
+ }
2866
+
2867
+ // Sanitize the received input.
2868
+ $plugins_to_install = array_map( 'urldecode', $plugins_to_install );
2869
+ $plugins_to_install = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins_to_install );
2870
+
2871
+ // Validate the received input.
2872
+ foreach ( $plugins_to_install as $key => $slug ) {
2873
+ // Check if the plugin was registered with TGMPA and remove if not.
2874
+ if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) {
2875
+ unset( $plugins_to_install[ $key ] );
2876
+ continue;
2877
+ }
2878
+
2879
+ // For install: make sure this is a plugin we *can* install and not one already installed.
2880
+ if ( 'install' === $install_type && true === $this->tgmpa->is_plugin_installed( $slug ) ) {
2881
+ unset( $plugins_to_install[ $key ] );
2882
+ }
2883
+
2884
+ // For updates: make sure this is a plugin we *can* update (update available and WP version ok).
2885
+ if ( 'update' === $install_type && false === $this->tgmpa->is_plugin_updatetable( $slug ) ) {
2886
+ unset( $plugins_to_install[ $key ] );
2887
+ }
2888
+ }
2889
+
2890
+ // No need to proceed further if we have no plugins to handle.
2891
+ if ( empty( $plugins_to_install ) ) {
2892
+ if ( 'install' === $install_type ) {
2893
+ $message = __( 'No plugins are available to be installed at this time.', 'elementor-templater' );
2894
+ } else {
2895
+ $message = __( 'No plugins are available to be updated at this time.', 'elementor-templater' );
2896
+ }
2897
+
2898
+ echo '<div id="message" class="error"><p>', esc_html( $message ), '</p></div>';
2899
+
2900
+ return false;
2901
+ }
2902
+
2903
+ // Pass all necessary information if WP_Filesystem is needed.
2904
+ $url = wp_nonce_url(
2905
+ $this->tgmpa->get_tgmpa_url(),
2906
+ 'bulk-' . $this->_args['plural']
2907
+ );
2908
+
2909
+ // Give validated data back to $_POST which is the only place the filesystem looks for extra fields.
2910
+ $_POST['plugin'] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643.
2911
+
2912
+ $method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
2913
+ $fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem.
2914
+
2915
+ if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, $fields ) ) ) {
2916
+ return true; // Stop the normal page form from displaying, credential request form will be shown.
2917
+ }
2918
+
2919
+ // Now we have some credentials, setup WP_Filesystem.
2920
+ if ( ! WP_Filesystem( $creds ) ) {
2921
+ // Our credentials were no good, ask the user for them again.
2922
+ request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, $fields );
2923
+
2924
+ return true;
2925
+ }
2926
+
2927
+ /* If we arrive here, we have the filesystem */
2928
+
2929
+ // Store all information in arrays since we are processing a bulk installation.
2930
+ $names = array();
2931
+ $sources = array(); // Needed for installs.
2932
+ $file_paths = array(); // Needed for upgrades.
2933
+ $to_inject = array(); // Information to inject into the update_plugins transient.
2934
+
2935
+ // Prepare the data for validated plugins for the install/upgrade.
2936
+ foreach ( $plugins_to_install as $slug ) {
2937
+ $name = $this->tgmpa->plugins[ $slug ]['name'];
2938
+ $source = $this->tgmpa->get_download_url( $slug );
2939
+
2940
+ if ( ! empty( $name ) && ! empty( $source ) ) {
2941
+ $names[] = $name;
2942
+
2943
+ switch ( $install_type ) {
2944
+
2945
+ case 'install':
2946
+ $sources[] = $source;
2947
+ break;
2948
+
2949
+ case 'update':
2950
+ $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path'];
2951
+ $to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ];
2952
+ $to_inject[ $slug ]['source'] = $source;
2953
+ break;
2954
+ }
2955
+ }
2956
+ }
2957
+ unset( $slug, $name, $source );
2958
+
2959
+ // Create a new instance of TGMPA_Bulk_Installer.
2960
+ $installer = new TGMPA_Bulk_Installer(
2961
+ new TGMPA_Bulk_Installer_Skin(
2962
+ array(
2963
+ 'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ),
2964
+ 'nonce' => 'bulk-' . $this->_args['plural'],
2965
+ 'names' => $names,
2966
+ 'install_type' => $install_type,
2967
+ )
2968
+ )
2969
+ );
2970
+
2971
+ // Wrap the install process with the appropriate HTML.
2972
+ echo '<div class="tgmpa">',
2973
+ '<h2 style="font-size: 23px; font-weight: 400; line-height: 29px; margin: 0; padding: 9px 15px 4px 0;">', esc_html( get_admin_page_title() ), '</h2>
2974
+ <div class="update-php" style="width: 100%; height: 98%; min-height: 850px; padding-top: 1px;">';
2975
+
2976
+ // Process the bulk installation submissions.
2977
+ add_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 );
2978
+
2979
+ if ( 'tgmpa-bulk-update' === $this->current_action() ) {
2980
+ // Inject our info into the update transient.
2981
+ $this->tgmpa->inject_update_info( $to_inject );
2982
+
2983
+ $installer->bulk_upgrade( $file_paths );
2984
+ } else {
2985
+ $installer->bulk_install( $sources );
2986
+ }
2987
+
2988
+ remove_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1 );
2989
+
2990
+ echo '</div></div>';
2991
+
2992
+ return true;
2993
+ }
2994
+
2995
+ // Bulk activation process.
2996
+ if ( 'tgmpa-bulk-activate' === $this->current_action() ) {
2997
+ check_admin_referer( 'bulk-' . $this->_args['plural'] );
2998
+
2999
+ // Did user actually select any plugins to activate ?
3000
+ if ( empty( $_POST['plugin'] ) ) {
3001
+ echo '<div id="message" class="error"><p>', esc_html__( 'No plugins were selected to be activated. No action taken.', 'elementor-templater' ), '</p></div>';
3002
+
3003
+ return false;
3004
+ }
3005
+
3006
+ // Grab plugin data from $_POST.
3007
+ $plugins = array();
3008
+ if ( isset( $_POST['plugin'] ) ) {
3009
+ $plugins = array_map( 'urldecode', (array) $_POST['plugin'] );
3010
+ $plugins = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins );
3011
+ }
3012
+
3013
+ $plugins_to_activate = array();
3014
+ $plugin_names = array();
3015
+
3016
+ // Grab the file paths for the selected & inactive plugins from the registration array.
3017
+ foreach ( $plugins as $slug ) {
3018
+ if ( $this->tgmpa->can_plugin_activate( $slug ) ) {
3019
+ $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path'];
3020
+ $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name'];
3021
+ }
3022
+ }
3023
+ unset( $slug );
3024
+
3025
+ // Return early if there are no plugins to activate.
3026
+ if ( empty( $plugins_to_activate ) ) {
3027
+ echo '<div id="message" class="error"><p>', esc_html__( 'No plugins are available to be activated at this time.', 'elementor-templater' ), '</p></div>';
3028
+
3029
+ return false;
3030
+ }
3031
+
3032
+ // Now we are good to go - let's start activating plugins.
3033
+ $activate = activate_plugins( $plugins_to_activate );
3034
+
3035
+ if ( is_wp_error( $activate ) ) {
3036
+ echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>';
3037
+ } else {
3038
+ $count = count( $plugin_names ); // Count so we can use _n function.
3039
+ $plugin_names = array_map( array( 'TGMPA_Utils', 'wrap_in_strong' ), $plugin_names );
3040
+ $last_plugin = array_pop( $plugin_names ); // Pop off last name to prep for readability.
3041
+ $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'elementor-templater' ) . ' ' . $last_plugin );
3042
+
3043
+ printf( // WPCS: xss ok.
3044
+ '<div id="message" class="updated"><p>%1$s %2$s.</p></div>',
3045
+ esc_html( _n( 'The following plugin was activated successfully:', 'The following plugins were activated successfully:', $count, 'elementor-templater' ) ),
3046
+ $imploded
3047
+ );
3048
+
3049
+ // Update recently activated plugins option.
3050
+ $recent = (array) get_option( 'recently_activated' );
3051
+ foreach ( $plugins_to_activate as $plugin => $time ) {
3052
+ if ( isset( $recent[ $plugin ] ) ) {
3053
+ unset( $recent[ $plugin ] );
3054
+ }
3055
+ }
3056
+ update_option( 'recently_activated', $recent );
3057
+ }
3058
+
3059
+ unset( $_POST ); // Reset the $_POST variable in case user wants to perform one action after another.
3060
+
3061
+ return true;
3062
+ }
3063
+
3064
+ return false;
3065
+ }
3066
+
3067
+ /**
3068
+ * Prepares all of our information to be outputted into a usable table.
3069
+ *
3070
+ * @since 2.2.0
3071
+ */
3072
+ public function prepare_items() {
3073
+ $columns = $this->get_columns(); // Get all necessary column information.
3074
+ $hidden = array(); // No columns to hide, but we must set as an array.
3075
+ $sortable = array(); // No reason to make sortable columns.
3076
+ $primary = $this->get_primary_column_name(); // Column which has the row actions.
3077
+ $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); // Get all necessary column headers.
3078
+
3079
+ // Process our bulk activations here.
3080
+ if ( 'tgmpa-bulk-activate' === $this->current_action() ) {
3081
+ $this->process_bulk_actions();
3082
+ }
3083
+
3084
+ // Store all of our plugin data into $items array so WP_List_Table can use it.
3085
+ $this->items = apply_filters( 'tgmpa_table_data_items', $this->_gather_plugin_data() );
3086
+ }
3087
+
3088
+ /* *********** DEPRECATED METHODS *********** */
3089
+
3090
+ /**
3091
+ * Retrieve plugin data, given the plugin name.
3092
+ *
3093
+ * @since 2.2.0
3094
+ * @deprecated 2.5.0 use {@see TGM_Plugin_Activation::_get_plugin_data_from_name()} instead.
3095
+ * @see TGM_Plugin_Activation::_get_plugin_data_from_name()
3096
+ *
3097
+ * @param string $name Name of the plugin, as it was registered.
3098
+ * @param string $data Optional. Array key of plugin data to return. Default is slug.
3099
+ * @return string|boolean Plugin slug if found, false otherwise.
3100
+ */
3101
+ protected function _get_plugin_data_from_name( $name, $data = 'slug' ) {
3102
+ _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'TGM_Plugin_Activation::_get_plugin_data_from_name()' );
3103
+
3104
+ return $this->tgmpa->_get_plugin_data_from_name( $name, $data );
3105
+ }
3106
+ }
3107
+ }
3108
+
3109
+
3110
+ if ( ! class_exists( 'TGM_Bulk_Installer' ) ) {
3111
+
3112
+ /**
3113
+ * Hack: Prevent TGMPA v2.4.1- bulk installer class from being loaded if 2.4.1- is loaded after 2.5+.
3114
+ *
3115
+ * @since 2.5.2
3116
+ *
3117
+ * {@internal The TGMPA_Bulk_Installer class was originally called TGM_Bulk_Installer.
3118
+ * For more information, see that class.}}
3119
+ */
3120
+ class TGM_Bulk_Installer {
3121
+ }
3122
+ }
3123
+ if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) {
3124
+
3125
+ /**
3126
+ * Hack: Prevent TGMPA v2.4.1- bulk installer skin class from being loaded if 2.4.1- is loaded after 2.5+.
3127
+ *
3128
+ * @since 2.5.2
3129
+ *
3130
+ * {@internal The TGMPA_Bulk_Installer_Skin class was originally called TGM_Bulk_Installer_Skin.
3131
+ * For more information, see that class.}}
3132
+ */
3133
+ class TGM_Bulk_Installer_Skin {
3134
+ }
3135
+ }
3136
+
3137
+ /**
3138
+ * The WP_Upgrader file isn't always available. If it isn't available,
3139
+ * we load it here.
3140
+ *
3141
+ * We check to make sure no action or activation keys are set so that WordPress
3142
+ * does not try to re-include the class when processing upgrades or installs outside
3143
+ * of the class.
3144
+ *
3145
+ * @since 2.2.0
3146
+ */
3147
+ add_action( 'admin_init', 'tgmpa_load_bulk_installer' );
3148
+ if ( ! function_exists( 'tgmpa_load_bulk_installer' ) ) {
3149
+ /**
3150
+ * Load bulk installer
3151
+ */
3152
+ function tgmpa_load_bulk_installer() {
3153
+ // Silently fail if 2.5+ is loaded *after* an older version.
3154
+ if ( ! isset( $GLOBALS['tgmpa'] ) ) {
3155
+ return;
3156
+ }
3157
+
3158
+ // Get TGMPA class instance.
3159
+ $tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
3160
+
3161
+ if ( isset( $_GET['page'] ) && $tgmpa_instance->menu === $_GET['page'] ) {
3162
+ if ( ! class_exists( 'Plugin_Upgrader', false ) ) {
3163
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
3164
+ }
3165
+
3166
+ if ( ! class_exists( 'TGMPA_Bulk_Installer' ) ) {
3167
+
3168
+ /**
3169
+ * Installer class to handle bulk plugin installations.
3170
+ *
3171
+ * Extends WP_Upgrader and customizes to suit the installation of multiple
3172
+ * plugins.
3173
+ *
3174
+ * @since 2.2.0
3175
+ *
3176
+ * {@internal Since 2.5.0 the class is an extension of Plugin_Upgrader rather than WP_Upgrader.}}
3177
+ * {@internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer to TGMPA_Bulk_Installer.
3178
+ * This was done to prevent backward compatibility issues with v2.3.6.}}
3179
+ *
3180
+ * @package TGM-Plugin-Activation
3181
+ * @author Thomas Griffin
3182
+ * @author Gary Jones
3183
+ */
3184
+ class TGMPA_Bulk_Installer extends Plugin_Upgrader {
3185
+ /**
3186
+ * Holds result of bulk plugin installation.
3187
+ *
3188
+ * @since 2.2.0
3189
+ *
3190
+ * @var string
3191
+ */
3192
+ public $result;
3193
+
3194
+ /**
3195
+ * Flag to check if bulk installation is occurring or not.
3196
+ *
3197
+ * @since 2.2.0
3198
+ *
3199
+ * @var boolean
3200
+ */
3201
+ public $bulk = false;
3202
+
3203
+ /**
3204
+ * TGMPA instance
3205
+ *
3206
+ * @since 2.5.0
3207
+ *
3208
+ * @var object
3209
+ */
3210
+ protected $tgmpa;
3211
+
3212
+ /**
3213
+ * Whether or not the destination directory needs to be cleared ( = on update).
3214
+ *
3215
+ * @since 2.5.0
3216
+ *
3217
+ * @var bool
3218
+ */
3219
+ protected $clear_destination = false;
3220
+
3221
+ /**
3222
+ * References parent constructor and sets defaults for class.
3223
+ *
3224
+ * @since 2.2.0
3225
+ *
3226
+ * @param \Bulk_Upgrader_Skin|null $skin Installer skin.
3227
+ */
3228
+ public function __construct( $skin = null ) {
3229
+ // Get TGMPA class instance.
3230
+ $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
3231
+
3232
+ parent::__construct( $skin );
3233
+
3234
+ if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) {
3235
+ $this->clear_destination = true;
3236
+ }
3237
+
3238
+ if ( $this->tgmpa->is_automatic ) {
3239
+ $this->activate_strings();
3240
+ }
3241
+
3242
+ add_action( 'upgrader_process_complete', array( $this->tgmpa, 'populate_file_path' ) );
3243
+ }
3244
+
3245
+ /**
3246
+ * Sets the correct activation strings for the installer skin to use.
3247
+ *
3248
+ * @since 2.2.0
3249
+ */
3250
+ public function activate_strings() {
3251
+ $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'elementor-templater' );
3252
+ $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'elementor-templater' );
3253
+ }
3254
+
3255
+ /**
3256
+ * Performs the actual installation of each plugin.
3257
+ *
3258
+ * @since 2.2.0
3259
+ *
3260
+ * @see WP_Upgrader::run()
3261
+ *
3262
+ * @param array $options The installation config options.
3263
+ * @return null|array Return early if error, array of installation data on success.
3264
+ */
3265
+ public function run( $options ) {
3266
+ $result = parent::run( $options );
3267
+
3268
+ // Reset the strings in case we changed one during automatic activation.
3269
+ if ( $this->tgmpa->is_automatic ) {
3270
+ if ( 'update' === $this->skin->options['install_type'] ) {
3271
+ $this->upgrade_strings();
3272
+ } else {
3273
+ $this->install_strings();
3274
+ }
3275
+ }
3276
+
3277
+ return $result;
3278
+ }
3279
+
3280
+ /**
3281
+ * Processes the bulk installation of plugins.
3282
+ *
3283
+ * @since 2.2.0
3284
+ *
3285
+ * {@internal This is basically a near identical copy of the WP Core
3286
+ * Plugin_Upgrader::bulk_upgrade() method, with minor adjustments to deal with
3287
+ * new installs instead of upgrades.
3288
+ * For ease of future synchronizations, the adjustments are clearly commented, but no other
3289
+ * comments are added. Code style has been made to comply.}}
3290
+ *
3291
+ * @see Plugin_Upgrader::bulk_upgrade()
3292
+ * @see https://core.trac.wordpress.org/browser/tags/4.2.1/src/wp-admin/includes/class-wp-upgrader.php#L838
3293
+ * (@internal Last synced: Dec 31st 2015 against https://core.trac.wordpress.org/browser/trunk?rev=36134}}
3294
+ *
3295
+ * @param array $plugins The plugin sources needed for installation.
3296
+ * @param array $args Arbitrary passed extra arguments.
3297
+ * @return array|false Install confirmation messages on success, false on failure.
3298
+ */
3299
+ public function bulk_install( $plugins, $args = array() ) {
3300
+ // [TGMPA + ] Hook auto-activation in.
3301
+ add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
3302
+
3303
+ $defaults = array(
3304
+ 'clear_update_cache' => true,
3305
+ );
3306
+ $parsed_args = wp_parse_args( $args, $defaults );
3307
+
3308
+ $this->init();
3309
+ $this->bulk = true;
3310
+
3311
+ $this->install_strings(); // [TGMPA + ] adjusted.
3312
+
3313
+ /* [TGMPA - ] $current = get_site_transient( 'update_plugins' ); */
3314
+
3315
+ /* [TGMPA - ] add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); */
3316
+
3317
+ $this->skin->header();
3318
+
3319
+ // Connect to the Filesystem first.
3320
+ $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
3321
+ if ( ! $res ) {
3322
+ $this->skin->footer();
3323
+ return false;
3324
+ }
3325
+
3326
+ $this->skin->bulk_header();
3327
+
3328
+ /*
3329
+ * Only start maintenance mode if:
3330
+ * - running Multisite and there are one or more plugins specified, OR
3331
+ * - a plugin with an update available is currently active.
3332
+ * @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible.
3333
+ */
3334
+ $maintenance = ( is_multisite() && ! empty( $plugins ) );
3335
+
3336
+ /*
3337
+ [TGMPA - ]
3338
+ foreach ( $plugins as $plugin )
3339
+ $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) );
3340
+ */
3341
+ if ( $maintenance ) {
3342
+ $this->maintenance_mode( true );
3343
+ }
3344
+
3345
+ $results = array();
3346
+
3347
+ $this->update_count = count( $plugins );
3348
+ $this->update_current = 0;
3349
+ foreach ( $plugins as $plugin ) {
3350
+ $this->update_current++;
3351
+
3352
+ /*
3353
+ [TGMPA - ]
3354
+ $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true);
3355
+
3356
+ if ( !isset( $current->response[ $plugin ] ) ) {
3357
+ $this->skin->set_result('up_to_date');
3358
+ $this->skin->before();
3359
+ $this->skin->feedback('up_to_date');
3360
+ $this->skin->after();
3361
+ $results[$plugin] = true;
3362
+ continue;
3363
+ }
3364
+
3365
+ // Get the URL to the zip file.
3366
+ $r = $current->response[ $plugin ];
3367
+
3368
+ $this->skin->plugin_active = is_plugin_active($plugin);
3369
+ */
3370
+
3371
+ $result = $this->run(
3372
+ array(
3373
+ 'package' => $plugin, // [TGMPA + ] adjusted.
3374
+ 'destination' => WP_PLUGIN_DIR,
3375
+ 'clear_destination' => false, // [TGMPA + ] adjusted.
3376
+ 'clear_working' => true,
3377
+ 'is_multi' => true,
3378
+ 'hook_extra' => array(
3379
+ 'plugin' => $plugin,
3380
+ ),
3381
+ )
3382
+ );
3383
+
3384
+ $results[ $plugin ] = $this->result;
3385
+
3386
+ // Prevent credentials auth screen from displaying multiple times.
3387
+ if ( false === $result ) {
3388
+ break;
3389
+ }
3390
+ } //end foreach $plugins
3391
+
3392
+ $this->maintenance_mode( false );
3393
+
3394
+ /**
3395
+ * Fires when the bulk upgrader process is complete.
3396
+ *
3397
+ * @since WP 3.6.0 / TGMPA 2.5.0
3398
+ *
3399
+ * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might
3400
+ * be a Theme_Upgrader or Core_Upgrade instance.
3401
+ * @param array $data {
3402
+ * Array of bulk item update data.
3403
+ *
3404
+ * @type string $action Type of action. Default 'update'.
3405
+ * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'.
3406
+ * @type bool $bulk Whether the update process is a bulk update. Default true.
3407
+ * @type array $packages Array of plugin, theme, or core packages to update.
3408
+ * }
3409
+ */
3410
+ do_action(
3411
+ 'upgrader_process_complete', $this, array(
3412
+ 'action' => 'install', // [TGMPA + ] adjusted.
3413
+ 'type' => 'plugin',
3414
+ 'bulk' => true,
3415
+ 'plugins' => $plugins,
3416
+ )
3417
+ );
3418
+
3419
+ $this->skin->bulk_footer();
3420
+
3421
+ $this->skin->footer();
3422
+
3423
+ // Cleanup our hooks, in case something else does a upgrade on this connection.
3424
+ /* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); */
3425
+
3426
+ // [TGMPA + ] Remove our auto-activation hook.
3427
+ remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
3428
+
3429
+ // Force refresh of plugin update information.
3430
+ wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
3431
+
3432
+ return $results;
3433
+ }
3434
+
3435
+ /**
3436
+ * Handle a bulk upgrade request.
3437
+ *
3438
+ * @since 2.5.0
3439
+ *
3440
+ * @see Plugin_Upgrader::bulk_upgrade()
3441
+ *
3442
+ * @param array $plugins The local WP file_path's of the plugins which should be upgraded.
3443
+ * @param array $args Arbitrary passed extra arguments.
3444
+ * @return string|bool Install confirmation messages on success, false on failure.
3445
+ */
3446
+ public function bulk_upgrade( $plugins, $args = array() ) {
3447
+
3448
+ add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
3449
+
3450
+ $result = parent::bulk_upgrade( $plugins, $args );
3451
+
3452
+ remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
3453
+
3454
+ return $result;
3455
+ }
3456
+
3457
+ /**
3458
+ * Abuse a filter to auto-activate plugins after installation.
3459
+ *
3460
+ * Hooked into the 'upgrader_post_install' filter hook.
3461
+ *
3462
+ * @since 2.5.0
3463
+ *
3464
+ * @param bool $bool The value we need to give back (true).
3465
+ * @return bool
3466
+ */
3467
+ public function auto_activate( $bool ) {
3468
+ // Only process the activation of installed plugins if the automatic flag is set to true.
3469
+ if ( $this->tgmpa->is_automatic ) {
3470
+ // Flush plugins cache so the headers of the newly installed plugins will be read correctly.
3471
+ wp_clean_plugins_cache();
3472
+
3473
+ // Get the installed plugin file.
3474
+ $plugin_info = $this->plugin_info();
3475
+
3476
+ // Don't try to activate on upgrade of active plugin as WP will do this already.
3477
+ if ( ! is_plugin_active( $plugin_info ) ) {
3478
+ $activate = activate_plugin( $plugin_info );
3479
+
3480
+ // Adjust the success string based on the activation result.
3481
+ $this->strings['process_success'] = $this->strings['process_success'] . "<br />\n";
3482
+
3483
+ if ( is_wp_error( $activate ) ) {
3484
+ $this->skin->error( $activate );
3485
+ $this->strings['process_success'] .= $this->strings['activation_failed'];
3486
+ } else {
3487
+ $this->strings['process_success'] .= $this->strings['activation_success'];
3488
+ }
3489
+ }
3490
+ }
3491
+
3492
+ return $bool;
3493
+ }
3494
+ }
3495
+ }
3496
+
3497
+ if ( ! class_exists( 'TGMPA_Bulk_Installer_Skin' ) ) {
3498
+
3499
+ /**
3500
+ * Installer skin to set strings for the bulk plugin installations..
3501
+ *
3502
+ * Extends Bulk_Upgrader_Skin and customizes to suit the installation of multiple
3503
+ * plugins.
3504
+ *
3505
+ * @since 2.2.0
3506
+ *
3507
+ * {@internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer_Skin to
3508
+ * TGMPA_Bulk_Installer_Skin.
3509
+ * This was done to prevent backward compatibility issues with v2.3.6.}}
3510
+ *
3511
+ * @see https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-upgrader-skins.php
3512
+ *
3513
+ * @package TGM-Plugin-Activation
3514
+ * @author Thomas Griffin
3515
+ * @author Gary Jones
3516
+ */
3517
+ class TGMPA_Bulk_Installer_Skin extends Bulk_Upgrader_Skin {
3518
+ /**
3519
+ * Holds plugin info for each individual plugin installation.
3520
+ *
3521
+ * @since 2.2.0
3522
+ *
3523
+ * @var array
3524
+ */
3525
+ public $plugin_info = array();
3526
+
3527
+ /**
3528
+ * Holds names of plugins that are undergoing bulk installations.
3529
+ *
3530
+ * @since 2.2.0
3531
+ *
3532
+ * @var array
3533
+ */
3534
+ public $plugin_names = array();
3535
+
3536
+ /**
3537
+ * Integer to use for iteration through each plugin installation.
3538
+ *
3539
+ * @since 2.2.0
3540
+ *
3541
+ * @var integer
3542
+ */
3543
+ public $i = 0;
3544
+
3545
+ /**
3546
+ * TGMPA instance
3547
+ *
3548
+ * @since 2.5.0
3549
+ *
3550
+ * @var object
3551
+ */
3552
+ protected $tgmpa;
3553
+
3554
+ /**
3555
+ * Constructor. Parses default args with new ones and extracts them for use.
3556
+ *
3557
+ * @since 2.2.0
3558
+ *
3559
+ * @param array $args Arguments to pass for use within the class.
3560
+ */
3561
+ public function __construct( $args = array() ) {
3562
+ // Get TGMPA class instance.
3563
+ $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
3564
+
3565
+ // Parse default and new args.
3566
+ $defaults = array(
3567
+ 'url' => '',
3568
+ 'nonce' => '',
3569
+ 'names' => array(),
3570
+ 'install_type' => 'install',
3571
+ );
3572
+ $args = wp_parse_args( $args, $defaults );
3573
+
3574
+ // Set plugin names to $this->plugin_names property.
3575
+ $this->plugin_names = $args['names'];
3576
+
3577
+ // Extract the new args.
3578
+ parent::__construct( $args );
3579
+ }
3580
+
3581
+ /**
3582
+ * Sets install skin strings for each individual plugin.
3583
+ *
3584
+ * Checks to see if the automatic activation flag is set and uses the
3585
+ * the proper strings accordingly.
3586
+ *
3587
+ * @since 2.2.0
3588
+ */
3589
+ public function add_strings() {
3590
+ if ( 'update' === $this->options['install_type'] ) {
3591
+ parent::add_strings();
3592
+ /* translators: 1: plugin name, 2: action number 3: total number of actions. */
3593
+ $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'elementor-templater' );
3594
+ } else {
3595
+ /* translators: 1: plugin name, 2: error message. */
3596
+ $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'elementor-templater' );
3597
+ /* translators: 1: plugin name. */
3598
+ $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'elementor-templater' );
3599
+
3600
+ if ( $this->tgmpa->is_automatic ) {
3601
+ // Automatic activation strings.
3602
+ $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'elementor-templater' );
3603
+ /* translators: 1: plugin name. */
3604
+ $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'elementor-templater' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'elementor-templater' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'elementor-templater' ) . '</span>.</a>';
3605
+ $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'elementor-templater' );
3606
+ /* translators: 1: plugin name, 2: action number 3: total number of actions. */
3607
+ $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'elementor-templater' );
3608
+ } else {
3609
+ // Default installation strings.
3610
+ $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'elementor-templater' );
3611
+ /* translators: 1: plugin name. */
3612
+ $this->upgrader->strings['skin_update_successful'] = esc_html__( '%1$s installed successfully.', 'elementor-templater' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'elementor-templater' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'elementor-templater' ) . '</span>.</a>';
3613
+ $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'elementor-templater' );
3614
+ /* translators: 1: plugin name, 2: action number 3: total number of actions. */
3615
+ $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'elementor-templater' );
3616
+ }
3617
+ }
3618
+ }
3619
+
3620
+ /**
3621
+ * Outputs the header strings and necessary JS before each plugin installation.
3622
+ *
3623
+ * @since 2.2.0
3624
+ *
3625
+ * @param string $title Unused in this implementation.
3626
+ */
3627
+ public function before( $title = '' ) {
3628
+ if ( empty( $title ) ) {
3629
+ $title = esc_html( $this->plugin_names[ $this->i ] );
3630
+ }
3631
+ parent::before( $title );
3632
+ }
3633
+
3634
+ /**
3635
+ * Outputs the footer strings and necessary JS after each plugin installation.
3636
+ *
3637
+ * Checks for any errors and outputs them if they exist, else output
3638
+ * success strings.
3639
+ *
3640
+ * @since 2.2.0
3641
+ *
3642
+ * @param string $title Unused in this implementation.
3643
+ */
3644
+ public function after( $title = '' ) {
3645
+ if ( empty( $title ) ) {
3646
+ $title = esc_html( $this->plugin_names[ $this->i ] );
3647
+ }
3648
+ parent::after( $title );
3649
+
3650
+ $this->i++;
3651
+ }
3652
+
3653
+ /**
3654
+ * Outputs links after bulk plugin installation is complete.
3655
+ *
3656
+ * @since 2.2.0
3657
+ */
3658
+ public function bulk_footer() {
3659
+ // Serve up the string to say installations (and possibly activations) are complete.
3660
+ parent::bulk_footer();
3661
+
3662
+ // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
3663
+ wp_clean_plugins_cache();
3664
+
3665
+ $this->tgmpa->show_tgmpa_version();
3666
+
3667
+ // Display message based on if all plugins are now active or not.
3668
+ $update_actions = array();
3669
+
3670
+ if ( $this->tgmpa->is_tgmpa_complete() ) {
3671
+ // All plugins are active, so we display the complete string and hide the menu to protect users.
3672
+ echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
3673
+ $update_actions['dashboard'] = sprintf(
3674
+ esc_html( $this->tgmpa->strings['complete'] ),
3675
+ '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'elementor-templater' ) . '</a>'
3676
+ );
3677
+ } else {
3678
+ $update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>';
3679
+ }
3680
+
3681
+ /**
3682
+ * Filter the list of action links available following bulk plugin installs/updates.
3683
+ *
3684
+ * @since 2.5.0
3685
+ *
3686
+ * @param array $update_actions Array of plugin action links.
3687
+ * @param array $plugin_info Array of information for the last-handled plugin.
3688
+ */
3689
+ $update_actions = apply_filters( 'tgmpa_update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
3690
+
3691
+ if ( ! empty( $update_actions ) ) {
3692
+ $this->feedback( implode( ' | ', (array) $update_actions ) );
3693
+ }
3694
+ }
3695
+
3696
+ /* *********** DEPRECATED METHODS *********** */
3697
+
3698
+ /**
3699
+ * Flush header output buffer.
3700
+ *
3701
+ * @since 2.2.0
3702
+ * @deprecated 2.5.0 use {@see Bulk_Upgrader_Skin::flush_output()} instead
3703
+ * @see Bulk_Upgrader_Skin::flush_output()
3704
+ */
3705
+ public function before_flush_output() {
3706
+ _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' );
3707
+ $this->flush_output();
3708
+ }
3709
+
3710
+ /**
3711
+ * Flush footer output buffer and iterate $this->i to make sure the
3712
+ * installation strings reference the correct plugin.
3713
+ *
3714
+ * @since 2.2.0
3715
+ * @deprecated 2.5.0 use {@see Bulk_Upgrader_Skin::flush_output()} instead
3716
+ * @see Bulk_Upgrader_Skin::flush_output()
3717
+ */
3718
+ public function after_flush_output() {
3719
+ _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' );
3720
+ $this->flush_output();
3721
+ $this->i++;
3722
+ }
3723
+ }
3724
+ }
3725
+ }
3726
+ }
3727
+ }
3728
+
3729
+ if ( ! class_exists( 'TGMPA_Utils' ) ) {
3730
+
3731
+ /**
3732
+ * Generic utilities for TGMPA.
3733
+ *
3734
+ * All methods are static, poor-dev name-spacing class wrapper.
3735
+ *
3736
+ * Class was called TGM_Utils in 2.5.0 but renamed TGMPA_Utils in 2.5.1 as this was conflicting with Soliloquy.
3737
+ *
3738
+ * @since 2.5.0
3739
+ *
3740
+ * @package TGM-Plugin-Activation
3741
+ * @author Juliette Reinders Folmer
3742
+ */
3743
+ class TGMPA_Utils {
3744
+ /**
3745
+ * Whether the PHP filter extension is enabled.
3746
+ *
3747
+ * @see http://php.net/book.filter
3748
+ *
3749
+ * @since 2.5.0
3750
+ *
3751
+ * @static
3752
+ *
3753
+ * @var bool $has_filters True is the extension is enabled.
3754
+ */
3755
+ public static $has_filters;
3756
+
3757
+ /**
3758
+ * Wrap an arbitrary string in <em> tags. Meant to be used in combination with array_map().
3759
+ *
3760
+ * @since 2.5.0
3761
+ *
3762
+ * @static
3763
+ *
3764
+ * @param string $string Text to be wrapped.
3765
+ * @return string
3766
+ */
3767
+ public static function wrap_in_em( $string ) {
3768
+ return '<em>' . wp_kses_post( $string ) . '</em>';
3769
+ }
3770
+
3771
+ /**
3772
+ * Wrap an arbitrary string in <strong> tags. Meant to be used in combination with array_map().
3773
+ *
3774
+ * @since 2.5.0
3775
+ *
3776
+ * @static
3777
+ *
3778
+ * @param string $string Text to be wrapped.
3779
+ * @return string
3780
+ */
3781
+ public static function wrap_in_strong( $string ) {
3782
+ return '<strong>' . wp_kses_post( $string ) . '</strong>';
3783
+ }
3784
+
3785
+ /**
3786
+ * Helper function: Validate a value as boolean
3787
+ *
3788
+ * @since 2.5.0
3789
+ *
3790
+ * @static
3791
+ *
3792
+ * @param mixed $value Arbitrary value.
3793
+ * @return bool
3794
+ */
3795
+ public static function validate_bool( $value ) {
3796
+ if ( ! isset( self::$has_filters ) ) {
3797
+ self::$has_filters = extension_loaded( 'filter' );
3798
+ }
3799
+
3800
+ if ( self::$has_filters ) {
3801
+ return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
3802
+ } else {
3803
+ return self::emulate_filter_bool( $value );
3804
+ }
3805
+ }
3806
+
3807
+ /**
3808
+ * Helper function: Cast a value to bool
3809
+ *
3810
+ * @since 2.5.0
3811
+ *
3812
+ * @static
3813
+ *
3814
+ * @param mixed $value Value to cast.
3815
+ * @return bool
3816
+ */
3817
+ protected static function emulate_filter_bool( $value ) {
3818
+ // @codingStandardsIgnoreStart
3819
+ static $true = array(
3820
+ '1',
3821
+ 'true', 'True', 'TRUE',
3822
+ 'y', 'Y',
3823
+ 'yes', 'Yes', 'YES',
3824
+ 'on', 'On', 'ON',
3825
+ );
3826
+ static $false = array(
3827
+ '0',
3828
+ 'false', 'False', 'FALSE',
3829
+ 'n', 'N',
3830
+ 'no', 'No', 'NO',
3831
+ 'off', 'Off', 'OFF',
3832
+ );
3833
+ // @codingStandardsIgnoreEnd
3834
+
3835
+ if ( is_bool( $value ) ) {
3836
+ return $value;
3837
+ } elseif ( is_int( $value ) && ( 0 === $value || 1 === $value ) ) {
3838
+ return (bool) $value;
3839
+ } elseif ( ( is_float( $value ) && ! is_nan( $value ) ) && ( (float) 0 === $value || (float) 1 === $value ) ) {
3840
+ return (bool) $value;
3841
+ } elseif ( is_string( $value ) ) {
3842
+ $value = trim( $value );
3843
+ if ( in_array( $value, $true, true ) ) {
3844
+ return true;
3845
+ } elseif ( in_array( $value, $false, true ) ) {
3846
+ return false;
3847
+ } else {
3848
+ return false;
3849
+ }
3850
+ }
3851
+
3852
+ return false;
3853
+ }
3854
+ } // End of class TGMPA_Utils
3855
+ } // End of class_exists wrapper
inc/custom-posttype-class.php CHANGED
@@ -45,8 +45,8 @@ class WP_CustomTemplates {
45
  function wptcp_post_template( $post ) {
46
  $this->post_ID = $post->ID;
47
 
48
- $template_vars = array();
49
- $templates = $this->wptcp_get_post_templates();
50
  $custom_template = $this->wptcp_get_custom_post_template();
51
 
52
  if ( $templates ) { ?>
@@ -79,9 +79,9 @@ class WP_CustomTemplates {
79
  }
80
 
81
  function wptcp_get_post_templates() {
82
- $theme = wp_get_theme();
83
  $post_templates = array();
84
- $files = (array) $theme->get_files( 'php', 1 );
85
  foreach ( $files as $file => $full_path ) {
86
  $headers = @get_file_data( $full_path, array( 'Post Template Name' => 'Post Template Name' ) );
87
  if ( empty( $headers['Post Template Name'] ) ) {
@@ -112,8 +112,8 @@ class WP_CustomTemplates {
112
  }
113
 
114
  $this->post_ID = $post_ID;
115
- $template = (string) @ $_POST['custom_post_template'];
116
- $template = stripslashes_deep( $template );
117
  $this->wptcp_set_custom_post_template( $template );
118
  }
119
 
@@ -154,7 +154,7 @@ class WP_CustomTemplates {
154
  }
155
 
156
  check_admin_referer( 'nonce_wptcp' );
157
- $input_options = array();
158
  $input_options['objects'] = isset( $_POST['objects'] ) ? $_POST['objects'] : '';
159
  update_option( 'wptcp_options', $input_options );
160
  wp_redirect( 'options-general.php?page=wptcp-settings&msg=update' );
45
  function wptcp_post_template( $post ) {
46
  $this->post_ID = $post->ID;
47
 
48
+ $template_vars = array();
49
+ $templates = $this->wptcp_get_post_templates();
50
  $custom_template = $this->wptcp_get_custom_post_template();
51
 
52
  if ( $templates ) { ?>
79
  }
80
 
81
  function wptcp_get_post_templates() {
82
+ $theme = wp_get_theme();
83
  $post_templates = array();
84
+ $files = (array) $theme->get_files( 'php', 1 );
85
  foreach ( $files as $file => $full_path ) {
86
  $headers = @get_file_data( $full_path, array( 'Post Template Name' => 'Post Template Name' ) );
87
  if ( empty( $headers['Post Template Name'] ) ) {
112
  }
113
 
114
  $this->post_ID = $post_ID;
115
+ $template = (string) @ $_POST['custom_post_template'];
116
+ $template = stripslashes_deep( $template );
117
  $this->wptcp_set_custom_post_template( $template );
118
  }
119
 
154
  }
155
 
156
  check_admin_referer( 'nonce_wptcp' );
157
+ $input_options = array();
158
  $input_options['objects'] = isset( $_POST['objects'] ) ? $_POST['objects'] : '';
159
  update_option( 'wptcp_options', $input_options );
160
  wp_redirect( 'options-general.php?page=wptcp-settings&msg=update' );
inc/elementemplater-functions.php CHANGED
@@ -84,7 +84,7 @@ if ( ! function_exists( 'elementor_page_content' ) ) {
84
  the_content();
85
  }
86
  }
87
- add_action( 'elementor_page_elements', 'elementor_page_content', 20 );
88
 
89
  $theme = get_option( 'template' );
90
  if ( 'GeneratePress' == $theme || 'generatepress' == $theme ) {
@@ -104,5 +104,5 @@ if ( 'GeneratePress' == $theme || 'generatepress' == $theme ) {
104
  endif;
105
  }
106
  }
107
- add_action( 'elementor_page_elements', 'elementor_generate_title', 10 );
108
  }
84
  the_content();
85
  }
86
  }
87
+ add_action( 'elementor_page_elements', 'elementor_page_content', 20 );
88
 
89
  $theme = get_option( 'template' );
90
  if ( 'GeneratePress' == $theme || 'generatepress' == $theme ) {
104
  endif;
105
  }
106
  }
107
+ add_action( 'elementor_page_elements', 'elementor_generate_title', 10 );
108
  }
inc/settings.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  $cpt_options = get_option( 'elcpt_options' );
3
- $cpt_pts = isset( $cpt_options['objects'] ) ? $cpt_options['objects'] : array();
4
  ?>
5
 
6
  <div class="wrap">
@@ -9,7 +9,7 @@ $cpt_pts = isset( $cpt_options['objects'] ) ? $cpt_options['objects'] : array();
9
  <?php if ( isset( $_GET['msg'] ) ) : ?>
10
  <div id="message" class="updated below-h2">
11
  <?php if ( $_GET['msg'] == 'update' ) : ?>
12
- <p><?php _e( 'Settings Updated.','elementor-templater' ); ?></p>
13
  <?php endif; ?>
14
  </div>
15
  <?php endif; ?>
@@ -33,7 +33,7 @@ $cpt_pts = isset( $cpt_options['objects'] ) ? $cpt_options['objects'] : array();
33
  <?php
34
  $post_types = get_post_types(
35
  array(
36
- 'public' => true,
37
  ), 'objects'
38
  );
39
 
1
  <?php
2
  $cpt_options = get_option( 'elcpt_options' );
3
+ $cpt_pts = isset( $cpt_options['objects'] ) ? $cpt_options['objects'] : array();
4
  ?>
5
 
6
  <div class="wrap">
9
  <?php if ( isset( $_GET['msg'] ) ) : ?>
10
  <div id="message" class="updated below-h2">
11
  <?php if ( $_GET['msg'] == 'update' ) : ?>
12
+ <p><?php _e( 'Settings Updated.', 'elementor-templater' ); ?></p>
13
  <?php endif; ?>
14
  </div>
15
  <?php endif; ?>
33
  <?php
34
  $post_types = get_post_types(
35
  array(
36
+ 'public' => true,
37
  ), 'objects'
38
  );
39
 
readme.md CHANGED
@@ -2,7 +2,7 @@
2
  **Contributors:** [themeisle](https://profiles.wordpress.org/themeisle), [codeinwp](https://profiles.wordpress.org/codeinwp)
3
  **Tags:** elementor, pagebuilder, page builder, page builder template, page builder templates, actions, storefront, twentysixteen, genesis, template builder, builder templates
4
  **Requires at least:** 4.4
5
- **Tested up to:** 4.7.3
6
  **License:** GPLv2 or later
7
  **License URI:** http://www.gnu.org/licenses/gpl-2.0.html
8
 
@@ -90,6 +90,11 @@ Further details will be available near the time of the release.
90
  2. Fullwidth no Header no Footer
91
 
92
  ## Changelog ##
 
 
 
 
 
93
  ### 1.2.0 - 2017-09-29 ###
94
 
95
  * ---
2
  **Contributors:** [themeisle](https://profiles.wordpress.org/themeisle), [codeinwp](https://profiles.wordpress.org/codeinwp)
3
  **Tags:** elementor, pagebuilder, page builder, page builder template, page builder templates, actions, storefront, twentysixteen, genesis, template builder, builder templates
4
  **Requires at least:** 4.4
5
+ **Tested up to:** 4.9
6
  **License:** GPLv2 or later
7
  **License URI:** http://www.gnu.org/licenses/gpl-2.0.html
8
 
90
  2. Fullwidth no Header no Footer
91
 
92
  ## Changelog ##
93
+ ### 1.2.1 - 2017-10-11 ###
94
+
95
+ * Added Recommendation for Elementor Addons & Widgets.
96
+
97
+
98
  ### 1.2.0 - 2017-09-29 ###
99
 
100
  * ---
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: themeisle, codeinwp
3
  Tags: elementor, pagebuilder, page builder, page builder template, page builder templates, actions, storefront, twentysixteen, genesis, template builder, builder templates
4
  Requires at least: 4.4
5
- Tested up to: 4.7.3
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
 
@@ -90,6 +90,11 @@ Further details will be available near the time of the release.
90
  2. Fullwidth no Header no Footer
91
 
92
  == Changelog ==
 
 
 
 
 
93
  = 1.2.0 - 2017-09-29 =
94
 
95
  * ---
2
  Contributors: themeisle, codeinwp
3
  Tags: elementor, pagebuilder, page builder, page builder template, page builder templates, actions, storefront, twentysixteen, genesis, template builder, builder templates
4
  Requires at least: 4.4
5
+ Tested up to: 4.9
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
 
90
  2. Fullwidth no Header no Footer
91
 
92
  == Changelog ==
93
+ = 1.2.1 - 2017-10-11 =
94
+
95
+ * Added Recommendation for Elementor Addons & Widgets.
96
+
97
+
98
  = 1.2.0 - 2017-09-29 =
99
 
100
  * ---
vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer' . '/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit01ee155dcae9890415e2917f84ad7e0b::getLoader();
vendor/codeinwp/themeisle-sdk/LICENSE ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ {one line to give the program's name and a brief idea of what it does.}
635
+ Copyright (C) {year} {name of author}
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ {project} Copyright (C) {year} {fullname}
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <http://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <http://www.gnu.org/philosophy/why-not-lgpl.html>.
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-feedback-deactivate.php ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The deactivate feedback model class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Feedback
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ if ( ! class_exists( 'ThemeIsle_SDK_Feedback_Deactivate' ) ) :
16
+ /**
17
+ * Deactivate feedback model for ThemeIsle SDK.
18
+ */
19
+ class ThemeIsle_SDK_Feedback_Deactivate extends ThemeIsle_SDK_Feedback {
20
+
21
+ /**
22
+ * @var array $options_plugin The main options list for plugins.
23
+ */
24
+ private $options_plugin = array(
25
+ 'I only needed the plugin for a short period' => array(
26
+ 'id' => 1,
27
+ ),
28
+ 'The plugin broke my site' => array(
29
+ 'id' => 2,
30
+ ),
31
+ 'I found a better plugin' => array(
32
+ 'id' => 3,
33
+ 'type' => 'text',
34
+ 'placeholder' => 'What\'s the plugin\'s name?',
35
+ ),
36
+ 'The plugin suddenly stopped working' => array(
37
+ 'id' => 4,
38
+ ),
39
+ 'I no longer need the plugin' => array(
40
+ 'id' => 5,
41
+ 'type' => 'textarea',
42
+ 'placeholder' => 'If you could improve one thing about our product, what would it be?',
43
+ ),
44
+ 'It\'s a temporary deactivation. I\'m just debugging an issue.' => array(
45
+ 'id' => 6,
46
+ ),
47
+ );
48
+
49
+ /**
50
+ * @var array $options_theme The main options list for themes.
51
+ */
52
+ private $options_theme = array(
53
+ 'I don\'t know how to make it look like demo' => array(
54
+ 'id' => 7,
55
+ ),
56
+ 'It lacks options' => array(
57
+ 'id' => 8,
58
+ ),
59
+ 'Is not working with a plugin that I need' => array(
60
+ 'id' => 9,
61
+ 'type' => 'text',
62
+ 'placeholder' => 'What is the name of the plugin',
63
+ ),
64
+ 'I want to try a new design, I don\'t like {theme} style' => array(
65
+ 'id' => 10,
66
+ ),
67
+ );
68
+
69
+ /**
70
+ * @var array $other The other option
71
+ */
72
+ private $other = array(
73
+ 'Other' => array(
74
+ 'id' => 999,
75
+ 'type' => 'textarea',
76
+ 'placeholder' => 'cmon cmon tell us',
77
+ ),
78
+ );
79
+
80
+ /**
81
+ * @var string $heading_plugin The heading of the modal
82
+ */
83
+ private $heading_plugin = 'If you have a moment, please let us know why you are deactivating:';
84
+
85
+ /**
86
+ * @var string $heading_theme The heading of the modal
87
+ */
88
+ private $heading_theme = 'Looking to change {theme}, what doesn\'t work for you?';
89
+
90
+ /**
91
+ * @var string $button_submit_before The text of the deactivate button before an option is chosen
92
+ */
93
+ private $button_submit_before = 'Skip &amp; Deactivate';
94
+
95
+ /**
96
+ * @var string $button_submit The text of the deactivate button
97
+ */
98
+ private $button_submit = 'Submit &amp; Deactivate';
99
+
100
+ /**
101
+ * @var string $button_cancel The text of the cancel button
102
+ */
103
+ private $button_cancel = 'Cancel';
104
+
105
+ /**
106
+ * @var int how many seconds before the deactivation window is triggered for themes
107
+ */
108
+ const AUTO_TRIGGER_DEACTIVATE_WINDOW_SECONDS = 3;
109
+
110
+ /**
111
+ * @var int how many days before the deactivation window pops up again for the theme
112
+ */
113
+ const PAUSE_DEACTIVATE_WINDOW_DAYS = 100;
114
+
115
+ /**
116
+ * ThemeIsle_SDK_Feedback_Deactivate constructor.
117
+ *
118
+ * @param ThemeIsle_SDK_Product $product_object The product object.
119
+ */
120
+ public function __construct( $product_object ) {
121
+ parent::__construct( $product_object );
122
+ }
123
+
124
+ /**
125
+ * Registers the hooks
126
+ */
127
+ public function setup_hooks_child() {
128
+ global $pagenow;
129
+
130
+ if ( ( $this->product->get_type() === 'plugin' && $pagenow === 'plugins.php' ) || ( $this->product->get_type() === 'theme' && $pagenow === 'theme-install.php' ) ) {
131
+ add_action( 'admin_head', array( $this, 'load_resources' ) );
132
+ }
133
+ add_action( 'wp_ajax_' . $this->product->get_key() . __CLASS__, array( $this, 'post_deactivate' ) );
134
+ }
135
+
136
+ /**
137
+ * Loads the additional resources
138
+ */
139
+ function load_resources() {
140
+ add_thickbox();
141
+
142
+ $id = $this->product->get_key() . '_deactivate';
143
+
144
+ $this->add_css( $this->product->get_type(), $this->product->get_key() );
145
+ $this->add_js( $this->product->get_type(), $this->product->get_key(), '#TB_inline?' . apply_filters( $this->product->get_key() . '_feedback_deactivate_attributes', 'width=600&height=550' ) . '&inlineId=' . $id );
146
+
147
+ echo '<div id="' . $id . '" style="display:none;" class="themeisle-deactivate-box">' . $this->get_html( $this->product->get_type(), $this->product->get_key() ) . '</div>';
148
+ }
149
+
150
+ /**
151
+ * Loads the css
152
+ *
153
+ * @param string $type The type of product.
154
+ * @param string $key The product key.
155
+ */
156
+ function add_css( $type, $key ) {
157
+ $suffix = 'theme' === $type ? 'theme-install-php' : 'plugins-php';
158
+ ?>
159
+ <style type="text/css" id="<?php echo $key; ?>ti-deactivate-css">
160
+ input[name="ti-deactivate-option"] ~ div {
161
+ display: none;
162
+ }
163
+
164
+ input[name="ti-deactivate-option"]:checked ~ div {
165
+ display: block;
166
+ }
167
+
168
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container #TB_window.thickbox-loading:before {
169
+ background: none !important;
170
+ }
171
+
172
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container #TB_title {
173
+ font-size: 21px;
174
+ padding: 20px 0;
175
+ background-color: #f3f3f3;
176
+ }
177
+
178
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container div.actions {
179
+ padding: 20px 0;
180
+ background-color: #f3f3f3;
181
+ border-top: 1px solid #dddddd;
182
+ }
183
+
184
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container input.button.button-primary {
185
+ margin-right: 20px;
186
+ }
187
+
188
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container input.button {
189
+ margin-right: 20px;
190
+ }
191
+
192
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container #TB_ajaxWindowTitle {
193
+ text-align: left;
194
+ margin-left: 15px;
195
+ }
196
+
197
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container div.revive_network-container {
198
+ background-color: #ffffff;
199
+ }
200
+
201
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container ul.ti-list li {
202
+ font-size: 14px;
203
+ }
204
+
205
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container ul.ti-list li label {
206
+ margin-left: 10px;
207
+ line-height: 32px;
208
+ font-size: 16px;
209
+ }
210
+
211
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container #TB_ajaxContent {
212
+ padding: 10px 20px;
213
+ }
214
+
215
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container li div textarea {
216
+ padding: 10px 15px;
217
+ width: 100%;
218
+ }
219
+
220
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container ul.ti-list li div {
221
+ margin: 10px 30px;
222
+ }
223
+
224
+ .<?php echo $key; ?>-container #TB_title #TB_ajaxWindowTitle {
225
+ display: block;
226
+ }
227
+
228
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container .actions {
229
+
230
+ width: 100%;
231
+ display: block;
232
+ position: absolute;
233
+ left: 0px;
234
+ bottom: 0px;
235
+ text-align: right;
236
+ }
237
+
238
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container #TB_title {
239
+
240
+ height: 33px;
241
+ width: 100%;
242
+ text-align: center;
243
+ }
244
+
245
+ .theme-install-php .<?php echo $key; ?>-container #TB_closeWindowButton .tb-close-icon:before {
246
+ font-size: 32px;
247
+ }
248
+
249
+ .<?php echo $key; ?>-container #TB_closeWindowButton .tb-close-icon {
250
+
251
+ color: #eee;
252
+ }
253
+
254
+ .<?php echo $key; ?>-container #TB_closeWindowButton {
255
+ left: auto;
256
+ right: -30px;
257
+ color: #eee;
258
+ }
259
+
260
+ body.<?php echo $suffix; ?> .<?php echo $key; ?>-container {
261
+
262
+ margin: auto !important;
263
+ height: 550px !important;
264
+ top: 0 !important;
265
+ left: 0 !important;
266
+ bottom: 0 !important;
267
+ right: 0 !important;
268
+ }
269
+ </style>
270
+ <?php
271
+ }
272
+
273
+ /**
274
+ * Loads the js
275
+ *
276
+ * @param string $type The type of product.
277
+ * @param string $key The product key.
278
+ * @param string $src The url that will hijack the deactivate button url.
279
+ */
280
+ function add_js( $type, $key, $src ) {
281
+ $heading = 'plugin' === $type ? $this->heading_plugin : str_replace( '{theme}', $this->product->get_name(), $this->heading_theme );
282
+ $heading = apply_filters( $this->product->get_key() . '_feedback_deactivate_heading', $heading );
283
+ ?>
284
+ <script type="text/javascript" id="ti-deactivate-js">
285
+ (function ($) {
286
+ $(document).ready(function () {
287
+ var auto_trigger = false;
288
+ var target_element = 'tr[data-plugin^="<?php echo $this->product->get_slug(); ?>/"] span.deactivate a';
289
+ <?php
290
+ if ( 'theme' === $type ) {
291
+ ?>
292
+ auto_trigger = true;
293
+ if ($('a.ti-auto-anchor').length == 0) {
294
+ $('body').append($('<a class="ti-auto-anchor" href=""></a>'));
295
+ }
296
+ target_element = 'a.ti-auto-anchor';
297
+ <?php
298
+ }
299
+ ?>
300
+
301
+ if (auto_trigger) {
302
+ setTimeout(function () {
303
+ $('a.ti-auto-anchor').trigger('click');
304
+ }, <?php echo self::AUTO_TRIGGER_DEACTIVATE_WINDOW_SECONDS * 1000; ?> );
305
+ }
306
+ $( document ).on( 'thickbox:removed', function() {
307
+ $.ajax({
308
+ url: ajaxurl,
309
+ method: 'post',
310
+ data: {
311
+ 'action' : '<?php echo $key . __CLASS__; ?>',
312
+ 'nonce' : '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>',
313
+ 'type' : '<?php echo $type; ?>',
314
+ 'key' : '<?php echo $key; ?>'
315
+ },
316
+ });
317
+ });
318
+ var href = $(target_element).attr('href');
319
+ $('#<?php echo $key; ?>ti-deactivate-no').on('click', function (e) {
320
+ e.preventDefault();
321
+ e.stopPropagation();
322
+
323
+ $('body').unbind('thickbox:removed');
324
+ tb_remove();
325
+ });
326
+
327
+ $('#<?php echo $key; ?> ul.ti-list label, #<?php echo $key; ?> ul.ti-list input[name="ti-deactivate-option"]').on('click', function (e) {
328
+ $('#<?php echo $key; ?>ti-deactivate-yes').val($('#<?php echo $key; ?>ti-deactivate-yes').attr('data-after-text'));
329
+
330
+ var radio = $(this).prop('tagName') === 'LABEL' ? $(this).parent() : $(this);
331
+ if (radio.parent().find('textarea').length > 0 && radio.parent().find('textarea').val().length === 0) {
332
+ $('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled');
333
+ radio.parent().find('textarea').on('keyup', function (ee) {
334
+ if ($(this).val().length === 0) {
335
+ $('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled');
336
+ } else {
337
+ $('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled');
338
+ }
339
+ });
340
+ } else {
341
+ $('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled');
342
+ }
343
+ });
344
+
345
+ $('#<?php echo $key; ?>ti-deactivate-yes').attr('data-ti-action', href).on('click', function (e) {
346
+ e.preventDefault();
347
+ e.stopPropagation();
348
+ $.ajax({
349
+ url: ajaxurl,
350
+ method: 'post',
351
+ data: {
352
+ 'action' : '<?php echo $key . __CLASS__; ?>',
353
+ 'nonce' : '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>',
354
+ 'id' : $('#<?php echo $key; ?> input[name="ti-deactivate-option"]:checked').parent().attr('ti-option-id'),
355
+ 'msg' : $('#<?php echo $key; ?> input[name="ti-deactivate-option"]:checked').parent().find('textarea').val(),
356
+ 'type' : '<?php echo $type; ?>',
357
+ 'key' : '<?php echo $key; ?>'
358
+ },
359
+ });
360
+ var redirect = $(this).attr('data-ti-action');
361
+ if (redirect != '') {
362
+ location.href = redirect;
363
+ } else {
364
+ $('body').unbind('thickbox:removed');
365
+ tb_remove();
366
+ }
367
+ });
368
+
369
+ $(target_element).attr('name', '<?php echo esc_html( $heading ); ?>').attr('href', '<?php echo $src; ?>').addClass('thickbox');
370
+ var thicbox_timer;
371
+ $(target_element).on('click', function () {
372
+ tiBindThickbox();
373
+ });
374
+
375
+ function tiBindThickbox() {
376
+ var thicbox_timer = setTimeout(function () {
377
+ if ($("#<?php echo esc_html( $key ); ?>").is(":visible")) {
378
+ $("body").trigger('thickbox:iframe:loaded');
379
+ $("#TB_window").addClass("<?php echo $key; ?>-container");
380
+ clearTimeout(thicbox_timer);
381
+ $('body').unbind('thickbox:removed');
382
+ } else {
383
+ tiBindThickbox();
384
+ }
385
+ }, 100);
386
+ }
387
+ });
388
+ })(jQuery);
389
+ </script>
390
+ <?php
391
+ }
392
+
393
+ /**
394
+ * Generates the HTML
395
+ *
396
+ * @param string $type The type of product.
397
+ * @param string $key The product key.
398
+ */
399
+ function get_html( $type, $key ) {
400
+ $options = 'plugin' === $type ? $this->options_plugin : $this->options_theme;
401
+ $button_submit_before = 'plugin' === $type ? $this->button_submit_before : 'Submit';
402
+ $button_submit = 'plugin' === $type ? $this->button_submit : 'Submit';
403
+ $options = $this->randomize_options( apply_filters( $this->product->get_key() . '_feedback_deactivate_options', $options ) );
404
+ $button_submit_before = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_submit_before', $button_submit_before );
405
+ $button_submit = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_submit', $button_submit );
406
+ $button_cancel = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_cancel', $this->button_cancel );
407
+
408
+ $options += $this->other;
409
+
410
+ $list = '';
411
+ foreach ( $options as $title => $attributes ) {
412
+ $id = $attributes['id'];
413
+ $list .= '<li ti-option-id="' . $id . '"><input type="radio" name="ti-deactivate-option" id="' . $key . $id . '"><label for="' . $key . $id . '">' . str_replace( '{theme}', $this->product->get_name(), $title ) . '</label>';
414
+ if ( array_key_exists( 'type', $attributes ) ) {
415
+ $list .= '<div>';
416
+ $placeholder = array_key_exists( 'placeholder', $attributes ) ? $attributes['placeholder'] : '';
417
+ switch ( $attributes['type'] ) {
418
+ case 'text':
419
+ $list .= '<textarea style="width: 100%" rows="1" name="comments" placeholder="' . $placeholder . '"></textarea>';
420
+ break;
421
+ case 'textarea':
422
+ $list .= '<textarea style="width: 100%" rows="2" name="comments" placeholder="' . $placeholder . '"></textarea>';
423
+ break;
424
+ }
425
+ $list .= '</div>';
426
+ }
427
+ $list .= '</li>';
428
+ }
429
+
430
+ return '<div id="' . $this->product->get_key() . '">'
431
+ . '<ul class="ti-list">' . $list . '</ul>'
432
+ . '<div class="actions">'
433
+ . get_submit_button(
434
+ $button_submit_before , 'secondary', $this->product->get_key() . 'ti-deactivate-yes', false, array(
435
+ 'data-after-text' => $button_submit,
436
+ )
437
+ )
438
+ . get_submit_button( $button_cancel, 'primary', $this->product->get_key() . 'ti-deactivate-no', false )
439
+ . '</div></div>';
440
+ }
441
+
442
+ /**
443
+ * Called when the deactivate button is clicked
444
+ */
445
+ function post_deactivate() {
446
+ check_ajax_referer( (string) __CLASS__, 'nonce' );
447
+
448
+ if ( ! empty( $_POST['id'] ) ) {
449
+ $this->call_api(
450
+ array(
451
+ 'type' => 'deactivate',
452
+ 'id' => $_POST['id'],
453
+ 'comment' => isset( $_POST['msg'] ) ? $_POST['msg'] : '',
454
+ )
455
+ );
456
+ }
457
+
458
+ $this->post_deactivate_or_cancel();
459
+ }
460
+
461
+ /**
462
+ * Called when the deactivate/cancel button is clicked
463
+ */
464
+ private function post_deactivate_or_cancel() {
465
+ if ( isset( $_POST['type'] ) && isset( $_POST['key'] ) && 'theme' === $_POST['type'] ) {
466
+ set_transient( 'ti_sdk_pause_' . $_POST['key'], true, PAUSE_DEACTIVATE_WINDOW_DAYS * DAY_IN_SECONDS );
467
+ }
468
+ }
469
+ }
470
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-feedback-factory.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The feedback factory class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Feedback
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ if ( ! class_exists( 'ThemeIsle_SDK_Feedback_Factory' ) ) :
16
+ /**
17
+ * Feedback model for ThemeIsle SDK.
18
+ */
19
+ class ThemeIsle_SDK_Feedback_Factory {
20
+
21
+ /**
22
+ * @var array $instances collection of the instances that are registered with the factory
23
+ */
24
+ private $_instances = array();
25
+
26
+ /**
27
+ * ThemeIsle_SDK_Feedback_Factory constructor.
28
+ *
29
+ * @param ThemeIsle_SDK_Product $product_object Product Object.
30
+ * @param array $feedback_types the feedback types.
31
+ */
32
+ public function __construct( $product_object, $feedback_types ) {
33
+ if ( $product_object instanceof ThemeIsle_SDK_Product && $feedback_types && is_array( $feedback_types ) ) {
34
+ foreach ( $feedback_types as $type ) {
35
+ $class = 'ThemeIsle_SDK_Feedback_' . ucwords( $type );
36
+ $instance = new $class( $product_object );
37
+ $this->_instances[ $type ] = $instance;
38
+ $instance->setup_hooks();
39
+ }
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Get the registered instances
45
+ */
46
+ public function get_instances() {
47
+ return $this->_instances;
48
+ }
49
+ }
50
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-feedback-review.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The review feedback model class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Feedback
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ if ( ! class_exists( 'ThemeIsle_SDK_Feedback_Review' ) ) :
16
+ /**
17
+ * Deactivate feedback model for ThemeIsle SDK.
18
+ */
19
+ class ThemeIsle_SDK_Feedback_Review extends ThemeIsle_SDK_Feedback {
20
+
21
+ /**
22
+ * @var string $heading The heading of the modal
23
+ */
24
+ private $heading = 'Hey, it’s great to see you have <b>{product}</b> active for a few days now. How is everything going? If you can spare a few moments to rate it on WordPress.org it would help us a lot (and boost my motivation). Cheers! <br/> <br/>~ {developer}, developer of {product}';
25
+
26
+ /**
27
+ * @var string $msg The text of the modal
28
+ */
29
+ private $msg = '';
30
+
31
+ /**
32
+ * @var string $button_cancel The text of the cancel button
33
+ */
34
+ private $button_cancel = 'No, thanks.';
35
+ /**
36
+ * @var array Developers who work for each type of product for review purpose.
37
+ */
38
+ private $developers = array(
39
+ 'plugin' => array( 'Marius', 'Bogdan' ),
40
+ 'theme' => array( 'Rodica', 'Andrei', 'Bogdan', 'Cristi' ),
41
+ );
42
+ /**
43
+ * @var string $button_already The text of the already did it button
44
+ */
45
+ private $button_do = 'Ok, I will gladly help.';
46
+
47
+ /**
48
+ * ThemeIsle_SDK_Feedback_Deactivate constructor.
49
+ *
50
+ * @param ThemeIsle_SDK_Product $product_object The product object.
51
+ */
52
+ public function __construct( $product_object ) {
53
+ parent::__construct( $product_object );
54
+ }
55
+
56
+ /**
57
+ * Registers the hooks
58
+ */
59
+ public function setup_hooks_child() {
60
+ add_action( 'wp_ajax_' . $this->product->get_key() . __CLASS__, array( $this, 'dismiss' ) );
61
+ }
62
+
63
+ /**
64
+ * Either we can notify or not.
65
+ *
66
+ * @return bool Notification available or not.
67
+ */
68
+ public function can_notify() {
69
+ if ( ! $this->product->is_wordpress_available() ) {
70
+ $this->disable();
71
+
72
+ return false;
73
+ }
74
+ $show = get_option( $this->product->get_key() . '_review_flag', 'yes' );
75
+ if ( 'no' === $show ) {
76
+ return false;
77
+ }
78
+ $finally_show = apply_filters( $this->product->get_key() . '_feedback_review_trigger', true );
79
+ if ( false !== $finally_show ) {
80
+ if ( is_array( $finally_show ) && ! empty( $finally_show ) ) {
81
+ $this->heading = $finally_show['heading'];
82
+ $this->msg = $finally_show['msg'];
83
+ }
84
+ } else {
85
+ return false;
86
+ }
87
+
88
+ return true;
89
+ }
90
+
91
+ /**
92
+ * Shows the notification
93
+ */
94
+ function show_notification() {
95
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
96
+ }
97
+
98
+ /**
99
+ * Shows the admin notice
100
+ */
101
+ function admin_notices() {
102
+ $id = $this->product->get_key() . '_review';
103
+
104
+ $this->add_css( $this->product->get_key() );
105
+ $this->add_js( $this->product->get_key() );
106
+
107
+ echo '<div class="notice notice-success is-dismissible" id="' . $id . '" ><div class="themeisle-review-box">' . $this->get_html( $this->product->get_key() ) . '</div></div>';
108
+ }
109
+
110
+ /**
111
+ * Loads the css
112
+ *
113
+ * @param string $key The product key.
114
+ */
115
+ function add_css( $key ) {
116
+ ?>
117
+ <style type="text/css" id="<?php echo $key; ?>ti-review-css">
118
+ #<?php echo $key; ?>-review-notification {
119
+ padding-bottom: 5px;
120
+ }
121
+
122
+ #<?php echo $key; ?>-review-notification .review-dismiss {
123
+ margin-left: 5px;
124
+ }
125
+ </style>
126
+ <?php
127
+ }
128
+
129
+ /**
130
+ * Loads the js
131
+ *
132
+ * @param string $key The product key.
133
+ */
134
+ function add_js( $key ) {
135
+ ?>
136
+ <script type="text/javascript" id="<?php echo $key; ?>ti-review-js">
137
+ (function ($) {
138
+ $(document).ready(function () {
139
+ $('#<?php echo $key; ?>_review').on('click', '.notice-dismiss, .review-dismiss', function (e) {
140
+
141
+ $.ajax({
142
+ url: ajaxurl,
143
+ method: "post",
144
+ data: {
145
+ 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>',
146
+ 'action': '<?php echo $this->product->get_key() . __CLASS__; ?>'
147
+ },
148
+ success: function () {
149
+ $('#<?php echo $key; ?>_review').hide();
150
+ }
151
+ });
152
+ });
153
+ });
154
+ })(jQuery);
155
+ </script>
156
+ <?php
157
+ }
158
+
159
+ /**
160
+ * Generates the HTML
161
+ *
162
+ * @param string $key The product key.
163
+ */
164
+ function get_html( $key ) {
165
+ $link = 'https://wordpress.org/support/' . $this->product->get_type() . '/' . $this->product->get_slug() . '/reviews/#wporg-footer';
166
+ $heading = apply_filters( $this->product->get_key() . '_feedback_review_heading', $this->heading );
167
+ $heading = str_replace(
168
+ array( '{product}' ),
169
+ $this->product->get_friendly_name(), $heading
170
+ );
171
+ $heading = str_replace( '{developer}', $this->developers[ $this->product->get_type() ][ rand( 0, ( count( $this->developers[ $this->product->get_type() ] ) - 1 ) ) ], $heading );
172
+
173
+ $button_cancel = apply_filters( $this->product->get_key() . '_feedback_review_button_cancel', $this->button_cancel );
174
+ $button_do = apply_filters( $this->product->get_key() . '_feedback_review_button_do', $this->button_do );
175
+ $msg = apply_filters( $this->product->get_key() . '_feedback_review_message', $this->msg );
176
+
177
+ return '<div id="' . $this->product->get_key() . '-review-notification" class="themeisle-sdk-review-box">'
178
+ . '<p>' . $heading . '</p>'
179
+ . ( $msg ? '<p>' . $msg . '</p>' : '' )
180
+ . '<div class="actions">'
181
+ . '<a href="' . $link . '" target="_blank" class="button button-primary review-dismiss"> ' . $button_do . '</a>'
182
+ . get_submit_button( $button_cancel, 'review-dismiss ' . $this->product->get_key() . '-ti-review', $this->product->get_key() . 'ti-review-no', false )
183
+ . '</div></div>';
184
+ }
185
+
186
+ /**
187
+ * Called when the either button is clicked
188
+ */
189
+ function dismiss() {
190
+ check_ajax_referer( (string) __CLASS__, 'nonce' );
191
+
192
+ $this->disable();
193
+ }
194
+
195
+ /**
196
+ * Disables the notification
197
+ */
198
+ protected function disable() {
199
+ update_option( $this->product->get_key() . '_review_flag', 'no' );
200
+ }
201
+
202
+ /**
203
+ * Enables the notification
204
+ */
205
+ protected function enable() {
206
+ update_option( $this->product->get_key() . '_review_flag', 'yes' );
207
+ }
208
+ }
209
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-feedback-translate.php ADDED
@@ -0,0 +1,966 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The Translate feedback model class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Feedback
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ if ( ! class_exists( 'ThemeIsle_SDK_Feedback_Translate' ) ) :
16
+ /**
17
+ * Translate feedback model for ThemeIsle SDK.
18
+ */
19
+ class ThemeIsle_SDK_Feedback_Translate extends ThemeIsle_SDK_Feedback {
20
+
21
+ /**
22
+ * @var string $heading The heading of the modal
23
+ */
24
+ private $heading = 'Improve {product}';
25
+ /**
26
+ * @var string The message.
27
+ */
28
+ private $msg = 'Translating <b>{product}</b> into as many languages as possible is a huge project. We still need help with a lot of them, so if you are good at translating into <b>{language}</b>, it would be greatly appreciated.
29
+ The process is easy, and you can join by following the link below!';
30
+ /**
31
+ * @var string $button_cancel The text of the cancel button
32
+ */
33
+ private $button_cancel = 'No, thanks.';
34
+ /**
35
+ * @var string $button_already The text of the already did it button
36
+ */
37
+ private $button_do = 'Ok, I will gladly help.';
38
+ /**
39
+ * @var array Array of available locals.
40
+ */
41
+ private $locales = array(
42
+ 'af' => array(
43
+ 'slug' => 'af',
44
+ 'name' => 'Afrikaans',
45
+ ),
46
+ 'ak' => array(
47
+ 'slug' => 'ak',
48
+ 'name' => 'Akan',
49
+ ),
50
+ 'am' => array(
51
+ 'slug' => 'am',
52
+ 'name' => 'Amharic',
53
+ ),
54
+ 'ar' => array(
55
+ 'slug' => 'ar',
56
+ 'name' => 'Arabic',
57
+ ),
58
+ 'arq' => array(
59
+ 'slug' => 'arq',
60
+ 'name' => 'Algerian Arabic',
61
+ ),
62
+ 'ary' => array(
63
+ 'slug' => 'ary',
64
+ 'name' => 'Moroccan Arabic',
65
+ ),
66
+ 'as' => array(
67
+ 'slug' => 'as',
68
+ 'name' => 'Assamese',
69
+ ),
70
+ 'ast' => array(
71
+ 'slug' => 'ast',
72
+ 'name' => 'Asturian',
73
+ ),
74
+ 'az' => array(
75
+ 'slug' => 'az',
76
+ 'name' => 'Azerbaijani',
77
+ ),
78
+ 'azb' => array(
79
+ 'slug' => 'azb',
80
+ 'name' => 'South Azerbaijani',
81
+ ),
82
+ 'az_TR' => array(
83
+ 'slug' => 'az-tr',
84
+ 'name' => 'Azerbaijani (Turkey)',
85
+ ),
86
+ 'ba' => array(
87
+ 'slug' => 'ba',
88
+ 'name' => 'Bashkir',
89
+ ),
90
+ 'bal' => array(
91
+ 'slug' => 'bal',
92
+ 'name' => 'Catalan (Balear)',
93
+ ),
94
+ 'bcc' => array(
95
+ 'slug' => 'bcc',
96
+ 'name' => 'Balochi Southern',
97
+ ),
98
+ 'bel' => array(
99
+ 'slug' => 'bel',
100
+ 'name' => 'Belarusian',
101
+ ),
102
+ 'bg_BG' => array(
103
+ 'slug' => 'bg',
104
+ 'name' => 'Bulgarian',
105
+ ),
106
+ 'bn_BD' => array(
107
+ 'slug' => 'bn',
108
+ 'name' => 'Bengali',
109
+ ),
110
+ 'bo' => array(
111
+ 'slug' => 'bo',
112
+ 'name' => 'Tibetan',
113
+ ),
114
+ 'bre' => array(
115
+ 'slug' => 'br',
116
+ 'name' => 'Breton',
117
+ ),
118
+ 'bs_BA' => array(
119
+ 'slug' => 'bs',
120
+ 'name' => 'Bosnian',
121
+ ),
122
+ 'ca' => array(
123
+ 'slug' => 'ca',
124
+ 'name' => 'Catalan',
125
+ ),
126
+ 'ceb' => array(
127
+ 'slug' => 'ceb',
128
+ 'name' => 'Cebuano',
129
+ ),
130
+ 'ckb' => array(
131
+ 'slug' => 'ckb',
132
+ 'name' => 'Kurdish (Sorani)',
133
+ ),
134
+ 'co' => array(
135
+ 'slug' => 'co',
136
+ 'name' => 'Corsican',
137
+ ),
138
+ 'cs_CZ' => array(
139
+ 'slug' => 'cs',
140
+ 'name' => 'Czech',
141
+ ),
142
+ 'cy' => array(
143
+ 'slug' => 'cy',
144
+ 'name' => 'Welsh',
145
+ ),
146
+ 'da_DK' => array(
147
+ 'slug' => 'da',
148
+ 'name' => 'Danish',
149
+ ),
150
+ 'de_DE' => array(
151
+ 'slug' => 'de',
152
+ 'name' => 'German',
153
+ ),
154
+ 'de_CH' => array(
155
+ 'slug' => 'de-ch',
156
+ 'name' => 'German (Switzerland)',
157
+ ),
158
+ 'dv' => array(
159
+ 'slug' => 'dv',
160
+ 'name' => 'Dhivehi',
161
+ ),
162
+ 'dzo' => array(
163
+ 'slug' => 'dzo',
164
+ 'name' => 'Dzongkha',
165
+ ),
166
+ 'el' => array(
167
+ 'slug' => 'el',
168
+ 'name' => 'Greek',
169
+ ),
170
+ 'art_xemoji' => array(
171
+ 'slug' => 'art-xemoji',
172
+ 'name' => 'Emoji',
173
+ ),
174
+ 'en_US' => array(
175
+ 'slug' => 'en',
176
+ 'name' => 'English',
177
+ ),
178
+ 'en_AU' => array(
179
+ 'slug' => 'en-au',
180
+ 'name' => 'English (Australia)',
181
+ ),
182
+ 'en_CA' => array(
183
+ 'slug' => 'en-ca',
184
+ 'name' => 'English (Canada)',
185
+ ),
186
+ 'en_GB' => array(
187
+ 'slug' => 'en-gb',
188
+ 'name' => 'English (UK)',
189
+ ),
190
+ 'en_NZ' => array(
191
+ 'slug' => 'en-nz',
192
+ 'name' => 'English (New Zealand)',
193
+ ),
194
+ 'en_ZA' => array(
195
+ 'slug' => 'en-za',
196
+ 'name' => 'English (South Africa)',
197
+ ),
198
+ 'eo' => array(
199
+ 'slug' => 'eo',
200
+ 'name' => 'Esperanto',
201
+ ),
202
+ 'es_ES' => array(
203
+ 'slug' => 'es',
204
+ 'name' => 'Spanish (Spain)',
205
+ ),
206
+ 'es_AR' => array(
207
+ 'slug' => 'es-ar',
208
+ 'name' => 'Spanish (Argentina)',
209
+ ),
210
+ 'es_CL' => array(
211
+ 'slug' => 'es-cl',
212
+ 'name' => 'Spanish (Chile)',
213
+ ),
214
+ 'es_CO' => array(
215
+ 'slug' => 'es-co',
216
+ 'name' => 'Spanish (Colombia)',
217
+ ),
218
+ 'es_CR' => array(
219
+ 'slug' => 'es-cr',
220
+ 'name' => 'Spanish (Costa Rica)',
221
+ ),
222
+ 'es_GT' => array(
223
+ 'slug' => 'es-gt',
224
+ 'name' => 'Spanish (Guatemala)',
225
+ ),
226
+ 'es_MX' => array(
227
+ 'slug' => 'es-mx',
228
+ 'name' => 'Spanish (Mexico)',
229
+ ),
230
+ 'es_PE' => array(
231
+ 'slug' => 'es-pe',
232
+ 'name' => 'Spanish (Peru)',
233
+ ),
234
+ 'es_PR' => array(
235
+ 'slug' => 'es-pr',
236
+ 'name' => 'Spanish (Puerto Rico)',
237
+ ),
238
+ 'es_VE' => array(
239
+ 'slug' => 'es-ve',
240
+ 'name' => 'Spanish (Venezuela)',
241
+ ),
242
+ 'et' => array(
243
+ 'slug' => 'et',
244
+ 'name' => 'Estonian',
245
+ ),
246
+ 'eu' => array(
247
+ 'slug' => 'eu',
248
+ 'name' => 'Basque',
249
+ ),
250
+ 'fa_IR' => array(
251
+ 'slug' => 'fa',
252
+ 'name' => 'Persian',
253
+ ),
254
+ 'fa_AF' => array(
255
+ 'slug' => 'fa-af',
256
+ 'name' => 'Persian (Afghanistan)',
257
+ ),
258
+ 'fuc' => array(
259
+ 'slug' => 'fuc',
260
+ 'name' => 'Fulah',
261
+ ),
262
+ 'fi' => array(
263
+ 'slug' => 'fi',
264
+ 'name' => 'Finnish',
265
+ ),
266
+ 'fo' => array(
267
+ 'slug' => 'fo',
268
+ 'name' => 'Faroese',
269
+ ),
270
+ 'fr_FR' => array(
271
+ 'slug' => 'fr',
272
+ 'name' => 'French (France)',
273
+ ),
274
+ 'fr_BE' => array(
275
+ 'slug' => 'fr-be',
276
+ 'name' => 'French (Belgium)',
277
+ ),
278
+ 'fr_CA' => array(
279
+ 'slug' => 'fr-ca',
280
+ 'name' => 'French (Canada)',
281
+ ),
282
+ 'frp' => array(
283
+ 'slug' => 'frp',
284
+ 'name' => 'Arpitan',
285
+ ),
286
+ 'fur' => array(
287
+ 'slug' => 'fur',
288
+ 'name' => 'Friulian',
289
+ ),
290
+ 'fy' => array(
291
+ 'slug' => 'fy',
292
+ 'name' => 'Frisian',
293
+ ),
294
+ 'ga' => array(
295
+ 'slug' => 'ga',
296
+ 'name' => 'Irish',
297
+ ),
298
+ 'gd' => array(
299
+ 'slug' => 'gd',
300
+ 'name' => 'Scottish Gaelic',
301
+ ),
302
+ 'gl_ES' => array(
303
+ 'slug' => 'gl',
304
+ 'name' => 'Galician',
305
+ ),
306
+ 'gn' => array(
307
+ 'slug' => 'gn',
308
+ 'name' => 'Guaraní',
309
+ ),
310
+ 'gsw' => array(
311
+ 'slug' => 'gsw',
312
+ 'name' => 'Swiss German',
313
+ ),
314
+ 'gu' => array(
315
+ 'slug' => 'gu',
316
+ 'name' => 'Gujarati',
317
+ ),
318
+ 'hat' => array(
319
+ 'slug' => 'hat',
320
+ 'name' => 'Haitian Creole',
321
+ ),
322
+ 'hau' => array(
323
+ 'slug' => 'hau',
324
+ 'name' => 'Hausa',
325
+ ),
326
+ 'haw_US' => array(
327
+ 'slug' => 'haw',
328
+ 'name' => 'Hawaiian',
329
+ ),
330
+ 'haz' => array(
331
+ 'slug' => 'haz',
332
+ 'name' => 'Hazaragi',
333
+ ),
334
+ 'he_IL' => array(
335
+ 'slug' => 'he',
336
+ 'name' => 'Hebrew',
337
+ ),
338
+ 'hi_IN' => array(
339
+ 'slug' => 'hi',
340
+ 'name' => 'Hindi',
341
+ ),
342
+ 'hr' => array(
343
+ 'slug' => 'hr',
344
+ 'name' => 'Croatian',
345
+ ),
346
+ 'hu_HU' => array(
347
+ 'slug' => 'hu',
348
+ 'name' => 'Hungarian',
349
+ ),
350
+ 'hy' => array(
351
+ 'slug' => 'hy',
352
+ 'name' => 'Armenian',
353
+ ),
354
+ 'id_ID' => array(
355
+ 'slug' => 'id',
356
+ 'name' => 'Indonesian',
357
+ ),
358
+ 'ido' => array(
359
+ 'slug' => 'ido',
360
+ 'name' => 'Ido',
361
+ ),
362
+ 'is_IS' => array(
363
+ 'slug' => 'is',
364
+ 'name' => 'Icelandic',
365
+ ),
366
+ 'it_IT' => array(
367
+ 'slug' => 'it',
368
+ 'name' => 'Italian',
369
+ ),
370
+ 'ja' => array(
371
+ 'slug' => 'ja',
372
+ 'name' => 'Japanese',
373
+ ),
374
+ 'jv_ID' => array(
375
+ 'slug' => 'jv',
376
+ 'name' => 'Javanese',
377
+ ),
378
+ 'ka_GE' => array(
379
+ 'slug' => 'ka',
380
+ 'name' => 'Georgian',
381
+ ),
382
+ 'kab' => array(
383
+ 'slug' => 'kab',
384
+ 'name' => 'Kabyle',
385
+ ),
386
+ 'kal' => array(
387
+ 'slug' => 'kal',
388
+ 'name' => 'Greenlandic',
389
+ ),
390
+ 'kin' => array(
391
+ 'slug' => 'kin',
392
+ 'name' => 'Kinyarwanda',
393
+ ),
394
+ 'kk' => array(
395
+ 'slug' => 'kk',
396
+ 'name' => 'Kazakh',
397
+ ),
398
+ 'km' => array(
399
+ 'slug' => 'km',
400
+ 'name' => 'Khmer',
401
+ ),
402
+ 'kn' => array(
403
+ 'slug' => 'kn',
404
+ 'name' => 'Kannada',
405
+ ),
406
+ 'ko_KR' => array(
407
+ 'slug' => 'ko',
408
+ 'name' => 'Korean',
409
+ ),
410
+ 'kir' => array(
411
+ 'slug' => 'kir',
412
+ 'name' => 'Kyrgyz',
413
+ ),
414
+ 'lb_LU' => array(
415
+ 'slug' => 'lb',
416
+ 'name' => 'Luxembourgish',
417
+ ),
418
+ 'li' => array(
419
+ 'slug' => 'li',
420
+ 'name' => 'Limburgish',
421
+ ),
422
+ 'lin' => array(
423
+ 'slug' => 'lin',
424
+ 'name' => 'Lingala',
425
+ ),
426
+ 'lo' => array(
427
+ 'slug' => 'lo',
428
+ 'name' => 'Lao',
429
+ ),
430
+ 'lt_LT' => array(
431
+ 'slug' => 'lt',
432
+ 'name' => 'Lithuanian',
433
+ ),
434
+ 'lv' => array(
435
+ 'slug' => 'lv',
436
+ 'name' => 'Latvian',
437
+ ),
438
+ 'me_ME' => array(
439
+ 'slug' => 'me',
440
+ 'name' => 'Montenegrin',
441
+ ),
442
+ 'mg_MG' => array(
443
+ 'slug' => 'mg',
444
+ 'name' => 'Malagasy',
445
+ ),
446
+ 'mk_MK' => array(
447
+ 'slug' => 'mk',
448
+ 'name' => 'Macedonian',
449
+ ),
450
+ 'ml_IN' => array(
451
+ 'slug' => 'ml',
452
+ 'name' => 'Malayalam',
453
+ ),
454
+ 'mlt' => array(
455
+ 'slug' => 'mlt',
456
+ 'name' => 'Maltese',
457
+ ),
458
+ 'mn' => array(
459
+ 'slug' => 'mn',
460
+ 'name' => 'Mongolian',
461
+ ),
462
+ 'mr' => array(
463
+ 'slug' => 'mr',
464
+ 'name' => 'Marathi',
465
+ ),
466
+ 'mri' => array(
467
+ 'slug' => 'mri',
468
+ 'name' => 'Maori',
469
+ ),
470
+ 'ms_MY' => array(
471
+ 'slug' => 'ms',
472
+ 'name' => 'Malay',
473
+ ),
474
+ 'my_MM' => array(
475
+ 'slug' => 'mya',
476
+ 'name' => 'Myanmar (Burmese)',
477
+ ),
478
+ 'ne_NP' => array(
479
+ 'slug' => 'ne',
480
+ 'name' => 'Nepali',
481
+ ),
482
+ 'nb_NO' => array(
483
+ 'slug' => 'nb',
484
+ 'name' => 'Norwegian (Bokmål)',
485
+ ),
486
+ 'nl_NL' => array(
487
+ 'slug' => 'nl',
488
+ 'name' => 'Dutch',
489
+ ),
490
+ 'nl_BE' => array(
491
+ 'slug' => 'nl-be',
492
+ 'name' => 'Dutch (Belgium)',
493
+ ),
494
+ 'nn_NO' => array(
495
+ 'slug' => 'nn',
496
+ 'name' => 'Norwegian (Nynorsk)',
497
+ ),
498
+ 'oci' => array(
499
+ 'slug' => 'oci',
500
+ 'name' => 'Occitan',
501
+ ),
502
+ 'ory' => array(
503
+ 'slug' => 'ory',
504
+ 'name' => 'Oriya',
505
+ ),
506
+ 'os' => array(
507
+ 'slug' => 'os',
508
+ 'name' => 'Ossetic',
509
+ ),
510
+ 'pa_IN' => array(
511
+ 'slug' => 'pa',
512
+ 'name' => 'Punjabi',
513
+ ),
514
+ 'pl_PL' => array(
515
+ 'slug' => 'pl',
516
+ 'name' => 'Polish',
517
+ ),
518
+ 'pt_BR' => array(
519
+ 'slug' => 'pt-br',
520
+ 'name' => 'Portuguese (Brazil)',
521
+ ),
522
+ 'pt_PT' => array(
523
+ 'slug' => 'pt',
524
+ 'name' => 'Portuguese (Portugal)',
525
+ ),
526
+ 'ps' => array(
527
+ 'slug' => 'ps',
528
+ 'name' => 'Pashto',
529
+ ),
530
+ 'rhg' => array(
531
+ 'slug' => 'rhg',
532
+ 'name' => 'Rohingya',
533
+ ),
534
+ 'ro_RO' => array(
535
+ 'slug' => 'ro',
536
+ 'name' => 'Romanian',
537
+ ),
538
+ 'roh' => array(
539
+ 'slug' => 'roh',
540
+ 'name' => 'Romansh',
541
+ ),
542
+ 'ru_RU' => array(
543
+ 'slug' => 'ru',
544
+ 'name' => 'Russian',
545
+ ),
546
+ 'rue' => array(
547
+ 'slug' => 'rue',
548
+ 'name' => 'Rusyn',
549
+ ),
550
+ 'rup_MK' => array(
551
+ 'slug' => 'rup',
552
+ 'name' => 'Aromanian',
553
+ ),
554
+ 'sah' => array(
555
+ 'slug' => 'sah',
556
+ 'name' => 'Sakha',
557
+ ),
558
+ 'sa_IN' => array(
559
+ 'slug' => 'sa-in',
560
+ 'name' => 'Sanskrit',
561
+ ),
562
+ 'scn' => array(
563
+ 'slug' => 'scn',
564
+ 'name' => 'Sicilian',
565
+ ),
566
+ 'si_LK' => array(
567
+ 'slug' => 'si',
568
+ 'name' => 'Sinhala',
569
+ ),
570
+ 'sk_SK' => array(
571
+ 'slug' => 'sk',
572
+ 'name' => 'Slovak',
573
+ ),
574
+ 'sl_SI' => array(
575
+ 'slug' => 'sl',
576
+ 'name' => 'Slovenian',
577
+ ),
578
+ 'sna' => array(
579
+ 'slug' => 'sna',
580
+ 'name' => 'Shona',
581
+ ),
582
+ 'snd' => array(
583
+ 'slug' => 'snd',
584
+ 'name' => 'Sindhi',
585
+ ),
586
+ 'so_SO' => array(
587
+ 'slug' => 'so',
588
+ 'name' => 'Somali',
589
+ ),
590
+ 'sq' => array(
591
+ 'slug' => 'sq',
592
+ 'name' => 'Albanian',
593
+ ),
594
+ 'sq_XK' => array(
595
+ 'slug' => 'sq-xk',
596
+ 'name' => 'Shqip (Kosovo)',
597
+ ),
598
+ 'sr_RS' => array(
599
+ 'slug' => 'sr',
600
+ 'name' => 'Serbian',
601
+ ),
602
+ 'srd' => array(
603
+ 'slug' => 'srd',
604
+ 'name' => 'Sardinian',
605
+ ),
606
+ 'su_ID' => array(
607
+ 'slug' => 'su',
608
+ 'name' => 'Sundanese',
609
+ ),
610
+ 'sv_SE' => array(
611
+ 'slug' => 'sv',
612
+ 'name' => 'Swedish',
613
+ ),
614
+ 'sw' => array(
615
+ 'slug' => 'sw',
616
+ 'name' => 'Swahili',
617
+ ),
618
+ 'syr' => array(
619
+ 'slug' => 'syr',
620
+ 'name' => 'Syriac',
621
+ ),
622
+ 'szl' => array(
623
+ 'slug' => 'szl',
624
+ 'name' => 'Silesian',
625
+ ),
626
+ 'ta_IN' => array(
627
+ 'slug' => 'ta',
628
+ 'name' => 'Tamil',
629
+ ),
630
+ 'ta_LK' => array(
631
+ 'slug' => 'ta-lk',
632
+ 'name' => 'Tamil (Sri Lanka)',
633
+ ),
634
+ 'tah' => array(
635
+ 'slug' => 'tah',
636
+ 'name' => 'Tahitian',
637
+ ),
638
+ 'te' => array(
639
+ 'slug' => 'te',
640
+ 'name' => 'Telugu',
641
+ ),
642
+ 'tg' => array(
643
+ 'slug' => 'tg',
644
+ 'name' => 'Tajik',
645
+ ),
646
+ 'th' => array(
647
+ 'slug' => 'th',
648
+ 'name' => 'Thai',
649
+ ),
650
+ 'tir' => array(
651
+ 'slug' => 'tir',
652
+ 'name' => 'Tigrinya',
653
+ ),
654
+ 'tl' => array(
655
+ 'slug' => 'tl',
656
+ 'name' => 'Tagalog',
657
+ ),
658
+ 'tr_TR' => array(
659
+ 'slug' => 'tr',
660
+ 'name' => 'Turkish',
661
+ ),
662
+ 'tt_RU' => array(
663
+ 'slug' => 'tt',
664
+ 'name' => 'Tatar',
665
+ ),
666
+ 'tuk' => array(
667
+ 'slug' => 'tuk',
668
+ 'name' => 'Turkmen',
669
+ ),
670
+ 'twd' => array(
671
+ 'slug' => 'twd',
672
+ 'name' => 'Tweants',
673
+ ),
674
+ 'tzm' => array(
675
+ 'slug' => 'tzm',
676
+ 'name' => 'Tamazight (Central Atlas)',
677
+ ),
678
+ 'ug_CN' => array(
679
+ 'slug' => 'ug',
680
+ 'name' => 'Uighur',
681
+ ),
682
+ 'uk' => array(
683
+ 'slug' => 'uk',
684
+ 'name' => 'Ukrainian',
685
+ ),
686
+ 'ur' => array(
687
+ 'slug' => 'ur',
688
+ 'name' => 'Urdu',
689
+ ),
690
+ 'uz_UZ' => array(
691
+ 'slug' => 'uz',
692
+ 'name' => 'Uzbek',
693
+ ),
694
+ 'vi' => array(
695
+ 'slug' => 'vi',
696
+ 'name' => 'Vietnamese',
697
+ ),
698
+ 'wa' => array(
699
+ 'slug' => 'wa',
700
+ 'name' => 'Walloon',
701
+ ),
702
+ 'xho' => array(
703
+ 'slug' => 'xho',
704
+ 'name' => 'Xhosa',
705
+ ),
706
+ 'xmf' => array(
707
+ 'slug' => 'xmf',
708
+ 'name' => 'Mingrelian',
709
+ ),
710
+ 'yor' => array(
711
+ 'slug' => 'yor',
712
+ 'name' => 'Yoruba',
713
+ ),
714
+ 'zh_CN' => array(
715
+ 'slug' => 'zh-cn',
716
+ 'name' => 'Chinese (China)',
717
+ ),
718
+ 'zh_HK' => array(
719
+ 'slug' => 'zh-hk',
720
+ 'name' => 'Chinese (Hong Kong)',
721
+ ),
722
+ 'zh_TW' => array(
723
+ 'slug' => 'zh-tw',
724
+ 'name' => 'Chinese (Taiwan)',
725
+ ),
726
+ 'de_DE_formal' => array(
727
+ 'slug' => 'de/formal',
728
+ 'name' => 'German (Formal)',
729
+ ),
730
+ 'nl_NL_formal' => array(
731
+ 'slug' => 'nl/formal',
732
+ 'name' => 'Dutch (Formal)',
733
+ ),
734
+ 'de_CH_informal' => array(
735
+ 'slug' => 'de-ch/informal',
736
+ 'name' => 'Chinese (Taiwan)',
737
+ ),
738
+ 'pt_PT_ao90' => array(
739
+ 'slug' => 'pt/ao90',
740
+ 'name' => 'Portuguese (Portugal, AO90)',
741
+ ),
742
+ );
743
+
744
+ /**
745
+ * ThemeIsle_SDK_Feedback_Translate constructor.
746
+ *
747
+ * @param ThemeIsle_SDK_Product $product_object The product object.
748
+ */
749
+ public function __construct( $product_object ) {
750
+ parent::__construct( $product_object );
751
+ }
752
+
753
+ /**
754
+ * Return the locale path.
755
+ *
756
+ * @param string $locale Locale code.
757
+ *
758
+ * @return string Locale path.
759
+ */
760
+ private function get_locale_paths( $locale ) {
761
+ if ( empty( $locale ) ) {
762
+ return '';
763
+ }
764
+
765
+ $slug = isset( $this->locales[ $locale ] ) ? $this->locales[ $locale ]['slug'] : '';
766
+ if ( empty( $slug ) ) {
767
+ return '';
768
+ }
769
+ if ( strpos( $slug, '/' ) === false ) {
770
+ $slug .= '/default';
771
+ }
772
+ $url = 'https://translate.wordpress.org/projects/wp-' . $this->product->get_type() . 's/' . $this->product->get_slug() . '/' . ( $this->product->get_type() === 'plugin' ? 'dev/' : '' ) . $slug . '?filters%5Bstatus%5D=untranslated&sort%5Bby%5D=random';
773
+
774
+ return $url;
775
+ }
776
+
777
+ /**
778
+ * Registers the hooks
779
+ */
780
+ public function setup_hooks_child() {
781
+ add_action( 'wp_ajax_' . $this->product->get_key() . __CLASS__, array( $this, 'dismiss' ) );
782
+ }
783
+
784
+ /**
785
+ * Either we should show the notification or not.
786
+ *
787
+ * @return bool Valid notification.
788
+ */
789
+ function can_notify() {
790
+ if ( ! $this->product->is_wordpress_available() ) {
791
+ $this->disable();
792
+
793
+ return false;
794
+ }
795
+ $show = get_option( $this->product->get_key() . '_translate_flag', 'yes' );
796
+ if ( 'no' === $show ) {
797
+ return false;
798
+ }
799
+ $lang = get_user_locale();
800
+ if ( 'en_US' === $lang ) {
801
+ return false;
802
+ }
803
+ $languages = $this->get_translations();
804
+ if ( ! isset( $languages['translations'] ) ) {
805
+ return false;
806
+ }
807
+
808
+ $languages = $languages['translations'];
809
+ $available = wp_list_pluck( $languages, 'language' );
810
+ if ( in_array( $lang, $available ) ) {
811
+ return false;
812
+ }
813
+ if ( ! isset( $this->locales[ $lang ] ) ) {
814
+ return false;
815
+ }
816
+
817
+ return true;
818
+ }
819
+
820
+ /**
821
+ * Shows the notification
822
+ */
823
+ function show_notification() {
824
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
825
+ }
826
+
827
+ /**
828
+ * Shows the admin notice
829
+ */
830
+ function admin_notices() {
831
+ $id = $this->product->get_key() . '_translate';
832
+
833
+ $this->add_css( $this->product->get_key() );
834
+ $this->add_js( $this->product->get_key() );
835
+ $html = $this->get_html( $this->product->get_key() );
836
+
837
+ if ( $html ) {
838
+ echo '<div class="notice notice-success is-dismissible" id="' . $id . '" ><div class="themeisle-translate-box">' . $html . '</div></div>';
839
+ }
840
+ }
841
+
842
+ /**
843
+ * Loads the css
844
+ *
845
+ * @param string $key The product key.
846
+ */
847
+ function add_css( $key ) {
848
+ ?>
849
+ <style type="text/css" id="<?php echo $key; ?>ti-translate-css">
850
+ </style>
851
+ <?php
852
+ }
853
+
854
+ /**
855
+ * Loads the js
856
+ *
857
+ * @param string $key The product key.
858
+ */
859
+ function add_js( $key ) {
860
+ ?>
861
+ <script type="text/javascript" id="<?php echo $key; ?>ti-translate-js">
862
+ (function ($) {
863
+ $(document).ready(function () {
864
+ $('#<?php echo $key; ?>_translate').on('click', '.translate-dismiss', function (e) {
865
+
866
+ $.ajax({
867
+ url: ajaxurl,
868
+ method: "post",
869
+ data: {
870
+ 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>',
871
+ 'action': '<?php echo $this->product->get_key() . __CLASS__; ?>'
872
+ },
873
+ success: function () {
874
+ $('#<?php echo $key; ?>_translate').hide();
875
+ }
876
+ });
877
+ });
878
+ });
879
+ })(jQuery);
880
+ </script>
881
+ <?php
882
+ }
883
+
884
+ /**
885
+ * Fetch translations from api.
886
+ *
887
+ * @return mixed Translation array.
888
+ */
889
+ private function get_translations() {
890
+ $cache_key = $this->product->get_key() . '_all_languages';
891
+ $translations = get_transient( $cache_key );
892
+
893
+ if ( $translations === false ) {
894
+ require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
895
+ $translations = translations_api(
896
+ $this->product->get_type() . 's',
897
+ array(
898
+ 'slug' => $this->product->get_slug(),
899
+ 'version' => $this->product->get_version(),
900
+ )
901
+ );
902
+ set_transient( $cache_key, $translations, WEEK_IN_SECONDS );
903
+ }
904
+
905
+ return $translations;
906
+
907
+ }
908
+
909
+ /**
910
+ * Generates the HTML
911
+ *
912
+ * @param string $key The product key.
913
+ *
914
+ * @return void|string Html code of the notification.
915
+ */
916
+ function get_html( $key ) {
917
+ $lang = get_user_locale();
918
+ $link = $this->get_locale_paths( $lang );
919
+ $heading = apply_filters( $this->product->get_key() . '_feedback_translate_heading', $this->heading );
920
+ $product = $this->product->get_friendly_name();
921
+ $heading = str_replace(
922
+ array( '{product}' ),
923
+ $product, $heading
924
+ );
925
+
926
+ $message = apply_filters( $this->product->get_key() . '_feedback_translation', $this->msg );
927
+ $language_meta = $this->locales[ $lang ];
928
+ $message = str_replace( '{language}', $language_meta['name'], $message );
929
+ $message = str_replace( '{product}', $product, $message );
930
+ $button_cancel = apply_filters( $this->product->get_key() . '_feedback_translate_button_cancel', $this->button_cancel );
931
+ $button_do = apply_filters( $this->product->get_key() . '_feedback_translate_button_do', $this->button_do );
932
+
933
+ return '<div id="' . $this->product->get_key() . '-translate-notification" class="themeisle-sdk-translate-box">'
934
+ . '<h2>' . $heading . '</h2>'
935
+ . '<p>' . $message . '</p>'
936
+ . '<div class="actions">'
937
+ . '<a href="' . $link . '" target="_blank" class="button button-primary translate-dismiss"> ' . $button_do . '</a>&nbsp;'
938
+ . get_submit_button( $button_cancel, 'translate-dismiss ' . $this->product->get_key() . '-ti-translate', $this->product->get_key() . 'ti-translate-no', false )
939
+ . '</div></br></div>';
940
+ }
941
+
942
+ /**
943
+ * Called when the either button is clicked
944
+ */
945
+ function dismiss() {
946
+ check_ajax_referer( (string) __CLASS__, 'nonce' );
947
+
948
+ $this->disable();
949
+ }
950
+
951
+ /**
952
+ * Disables the notification
953
+ */
954
+ protected function disable() {
955
+
956
+ update_option( $this->product->get_key() . '_translate_flag', 'no' );
957
+ }
958
+
959
+ /**
960
+ * Enables the notification
961
+ */
962
+ protected function enable() {
963
+ update_option( $this->product->get_key() . '_translate_flag', 'yes' );
964
+ }
965
+ }
966
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-feedback.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The feedback model class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Feedback
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ if ( ! class_exists( 'ThemeIsle_SDK_Feedback' ) ) :
16
+ /**
17
+ * Feedback model for ThemeIsle SDK.
18
+ */
19
+ abstract class ThemeIsle_SDK_Feedback {
20
+ /**
21
+ * @var ThemeIsle_SDK_Product $product Themeisle Product.
22
+ */
23
+ protected $product;
24
+
25
+ /**
26
+ * @var string $feedback_url Url where to send the feedback
27
+ */
28
+ private $feedback_url = 'http://feedback.themeisle.com/wordpress/wp-json/__pirate_feedback_/v1/feedback';
29
+
30
+ /**
31
+ * ThemeIsle_SDK_Feedback constructor.
32
+ *
33
+ * @param ThemeIsle_SDK_Product $product_object Product Object.
34
+ */
35
+ public function __construct( $product_object ) {
36
+ if ( $product_object instanceof ThemeIsle_SDK_Product ) {
37
+ $this->product = $product_object;
38
+ }
39
+ $this->setup_hooks();
40
+ }
41
+
42
+ /**
43
+ * Registers the hooks and then delegates to the child
44
+ */
45
+ public function setup_hooks() {
46
+ $this->setup_hooks_child();
47
+ }
48
+
49
+ /**
50
+ * Calls the API
51
+ *
52
+ * @param string $attributes The attributes of the post body.
53
+ */
54
+ protected function call_api( $attributes ) {
55
+ $slug = $this->product->get_slug();
56
+ $version = $this->product->get_version();
57
+ $attributes['slug'] = $slug;
58
+ $attributes['version'] = $version;
59
+
60
+ $response = wp_remote_post(
61
+ $this->feedback_url, array(
62
+ 'body' => $attributes,
63
+ )
64
+ );
65
+ }
66
+
67
+ /**
68
+ * Randomizes the options array
69
+ *
70
+ * @param array $options The options array.
71
+ */
72
+ function randomize_options( $options ) {
73
+ $new = array();
74
+ $keys = array_keys( $options );
75
+ shuffle( $keys );
76
+
77
+ foreach ( $keys as $key ) {
78
+ $new[ $key ] = $options[ $key ];
79
+ }
80
+
81
+ return $new;
82
+ }
83
+
84
+ /**
85
+ * Abstract function for delegating to the child
86
+ */
87
+ protected abstract function setup_hooks_child();
88
+
89
+ }
90
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-licenser.php ADDED
@@ -0,0 +1,710 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The main loader class for license handling.
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Licenser
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ if ( ! class_exists( 'ThemeIsle_SDK_Licenser' ) ) :
12
+ /**
13
+ * Class ThemeIsle_SDK_Licenser
14
+ *
15
+ * Used to update the themeisle products
16
+ */
17
+ class ThemeIsle_SDK_Licenser {
18
+
19
+ /**
20
+ * @var string $license_key The license key string
21
+ */
22
+ public $license_key;
23
+
24
+ /**
25
+ * @var bool $do_check This ensures that the custom API request only runs on the second time that WP fires the update check
26
+ */
27
+ private $do_check = false;
28
+
29
+ /**
30
+ * @var bool $failed_checks Number of failed checks to the api endpoint
31
+ */
32
+ private $failed_checks = 0;
33
+ /**
34
+ * @var ThemeIsle_SDK_Product $product The ThemeIsle Product.
35
+ */
36
+ private $product;
37
+ /**
38
+ * @var string $product_key The product update response key.
39
+ */
40
+ private $product_key;
41
+ /**
42
+ * @var int $max_failed Maximum failed checks allowed before show the notice
43
+ */
44
+ private static $max_failed = 5;
45
+
46
+ /**
47
+ * ThemeIsle_SDK_Licenser constructor.
48
+ *
49
+ * @param ThemeIsle_SDK_Product $product The product object.
50
+ */
51
+ public function __construct( $product ) {
52
+ $this->product = $product;
53
+ $this->product_key = $this->product->get_key() . '-update-response';
54
+ if ( ! $this->product->requires_license() ) {
55
+ $this->license_key = 'free';
56
+ } else {
57
+ $license_data = get_option( $this->product->get_key() . '_license_data', '' );
58
+ $this->failed_checks = intval( get_option( $this->product->get_key() . '_failed_checks', 0 ) );
59
+ if ( $license_data !== '' ) {
60
+ $this->license_key = isset( $license_data->key ) ? $license_data->key : get_option( $this->product->get_key() . '_license', '' );
61
+ } else {
62
+ $this->license_key = get_option( $this->product->get_key() . '_license', '' );
63
+ }
64
+ $this->register_license_hooks();
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Register license hooks for the themeisle products
70
+ */
71
+ public function register_license_hooks() {
72
+ add_action( 'admin_init', array( $this, 'register_settings' ) );
73
+ add_action( 'admin_init', array( $this, 'activate_license' ) );
74
+ add_action( 'admin_init', array( $this, 'product_valid' ), 99999999 );
75
+ add_action( 'admin_notices', array( $this, 'show_notice' ) );
76
+ }
77
+
78
+ /**
79
+ * @param string $r Update payload.
80
+ * @param string $url The api url.
81
+ *
82
+ * @return mixed List of themes to check for update.
83
+ */
84
+ function disable_wporg_update( $r, $url ) {
85
+
86
+ if ( 0 !== strpos( $url, 'https://api.wordpress.org/themes/update-check/' ) ) {
87
+ return $r;
88
+ }
89
+
90
+ // Decode the JSON response
91
+ $themes = json_decode( $r['body']['themes'] );
92
+
93
+ unset( $themes->themes->{$this->product->get_slug()} );
94
+
95
+ // Encode the updated JSON response
96
+ $r['body']['themes'] = json_encode( $themes );
97
+
98
+ return $r;
99
+ }
100
+
101
+ /**
102
+ * Register the setting for the license of the product
103
+ *
104
+ * @return bool
105
+ */
106
+ public function register_settings() {
107
+ if ( ! is_admin() ) {
108
+ return false;
109
+ }
110
+ add_settings_field(
111
+ $this->product->get_key() . '_license',
112
+ $this->product->get_name() . ' license',
113
+ array( $this, 'license_view' ),
114
+ 'general'
115
+ );
116
+ }
117
+
118
+ /**
119
+ * The license view field
120
+ */
121
+ public function license_view() {
122
+ $status = $this->get_license_status();
123
+ $value = $this->license_key;
124
+
125
+ $activate_string = apply_filters( $this->product->get_key() . '_lc_activate_string', 'Activate' );
126
+ $deactivate_string = apply_filters( $this->product->get_key() . '_lc_deactivate_string', 'Deactivate' );
127
+ $valid_string = apply_filters( $this->product->get_key() . '_lc_valid_string', 'Valid' );
128
+ $invalid_string = apply_filters( $this->product->get_key() . '_lc_invalid_string', 'Invalid' );
129
+ $license_message = apply_filters( $this->product->get_key() . '_lc_license_message', 'Enter your license from %s purchase history in order to get %s updates' );
130
+
131
+ echo '<p ><input ' . ( ( $status === 'valid' ) ? ( 'style="border:1px solid #7ad03a; "' ) : '' ) . ' type="text" id="' . $this->product->get_key() . '_license" name="' . $this->product->get_key() . '_license" value="' . $value . '" /><a ' . ( ( $status === 'valid' ) ? ( 'style="color:#fff;background: #7ad03a; display: inline-block;text-decoration: none;font-size: 13px;line-height: 26px;height: 26px; margin-left:5px; padding: 0 10px 1px; -webkit-border-radius: 3px;border-radius: 3px; ">' . $valid_string ) : ( 'style="color:#fff;background: #dd3d36; display: inline-block;text-decoration: none;font-size: 13px;line-height: 26px;height: 26px; margin-left:5px; padding: 0 10px 1px; -webkit-border-radius: 3px;border-radius: 3px; ">' . $invalid_string ) ) . ' </a>&nbsp;&nbsp;&nbsp;<button name="' . $this->product->get_key() . '_btn_trigger" ' . ( ( $status === 'valid' ) ? ( ' class="button button-primary">' . $deactivate_string ) : ( ' class="button button-primary" value="yes" type="submit" >' . $activate_string ) ) . ' </button></p><p class="description">' . sprintf( $license_message, '<a href="' . $this->product->get_store_url() . '">' . $this->product->get_store_name() . '</a> ', $this->product->get_type() ) . '</p>';
132
+
133
+ }
134
+
135
+ /**
136
+ * Return the license status.
137
+ *
138
+ * @return string The License status.
139
+ */
140
+ public function get_license_status() {
141
+ $license_data = get_option( $this->product->get_key() . '_license_data', '' );
142
+ if ( $license_data !== '' ) {
143
+ return isset( $license_data->license ) ? $license_data->license : get_option( $this->product->get_key() . '_license_status', 'not_active' );
144
+ } else {
145
+ return get_option( $this->product->get_key() . '_license_status', 'not_active' );
146
+ }
147
+
148
+ }
149
+
150
+ /**
151
+ * Check if the license is active or not
152
+ *
153
+ * @return bool
154
+ */
155
+ public function check_activation() {
156
+ $license_data = get_option( $this->product->get_key() . '_license_data', '' );
157
+ if ( $license_data !== '' ) {
158
+ return isset( $license_data->error ) ? ( $license_data->error == 'no_activations_left' ) : false;
159
+ }
160
+
161
+ return false;
162
+ }
163
+
164
+ /**
165
+ * Check if the license is about to expire in the next month
166
+ *
167
+ * @return bool
168
+ */
169
+ function check_expiration() {
170
+ $license_data = get_option( $this->product->get_key() . '_license_data', '' );
171
+ if ( $license_data !== '' ) {
172
+ if ( isset( $license_data->expires ) ) {
173
+ if ( strtotime( $license_data->expires ) - time() < 30 * 24 * 3600 ) {
174
+ return true;
175
+ }
176
+ }
177
+ }
178
+
179
+ return false;
180
+ }
181
+
182
+ /**
183
+ * Return the renew url from the store used
184
+ *
185
+ * @return string The renew url.
186
+ */
187
+ function renew_url() {
188
+ $license_data = get_option( $this->product->get_key() . '_license_data', '' );
189
+ if ( $license_data !== '' ) {
190
+ if ( isset( $license_data->download_id ) && isset( $license_data->key ) ) {
191
+ return $this->product->get_store_url() . '/checkout/?edd_license_key=' . $license_data->key . '&download_id=' . $license_data->download_id;
192
+ }
193
+ }
194
+
195
+ return $this->product->get_store_url();
196
+ }
197
+
198
+ /**
199
+ * Check if we hide the notificatin nag or not
200
+ *
201
+ * @param string $hide The notification to hide.
202
+ *
203
+ * @return bool Either hide them or not.
204
+ */
205
+ function check_hide( $hide ) {
206
+ if ( isset( $_GET[ $this->product->get_key() . '_hide_' . $hide ] ) ) {
207
+ if ( $_GET[ $this->product->get_key() . '_hide_' . $hide ] === 'yes' ) {
208
+ update_option( $this->product->get_key() . '_hide_' . $hide, 'yes' );
209
+
210
+ return false;
211
+ }
212
+ } else {
213
+ $license = get_option( $this->product->get_key() . '_hide_' . $hide, '' );
214
+ if ( $license === 'yes' ) {
215
+ return false;
216
+ }
217
+ }
218
+
219
+ return true;
220
+ }
221
+
222
+ /**
223
+ * Show the admin notice regarding the license status
224
+ *
225
+ * @return bool
226
+ */
227
+ function show_notice() {
228
+ if ( ! is_admin() ) {
229
+ return false;
230
+ }
231
+ $status = $this->get_license_status();
232
+ $no_activations_string = apply_filters(
233
+ $this->product->get_key() . '_lc_no_activations_string', 'No activations left for %s !!!. You need to
234
+ upgrade your plan in order to use %s on more
235
+ websites. Please ask the %s
236
+ Staff for more details.'
237
+ );
238
+ $no_valid_string = apply_filters(
239
+ $this->product->get_key() . '_lc_no_valid_string', 'In order to benefit from updates and support for %s , please add
240
+ your license code from your <a href="%s" target="_blank">purchase history</a> and validate it <a
241
+ href="%s">here</a> '
242
+ );
243
+ $expiration_string = apply_filters(
244
+ $this->product->get_key() . '_lc_expiration_string', 'Your license is about to expire
245
+ for %s. You can go to %s and renew it '
246
+ );
247
+ $hide_notice_string = apply_filters( $this->product->get_key() . '_lc_hide_notice_string', 'Hide Notice' );
248
+ if ( $status != 'valid' ) {
249
+ if ( $this->check_activation() ) {
250
+ if ( $this->check_hide( 'activation' ) ) {
251
+ ?>
252
+ <div class="error">
253
+ <p><strong>
254
+ <?php
255
+ echo sprintf(
256
+ $no_activations_string, $this->product->get_name(), $this->product->get_name(), '<a href="' . $this->product->get_store_url() . '"
257
+ target="_blank">' . $this->product->get_store_name() . '</a>'
258
+ );
259
+ ?>
260
+ </strong> | <a
261
+ href="<?php echo add_query_arg( $this->product->get_key() . '_activation', 'yes' ); ?> "><?php echo $hide_notice_string; ?></a>
262
+ </p>
263
+ </div>
264
+ <?php
265
+ return false;
266
+ }
267
+ }
268
+ ?>
269
+ <?php if ( $this->check_hide( 'valid' ) ) : ?>
270
+ <div class="error">
271
+ <p>
272
+ <strong><?php echo sprintf( $no_valid_string, $this->product->get_name() . ' ' . $this->product->get_type(), $this->product->get_store_url(), admin_url( 'options-general.php' ) . '#' . $this->product->get_key() ); ?> </strong>|
273
+ <a
274
+ href="<?php echo add_query_arg( $this->product->get_key() . '_hide_valid', 'yes' ); ?> "><?php echo $hide_notice_string; ?></a>
275
+ </p>
276
+ </div>
277
+ <?php endif; ?>
278
+ <?php
279
+ } else {
280
+ if ( $this->check_expiration() ) {
281
+ if ( $this->check_hide( 'expiration' ) ) {
282
+ ?>
283
+ <div class="update-nag">
284
+ <p>
285
+ <strong>
286
+ <?php
287
+ echo sprintf(
288
+ $expiration_string, $this->product->get_name() . ' ' . $this->product->get_type(), '<a
289
+ href="' . $this->renew_url() . '"
290
+ target="_blank">' . $this->product->get_store_name() . '</a>'
291
+ );
292
+ ?>
293
+ </strong> |
294
+ <a
295
+ href="<?php echo add_query_arg( $this->product->get_key() . '_hide_expiration', 'yes' ); ?> "><?php echo $hide_notice_string; ?></a>
296
+ </p>
297
+ </div>
298
+ <?php
299
+ }
300
+ }
301
+ }
302
+ }
303
+
304
+ /**
305
+ * Run the license check call
306
+ */
307
+ public function product_valid() {
308
+ if ( false === ( $license = get_transient( $this->product->get_key() . '_license_data' ) ) ) {
309
+ $license = $this->check_license();
310
+ set_transient( $this->product->get_key() . '_license_data', $license, 12 * HOUR_IN_SECONDS );
311
+ update_option( $this->product->get_key() . '_license_data', $license );
312
+ }
313
+
314
+ }
315
+
316
+ /**
317
+ * Increment the failed checks
318
+ */
319
+ private function increment_failed_checks() {
320
+ $this->failed_checks ++;
321
+ update_option( $this->product->get_key() . '_failed_checks', $this->failed_checks );
322
+ }
323
+
324
+ /**
325
+ * Reset the failed checks
326
+ */
327
+ private function reset_failed_checks() {
328
+ $this->failed_checks = 1;
329
+ update_option( $this->product->get_key() . '_failed_checks', $this->failed_checks );
330
+ }
331
+
332
+ /**
333
+ * Check the license status
334
+ *
335
+ * @return object The license data.
336
+ */
337
+ public function check_license() {
338
+ $status = $this->get_license_status();
339
+ if ( $status == 'not_active' ) {
340
+ $license_data = new stdClass();
341
+ $license_data->license = 'not_active';
342
+
343
+ return $license_data;
344
+ }
345
+ $license = trim( $this->license_key );
346
+ $api_params = array(
347
+ 'edd_action' => 'check_license',
348
+ 'license' => $license,
349
+ 'item_name' => rawurlencode( $this->product->get_name() ),
350
+ 'url' => rawurlencode( home_url() ),
351
+ );
352
+ // Call the custom API.
353
+ $response = wp_remote_get(
354
+ add_query_arg( $api_params, $this->product->get_store_url() ), array(
355
+ 'timeout' => 15,
356
+ 'sslverify' => false,
357
+ )
358
+ );
359
+ if ( is_wp_error( $response ) ) {
360
+ $license_data = new stdClass();
361
+ $license_data->license = 'valid';
362
+
363
+ } else {
364
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
365
+ if ( ! is_object( $license_data ) ) {
366
+ $license_data = new stdClass();
367
+ $license_data->license = 'valid';
368
+ }
369
+ }
370
+ $license_old = get_option( $this->product->get_key() . '_license_data', '' );
371
+ if ( $license_old->license == 'valid' && ( $license_data->license != $license_old->license ) ) {
372
+ $this->increment_failed_checks();
373
+ } else {
374
+ $this->reset_failed_checks();
375
+ }
376
+
377
+ if ( $this->failed_checks <= self::$max_failed ) {
378
+ return $license_old;
379
+ }
380
+
381
+ if ( isset( $license_old->hide_valid ) ) {
382
+ $license_data->hide_valid = true;
383
+ }
384
+
385
+ if ( ! isset( $license_data->key ) ) {
386
+ $license_data->key = isset( $license_old->key ) ? $license_old->key : '';
387
+ }
388
+
389
+ if ( isset( $license_old->hide_expiration ) ) {
390
+ $license_data->hide_expiration = true;
391
+ }
392
+
393
+ if ( isset( $license_old->hide_activation ) ) {
394
+ $license_data->hide_activation = true;
395
+ }
396
+
397
+ return $license_data;
398
+
399
+ }
400
+
401
+ /**
402
+ * Activate the license remotely
403
+ */
404
+ function activate_license() {
405
+ // listen for our activate button to be clicked
406
+ if ( isset( $_POST[ $this->product->get_key() . '_btn_trigger' ] ) ) {
407
+ $status = $this->get_license_status();
408
+ // retrieve the license from the database
409
+ $license = $_POST[ $this->product->get_key() . '_license' ];
410
+ $api_params = array(
411
+ 'license' => $license,
412
+ 'item_name' => rawurlencode( $this->product->get_name() ),
413
+ 'url' => rawurlencode( home_url() ),
414
+ );
415
+ if ( $status != 'valid' ) {
416
+ // data to send in our API request
417
+ $api_params['edd_action'] = 'activate_license';
418
+ } else {
419
+ $api_params['edd_action'] = 'deactivate_license';
420
+ }
421
+ // Call the custom API.
422
+ $response = wp_remote_get( add_query_arg( $api_params, $this->product->get_store_url() ) );
423
+ // make sure the response came back okay
424
+ if ( is_wp_error( $response ) ) {
425
+ $license_data = new stdClass();
426
+ $license_data->license = ( $status != 'valid' ) ? 'valid' : 'invalid';
427
+
428
+ } else {
429
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
430
+ if ( ! is_object( $license_data ) ) {
431
+ $license_data = new stdClass();
432
+ $license_data->license = ( $status != 'valid' ) ? 'valid' : 'invalid';
433
+ }
434
+ }
435
+ if ( ! isset( $license_data->key ) ) {
436
+ $license_data->key = $license;
437
+ }
438
+ if ( $license_data->license == 'valid' ) {
439
+ $this->reset_failed_checks();
440
+ }
441
+
442
+ if ( isset( $license_data->plan ) ) {
443
+ update_option( $this->product->get_key() . '_license_plan', $license_data->plan );
444
+ }
445
+
446
+ update_option( $this->product->get_key() . '_license_data', $license_data );
447
+ delete_transient( $this->product->get_key() . '_license_data' );
448
+ set_transient( $this->product->get_key() . '_license_data', $license_data, 12 * HOUR_IN_SECONDS );
449
+
450
+ }
451
+ }
452
+
453
+ /**
454
+ * Enable the license system
455
+ */
456
+ public function enable() {
457
+ if ( $this->product->get_type() == 'plugin' ) {
458
+ add_filter(
459
+ 'pre_set_site_transient_update_plugins', array(
460
+ $this,
461
+ 'pre_set_site_transient_update_plugins_filter',
462
+ )
463
+ );
464
+ add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
465
+ add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 );
466
+ }
467
+ if ( $this->product->get_type() == 'theme' ) {
468
+ add_filter( 'site_transient_update_themes', array( &$this, 'theme_update_transient' ) );
469
+ add_filter( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) );
470
+ add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) );
471
+ add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) );
472
+ add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) );
473
+ add_filter( 'http_request_args', array( $this, 'disable_wporg_update' ), 5, 2 );
474
+
475
+ }
476
+
477
+ }
478
+
479
+ /**
480
+ * Load the Themes screen
481
+ */
482
+ function load_themes_screen() {
483
+ add_thickbox();
484
+ add_action( 'admin_notices', array( &$this, 'update_nag' ) );
485
+ }
486
+
487
+ /**
488
+ * Alter the nag for themes update
489
+ */
490
+ function update_nag() {
491
+ $theme = wp_get_theme( $this->product->get_slug() );
492
+ $api_response = get_transient( $this->product_key );
493
+ if ( false === $api_response ) {
494
+ return;
495
+ }
496
+ $update_url = wp_nonce_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $this->product->get_slug() ), 'upgrade-theme_' . $this->product->get_slug() );
497
+ $update_message = apply_filters( 'themeisle_sdk_license_update_message', 'Updating this theme will lose any customizations you have made. Cancel to stop, OK to update.' );
498
+ $update_onclick = ' onclick="if ( confirm(\'' . esc_js( $update_message ) . '\') ) {return true;}return false;"';
499
+ if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) {
500
+ echo '<div id="update-nag">';
501
+ printf(
502
+ '<strong>%1$s %2$s</strong> is available. <a href="%3$s" class="thickbox" title="%4s">Check out what\'s new</a> or <a href="%5$s"%6$s>update now</a>.',
503
+ $theme->get( 'Name' ),
504
+ $api_response->new_version,
505
+ '#TB_inline?width=640&amp;inlineId=' . $this->product->get_version() . '_changelog',
506
+ $theme->get( 'Name' ),
507
+ $update_url,
508
+ $update_onclick
509
+ );
510
+ echo '</div>';
511
+ echo '<div id="' . $this->product->get_slug() . '_' . 'changelog" style="display:none;">';
512
+ echo wpautop( $api_response->sections['changelog'] );
513
+ echo '</div>';
514
+ }
515
+ }
516
+
517
+ /**
518
+ * @param mixed $value The transient data.
519
+ *
520
+ * @return mixed
521
+ */
522
+ function theme_update_transient( $value ) {
523
+ $update_data = $this->check_for_update();
524
+ if ( $update_data ) {
525
+ $value->response[ $this->product->get_slug() ] = $update_data;
526
+ }
527
+
528
+ return $value;
529
+ }
530
+
531
+ /**
532
+ * Delete the update transient
533
+ */
534
+ function delete_theme_update_transient() {
535
+ delete_transient( $this->product_key );
536
+ }
537
+
538
+ /**
539
+ * Check for updates
540
+ *
541
+ * @return array|bool Either the update data or false in case of failure
542
+ */
543
+ function check_for_update() {
544
+ $theme = wp_get_theme( $this->product->get_slug() );
545
+ $update_data = get_transient( $this->product_key );
546
+ if ( false === $update_data ) {
547
+ $failed = false;
548
+ if ( empty( $this->license_key ) ) {
549
+ return false;
550
+ }
551
+ $api_params = array(
552
+ 'edd_action' => 'get_version',
553
+ 'version' => $this->product->get_version(),
554
+ 'license' => $this->license_key,
555
+ 'name' => $this->product->get_name(),
556
+ 'slug' => $this->product->get_slug(),
557
+ 'author' => $this->product->get_store_name(),
558
+ 'url' => rawurlencode( home_url() ),
559
+ );
560
+ $response = wp_remote_post(
561
+ $this->product->get_store_url(), array(
562
+ 'timeout' => 15,
563
+ 'sslverify' => false,
564
+ 'body' => $api_params,
565
+ )
566
+ );
567
+ // make sure the response was successful
568
+ if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
569
+ $failed = true;
570
+ }
571
+ $update_data = json_decode( wp_remote_retrieve_body( $response ) );
572
+ if ( ! is_object( $update_data ) ) {
573
+ $failed = true;
574
+ }
575
+ // if the response failed, try again in 30 minutes
576
+ if ( $failed ) {
577
+ $data = new stdClass;
578
+ $data->new_version = $this->product->get_version();
579
+ set_transient( $this->product_key, $data, strtotime( '+30 minutes' ) );
580
+
581
+ return false;
582
+ }
583
+ // if the status is 'ok', return the update arguments
584
+ if ( ! $failed ) {
585
+ $update_data->sections = maybe_unserialize( $update_data->sections );
586
+ set_transient( $this->product_key, $update_data, strtotime( '+12 hours' ) );
587
+ }
588
+ }
589
+ if ( version_compare( $this->product->get_version(), $update_data->new_version, '>=' ) ) {
590
+ return false;
591
+ }
592
+
593
+ return (array) $update_data;
594
+ }
595
+
596
+ /**
597
+ * Check for Updates at the defined API endpoint and modify the update array.
598
+ *
599
+ * This function dives into the update API just when WordPress creates its update array,
600
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
601
+ * It is reassembled from parts of the native WordPress plugin update code.
602
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
603
+ *
604
+ * @uses api_request()
605
+ *
606
+ * @param array $_transient_data Update array build by WordPress.
607
+ *
608
+ * @return array Modified update array with custom plugin data.
609
+ */
610
+ public function pre_set_site_transient_update_plugins_filter( $_transient_data ) {
611
+ if ( empty( $_transient_data ) || ! $this->do_check ) {
612
+ $this->do_check = true;
613
+
614
+ return $_transient_data;
615
+ }
616
+ $api_response = $this->api_request();
617
+ if ( false !== $api_response && is_object( $api_response ) && isset( $api_response->new_version ) ) {
618
+ if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) {
619
+ $_transient_data->response[ $this->product->get_slug() . '/' . $this->product->get_file() ] = $api_response;
620
+ }
621
+ }
622
+
623
+ return $_transient_data;
624
+ }
625
+
626
+ /**
627
+ * Calls the API and, if successfull, returns the object delivered by the API.
628
+ *
629
+ * @uses get_bloginfo()
630
+ * @uses wp_remote_post()
631
+ * @uses is_wp_error()
632
+ *
633
+ * @param string $_action The requested action.
634
+ * @param array $_data Parameters for the API action.
635
+ *
636
+ * @return false||object
637
+ */
638
+ private function api_request( $_action = '', $_data = '' ) {
639
+ if ( empty( $this->license_key ) ) {
640
+ return;
641
+ }
642
+ $api_params = array(
643
+ 'edd_action' => 'get_version',
644
+ 'license' => $this->license_key,
645
+ 'name' => rawurlencode( $this->product->get_name() ),
646
+ 'slug' => rawurlencode( $this->product->get_slug() ),
647
+ 'author' => $this->product->get_store_name(),
648
+ 'url' => rawurlencode( home_url() ),
649
+ );
650
+ $request = wp_remote_post(
651
+ $this->product->get_store_url(), array(
652
+ 'timeout' => 15,
653
+ 'sslverify' => false,
654
+ 'body' => $api_params,
655
+ )
656
+ );
657
+ if ( ! is_wp_error( $request ) ) :
658
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
659
+ if ( $request && isset( $request->sections ) ) {
660
+ $request->sections = maybe_unserialize( $request->sections );
661
+ }
662
+
663
+ return $request;
664
+ else :
665
+ return false;
666
+ endif;
667
+ }
668
+
669
+ /**
670
+ * Updates information on the "View version x.x details" page with custom data.
671
+ *
672
+ * @uses api_request()
673
+ *
674
+ * @param mixed $_data Plugin data.
675
+ * @param string $_action Action to send.
676
+ * @param object $_args Arguments to use.
677
+ *
678
+ * @return object $_data
679
+ */
680
+ public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
681
+ if ( ( $_action != 'plugin_information' ) || ! isset( $_args->slug ) || ( $_args->slug != $this->product->get_slug() ) ) {
682
+ return $_data;
683
+ }
684
+ $api_response = $this->api_request();
685
+ if ( false !== $api_response ) {
686
+ $_data = $api_response;
687
+ }
688
+
689
+ return $_data;
690
+ }
691
+
692
+ /**
693
+ * Disable SSL verification in order to prevent download update failures
694
+ *
695
+ * @param array $args Http args.
696
+ * @param string $url Url to check.
697
+ *
698
+ * @return object $array
699
+ */
700
+ function http_request_args( $args, $url ) {
701
+ // If it is an https request and we are performing a package download, disable ssl verification
702
+ if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
703
+ $args['sslverify'] = false;
704
+ }
705
+
706
+ return $args;
707
+ }
708
+
709
+ }
710
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-loader.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The main loader class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Loader
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ if ( ! class_exists( 'ThemeIsle_SDK_Loader' ) ) :
16
+ /**
17
+ * Singleton loader for ThemeIsle SDK.
18
+ */
19
+ final class ThemeIsle_SDK_Loader {
20
+ /**
21
+ * @var ThemeIsle_SDK_Loader instance The singleton instance
22
+ */
23
+ private static $instance;
24
+ /**
25
+ * @var string $version The class version.
26
+ */
27
+ private static $version = '1.0.0';
28
+ /**
29
+ * @var array The products which use the SDK.
30
+ */
31
+ private static $products;
32
+
33
+ /**
34
+ * Register product into SDK.
35
+ *
36
+ * @param string $basefile The product basefile.
37
+ *
38
+ * @return ThemeIsle_SDK_Loader The singleton object.
39
+ */
40
+ public static function init_product( $basefile ) {
41
+
42
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof ThemeIsle_SDK_Loader ) ) {
43
+ self::$instance = new ThemeIsle_SDK_Loader;
44
+
45
+ }
46
+ $product_object = new ThemeIsle_SDK_Product( $basefile );
47
+ self::$products[ $product_object->get_slug() ] = $product_object;
48
+
49
+ $notifications = array();
50
+ // Based on the WordPress Available file header we enable the logger or not.
51
+ if ( ! $product_object->is_wordpress_available() ) {
52
+ $licenser = new ThemeIsle_SDK_Licenser( $product_object );
53
+ $licenser->enable();
54
+ }
55
+
56
+ $logger = new ThemeIsle_SDK_Logger( $product_object );
57
+ if ( $product_object->is_logger_active() ) {
58
+ $logger->enable();
59
+ } else {
60
+ $notifications[] = $logger;
61
+ }
62
+
63
+ $feedback = new ThemeIsle_SDK_Feedback_Factory( $product_object, $product_object->get_feedback_types() );
64
+
65
+ $instances = $feedback->get_instances();
66
+ if ( array_key_exists( 'review', $instances ) ) {
67
+ $notifications[] = $instances['review'];
68
+ }
69
+ if ( array_key_exists( 'translate', $instances ) ) {
70
+ $notifications[] = $instances['translate'];
71
+ }
72
+ new ThemeIsle_SDK_Notification_Manager( $product_object, $notifications );
73
+ if ( ! $product_object->is_external_author() ) {
74
+ new ThemeIsle_SDK_Widgets_Factory( $product_object, $product_object->get_widget_types() );
75
+ }
76
+ if ( ! $product_object->is_external_author() ) {
77
+ new ThemeIsle_SDK_Rollback( $product_object );
78
+ }
79
+ return self::$instance;
80
+ }
81
+
82
+ /**
83
+ * Get all products using the SDK.
84
+ *
85
+ * @return array Products available.
86
+ */
87
+ public static function get_products() {
88
+ return self::$products;
89
+ }
90
+
91
+
92
+ }
93
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-logger.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The main loader class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Logger
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ if ( ! class_exists( 'ThemeIsle_SDK_Logger' ) ) :
12
+ /**
13
+ * Class ThemeIsle_SDK_Logger
14
+ *
15
+ * Send the statistics to the Themeisle Endpoint
16
+ */
17
+ /**
18
+ * Class ThemeIsle_SDK_Logger
19
+ */
20
+ class ThemeIsle_SDK_Logger {
21
+
22
+ /**
23
+ * @var string $logging_url Url where to send the logs
24
+ */
25
+ private $logging_url = 'http://log.themeisle.com/wp-json/v1/logs/';
26
+
27
+ /**
28
+ * @var ThemeIsle_SDK_Product $product Themeisle Product.
29
+ */
30
+ private $product;
31
+
32
+ /**
33
+ * @var string $product_cron Cron name handler
34
+ */
35
+ private $product_cron;
36
+
37
+ /**
38
+ * @var string $heading The heading of the modal
39
+ */
40
+ private $heading = 'Do you enjoy <b>{product}</b>? Become a contributor by opting in to our anonymous data tracking. We guarantee no sensitive data is collected.';
41
+
42
+ /**
43
+ * @var string $button_submit The text of the submit button
44
+ */
45
+ private $button_submit = 'Sure, I would love to help.';
46
+
47
+ /**
48
+ * @var string $button_cancel The text of the cancel button
49
+ */
50
+ private $button_cancel = 'No, thanks.';
51
+
52
+ /**
53
+ * ThemeIsle_SDK_Logger constructor.
54
+ *
55
+ * @param ThemeIsle_SDK_Product $product_object Product Object.
56
+ */
57
+ public function __construct( $product_object ) {
58
+ if ( $product_object instanceof ThemeIsle_SDK_Product ) {
59
+ $this->product = $product_object;
60
+ $this->product_cron = $product_object->get_key() . '_log_activity';
61
+ }
62
+ add_action( 'wp_ajax_' . $this->product->get_key() . __CLASS__, array( $this, 'dismiss' ) );
63
+ }
64
+
65
+
66
+ /**
67
+ * Start the cron to send the log. It will randomize the interval in order to not send all the logs at the same time.
68
+ */
69
+ public function enable() {
70
+ if ( ! wp_next_scheduled( $this->product_cron ) ) {
71
+ wp_schedule_single_event( time() + ( rand( 15, 24 ) * 3600 ), $this->product_cron );
72
+ }
73
+ add_action( $this->product_cron, array( $this, 'send_log' ) );
74
+ }
75
+
76
+ /**
77
+ * Send the statistics to the api endpoint
78
+ */
79
+ public function send_log() {
80
+ wp_remote_post(
81
+ $this->logging_url, array(
82
+ 'method' => 'POST',
83
+ 'timeout' => 3,
84
+ 'redirection' => 5,
85
+ 'headers' => array(
86
+ 'X-ThemeIsle-Event' => 'log_site',
87
+ ),
88
+ 'body' => array(
89
+ 'site' => get_site_url(),
90
+ 'slug' => $this->product->get_slug(),
91
+ 'version' => $this->product->get_version(),
92
+ 'data' => apply_filters( $this->product->get_key() . '_logger_data', array() ),
93
+ ),
94
+ )
95
+ );
96
+ }
97
+
98
+ /**
99
+ * Dismiss the notification
100
+ */
101
+ function dismiss() {
102
+ check_ajax_referer( (string) __CLASS__, 'nonce' );
103
+
104
+ $flag = intval( $_POST['enable'] ) === 1;
105
+ update_option( $this->product->logger_option, ( $flag ? 'yes' : 'no' ) );
106
+
107
+ if ( true === $flag ) {
108
+ $this->enable();
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Either we should show the notification or not.
114
+ *
115
+ * @return bool Valida notification.
116
+ */
117
+ function can_notify() {
118
+ $show = $this->product->is_logger_active();
119
+ $checked = get_option( $this->product->logger_option, '' );
120
+ if ( ! $show && $checked == '' ) {
121
+ return true;
122
+ }
123
+
124
+ return false;
125
+ }
126
+
127
+ /**
128
+ * Shows the notification
129
+ */
130
+ function show_notification() {
131
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
132
+ }
133
+
134
+ /**
135
+ * Shows the admin notice
136
+ */
137
+ function admin_notices() {
138
+ $id = $this->product->get_key() . '_logger';
139
+
140
+ $this->add_media( $this->product->get_key() );
141
+
142
+ echo '<div class="notice notice-success is-dismissible " id="' . $this->product->get_key() . '-logger-notification" ><div id="' . $id . '" class="themeisle-logger-box">' . $this->get_html( $this->product->get_key() ) . '</div></div>';
143
+ }
144
+
145
+ /**
146
+ * Generates the HTML
147
+ *
148
+ * @param string $key The product key.
149
+ */
150
+ function get_html( $key ) {
151
+ $heading = apply_filters( $this->product->get_key() . '_logger_heading', $this->heading );
152
+ $heading = str_replace(
153
+ array( '{product}' ), array(
154
+ trim( str_replace( 'Lite', '', $this->product->get_name() ) ),
155
+ ),
156
+ $heading
157
+ );
158
+ $button_submit = apply_filters( $this->product->get_key() . '_logger_button_submit', $this->button_submit );
159
+ $button_cancel = apply_filters( $this->product->get_key() . '_logger_button_cancel', $this->button_cancel );
160
+
161
+ return '<div >'
162
+ . '<p>' . $heading . '</p>'
163
+ . '<div class="actions">'
164
+ . get_submit_button(
165
+ $button_submit, 'primary ' . $this->product->get_key() . '-ti-logger', $this->product->get_key() . 'ti-logger-yes', false, array(
166
+ 'data-ti-log-enable' => 1,
167
+ )
168
+ )
169
+ . get_submit_button(
170
+ $button_cancel, 'secondary ' . $this->product->get_key() . '-ti-logger', $this->product->get_key() . 'ti-logger-no', false, array(
171
+ 'data-ti-log-enable' => 0,
172
+ )
173
+ )
174
+ . '</div></div>';
175
+ }
176
+
177
+ /**
178
+ * Loads the js
179
+ *
180
+ * @param string $key The product key.
181
+ */
182
+ function add_media( $key ) {
183
+ ?>
184
+ <style type="text/css">
185
+ #<?php echo $key; ?>-logger-notification {
186
+ padding-bottom: 5px;
187
+ }
188
+
189
+ #<?php echo $key; ?>-logger-notification .button {
190
+ margin-left: 5px;
191
+ }
192
+ </style>
193
+ <script type="text/javascript" id="<?php echo $key; ?>ti-logger-js">
194
+ (function ($) {
195
+ $(document).ready(function () {
196
+ $('.<?php echo $key; ?>-ti-logger').on('click', function (e) {
197
+
198
+ $.ajax({
199
+ url: ajaxurl,
200
+ method: "post",
201
+ data: {
202
+ 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>',
203
+ 'action': '<?php echo $this->product->get_key() . __CLASS__; ?>',
204
+ 'enable': $(this).attr('data-ti-log-enable')
205
+ },
206
+ success: function () {
207
+ $('#<?php echo $key; ?>-logger-notification').hide();
208
+ }
209
+ });
210
+ });
211
+ });
212
+ })(jQuery);
213
+ </script>
214
+ <?php
215
+ }
216
+
217
+ }
218
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-notification-manager.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The notification manager class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Notification
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ if ( ! class_exists( 'ThemeIsle_SDK_Notification_Manager' ) ) :
16
+ /**
17
+ * Notification manager model for ThemeIsle SDK.
18
+ */
19
+ class ThemeIsle_SDK_Notification_Manager {
20
+ /**
21
+ * Time between notifications.
22
+ */
23
+ const NOTIFICATION_INTERVAL_HOURS = 100;
24
+ /**
25
+ * @var array Notifications for the current product.
26
+ */
27
+ static private $notifications = array();
28
+ /**
29
+ * @var ThemeIsle_SDK_Product Current product.
30
+ */
31
+ private $product;
32
+ /**
33
+ * @var array ThemeIsle_SDK_Feedback Feedbacks available.
34
+ */
35
+ private $callbacks = array();
36
+
37
+ /**
38
+ * ThemeIsle_SDK_Notification_Manager constructor.
39
+ *
40
+ * @param ThemeIsle_SDK_Product $product_object Product Object.
41
+ * @param array $callbacks the objects that will be called when a notification is due.
42
+ */
43
+ public function __construct( $product_object, $callbacks ) {
44
+ $this->product = $product_object;
45
+ $this->callbacks = $callbacks;
46
+ $this->setup_hooks();
47
+ }
48
+
49
+ /**
50
+ * Setup the notifications.
51
+ */
52
+ function setup_notifications() {
53
+ if ( ! current_user_can( 'manage_options' ) ) {
54
+ return;
55
+ }
56
+ // Load the notifications only if we have it installed after the required interval.
57
+ if ( ( time() - $this->product->get_install_time() ) > self::NOTIFICATION_INTERVAL_HOURS * HOUR_IN_SECONDS ) {
58
+ if ( $this->product instanceof ThemeIsle_SDK_Product && $this->callbacks && is_array( $this->callbacks ) ) {
59
+ foreach ( $this->callbacks as $instance ) {
60
+ self::$notifications[ $this->product->get_key() . get_class( $instance ) ] = $instance;
61
+ }
62
+ }
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Setup the internal hooks
68
+ */
69
+ private function setup_hooks() {
70
+ add_action( 'admin_head', array( $this, 'show_notification' ) );
71
+ add_action( 'admin_init', array( $this, 'setup_notifications' ) );
72
+ }
73
+
74
+ /**
75
+ * Shows the notification
76
+ */
77
+ function show_notification() {
78
+ $instances = self::$notifications;
79
+ if ( empty( $instances ) ) {
80
+ return;
81
+ }
82
+
83
+ $available = array_keys( $instances );
84
+ $active = get_option( 'themeisle_sdk_active_notification', array() );
85
+
86
+ foreach ( $available as $key ) {
87
+ $instance = $instances[ $key ];
88
+ if ( $instance->can_notify() ) {
89
+
90
+ // Detect notification switch.
91
+ if ( empty( $active['key'] ) || ( $active['key'] != $key ) ) {
92
+ $active['key'] = $key;
93
+ $active['time'] = time();
94
+ update_option( 'themeisle_sdk_active_notification', $active );
95
+ }
96
+ if ( ( time() - $active['time'] ) > ( self::NOTIFICATION_INTERVAL_HOURS * HOUR_IN_SECONDS ) ) {
97
+ $instance->show_notification();
98
+ }
99
+ break;
100
+ }
101
+ }
102
+
103
+ }
104
+ }
105
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-product.php ADDED
@@ -0,0 +1,555 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The product model class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Product
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ if ( ! class_exists( 'ThemeIsle_SDK_Product' ) ) :
16
+ /**
17
+ * Product model for ThemeIsle SDK.
18
+ */
19
+ class ThemeIsle_SDK_Product {
20
+ /**
21
+ * @var string $slug THe product slug.
22
+ */
23
+ private $slug;
24
+ /**
25
+ * @var string $basefile The file with headers.
26
+ */
27
+ private $basefile;
28
+ /**
29
+ * @var string $type The product type ( plugin | theme ).
30
+ */
31
+ private $type;
32
+ /**
33
+ * @var string $file The file name.
34
+ */
35
+ private $file;
36
+ /**
37
+ * @var string $name The product name.
38
+ */
39
+ private $name;
40
+ /**
41
+ * @var string $key The product ready key.
42
+ */
43
+ private $key;
44
+ /**
45
+ * @var string $author_url The url of the author.
46
+ */
47
+ private $author_url;
48
+ /**
49
+ * @var string $store_url The store url.
50
+ */
51
+ private $store_url;
52
+ /**
53
+ * @var int $install The date of install.
54
+ */
55
+ private $install;
56
+ /**
57
+ * @var string $store_name The store name.
58
+ */
59
+ private $store_name;
60
+ /**
61
+ * @var array $allowed_authors The allowed authors.
62
+ */
63
+ private $allowed_authors = array( 'proteusthemes.com', 'anarieldesign.com' );
64
+ /**
65
+ * @var bool $requires_license Either user needs to activate it with license.
66
+ */
67
+ private $requires_license;
68
+ /**
69
+ * @var bool $wordpress_available Either is available on WordPress or not.
70
+ */
71
+ private $wordpress_available;
72
+ /**
73
+ * @var string $version The product version.
74
+ */
75
+ private $version;
76
+ /**
77
+ * @var string $logger_option Logger option key.
78
+ */
79
+ public $logger_option;
80
+ /**
81
+ * @var string $pro_slug Pro slug, if available.
82
+ */
83
+ public $pro_slug;
84
+ /**
85
+ * @var string $feedback_types All the feedback types the product supports
86
+ */
87
+ private $feedback_types = array();
88
+
89
+ /**
90
+ * @var string $widget_types All the widget types the product supports
91
+ */
92
+ private $widget_types = array( 'dashboard_blog' );
93
+
94
+ /**
95
+ * ThemeIsle_SDK_Product constructor.
96
+ *
97
+ * @param string $basefile Product basefile.
98
+ */
99
+ public function __construct( $basefile ) {
100
+ if ( ! empty( $basefile ) ) {
101
+ if ( is_readable( $basefile ) ) {
102
+ $this->basefile = $basefile;
103
+ $this->setup_from_path();
104
+ $this->setup_from_fileheaders();
105
+ }
106
+ }
107
+ $install = get_option( $this->get_key() . '_install', 0 );
108
+ if ( $install === 0 ) {
109
+ $install = time();
110
+ update_option( $this->get_key() . '_install', time() );
111
+ }
112
+ $this->install = $install;
113
+
114
+ $this->logger_option = $this->get_key() . '_logger_flag';
115
+
116
+ }
117
+
118
+ /**
119
+ * Setup props from fileheaders.
120
+ */
121
+ public function setup_from_fileheaders() {
122
+ $file_headers = array(
123
+ 'Requires License' => 'Requires License',
124
+ 'WordPress Available' => 'WordPress Available',
125
+ 'Pro Slug' => 'Pro Slug',
126
+ 'Version' => 'Version',
127
+ );
128
+ if ( $this->type == 'plugin' ) {
129
+ $file_headers['Name'] = 'Plugin Name';
130
+ $file_headers['AuthorName'] = 'Author';
131
+ $file_headers['AuthorURI'] = 'Author URI';
132
+ }
133
+ if ( $this->type == 'theme' ) {
134
+ $file_headers['Name'] = 'Theme Name';
135
+ $file_headers['AuthorName'] = 'Author';
136
+ $file_headers['AuthorURI'] = 'Author URI';
137
+ }
138
+ $file_headers = get_file_data( $this->basefile, $file_headers );
139
+
140
+ $this->name = $file_headers['Name'];
141
+ $this->store_name = $file_headers['AuthorName'];
142
+ $this->author_url = $file_headers['AuthorURI'];
143
+ $this->store_url = $file_headers['AuthorURI'];
144
+ if ( $this->is_external_author() ) {
145
+ $this->store_url = 'https://themeisle.com';
146
+ $this->store_name = 'ThemeIsle';
147
+ }
148
+ $this->requires_license = ( $file_headers['Requires License'] == 'yes' ) ? true : false;
149
+ $this->wordpress_available = ( $file_headers['WordPress Available'] == 'yes' ) ? true : false;
150
+ $this->pro_slug = ! empty( $file_headers['Pro Slug'] ) ? $file_headers['Pro Slug'] : '';
151
+ $this->version = $file_headers['Version'];
152
+ if ( $this->require_uninstall_feedback() ) {
153
+ $this->feedback_types[] = 'deactivate';
154
+ }
155
+ if ( $this->is_wordpress_available() ) {
156
+ $this->feedback_types[] = 'review';
157
+ $this->feedback_types[] = 'translate';
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Check if the product is by external author or not.
163
+ *
164
+ * @return bool Either is external author or no.
165
+ */
166
+ public function is_external_author() {
167
+ foreach ( $this->allowed_authors as $author ) {
168
+ if ( strpos( $this->author_url, $author ) !== false ) {
169
+ return true;
170
+ }
171
+ }
172
+
173
+ return false;
174
+ }
175
+
176
+ /**
177
+ * The magic var_dump info method.
178
+ *
179
+ * @return array Debug info.
180
+ */
181
+ public function __debugInfo() {
182
+ return array(
183
+ 'name' => $this->name,
184
+ 'slug' => $this->slug,
185
+ 'version' => $this->version,
186
+ 'basefile' => $this->basefile,
187
+ 'key' => $this->key,
188
+ 'type' => $this->type,
189
+ 'store_name' => $this->store_name,
190
+ 'store_url' => $this->store_url,
191
+ 'wordpress_available' => $this->wordpress_available,
192
+ 'requires_license' => $this->requires_license,
193
+ );
194
+
195
+ }
196
+
197
+ /**
198
+ * Setup props from path.
199
+ */
200
+ public function setup_from_path() {
201
+ $this->file = basename( $this->basefile );
202
+ $dir = dirname( $this->basefile );
203
+ $this->slug = basename( $dir );
204
+ $exts = explode( '.', $this->basefile );
205
+ $ext = $exts[ count( $exts ) - 1 ];
206
+ if ( $ext == 'css' ) {
207
+ $this->type = 'theme';
208
+ }
209
+ if ( $ext == 'php' ) {
210
+ $this->type = 'plugin';
211
+ }
212
+ $this->key = self::key_ready_name( $this->slug );
213
+ }
214
+
215
+ /**
216
+ * @param string $string the String to be normalized for cron handler.
217
+ *
218
+ * @return string $name The normalized string.
219
+ */
220
+ static function key_ready_name( $string ) {
221
+ return str_replace( '-', '_', strtolower( trim( $string ) ) );
222
+ }
223
+
224
+ /**
225
+ * Getter for product name.
226
+ *
227
+ * @return string The product name.
228
+ */
229
+ public function get_name() {
230
+ return $this->name;
231
+ }
232
+
233
+ /**
234
+ * Getter for product version.
235
+ *
236
+ * @return string The product version.
237
+ */
238
+ public function get_version() {
239
+ return $this->version;
240
+ }
241
+
242
+ /**
243
+ * If product is available on wordpress.org or not.
244
+ *
245
+ * @return bool Either is wp available or not.
246
+ */
247
+ public function is_wordpress_available() {
248
+ return $this->wordpress_available;
249
+ }
250
+
251
+ /**
252
+ * @return array Array of available versions.
253
+ */
254
+ private function get_plugin_versions() {
255
+
256
+ $url = sprintf( 'https://api.wordpress.org/plugins/info/1.0/%s', $this->get_slug() );
257
+ $response = wp_remote_get( $url );
258
+ if ( is_wp_error( $response ) ) {
259
+ return array();
260
+ }
261
+ $response = wp_remote_retrieve_body( $response );
262
+ $response = maybe_unserialize( $response );
263
+
264
+ if ( ! is_object( $response ) ) {
265
+ return array();
266
+ }
267
+ if ( ! isset( $response->versions ) ) {
268
+ return array();
269
+ }
270
+ $versions = array();
271
+ foreach ( $response->versions as $version => $zip ) {
272
+ $versions[] = array(
273
+ 'version' => $version,
274
+ 'url' => $zip,
275
+ );
276
+ }
277
+
278
+ return $versions;
279
+ }
280
+
281
+ /**
282
+ * Return theme versions.
283
+ *
284
+ * @return array Theme versions array.
285
+ */
286
+ public function get_theme_versions() {
287
+ $url = sprintf( 'https://api.wordpress.org/themes/info/1.1/?action=theme_information&request[slug]=%s&request[fields][versions]=true', $this->get_slug() );
288
+ $response = wp_remote_get( $url );
289
+ if ( is_wp_error( $response ) ) {
290
+ return array();
291
+ }
292
+ $response = wp_remote_retrieve_body( $response );
293
+ $response = json_decode( $response );
294
+
295
+ if ( ! is_object( $response ) ) {
296
+ return array();
297
+ }
298
+ if ( ! isset( $response->versions ) ) {
299
+ return array();
300
+ }
301
+ $versions = array();
302
+ foreach ( $response->versions as $version => $zip ) {
303
+ $versions[] = array(
304
+ 'version' => $version,
305
+ 'url' => $zip,
306
+ );
307
+ }
308
+
309
+ return $versions;
310
+ }
311
+
312
+ /**
313
+ * Get versions array from wp.org
314
+ *
315
+ * @return array Array of versions.
316
+ */
317
+ private function get_api_versions() {
318
+ if ( ! $this->is_wordpress_available() ) {
319
+ return array();
320
+ }
321
+
322
+ $cache_key = $this->get_key() . '_' . preg_replace( '/[^0-9a-zA-Z ]/m', '', $this->version ) . 'versions';
323
+ $cache_versions = get_transient( $this->get_key() . '_' . preg_replace( '/[^0-9a-zA-Z ]/m', '', $this->version ) . 'versions' );
324
+ if ( false == $cache_versions ) {
325
+ $versions = array();
326
+ if ( $this->get_type() === 'plugin' ) {
327
+ $versions = $this->get_plugin_versions();
328
+ }
329
+
330
+ if ( $this->get_type() === 'theme' ) {
331
+ $versions = $this->get_theme_versions();
332
+ }
333
+ set_transient( $cache_key, $versions, MONTH_IN_SECONDS );
334
+ } else {
335
+ $versions = is_array( $cache_versions ) ? $cache_versions : array();
336
+ }
337
+
338
+ return $versions;
339
+ }
340
+
341
+ /**
342
+ * Get the last rollback for this product.
343
+ *
344
+ * @return array The rollback version.
345
+ */
346
+ public function get_rollback() {
347
+ $rollback = array();
348
+ $versions = $this->get_api_versions();
349
+ $versions = apply_filters( $this->get_key() . '_rollbacks', $versions );
350
+
351
+ if ( $versions ) {
352
+ usort( $versions, array( $this, 'sort_rollback_array' ) );
353
+ foreach ( $versions as $version ) {
354
+ if ( isset( $version['version'] ) && isset( $version['url'] ) && version_compare( $this->version, $version['version'], '>' ) ) {
355
+ $rollback = $version;
356
+ break;
357
+ }
358
+ }
359
+ }
360
+
361
+ return $rollback;
362
+ }
363
+
364
+ /**
365
+ * Sort the rollbacks array in descending order.
366
+ */
367
+ public function sort_rollback_array( $a, $b ) {
368
+ return version_compare( $a['version'], $b['version'], '<' ) > 0;
369
+ }
370
+
371
+ /**
372
+ * If product can be rolled back.
373
+ *
374
+ * @return bool Can the product be rolled back or not.
375
+ */
376
+ public function can_rollback() {
377
+ if ( $this->get_type() === 'theme' ) {
378
+ if ( ! current_user_can( 'switch_themes' ) ) {
379
+ return false;
380
+ }
381
+ }
382
+ if ( $this->get_type() === 'plugin' ) {
383
+ if ( ! current_user_can( 'install_plugins' ) ) {
384
+ return false;
385
+ }
386
+ }
387
+ $rollback = $this->get_rollback();
388
+
389
+ return ! empty( $rollback );
390
+ }
391
+
392
+ /**
393
+ * Return the product key.
394
+ *
395
+ * @return string The product key.
396
+ */
397
+ public function get_key() {
398
+ return $this->key;
399
+ }
400
+
401
+ /**
402
+ * Return friendly name.
403
+ *
404
+ * @return string Friendly name.
405
+ */
406
+ public function get_friendly_name() {
407
+ $name = apply_filters( $this->get_key() . '_friendly_name', trim( str_replace( 'Lite', '', $this->get_name() ) ) );
408
+ $name = rtrim( $name, '- ' );
409
+
410
+ return $name;
411
+ }
412
+
413
+ /**
414
+ * Either the product requires license or not.
415
+ *
416
+ * @return bool Either requires license or not.
417
+ */
418
+ public function requires_license() {
419
+ return $this->requires_license;
420
+ }
421
+
422
+ /**
423
+ * Check if the product is either theme or plugin.
424
+ *
425
+ * @return string Product type.
426
+ */
427
+ public function get_type() {
428
+ return $this->type;
429
+ }
430
+
431
+ /**
432
+ * Returns the Store name.
433
+ *
434
+ * @return string Store name.
435
+ */
436
+ public function get_store_name() {
437
+ return $this->store_name;
438
+ }
439
+
440
+ /**
441
+ * Returns the store url.
442
+ *
443
+ * @return string The store url.
444
+ */
445
+ public function get_store_url() {
446
+ return $this->store_url;
447
+ }
448
+
449
+ /**
450
+ * Returns the product slug.
451
+ *
452
+ * @return string The product slug.
453
+ */
454
+ public function get_slug() {
455
+ return $this->slug;
456
+ }
457
+
458
+ /**
459
+ * Returns product basefile, which holds the metaheaders.
460
+ *
461
+ * @return string The product basefile.
462
+ */
463
+ public function get_basefile() {
464
+ return $this->basefile;
465
+ }
466
+
467
+ /**
468
+ * Returns product filename.
469
+ *
470
+ * @return string The product filename.
471
+ */
472
+ public function get_file() {
473
+ return $this->file;
474
+ }
475
+
476
+ /**
477
+ * Returns feedback types
478
+ *
479
+ * @return array The feedback types.
480
+ */
481
+ public function get_feedback_types() {
482
+ return apply_filters( $this->get_key() . '_feedback_types', $this->feedback_types );
483
+ }
484
+
485
+ /**
486
+ * Returns widget types
487
+ *
488
+ * @return array The widget types.
489
+ */
490
+ public function get_widget_types() {
491
+ return apply_filters( $this->get_key() . '_widget_types', $this->widget_types );
492
+ }
493
+
494
+ /**
495
+ * We log the user website and product version.
496
+ *
497
+ * @return bool Either we log the data or not.
498
+ */
499
+ public function is_logger_active() {
500
+ // If is not available on WordPress log this automatically.
501
+ if ( ! $this->is_wordpress_available() ) {
502
+ return true;
503
+ } else {
504
+ $pro_slug = $this->get_pro_slug();
505
+ if ( ! empty( $pro_slug ) ) {
506
+
507
+ $all_products = ThemeIsle_SDK_Loader::get_products();
508
+ if ( isset( $all_products[ $pro_slug ] ) ) {
509
+ return true;
510
+ }
511
+ }
512
+
513
+ return ( get_option( $this->get_key() . '_logger_flag', 'no' ) === 'yes' );
514
+
515
+ }
516
+ }
517
+
518
+ /**
519
+ * Returns the pro slug, if available.
520
+ *
521
+ * @return string The pro slug.
522
+ */
523
+ public function get_pro_slug() {
524
+ return $this->pro_slug;
525
+ }
526
+
527
+ /**
528
+ * Return the install timestamp.
529
+ *
530
+ * @return int The install timestamp.
531
+ */
532
+ public function get_install_time() {
533
+ return $this->install;
534
+ }
535
+
536
+ /**
537
+ * We require feedback on uninstall.
538
+ *
539
+ * @return bool Either we should require feedback on uninstall or not.
540
+ */
541
+ public function require_uninstall_feedback() {
542
+ if ( $this->get_type() == 'theme' && ! $this->is_external_author() ) {
543
+ return ! get_transient( 'ti_sdk_pause_' . $this->get_key(), false );
544
+ }
545
+
546
+ if ( $this->get_type() == 'plugin' ) {
547
+
548
+ return true;
549
+ }
550
+
551
+ return false;
552
+ }
553
+
554
+ }
555
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-rollback.php ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The rollback class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Rollback
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ if ( ! class_exists( 'ThemeIsle_SDK_Rollback' ) ) :
16
+ /**
17
+ * Rollback for ThemeIsle SDK.
18
+ */
19
+ class ThemeIsle_SDK_Rollback {
20
+
21
+ /**
22
+ * @var ThemeIsle_SDK_Product $product Themeisle Product.
23
+ */
24
+ protected $product;
25
+
26
+
27
+ /**
28
+ * ThemeIsle_SDK_Rollback constructor.
29
+ *
30
+ * @param ThemeIsle_SDK_Product $product_object Product Object.
31
+ */
32
+ public function __construct( $product_object ) {
33
+ if ( $product_object instanceof ThemeIsle_SDK_Product ) {
34
+ $this->product = $product_object;
35
+ }
36
+ if ( $this->product->can_rollback() ) {
37
+ $this->show_link();
38
+ $this->add_hooks();
39
+
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Add js scripts for themes rollback.
45
+ */
46
+ public function add_footer() {
47
+ $screen = get_current_screen();
48
+ if ( ! isset( $screen->parent_file ) ) {
49
+ return;
50
+ }
51
+ if ( $screen->parent_file !== 'themes.php' ) {
52
+ return;
53
+ }
54
+ if ( $this->product->get_type() === 'plugin' ) {
55
+ return;
56
+ }
57
+
58
+ $version = $this->product->get_rollback();
59
+ ?>
60
+ <script type="text/javascript">
61
+ jQuery(document).ready(function ($) {
62
+ setInterval(checkTheme, 500);
63
+
64
+ function checkTheme() {
65
+ var theme = '<?php echo esc_attr( $this->product->get_slug() ); ?>-action';
66
+
67
+ if (jQuery('#' + theme).length > 0) {
68
+ if (jQuery('.theme-overlay.active').is(':visible')) {
69
+ if (jQuery('#' + theme + '-rollback').length === 0) {
70
+ jQuery('.theme-actions .active-theme').prepend('<a class="button" style="float:left" id="' + theme + '-rollback" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=' . $this->product->get_key() . '_rollback' ), $this->product->get_key() . '_rollback' ) ); ?>">Rollback to v<?php echo esc_attr( $version['version'] ); ?></a>')
71
+ }
72
+ }
73
+
74
+ }
75
+ }
76
+ })
77
+
78
+ </script>
79
+ <?php
80
+
81
+ }
82
+
83
+ /**
84
+ * Set the rollback hook. Strangely, this does not work if placed in the ThemeIsle_SDK_Rollback class, so it is being called from there instead.
85
+ */
86
+ public function add_hooks() {
87
+ add_action( 'admin_post_' . $this->product->get_key() . '_rollback', array( $this, 'start_rollback' ) );
88
+ add_action( 'admin_footer', array( $this, 'add_footer' ) );
89
+ }
90
+
91
+ /**
92
+ * If product can be rolled back, show the link to rollback.
93
+ */
94
+ private function show_link() {
95
+ add_filter(
96
+ 'plugin_action_links_' . plugin_basename( $this->product->get_basefile() ), array(
97
+ $this,
98
+ 'add_rollback_link',
99
+ )
100
+ );
101
+ }
102
+
103
+ /**
104
+ * Show the rollback links in the plugin page.
105
+ *
106
+ * @return array The links.
107
+ */
108
+ public function add_rollback_link( $links ) {
109
+ $version = $this->product->get_rollback();
110
+ $links[] = '<a href="' . wp_nonce_url( admin_url( 'admin-post.php?action=' . $this->product->get_key() . '_rollback' ), $this->product->get_key() . '_rollback' ) . '">' . sprintf( apply_filters( $this->product->get_key() . '_rollback_label', 'Rollback to v%s' ), $version['version'] ) . '</a>';
111
+
112
+ return $links;
113
+ }
114
+
115
+ /**
116
+ * Start the rollback operation.
117
+ */
118
+ public function start_rollback() {
119
+ if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], $this->product->get_key() . '_rollback' ) ) {
120
+ wp_nonce_ays( '' );
121
+ }
122
+
123
+ if ( $this->product->get_type() === 'plugin' ) {
124
+ $this->start_rollback_plugin();
125
+ } elseif ( $this->product->get_type() === 'theme' ) {
126
+ $this->start_rollback_theme();
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Alter links and remove duplicate customize message.
132
+ *
133
+ * @param array $links Array of old links.
134
+ *
135
+ * @return mixed Array of links.
136
+ */
137
+ public function alter_links_theme_upgrade( $links ) {
138
+ if ( isset( $links['preview'] ) ) {
139
+ $links['preview'] = str_replace( '<span aria-hidden="true">Customize</span>', '', $links['preview'] );
140
+ }
141
+
142
+ return $links;
143
+ }
144
+
145
+ /**
146
+ * Start the rollback operation for the theme.
147
+ */
148
+ private function start_rollback_theme() {
149
+ add_filter( 'update_theme_complete_actions', array( $this, 'alter_links_theme_upgrade' ) );
150
+ $rollback = $this->product->get_rollback();
151
+ $transient = get_site_transient( 'update_themes' );
152
+ $folder = $this->product->get_slug();
153
+ $version = $rollback['version'];
154
+ $temp_array = array(
155
+ 'new_version' => $version,
156
+ 'package' => $rollback['url'],
157
+ );
158
+
159
+ $transient->response[ $folder . '/style.css' ] = $temp_array;
160
+ set_site_transient( 'update_themes', $transient );
161
+
162
+ $transient = get_transient( $this->product->get_key() . '_warning_rollback' );
163
+
164
+ if ( false === $transient ) {
165
+ set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
166
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
167
+ $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
168
+ $theme = $folder . '/style.css';
169
+ $nonce = 'upgrade-theme_' . $theme;
170
+ $url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme );
171
+
172
+ $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'theme' ) ) );
173
+ $upgrader->upgrade( $theme );
174
+ delete_transient( $this->product->get_key() . '_warning_rollback' );
175
+ wp_die(
176
+ '', $title, array(
177
+ 'response' => 200,
178
+ )
179
+ );
180
+ }
181
+ }
182
+
183
+ /**
184
+ * Start the rollback operation for the plugin.
185
+ */
186
+ private function start_rollback_plugin() {
187
+ $rollback = $this->product->get_rollback();
188
+ $plugin_transient = get_site_transient( 'update_plugins' );
189
+ $plugin_folder = $this->product->get_slug();
190
+ $plugin_file = $this->product->get_file();
191
+ $version = $rollback['version'];
192
+ $temp_array = array(
193
+ 'slug' => $plugin_folder,
194
+ 'new_version' => $version,
195
+ 'package' => $rollback['url'],
196
+ );
197
+
198
+ $temp_object = (object) $temp_array;
199
+ $plugin_transient->response[ $plugin_folder . '/' . $plugin_file ] = $temp_object;
200
+ set_site_transient( 'update_plugins', $plugin_transient );
201
+
202
+ $transient = get_transient( $this->product->get_key() . '_warning_rollback' );
203
+
204
+ if ( false === $transient ) {
205
+ set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
206
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
207
+ $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
208
+ $plugin = $plugin_folder . '/' . $plugin_file;
209
+ $nonce = 'upgrade-plugin_' . $plugin;
210
+ $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );
211
+ $upgrader_skin = new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) );
212
+ $upgrader = new Plugin_Upgrader( $upgrader_skin );
213
+ $upgrader->upgrade( $plugin );
214
+ delete_transient( $this->product->get_key() . '_warning_rollback' );
215
+ wp_die(
216
+ '', $title, array(
217
+ 'response' => 200,
218
+ )
219
+ );
220
+ }
221
+ }
222
+ }
223
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-widget-dashboard-blog.php ADDED
@@ -0,0 +1,383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The blog dashboard model class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Widgets
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ if ( ! class_exists( 'ThemeIsle_SDK_Widget_Dashboard_Blog' ) ) :
16
+ /**
17
+ * Blog dashboard widget model for ThemeIsle SDK.
18
+ */
19
+ class ThemeIsle_SDK_Widget_Dashboard_Blog extends ThemeIsle_SDK_Widget {
20
+
21
+ /**
22
+ * @var array instance The instances.
23
+ */
24
+ protected $product;
25
+ /**
26
+ * @var array Feed items.
27
+ */
28
+ private $items = array();
29
+
30
+ /**
31
+ * ThemeIsle_SDK_Widget_Dashboard_Blog constructor.
32
+ *
33
+ * @param ThemeIsle_SDK_Product $product_object The product object.
34
+ */
35
+ public function __construct( $product_object ) {
36
+ $this->product = $product_object;
37
+ parent::__construct( $product_object );
38
+ }
39
+
40
+ /**
41
+ * Registers the hooks
42
+ */
43
+ public function setup_hooks_child() {
44
+ $this->setup_vars();
45
+ add_action( 'wp_dashboard_setup', array( &$this, 'add_widget' ) );
46
+ add_action( 'wp_network_dashboard_setup', array( &$this, 'add_widget' ) );
47
+ add_filter( 'themeisle_sdk_recommend_plugin_or_theme', array( &$this, 'recommend_plugin_or_theme' ) );
48
+ }
49
+
50
+ /**
51
+ * Setup class variables
52
+ */
53
+ function setup_vars() {
54
+ $this->dashboard_name = apply_filters( 'themeisle_sdk_dashboard_widget_name', 'WordPress Guides/Tutorials' );
55
+ $this->feeds = apply_filters(
56
+ 'themeisle_sdk_dashboard_widget_feeds', array(
57
+ 'https://themeisle.com/blog/feed',
58
+ )
59
+ );
60
+ }
61
+
62
+ /**
63
+ * Add widget to the dashboard
64
+ *
65
+ * @return string|void
66
+ */
67
+ function add_widget() {
68
+ global $wp_meta_boxes;
69
+ if ( isset( $wp_meta_boxes['dashboard']['normal']['core']['themeisle'] ) ) {
70
+ return;
71
+ }
72
+ wp_add_dashboard_widget(
73
+ 'themeisle', $this->dashboard_name, array(
74
+ &$this,
75
+ 'render_dashboard_widget',
76
+ )
77
+ );
78
+ }
79
+
80
+ /**
81
+ * Setup feed items.
82
+ */
83
+ private function setup_feeds() {
84
+ $items_normalized = array();
85
+ if ( false === ( $items_normalized = get_transient( 'themeisle_sdk_feed_items' ) ) ) {
86
+ // Load SimplePie Instance
87
+ $feed = fetch_feed( $this->feeds );
88
+ // TODO report error when is an error loading the feed
89
+ if ( is_wp_error( $feed ) ) {
90
+ return;
91
+ }
92
+
93
+ $items = $feed->get_items( 0, 5 );
94
+ foreach ( (array) $items as $item ) {
95
+ $items_normalized[] = array(
96
+ 'title' => $item->get_title(),
97
+ 'date' => $item->get_date( 'U' ),
98
+ 'link' => $item->get_permalink(),
99
+ );
100
+ }
101
+ set_transient( 'themeisle_sdk_feed_items', $items_normalized, 48 * HOUR_IN_SECONDS );
102
+ }
103
+ $this->items = $items_normalized;
104
+ }
105
+
106
+ /**
107
+ * Render widget content
108
+ */
109
+ function render_dashboard_widget() {
110
+ $this->setup_feeds();
111
+ ?>
112
+ <style type="text/css">
113
+ #themeisle ul {
114
+ margin-bottom: 0px;
115
+ }
116
+
117
+ #themeisle ul li.ti-dw-recommend-item {
118
+
119
+ padding-left: 7px;
120
+ border-top: 1px solid #eee;
121
+
122
+ margin-bottom: 0px;
123
+ padding-top: 6px;
124
+ }
125
+
126
+ #themeisle h2.hndle {
127
+ background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAYAAABWk2cPAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALfSURBVEhL7VW/ayJBFL7/5ZqziBzIcSCHxUE4hAiCgnAQsBASOAikEAIeCAaCiJAyIBICQURYwoJoEUmxa6MWioWxURu30mq77b57s86acX+oOQhp8sFjdmbfzrfve2/efMI74IP0VTB0gz/th/8iNbQxOt0eOmoN6WgAn78cwJeoYcLf78KrSPVneU3isEQZoz0D3pt03jhDrDTERJXxWM3A5yAOIPmgce/t2IvUGFzjkDa+7C5RTx0gWbxG0v8bBXUG3fLReigk4rh55gtbsAfpGDfhVTS+VA19bYbH7BkqU/56AzNU7nrYpbI7qfbEcxfBkSOHJGO27Vk0htqEYoXvARdS+tsEJyAJY1GRkOxnGTdq2zuaRZOkJ1Wi1+h7ODlJB/l1kYRKZVyKhMwoSmUw5M4uWMhIcl9f1l1qB2m/aMkZQIE2d5BeDTGiSD0VfC4jZPmSKiO+LMJGuoRE1bkiOIW00CAdW3NuxzLmxhD1hyHmug7dbBRD9KdLc4dR6Zfgn0ffXN2EjVSMLIcOrWxuwiyyPhYGI7X0m/agqPeIib5+yit/LWILKYuUlrTa5kbMwjko7J0AXc1RLZwifRF58Us1YXMzYSMV5WQ5ZWsG5VnYaG1BxM7zKBRzOAkHac460gxK9sUnVBqbu9rhKCS9lRaq1/poCeUq7tL6uPnjSLeoBRo9/KXjslqP4Na1gbiQssiULK9gP+VVqPnFQMblnwi+WmTfIji5amLES1mn/mz9yCFVuddZdiFlIJlTK+JtH2/AaPMogzipzrZ+4yQ1qCL1JSaNDL6bf81y1aOb5R6Vhow6G1tPNK9Borl0R2NLRiEaxNEF9Wa3yrHBSarTbeHot7ySqVmYR4AucDYuaJyzkfptZ0e/FeGa03m3jOQPizCAo0QG9W2ktL5HgGt45JRgaBh1x9R1WHY0KCTnLZOW5Kw0miuZq01ITGa6Z18Db9I3xAfpm+IdSIF/du91gSA2+I8AAAAASUVORK5CYII=');
128
+ background-repeat: no-repeat;
129
+ background-position: 90% 50%;
130
+ background-size: 29px;
131
+ }
132
+
133
+ .ti-dw-feed-item {
134
+ display: flex;
135
+ align-items: center;
136
+ }
137
+
138
+ .ti-dw-feed-item a {
139
+ float: left;
140
+ width: 89.9%;
141
+ }
142
+
143
+ .ti-dw-feed-item .ti-dw-day-container {
144
+ width: 100%;
145
+ letter-spacing: 3px;
146
+ display: block;
147
+ }
148
+
149
+ .ti-dw-feed-item .ti-dw-month-container {
150
+
151
+ width: 100%;
152
+ display: block;
153
+ font-weight: 600;
154
+ padding: 0px;
155
+ margin-top: -6px;
156
+ text-transform: uppercase;
157
+ font-size: 10px;
158
+ letter-spacing: 1px;
159
+ }
160
+
161
+ .ti-dw-feed-item .ti-dw-date-container {
162
+ float: left;
163
+ min-height: 30px;
164
+ margin-right: 0.1%;
165
+ width: 10%;
166
+ text-align: center;
167
+ }
168
+
169
+ .ti-dw-recommend-item span {
170
+ color: #72777c;
171
+ }
172
+
173
+ .ti-dw-powered-by {
174
+ font-style: italic;
175
+ text-align: right;
176
+ margin-top:3px;
177
+ }
178
+
179
+ </style>
180
+ <ul>
181
+ <?php
182
+ foreach ( $this->items as $item ) {
183
+ ?>
184
+ <li class="ti-dw-feed-item"><span class="ti-dw-date-container"><span
185
+ class="ti-dw-day-container"><?php echo date( 'd', $item['date'] ); ?></span> <span
186
+ class="ti-dw-month-container"><?php echo substr( date( 'M', $item['date'] ), 0, 3 ); ?></span></span><a
187
+ href="
188
+ <?php
189
+ echo add_query_arg(
190
+ array(
191
+ 'utm_campaign' => 'feed',
192
+ 'utm_medium' => 'dashboard_widget',
193
+ ), $item['link']
194
+ );
195
+ ?>
196
+ " target="_blank"><?php echo $item['title']; ?></a>
197
+ <div class="clear"></div>
198
+ </li>
199
+ <?php
200
+ }
201
+
202
+ $recommend = apply_filters( 'themeisle_sdk_recommend_plugin_or_theme', array() );
203
+ if ( is_array( $recommend ) && ! empty( $recommend ) ) {
204
+
205
+ $type = $recommend['type'];
206
+ if ( ( $type == 'theme' && current_user_can( 'install_themes' ) ) || ( $type == 'plugin' && current_user_can( 'install_plugins' ) ) ) {
207
+ add_thickbox();
208
+ $url = add_query_arg(
209
+ array(
210
+ 'theme' => $recommend['slug'],
211
+ ), network_admin_url( 'theme-install.php' )
212
+ );
213
+
214
+ if ( 'plugin' === $type ) {
215
+
216
+ $url = add_query_arg(
217
+ array(
218
+ 'tab' => 'plugin-information',
219
+ 'plugin' => $recommend['slug'],
220
+ ), network_admin_url( 'plugin-install.php' )
221
+ );
222
+ }
223
+ ?>
224
+ <li class="ti-dw-recommend-item ">
225
+ <span class="ti-dw-recommend"><?php echo apply_filters( 'themeisle_sdk_dashboard_popular_label', sprintf( 'Popular %s', ucwords( $type ) ) ); ?>
226
+ : </span>
227
+ <?php
228
+ echo trim(
229
+ str_replace(
230
+ array(
231
+ 'lite',
232
+ 'Lite',
233
+ ), '', $recommend['name']
234
+ )
235
+ );
236
+ ?>
237
+ (<a class="thickbox open-plugin-details-modal"
238
+ href="<?php echo $url . '&TB_iframe=true&width=600&height=500'; ?>"><?php echo apply_filters( 'themeisle_sdk_dashboard_install_label', 'Install' ); ?></a>)
239
+ </li>
240
+ <li class="ti-dw-powered-by">
241
+ Powered by <?php echo esc_attr( $this->product->get_friendly_name() ); ?>
242
+ </li>
243
+
244
+ <?php
245
+ }
246
+ }
247
+ ?>
248
+ </ul>
249
+
250
+ <?php
251
+
252
+ }
253
+
254
+ /**
255
+ * Either the current product is installed or not.
256
+ *
257
+ * @param array $val The current recommended product.
258
+ *
259
+ * @return bool Either we should exclude the plugin or not.
260
+ */
261
+ public function remove_current_products( $val ) {
262
+ if ( $val['type'] === 'theme' ) {
263
+ $exist = wp_get_theme( $val['slug'] );
264
+
265
+ return ! $exist->exists();
266
+ } else {
267
+ $all_plugins = array_keys( get_plugins() );
268
+ foreach ( $all_plugins as $slug ) {
269
+ if ( strpos( $slug, $val['slug'] ) !== false ) {
270
+ return false;
271
+ }
272
+ }
273
+
274
+ return true;
275
+ }
276
+ }
277
+
278
+ /**
279
+ * Fetch themes from wporg api.
280
+ *
281
+ * @param string $author The author name.
282
+ *
283
+ * @return array The list of themes.
284
+ */
285
+ function get_themes_from_wporg( $author ) {
286
+ $products = wp_remote_get(
287
+ 'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[author]=' . $author . '&request[per_page]=30&request[fields][active_installs]=true'
288
+ );
289
+ $products = json_decode( wp_remote_retrieve_body( $products ) );
290
+ if ( is_object( $products ) ) {
291
+ $products = isset( $products->themes ) ? $products->themes : array();
292
+ } else {
293
+ $products = array();
294
+ }
295
+
296
+ return $products;
297
+ }
298
+
299
+ /**
300
+ * Fetch plugin from wporg api.
301
+ *
302
+ * @param string $author The author slug.
303
+ *
304
+ * @return array The list of plugins for the selected author.
305
+ */
306
+ function get_plugins_from_wporg( $author ) {
307
+ $products = wp_remote_get(
308
+ 'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[author]=' . $author . '&request[author]=codeinwp&request[per_page]=20&request[fields][active_installs]=true'
309
+ );
310
+ $products = json_decode( wp_remote_retrieve_body( $products ) );
311
+ if ( is_object( $products ) ) {
312
+ $products = isset( $products->plugins ) ? $products->plugins : array();
313
+ } else {
314
+ $products = array();
315
+ }
316
+
317
+ return $products;
318
+ }
319
+
320
+ /**
321
+ * Fetch products from the recomended section.
322
+ *
323
+ * @return array|mixed The list of products to use in recomended section.
324
+ */
325
+ function get_product_from_api() {
326
+ if ( false === ( $products = get_transient( 'themeisle_sdk_products' ) ) ) {
327
+ $products = array();
328
+ $themeisle_themes = $this->get_themes_from_wporg( 'themeisle' );
329
+ $codeinwp_themes = $this->get_themes_from_wporg( 'codeinwp' );
330
+
331
+ $themeisle_plugins = $this->get_plugins_from_wporg( 'themeisle' );
332
+ $codeinwp_plugins = $this->get_plugins_from_wporg( 'codeinwp' );
333
+
334
+ $all_themes = array_merge( $themeisle_themes, $codeinwp_themes );
335
+ foreach ( $all_themes as $theme ) {
336
+ if ( $theme->active_installs < 4999 ) {
337
+ continue;
338
+ }
339
+ $products[] = array(
340
+ 'name' => $theme->name,
341
+ 'type' => 'theme',
342
+ 'slug' => $theme->slug,
343
+ 'installs' => $theme->active_installs,
344
+ );
345
+ }
346
+ $all_plugins = array_merge( $themeisle_plugins, $codeinwp_plugins );
347
+ foreach ( $all_plugins as $plugin ) {
348
+ if ( $plugin->active_installs < 5999 ) {
349
+ continue;
350
+ }
351
+ $products[] = array(
352
+ 'name' => $plugin->name,
353
+ 'type' => 'plugin',
354
+ 'slug' => $plugin->slug,
355
+ 'installs' => $plugin->active_installs,
356
+ );
357
+ }
358
+ set_transient( 'themeisle_sdk_products', $products, 6 * HOUR_IN_SECONDS );
359
+ }
360
+
361
+ return $products;
362
+ }
363
+
364
+ /**
365
+ * Contact the API and fetch the recommended plugins/themes
366
+ */
367
+ function recommend_plugin_or_theme() {
368
+ $products = $this->get_product_from_api();
369
+ if ( ! is_array( $products ) ) {
370
+ $products = array();
371
+ }
372
+ $products = array_filter( $products, array( $this, 'remove_current_products' ) );
373
+ $products = array_merge( $products );
374
+ if ( count( $products ) > 1 ) {
375
+ shuffle( $products );
376
+ $products = array_slice( $products, 0, 1 );
377
+ }
378
+ $to_recommend = isset( $products[0] ) ? $products[0] : $products;
379
+
380
+ return $to_recommend;
381
+ }
382
+ }
383
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-widget.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The widget model class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Widgets
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ if ( ! class_exists( 'ThemeIsle_SDK_Widget' ) ) :
16
+ /**
17
+ * Widget model for ThemeIsle SDK.
18
+ */
19
+ abstract class ThemeIsle_SDK_Widget {
20
+ /**
21
+ * @var ThemeIsle_SDK_Product $product Themeisle Product.
22
+ */
23
+ protected $product;
24
+
25
+ /**
26
+ * ThemeIsle_SDK_Widget constructor.
27
+ *
28
+ * @param ThemeIsle_SDK_Product $product_object Product Object.
29
+ */
30
+ public function __construct( $product_object ) {
31
+ if ( $product_object instanceof ThemeIsle_SDK_Product ) {
32
+ $this->product = $product_object;
33
+ }
34
+ $this->setup_hooks();
35
+ }
36
+
37
+ /**
38
+ * Registers the hooks and then delegates to the child
39
+ */
40
+ public function setup_hooks() {
41
+ $this->setup_hooks_child();
42
+ }
43
+
44
+ /**
45
+ * Abstract function for delegating to the child
46
+ */
47
+ protected abstract function setup_hooks_child();
48
+
49
+ }
50
+ endif;
vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-widgets-factory.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The widgets factory class for ThemeIsle SDK
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @subpackage Widgets
7
+ * @copyright Copyright (c) 2017, Marius Cristea
8
+ * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ if ( ! class_exists( 'ThemeIsle_SDK_Widgets_Factory' ) ) :
16
+ /**
17
+ * Widgets factory model for ThemeIsle SDK.
18
+ */
19
+ class ThemeIsle_SDK_Widgets_Factory {
20
+
21
+ /**
22
+ * ThemeIsle_SDK_Widgets_Factory constructor.
23
+ *
24
+ * @param ThemeIsle_SDK_Product $product_object Product Object.
25
+ * @param array $widgets the widgets.
26
+ */
27
+ public function __construct( $product_object, $widgets ) {
28
+ if ( $product_object instanceof ThemeIsle_SDK_Product && $widgets && is_array( $widgets ) ) {
29
+ foreach ( $widgets as $widget ) {
30
+ $class = 'ThemeIsle_SDK_Widget_' . str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget ) ) );
31
+ $instance = new $class( $product_object );
32
+ $instance->setup_hooks();
33
+ }
34
+ }
35
+ }
36
+ }
37
+ endif;
vendor/codeinwp/themeisle-sdk/composer.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "codeinwp/themeisle-sdk",
3
+ "description": "ThemeIsle SDK ",
4
+ "keywords": [
5
+ "wordpress"
6
+ ],
7
+ "homepage": "https://github.com/Codeinwp/themeisle-sdk",
8
+ "license": "GPL-2.0+",
9
+ "authors": [
10
+ {
11
+ "name": "ThemeIsle team",
12
+ "email": "friends@themeisle.com",
13
+ "homepage": "https://themeisle.com"
14
+ }
15
+ ],
16
+ "autoload": {
17
+ "files": [
18
+ "load.php"
19
+ ]
20
+ },
21
+ "support": {
22
+ "issues": "https://github.com/Codeinwp/themeisle-sdk/issues"
23
+ }
24
+ }
vendor/codeinwp/themeisle-sdk/index.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package ThemeIsleSDK
4
+ * Ignore this.
5
+ */
vendor/codeinwp/themeisle-sdk/load.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loader for the ThemeIsleSDK
4
+ *
5
+ * Logic for loading always the latest SDK from the installed themes/plugins.
6
+ *
7
+ * @package ThemeIsleSDK
8
+ * @copyright Copyright (c) 2017, Marius Cristea
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 1.1.0
11
+ */
12
+
13
+ // Current SDK version and path.
14
+ $themeisle_sdk_version = '1.9.1';
15
+ $themeisle_sdk_path = dirname( __FILE__ );
16
+
17
+ global $themeisle_sdk_max_version;
18
+ global $themeisle_sdk_max_path;
19
+
20
+ if ( version_compare( $themeisle_sdk_version, $themeisle_sdk_max_version ) >= 0 ) {
21
+ $themeisle_sdk_max_version = $themeisle_sdk_version;
22
+ $themeisle_sdk_max_path = $themeisle_sdk_path;
23
+ }
24
+
25
+ // load the latest sdk version from the active Themeisle products
26
+ if ( ! function_exists( 'themeisle_sdk_load_latest' ) ) :
27
+ /**
28
+ * Always load the latest sdk version.
29
+ */
30
+ function themeisle_sdk_load_latest() {
31
+ global $themeisle_sdk_max_path;
32
+ require_once $themeisle_sdk_max_path . '/start.php';
33
+ }
34
+ endif;
35
+ add_action( 'init', 'themeisle_sdk_load_latest' );
vendor/codeinwp/themeisle-sdk/start.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File responsible for sdk files loading.
4
+ *
5
+ * @package ThemeIsleSDK
6
+ * @copyright Copyright (c) 2017, Marius Cristea
7
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
8
+ * @since 1.1.0
9
+ */
10
+ $products = apply_filters( 'themeisle_sdk_products', array() );
11
+ $path = dirname( __FILE__ );
12
+ $files_to_load = array(
13
+ 'class-themeisle-sdk-loader.php',
14
+ 'class-themeisle-sdk-product.php',
15
+ 'class-themeisle-sdk-logger.php',
16
+ 'class-themeisle-sdk-licenser.php',
17
+ 'class-themeisle-sdk-rollback.php',
18
+ 'class-themeisle-sdk-feedback-factory.php',
19
+ 'class-themeisle-sdk-feedback.php',
20
+ 'class-themeisle-sdk-feedback-deactivate.php',
21
+ 'class-themeisle-sdk-feedback-review.php',
22
+ 'class-themeisle-sdk-feedback-translate.php',
23
+ 'class-themeisle-sdk-notification-manager.php',
24
+ 'class-themeisle-sdk-widget.php',
25
+ 'class-themeisle-sdk-widget-dashboard-blog.php',
26
+ 'class-themeisle-sdk-widgets-factory.php',
27
+ );
28
+
29
+ foreach ( $files_to_load as $file ) {
30
+ $file_path = $path . '/' . $file;
31
+ if ( is_readable( $file_path ) ) {
32
+ require_once $file_path;
33
+ }
34
+ }
35
+ foreach ( $products as $product ) {
36
+ ThemeIsle_SDK_Loader::init_product( $product );
37
+ }
vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see http://www.php-fig.org/psr/psr-0/
41
+ * @see http://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
53
+
54
+ private $useIncludePath = false;
55
+ private $classMap = array();
56
+
57
+ private $classMapAuthoritative = false;
58
+
59
+ public function getPrefixes()
60
+ {
61
+ if (!empty($this->prefixesPsr0)) {
62
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
63
+ }
64
+
65
+ return array();
66
+ }
67
+
68
+ public function getPrefixesPsr4()
69
+ {
70
+ return $this->prefixDirsPsr4;
71
+ }
72
+
73
+ public function getFallbackDirs()
74
+ {
75
+ return $this->fallbackDirsPsr0;
76
+ }
77
+
78
+ public function getFallbackDirsPsr4()
79
+ {
80
+ return $this->fallbackDirsPsr4;
81
+ }
82
+
83
+ public function getClassMap()
84
+ {
85
+ return $this->classMap;
86
+ }
87
+
88
+ /**
89
+ * @param array $classMap Class to filename map
90
+ */
91
+ public function addClassMap(array $classMap)
92
+ {
93
+ if ($this->classMap) {
94
+ $this->classMap = array_merge($this->classMap, $classMap);
95
+ } else {
96
+ $this->classMap = $classMap;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Registers a set of PSR-0 directories for a given prefix, either
102
+ * appending or prepending to the ones previously set for this prefix.
103
+ *
104
+ * @param string $prefix The prefix
105
+ * @param array|string $paths The PSR-0 root directories
106
+ * @param bool $prepend Whether to prepend the directories
107
+ */
108
+ public function add($prefix, $paths, $prepend = false)
109
+ {
110
+ if (!$prefix) {
111
+ if ($prepend) {
112
+ $this->fallbackDirsPsr0 = array_merge(
113
+ (array) $paths,
114
+ $this->fallbackDirsPsr0
115
+ );
116
+ } else {
117
+ $this->fallbackDirsPsr0 = array_merge(
118
+ $this->fallbackDirsPsr0,
119
+ (array) $paths
120
+ );
121
+ }
122
+
123
+ return;
124
+ }
125
+
126
+ $first = $prefix[0];
127
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
128
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
129
+
130
+ return;
131
+ }
132
+ if ($prepend) {
133
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
134
+ (array) $paths,
135
+ $this->prefixesPsr0[$first][$prefix]
136
+ );
137
+ } else {
138
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
139
+ $this->prefixesPsr0[$first][$prefix],
140
+ (array) $paths
141
+ );
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Registers a set of PSR-4 directories for a given namespace, either
147
+ * appending or prepending to the ones previously set for this namespace.
148
+ *
149
+ * @param string $prefix The prefix/namespace, with trailing '\\'
150
+ * @param array|string $paths The PSR-4 base directories
151
+ * @param bool $prepend Whether to prepend the directories
152
+ *
153
+ * @throws \InvalidArgumentException
154
+ */
155
+ public function addPsr4($prefix, $paths, $prepend = false)
156
+ {
157
+ if (!$prefix) {
158
+ // Register directories for the root namespace.
159
+ if ($prepend) {
160
+ $this->fallbackDirsPsr4 = array_merge(
161
+ (array) $paths,
162
+ $this->fallbackDirsPsr4
163
+ );
164
+ } else {
165
+ $this->fallbackDirsPsr4 = array_merge(
166
+ $this->fallbackDirsPsr4,
167
+ (array) $paths
168
+ );
169
+ }
170
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
171
+ // Register directories for a new namespace.
172
+ $length = strlen($prefix);
173
+ if ('\\' !== $prefix[$length - 1]) {
174
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
175
+ }
176
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
177
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
178
+ } elseif ($prepend) {
179
+ // Prepend directories for an already registered namespace.
180
+ $this->prefixDirsPsr4[$prefix] = array_merge(
181
+ (array) $paths,
182
+ $this->prefixDirsPsr4[$prefix]
183
+ );
184
+ } else {
185
+ // Append directories for an already registered namespace.
186
+ $this->prefixDirsPsr4[$prefix] = array_merge(
187
+ $this->prefixDirsPsr4[$prefix],
188
+ (array) $paths
189
+ );
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Registers a set of PSR-0 directories for a given prefix,
195
+ * replacing any others previously set for this prefix.
196
+ *
197
+ * @param string $prefix The prefix
198
+ * @param array|string $paths The PSR-0 base directories
199
+ */
200
+ public function set($prefix, $paths)
201
+ {
202
+ if (!$prefix) {
203
+ $this->fallbackDirsPsr0 = (array) $paths;
204
+ } else {
205
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Registers a set of PSR-4 directories for a given namespace,
211
+ * replacing any others previously set for this namespace.
212
+ *
213
+ * @param string $prefix The prefix/namespace, with trailing '\\'
214
+ * @param array|string $paths The PSR-4 base directories
215
+ *
216
+ * @throws \InvalidArgumentException
217
+ */
218
+ public function setPsr4($prefix, $paths)
219
+ {
220
+ if (!$prefix) {
221
+ $this->fallbackDirsPsr4 = (array) $paths;
222
+ } else {
223
+ $length = strlen($prefix);
224
+ if ('\\' !== $prefix[$length - 1]) {
225
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
226
+ }
227
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
228
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
229
+ }
230
+ }
231
+
232
+ /**
233
+ * Turns on searching the include path for class files.
234
+ *
235
+ * @param bool $useIncludePath
236
+ */
237
+ public function setUseIncludePath($useIncludePath)
238
+ {
239
+ $this->useIncludePath = $useIncludePath;
240
+ }
241
+
242
+ /**
243
+ * Can be used to check if the autoloader uses the include path to check
244
+ * for classes.
245
+ *
246
+ * @return bool
247
+ */
248
+ public function getUseIncludePath()
249
+ {
250
+ return $this->useIncludePath;
251
+ }
252
+
253
+ /**
254
+ * Turns off searching the prefix and fallback directories for classes
255
+ * that have not been registered with the class map.
256
+ *
257
+ * @param bool $classMapAuthoritative
258
+ */
259
+ public function setClassMapAuthoritative($classMapAuthoritative)
260
+ {
261
+ $this->classMapAuthoritative = $classMapAuthoritative;
262
+ }
263
+
264
+ /**
265
+ * Should class lookup fail if not found in the current class map?
266
+ *
267
+ * @return bool
268
+ */
269
+ public function isClassMapAuthoritative()
270
+ {
271
+ return $this->classMapAuthoritative;
272
+ }
273
+
274
+ /**
275
+ * Registers this instance as an autoloader.
276
+ *
277
+ * @param bool $prepend Whether to prepend the autoloader or not
278
+ */
279
+ public function register($prepend = false)
280
+ {
281
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
282
+ }
283
+
284
+ /**
285
+ * Unregisters this instance as an autoloader.
286
+ */
287
+ public function unregister()
288
+ {
289
+ spl_autoload_unregister(array($this, 'loadClass'));
290
+ }
291
+
292
+ /**
293
+ * Loads the given class or interface.
294
+ *
295
+ * @param string $class The name of the class
296
+ * @return bool|null True if loaded, null otherwise
297
+ */
298
+ public function loadClass($class)
299
+ {
300
+ if ($file = $this->findFile($class)) {
301
+ includeFile($file);
302
+
303
+ return true;
304
+ }
305
+ }
306
+
307
+ /**
308
+ * Finds the path to the file where the class is defined.
309
+ *
310
+ * @param string $class The name of the class
311
+ *
312
+ * @return string|false The path if found, false otherwise
313
+ */
314
+ public function findFile($class)
315
+ {
316
+ // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
317
+ if ('\\' == $class[0]) {
318
+ $class = substr($class, 1);
319
+ }
320
+
321
+ // class map lookup
322
+ if (isset($this->classMap[$class])) {
323
+ return $this->classMap[$class];
324
+ }
325
+ if ($this->classMapAuthoritative) {
326
+ return false;
327
+ }
328
+
329
+ $file = $this->findFileWithExtension($class, '.php');
330
+
331
+ // Search for Hack files if we are running on HHVM
332
+ if ($file === null && defined('HHVM_VERSION')) {
333
+ $file = $this->findFileWithExtension($class, '.hh');
334
+ }
335
+
336
+ if ($file === null) {
337
+ // Remember that this class does not exist.
338
+ return $this->classMap[$class] = false;
339
+ }
340
+
341
+ return $file;
342
+ }
343
+
344
+ private function findFileWithExtension($class, $ext)
345
+ {
346
+ // PSR-4 lookup
347
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
348
+
349
+ $first = $class[0];
350
+ if (isset($this->prefixLengthsPsr4[$first])) {
351
+ foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
352
+ if (0 === strpos($class, $prefix)) {
353
+ foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
354
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
355
+ return $file;
356
+ }
357
+ }
358
+ }
359
+ }
360
+ }
361
+
362
+ // PSR-4 fallback dirs
363
+ foreach ($this->fallbackDirsPsr4 as $dir) {
364
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
365
+ return $file;
366
+ }
367
+ }
368
+
369
+ // PSR-0 lookup
370
+ if (false !== $pos = strrpos($class, '\\')) {
371
+ // namespaced class name
372
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
373
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
374
+ } else {
375
+ // PEAR-like class name
376
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
377
+ }
378
+
379
+ if (isset($this->prefixesPsr0[$first])) {
380
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
381
+ if (0 === strpos($class, $prefix)) {
382
+ foreach ($dirs as $dir) {
383
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
384
+ return $file;
385
+ }
386
+ }
387
+ }
388
+ }
389
+ }
390
+
391
+ // PSR-0 fallback dirs
392
+ foreach ($this->fallbackDirsPsr0 as $dir) {
393
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
394
+ return $file;
395
+ }
396
+ }
397
+
398
+ // PSR-0 include paths.
399
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
400
+ return $file;
401
+ }
402
+ }
403
+ }
404
+
405
+ /**
406
+ * Scope isolated include.
407
+ *
408
+ * Prevents access to $this/self from included files.
409
+ */
410
+ function includeFile($file)
411
+ {
412
+ include $file;
413
+ }
vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Copyright (c) 2016 Nils Adermann, Jordi Boggiano
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_files.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_files.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ '957c51f8f334b5ea3be310bfb8b3492c' => $vendorDir . '/codeinwp/themeisle-sdk/load.php',
10
+ );
vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInit01ee155dcae9890415e2917f84ad7e0b
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ public static function getLoader()
17
+ {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInit01ee155dcae9890415e2917f84ad7e0b', 'loadClassLoader'), true, true);
23
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit01ee155dcae9890415e2917f84ad7e0b', 'loadClassLoader'));
25
+
26
+ $map = require __DIR__ . '/autoload_namespaces.php';
27
+ foreach ($map as $namespace => $path) {
28
+ $loader->set($namespace, $path);
29
+ }
30
+
31
+ $map = require __DIR__ . '/autoload_psr4.php';
32
+ foreach ($map as $namespace => $path) {
33
+ $loader->setPsr4($namespace, $path);
34
+ }
35
+
36
+ $classMap = require __DIR__ . '/autoload_classmap.php';
37
+ if ($classMap) {
38
+ $loader->addClassMap($classMap);
39
+ }
40
+
41
+ $loader->register(true);
42
+
43
+ $includeFiles = require __DIR__ . '/autoload_files.php';
44
+ foreach ($includeFiles as $fileIdentifier => $file) {
45
+ composerRequire01ee155dcae9890415e2917f84ad7e0b($fileIdentifier, $file);
46
+ }
47
+
48
+ return $loader;
49
+ }
50
+ }
51
+
52
+ function composerRequire01ee155dcae9890415e2917f84ad7e0b($fileIdentifier, $file)
53
+ {
54
+ if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
55
+ require $file;
56
+
57
+ $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
58
+ }
59
+ }
vendor/composer/installed.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "name": "codeinwp/themeisle-sdk",
4
+ "version": "dev-master",
5
+ "version_normalized": "9999999-dev",
6
+ "source": {
7
+ "type": "git",
8
+ "url": "https://github.com/Codeinwp/themeisle-sdk.git",
9
+ "reference": "1a64ea86e864d07a99c0f6fe89d3a1370df47c35"
10
+ },
11
+ "dist": {
12
+ "type": "zip",
13
+ "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/1a64ea86e864d07a99c0f6fe89d3a1370df47c35",
14
+ "reference": "1a64ea86e864d07a99c0f6fe89d3a1370df47c35",
15
+ "shasum": ""
16
+ },
17
+ "time": "2017-09-27 13:25:43",
18
+ "type": "library",
19
+ "installation-source": "dist",
20
+ "autoload": {
21
+ "files": [
22
+ "load.php"
23
+ ]
24
+ },
25
+ "license": [
26
+ "GPL-2.0+"
27
+ ],
28
+ "authors": [
29
+ {
30
+ "name": "ThemeIsle team",
31
+ "email": "friends@themeisle.com",
32
+ "homepage": "https://themeisle.com"
33
+ }
34
+ ],
35
+ "description": "ThemeIsle SDK ",
36
+ "homepage": "https://github.com/Codeinwp/themeisle-sdk",
37
+ "keywords": [
38
+ "wordpress"
39
+ ],
40
+ "support": {
41
+ "issues": "https://github.com/Codeinwp/themeisle-sdk/issues",
42
+ "source": "https://github.com/Codeinwp/themeisle-sdk/tree/master"
43
+ }
44
+ }
45
+ ]