Version Description
Download this release
Release Info
Developer | themeisle |
Plugin | WP Maintenance Mode |
Version | 2.4.3 |
Comparing to | |
See all releases |
Code changes from version 2.4.2 to 2.4.3
- changelog.txt → CHANGELOG.md +4 -0
- README.md +143 -0
- assets/images/backgrounds/bg10_thumb.jpg +0 -0
- assets/images/backgrounds/bg11_thumb.jpg +0 -0
- assets/images/backgrounds/bg1_thumb.jpg +0 -0
- assets/images/backgrounds/bg2_thumb.jpg +0 -0
- assets/images/backgrounds/bg3_thumb.jpg +0 -0
- assets/images/backgrounds/bg4_thumb.jpg +0 -0
- assets/images/backgrounds/bg5_thumb.jpg +0 -0
- assets/images/backgrounds/bg6_thumb.jpg +0 -0
- assets/images/backgrounds/bg7_thumb.jpg +0 -0
- assets/images/backgrounds/bg8_thumb.jpg +0 -0
- assets/images/backgrounds/bg9_thumb.jpg +0 -0
- assets/images/recommended/blocksy.jpg +0 -0
- assets/images/recommended/neve.jpg +0 -0
- assets/images/recommended/optimole.jpg +0 -0
- assets/images/recommended/otter.jpg +0 -0
- assets/images/recommended/postcards.jpg +0 -0
- assets/images/recommended/pulsetic.jpeg +0 -0
- assets/images/recommended/static-pages.png +0 -0
- includes/classes/wp-maintenance-mode-admin.php +0 -9
- includes/classes/wp-maintenance-mode.php +1 -1
- includes/functions/helpers.php +9 -15
- readme.txt +17 -10
- vendor/autoload.php +7 -0
- vendor/codeinwp/themeisle-sdk/CHANGELOG.md +265 -0
- vendor/codeinwp/themeisle-sdk/LICENSE +674 -0
- vendor/codeinwp/themeisle-sdk/index.php +3 -0
- vendor/codeinwp/themeisle-sdk/load.php +72 -0
- vendor/codeinwp/themeisle-sdk/src/Common/Abstract_module.php +83 -0
- vendor/codeinwp/themeisle-sdk/src/Common/Module_factory.php +108 -0
- vendor/codeinwp/themeisle-sdk/src/Loader.php +147 -0
- vendor/codeinwp/themeisle-sdk/src/Modules/Dashboard_widget.php +470 -0
- vendor/codeinwp/themeisle-sdk/src/Modules/Licenser.php +1040 -0
- vendor/codeinwp/themeisle-sdk/src/Modules/Logger.php +179 -0
- vendor/codeinwp/themeisle-sdk/src/Modules/Notification.php +463 -0
- vendor/codeinwp/themeisle-sdk/src/Modules/Recommendation.php +377 -0
- vendor/codeinwp/themeisle-sdk/src/Modules/Review.php +117 -0
- vendor/codeinwp/themeisle-sdk/src/Modules/Rollback.php +384 -0
- vendor/codeinwp/themeisle-sdk/src/Modules/Translate.php +918 -0
- vendor/codeinwp/themeisle-sdk/src/Modules/Uninstall_feedback.php +858 -0
- vendor/codeinwp/themeisle-sdk/src/Product.php +421 -0
- vendor/codeinwp/themeisle-sdk/start.php +49 -0
- vendor/composer/ClassLoader.php +572 -0
- vendor/composer/InstalledVersions.php +350 -0
- vendor/composer/LICENSE +21 -0
- vendor/composer/autoload_classmap.php +10 -0
- vendor/composer/autoload_files.php +10 -0
- vendor/composer/autoload_namespaces.php +9 -0
- vendor/composer/autoload_psr4.php +9 -0
- vendor/composer/autoload_real.php +78 -0
- vendor/composer/autoload_static.php +24 -0
- vendor/composer/installed.json +49 -0
- vendor/composer/installed.php +32 -0
- views/promo-blocksy.php +0 -18
- views/promo-pulsetic.php +0 -19
- views/settings.php +14 -14
- wp-maintenance-mode.php +29 -9
changelog.txt → CHANGELOG.md
RENAMED
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
1 |
= 2.4.2 (18/01/2022) =
|
2 |
* Misc: 900 000 Active Installs Celebrations!
|
3 |
* Misc: WordPress 5.9 compatibility
|
1 |
+
##### [Version 2.4.3](https://github.com/Codeinwp/wp-maintenance-mode/compare/v2.4.2...v2.4.3) (2022-01-27)
|
2 |
+
|
3 |
+
- Change ownership to Themeisle
|
4 |
+
|
5 |
= 2.4.2 (18/01/2022) =
|
6 |
* Misc: 900 000 Active Installs Celebrations!
|
7 |
* Misc: WordPress 5.9 compatibility
|
README.md
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# WP Maintenance Mode #
|
2 |
+
**Contributors:** [themeisle](https://profiles.wordpress.org/themeisle/)
|
3 |
+
**Plugin Name:** WP Maintenance Mode
|
4 |
+
**Plugin URI:** https://themeisle.com/
|
5 |
+
**Author:** Themeisle
|
6 |
+
**Author URI:** https://themeisle.com/
|
7 |
+
**Tags:** maintenance mode, admin, administration, unavailable, coming soon, multisite, landing page, under construction, contact form, subscribe, countdown
|
8 |
+
**Requires at least:** 3.5
|
9 |
+
**Tested up to:** 5.9
|
10 |
+
**Stable tag:** trunk
|
11 |
+
**Requires PHP:** 5.6
|
12 |
+
**License:** GPL-2.0+
|
13 |
+
|
14 |
+
Adds a splash page to your site that lets visitors know your site is down for maintenance. It's perfect for a coming soon page. The new Bot functionality is here!
|
15 |
+
|
16 |
+
## Description ##
|
17 |
+
|
18 |
+
Add a maintenance page to your blog that lets visitors know your blog is down for maintenance, or add a coming soon page for a new website. User with admin rights gets full access to the blog including the front end.
|
19 |
+
|
20 |
+
Activate the plugin and your blog is in maintenance-mode, works and only registered users with enough rights can see the front end. You can use a date with a countdown timer for visitor information or set a value and unit for information.
|
21 |
+
|
22 |
+
Also works with WordPress Multisite installs (each blog from the network has its own maintenance settings).
|
23 |
+
|
24 |
+
### Features ###
|
25 |
+
|
26 |
+
* Fully customizable (change colors, texts and backgrounds);
|
27 |
+
* Subscription form (export emails to .csv file);
|
28 |
+
* Countdown timer (remaining time);
|
29 |
+
* Contact form (receive emails from visitors);
|
30 |
+
* Coming soon page;
|
31 |
+
* Landing page templates;
|
32 |
+
* WordPress multisite;
|
33 |
+
* Responsive design;
|
34 |
+
* Social media icons;
|
35 |
+
* Works with any WordPress theme;
|
36 |
+
* SEO options;
|
37 |
+
* Exclude URLs from maintenance;
|
38 |
+
* Bot functionality to collect the emails in a friendly and efficient way;
|
39 |
+
* GDPR Ready;
|
40 |
+
|
41 |
+
### Bugs, technical hints or contribute ###
|
42 |
+
|
43 |
+
Please give us feedback, contribute and file technical bugs on [GitHub Repo](https://github.com/andrianvaleanu/WP-Maintenance-Mode).
|
44 |
+
|
45 |
+
### Credits ###
|
46 |
+
|
47 |
+
Developed by [Themeisle](https://themeisle.com)
|
48 |
+
|
49 |
+
## Installation ##
|
50 |
+
|
51 |
+
1. Unpack the download package
|
52 |
+
2. Upload all files to the `/wp-content/plugins/` directory, include folders
|
53 |
+
3. Activate the plugin through the 'Plugins' menu in WordPress
|
54 |
+
4. Go to `Settings` page, where you can change what settings you need (pay attention to **Exclude** option!)
|
55 |
+
|
56 |
+
## Screenshots ##
|
57 |
+
|
58 |
+
1. Maintenance Mode Example
|
59 |
+
2. Maintenance Mode Example #2
|
60 |
+
3. Bot Example
|
61 |
+
4. Dashboard General Settings
|
62 |
+
5. Dashboard Design Settings
|
63 |
+
6. Dashboard Modules Settings
|
64 |
+
7. Dashboard Bot Settings
|
65 |
+
8. Contact Form
|
66 |
+
|
67 |
+
## Frequently Asked Questions ##
|
68 |
+
|
69 |
+
### How to use plugin filters ###
|
70 |
+
Check out our [Snippet Library](https://github.com/codeinwp/Snippet-Library/).
|
71 |
+
|
72 |
+
### Cache Plugin Support ###
|
73 |
+
WP Maintenance Mode can be unstable due to the cache plugins; we recommend deactivating any cache plugin when maintenance mode is active. If you **really** want to use a cache plugin, make sure you delete the entire cache after each change.
|
74 |
+
|
75 |
+
### Exclude list ###
|
76 |
+
If you change your login url, please add the new slug (url: http://domain.com/newlogin, then you should add: newlogin) to Exclude list from plugin settings -> General Tab.
|
77 |
+
|
78 |
+
Notice: `wp-cron.php` is excluded by default.
|
79 |
+
|
80 |
+
## Changelog ##
|
81 |
+
|
82 |
+
##### [Version 2.4.3](https://github.com/Codeinwp/wp-maintenance-mode/compare/v2.4.2...v2.4.3) (2022-01-27)
|
83 |
+
|
84 |
+
- Change ownership to Themeisle
|
85 |
+
|
86 |
+
|
87 |
+
|
88 |
+
|
89 |
+
### 2.4.2 (18/01/2022) ###
|
90 |
+
* Misc: 900 000 Active Installs Celebrations!
|
91 |
+
* Misc: WordPress 5.9 compatibility
|
92 |
+
* Fix: jQuery UI CSS theme reference from jQuery CDN
|
93 |
+
* Misc: Text fixes in the dashboard
|
94 |
+
|
95 |
+
### 2.4.1 (20/07/2021) ###
|
96 |
+
* Misc: WordPress 5.8 compatibility
|
97 |
+
|
98 |
+
### 2.4.0 (13/05/2021) ###
|
99 |
+
* Design: add "Custom CSS" setting; Finally! :)
|
100 |
+
* Design: add "Footer links" color setting
|
101 |
+
* Design: add a list of available shortcodes under the "Text" editor
|
102 |
+
* Bot: make {visitor_name} placeholder work in all messages after the visitor types his name
|
103 |
+
* Misc: add [embed] shortcode for responsive video embeds; Compatible with YouTube, Vimeo, DailyMotion.
|
104 |
+
* Misc: make the exclude mechanism work with Cyrillic characters
|
105 |
+
* Misc: add `wpmm_maintenance_template` filter; It works the same way as the `wpmm_contact_template` filter, but for the maintenance template.
|
106 |
+
* Misc: now you can override the `contact` email template too; Check `/views/contact.php` for more details.
|
107 |
+
* Misc: better compatibility with translation plugins like Loco Translate
|
108 |
+
* Misc: the image uploaders (from the dashboard) are now translatable
|
109 |
+
* Misc: improve uninstall routine
|
110 |
+
* Misc: add `wpmm_delete_cache` action; It is called after each setting change.
|
111 |
+
* Misc: add support for cache plugins like WP Rocket, WP Fastest Cache, Endurance Page Cache, Swift Performance Lite, Cache Enabler, SG Optimizer, LiteSpeed Cache, Nginx Helper;
|
112 |
+
* Misc: remove `wpmm_count_where` helper function
|
113 |
+
* Misc: code improvements
|
114 |
+
|
115 |
+
### 2.3.0 (07/12/2020) ###
|
116 |
+
* Modules: add support for Google Analytics 4 measurement ID
|
117 |
+
* Design: enable media buttons on wp_editor (now you can add images from the editor)
|
118 |
+
* Bot: fix translation issue
|
119 |
+
* Misc: add filters for capabilities `wpmm_settings_capability`, `wpmm_subscribers_capability`, and `wpmm_all_actions_capability` (the last one can be used to override all capabilities)
|
120 |
+
* Misc: fix [loginform] shortcode redirect attribute
|
121 |
+
* Misc: a few CSS & Javascript improvements
|
122 |
+
* Misc: bump "Tested up to" version to 5.6
|
123 |
+
|
124 |
+
### 2.2.4 (20/05/2019) ###
|
125 |
+
* bump "Tested up to" to 5.2.0
|
126 |
+
* fix typo in Italian translation (it_IT)
|
127 |
+
* Bot: add a note about how you can export the list of subscribers [#195](https://github.com/andrianvaleanu/WP-Maintenance-Mode/issues/195)
|
128 |
+
* Bot: add client-side sanitization to the input fields [#176](https://github.com/andrianvaleanu/WP-Maintenance-Mode/issues/176)
|
129 |
+
|
130 |
+
### 2.2.3 (20/02/2019) ###
|
131 |
+
* bump "Tested up to" version to 5.1.0
|
132 |
+
* replace "wpmu_new_blog" action with "wp_initialize_site" action for WP 5.1.0 users because the first one is deprecated in the new version
|
133 |
+
* small improvement to "check_exclude" method from "WP_Maintenance_Mode" class
|
134 |
+
|
135 |
+
### 2.2.2 (27/11/2018) ###
|
136 |
+
* Google Analytics module: migrate from analytics.js to gtag.js + add ip anonymization [#178](https://github.com/andrianvaleanu/WP-Maintenance-Mode/issues/178)
|
137 |
+
* GDPR module: accept links inside texareas + add policy link target [#188](https://github.com/andrianvaleanu/WP-Maintenance-Mode/issues/188)
|
138 |
+
* add charset meta tag [#200](https://github.com/andrianvaleanu/WP-Maintenance-Mode/issues/200)
|
139 |
+
* fix PHP Notice: Undefined index: HTTP_USER_AGENT
|
140 |
+
* add plural and single form translation for subscribers number (settings page)
|
141 |
+
|
142 |
+
### Earlier versions ###
|
143 |
+
For the changelog of earlier versions, please refer to the [full changelog](http://plugins.svn.wordpress.org/wp-maintenance-mode/trunk/changelog.txt).
|
assets/images/backgrounds/bg10_thumb.jpg
CHANGED
Binary file
|
assets/images/backgrounds/bg11_thumb.jpg
CHANGED
Binary file
|
assets/images/backgrounds/bg1_thumb.jpg
CHANGED
Binary file
|
assets/images/backgrounds/bg2_thumb.jpg
CHANGED
Binary file
|
assets/images/backgrounds/bg3_thumb.jpg
CHANGED
Binary file
|
assets/images/backgrounds/bg4_thumb.jpg
CHANGED
Binary file
|
assets/images/backgrounds/bg5_thumb.jpg
CHANGED
Binary file
|
assets/images/backgrounds/bg6_thumb.jpg
CHANGED
Binary file
|
assets/images/backgrounds/bg7_thumb.jpg
CHANGED
Binary file
|
assets/images/backgrounds/bg8_thumb.jpg
CHANGED
Binary file
|
assets/images/backgrounds/bg9_thumb.jpg
CHANGED
Binary file
|
assets/images/recommended/blocksy.jpg
DELETED
Binary file
|
assets/images/recommended/neve.jpg
ADDED
Binary file
|
assets/images/recommended/optimole.jpg
ADDED
Binary file
|
assets/images/recommended/otter.jpg
ADDED
Binary file
|
assets/images/recommended/postcards.jpg
DELETED
Binary file
|
assets/images/recommended/pulsetic.jpeg
DELETED
Binary file
|
assets/images/recommended/static-pages.png
DELETED
Binary file
|
includes/classes/wp-maintenance-mode-admin.php
CHANGED
@@ -79,7 +79,6 @@ if ( ! class_exists( 'WP_Maintenance_Mode_Admin' ) ) {
|
|
79 |
return;
|
80 |
}
|
81 |
|
82 |
-
|
83 |
$screen = get_current_screen();
|
84 |
if ( $this->plugin_screen_hook_suffix === $screen->id ) {
|
85 |
$wp_scripts = wp_scripts();
|
@@ -606,14 +605,6 @@ if ( ! class_exists( 'WP_Maintenance_Mode_Admin' ) ) {
|
|
606 |
} else {
|
607 |
// delete wpmm_notice
|
608 |
delete_option( 'wpmm_notice' );
|
609 |
-
|
610 |
-
// notice for pulsetic
|
611 |
-
ob_start();
|
612 |
-
include_once wpmm_get_template_path( 'promo-pulsetic.php' );
|
613 |
-
$notices['promo-pulsetic'] = array(
|
614 |
-
'class' => 'wpmm_notices updated notice is-dismissible',
|
615 |
-
'msg' => ob_get_clean(),
|
616 |
-
);
|
617 |
}
|
618 |
|
619 |
// get dismissed notices
|
79 |
return;
|
80 |
}
|
81 |
|
|
|
82 |
$screen = get_current_screen();
|
83 |
if ( $this->plugin_screen_hook_suffix === $screen->id ) {
|
84 |
$wp_scripts = wp_scripts();
|
605 |
} else {
|
606 |
// delete wpmm_notice
|
607 |
delete_option( 'wpmm_notice' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
608 |
}
|
609 |
|
610 |
// get dismissed notices
|
includes/classes/wp-maintenance-mode.php
CHANGED
@@ -6,7 +6,7 @@ if ( ! class_exists( 'WP_Maintenance_Mode' ) ) {
|
|
6 |
|
7 |
class WP_Maintenance_Mode {
|
8 |
|
9 |
-
const VERSION = '2.4.
|
10 |
|
11 |
protected $plugin_slug = 'wp-maintenance-mode';
|
12 |
protected $plugin_settings;
|
6 |
|
7 |
class WP_Maintenance_Mode {
|
8 |
|
9 |
+
const VERSION = '2.4.3';
|
10 |
|
11 |
protected $plugin_slug = 'wp-maintenance-mode';
|
12 |
protected $plugin_settings;
|
includes/functions/helpers.php
CHANGED
@@ -109,27 +109,21 @@ function wpmm_get_banner_url( $filename ) {
|
|
109 |
function wpmm_get_banners() {
|
110 |
return array(
|
111 |
array(
|
112 |
-
'title' => '
|
113 |
-
'link' => 'https://
|
114 |
-
'image' => '
|
115 |
'utm' => true,
|
116 |
),
|
117 |
array(
|
118 |
-
'title' => '
|
119 |
-
'link' => 'https://
|
120 |
-
'image' => '
|
121 |
'utm' => true,
|
122 |
),
|
123 |
array(
|
124 |
-
'title' => '
|
125 |
-
'link' => 'https://
|
126 |
-
'image' => '
|
127 |
-
'utm' => true,
|
128 |
-
),
|
129 |
-
array(
|
130 |
-
'title' => 'Static Pages',
|
131 |
-
'link' => 'https://designmodo.com/static-pages/',
|
132 |
-
'image' => 'static-pages.png',
|
133 |
'utm' => true,
|
134 |
),
|
135 |
);
|
109 |
function wpmm_get_banners() {
|
110 |
return array(
|
111 |
array(
|
112 |
+
'title' => 'Neve',
|
113 |
+
'link' => 'https://themeisle.com/themes/neve/',
|
114 |
+
'image' => 'neve.jpg',
|
115 |
'utm' => true,
|
116 |
),
|
117 |
array(
|
118 |
+
'title' => 'Optimole',
|
119 |
+
'link' => 'https://optimole.com/wordpress/',
|
120 |
+
'image' => 'optimole.jpg',
|
121 |
'utm' => true,
|
122 |
),
|
123 |
array(
|
124 |
+
'title' => 'Otter Blocks',
|
125 |
+
'link' => 'https://themeisle.com/plugins/otter-blocks/',
|
126 |
+
'image' => 'otter.jpg',
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
'utm' => true,
|
128 |
),
|
129 |
);
|
readme.txt
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
=== WP Maintenance Mode ===
|
2 |
-
Contributors:
|
3 |
Plugin Name: WP Maintenance Mode
|
4 |
-
Plugin URI: https://
|
5 |
-
Author:
|
6 |
-
Author URI: https://
|
7 |
Tags: maintenance mode, admin, administration, unavailable, coming soon, multisite, landing page, under construction, contact form, subscribe, countdown
|
8 |
Requires at least: 3.5
|
9 |
Tested up to: 5.9
|
10 |
-
Stable tag:
|
11 |
Requires PHP: 5.6
|
12 |
License: GPL-2.0+
|
13 |
|
@@ -17,9 +17,9 @@ Adds a splash page to your site that lets visitors know your site is down for ma
|
|
17 |
|
18 |
Add a maintenance page to your blog that lets visitors know your blog is down for maintenance, or add a coming soon page for a new website. User with admin rights gets full access to the blog including the front end.
|
19 |
|
20 |
-
Activate the plugin and your blog is in maintenance-mode, works and only registered users with enough rights can see the front end. You can use a date with a countdown timer for visitor information or set a value and unit for information.
|
21 |
|
22 |
-
Also works with WordPress Multisite installs (each blog from the network has
|
23 |
|
24 |
= Features =
|
25 |
|
@@ -44,7 +44,7 @@ Please give us feedback, contribute and file technical bugs on [GitHub Repo](htt
|
|
44 |
|
45 |
= Credits =
|
46 |
|
47 |
-
Developed by [
|
48 |
|
49 |
== Installation ==
|
50 |
|
@@ -66,8 +66,8 @@ Developed by [Designmodo](https://designmodo.com)
|
|
66 |
|
67 |
== Frequently Asked Questions ==
|
68 |
|
69 |
-
= How to use plugin filters =
|
70 |
-
Check out our [Snippet Library](https://github.com/
|
71 |
|
72 |
= Cache Plugin Support =
|
73 |
WP Maintenance Mode can be unstable due to the cache plugins; we recommend deactivating any cache plugin when maintenance mode is active. If you **really** want to use a cache plugin, make sure you delete the entire cache after each change.
|
@@ -79,6 +79,13 @@ Notice: `wp-cron.php` is excluded by default.
|
|
79 |
|
80 |
== Changelog ==
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
= 2.4.2 (18/01/2022) =
|
83 |
* Misc: 900 000 Active Installs Celebrations!
|
84 |
* Misc: WordPress 5.9 compatibility
|
1 |
=== WP Maintenance Mode ===
|
2 |
+
Contributors: Themeisle
|
3 |
Plugin Name: WP Maintenance Mode
|
4 |
+
Plugin URI: https://themeisle.com/
|
5 |
+
Author: Themeisle
|
6 |
+
Author URI: https://themeisle.com/
|
7 |
Tags: maintenance mode, admin, administration, unavailable, coming soon, multisite, landing page, under construction, contact form, subscribe, countdown
|
8 |
Requires at least: 3.5
|
9 |
Tested up to: 5.9
|
10 |
+
Stable tag: trunk
|
11 |
Requires PHP: 5.6
|
12 |
License: GPL-2.0+
|
13 |
|
17 |
|
18 |
Add a maintenance page to your blog that lets visitors know your blog is down for maintenance, or add a coming soon page for a new website. User with admin rights gets full access to the blog including the front end.
|
19 |
|
20 |
+
Activate the plugin and your blog is in maintenance-mode, works and only registered users with enough rights can see the front end. You can use a date with a countdown timer for visitor information or set a value and unit for information.
|
21 |
|
22 |
+
Also works with WordPress Multisite installs (each blog from the network has its own maintenance settings).
|
23 |
|
24 |
= Features =
|
25 |
|
44 |
|
45 |
= Credits =
|
46 |
|
47 |
+
Developed by [Themeisle](https://themeisle.com)
|
48 |
|
49 |
== Installation ==
|
50 |
|
66 |
|
67 |
== Frequently Asked Questions ==
|
68 |
|
69 |
+
= How to use plugin filters =
|
70 |
+
Check out our [Snippet Library](https://github.com/codeinwp/Snippet-Library/).
|
71 |
|
72 |
= Cache Plugin Support =
|
73 |
WP Maintenance Mode can be unstable due to the cache plugins; we recommend deactivating any cache plugin when maintenance mode is active. If you **really** want to use a cache plugin, make sure you delete the entire cache after each change.
|
79 |
|
80 |
== Changelog ==
|
81 |
|
82 |
+
##### [Version 2.4.3](https://github.com/Codeinwp/wp-maintenance-mode/compare/v2.4.2...v2.4.3) (2022-01-27)
|
83 |
+
|
84 |
+
- Change ownership to Themeisle
|
85 |
+
|
86 |
+
|
87 |
+
|
88 |
+
|
89 |
= 2.4.2 (18/01/2022) =
|
90 |
* Misc: 900 000 Active Installs Celebrations!
|
91 |
* Misc: WordPress 5.9 compatibility
|
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 ComposerAutoloaderInitd450da3bedcb4518199c80b96d40a4f1::getLoader();
|
vendor/codeinwp/themeisle-sdk/CHANGELOG.md
ADDED
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
##### [Version 3.2.22](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.21...v3.2.22) (2021-10-27)
|
2 |
+
|
3 |
+
Fix edge case when reset failed checks was not working properly
|
4 |
+
|
5 |
+
##### [Version 3.2.21](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.20...v3.2.21) (2021-06-30)
|
6 |
+
|
7 |
+
review and improve compatibility with auto-updates on custom updates endpoint
|
8 |
+
|
9 |
+
##### [Version 3.2.20](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.19...v3.2.20) (2021-03-30)
|
10 |
+
|
11 |
+
add wp-config support
|
12 |
+
|
13 |
+
##### [Version 3.2.19](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.18...v3.2.19) (2021-03-12)
|
14 |
+
|
15 |
+
* Adds compatibility with latest PHPCS coding standards.
|
16 |
+
* Adds compatibility with core auto-update.
|
17 |
+
|
18 |
+
##### [Version 3.2.18](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.17...v3.2.18) (2021-03-04)
|
19 |
+
|
20 |
+
* Fix regression on rollback order
|
21 |
+
|
22 |
+
##### [Version 3.2.17](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.16...v3.2.17) (2021-03-04)
|
23 |
+
|
24 |
+
* Fix compatibility with PHP 8 due to usort
|
25 |
+
|
26 |
+
##### [Version 3.2.16](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.15...v3.2.16) (2020-11-17)
|
27 |
+
|
28 |
+
* Fix long texts on rollback.
|
29 |
+
* Fix RTL mode for uninstall feedback.
|
30 |
+
|
31 |
+
##### [Version 3.2.15](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.14...v3.2.15) (2020-07-23)
|
32 |
+
|
33 |
+
* remove no redundant module
|
34 |
+
|
35 |
+
##### [Version 3.2.14](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.13...v3.2.14) (2020-06-10)
|
36 |
+
|
37 |
+
> Things are getting better every day. 🚀
|
38 |
+
|
39 |
+
##### [Version 3.2.13](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.12...v3.2.13) (2020-06-10)
|
40 |
+
|
41 |
+
Adds plan logic and expiration
|
42 |
+
|
43 |
+
##### [Version 3.2.12](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.11...v3.2.12) (2020-06-10)
|
44 |
+
|
45 |
+
Adds key filter
|
46 |
+
|
47 |
+
##### [Version 3.2.11](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.10...v3.2.11) (2020-06-04)
|
48 |
+
|
49 |
+
* remove non-printable chars
|
50 |
+
|
51 |
+
##### [Version 3.2.10](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.9...v3.2.10) (2020-05-28)
|
52 |
+
|
53 |
+
* Remove extra files on export
|
54 |
+
|
55 |
+
##### [Version 3.2.9](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.8...v3.2.9) (2020-05-18)
|
56 |
+
|
57 |
+
adds new endpoints
|
58 |
+
|
59 |
+
##### [Version 3.2.8](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.7...v3.2.8) (2020-03-24)
|
60 |
+
|
61 |
+
* change license handler method access
|
62 |
+
|
63 |
+
##### [Version 3.2.7](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.6...v3.2.7) (2020-03-24)
|
64 |
+
|
65 |
+
* fix callback for license processing hook
|
66 |
+
|
67 |
+
##### [Version 3.2.6](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.5...v3.2.6) (2020-03-23)
|
68 |
+
|
69 |
+
* Fix notice on license deactivation
|
70 |
+
|
71 |
+
##### [Version 3.2.5](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.4...v3.2.5) (2020-03-23)
|
72 |
+
|
73 |
+
* always load notification manager last
|
74 |
+
|
75 |
+
##### [Version 3.2.4](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.3...v3.2.4) (2020-03-21)
|
76 |
+
|
77 |
+
* Cast version response to array for icons
|
78 |
+
|
79 |
+
##### [Version 3.2.3](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.2...v3.2.3) (2020-03-21)
|
80 |
+
|
81 |
+
* use product slug instead of the one from api
|
82 |
+
|
83 |
+
##### [Version 3.2.2](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.1...v3.2.2) (2020-03-13)
|
84 |
+
|
85 |
+
* improve notice dismiss mechanism
|
86 |
+
|
87 |
+
##### [Version 3.2.1](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.0...v3.2.1) (2020-03-05)
|
88 |
+
|
89 |
+
Fix rollback call for private products
|
90 |
+
|
91 |
+
#### [Version 3.2.0](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.9...v3.2.0) (2020-03-04)
|
92 |
+
|
93 |
+
* adds license activation/deactivation handlers for wp cli
|
94 |
+
* adds compatibility with the newest license API
|
95 |
+
|
96 |
+
##### [Version 3.1.9](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.8...v3.1.9) (2020-02-24)
|
97 |
+
|
98 |
+
* Add integration with GitHub actions
|
99 |
+
|
100 |
+
## [3.1.8](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.7...v3.1.8) (2019-11-18)
|
101 |
+
|
102 |
+
|
103 |
+
### Bug Fixes
|
104 |
+
|
105 |
+
* update developers name ([6aca63e](https://github.com/Codeinwp/themeisle-sdk/commit/6aca63e))
|
106 |
+
|
107 |
+
## [3.1.7](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.6...v3.1.7) (2019-11-07)
|
108 |
+
|
109 |
+
|
110 |
+
### Bug Fixes
|
111 |
+
|
112 |
+
* license field style on wp5.3 ([0239997](https://github.com/Codeinwp/themeisle-sdk/commit/0239997))
|
113 |
+
* license field style on wp5.3 ([86d3a1b](https://github.com/Codeinwp/themeisle-sdk/commit/86d3a1b))
|
114 |
+
|
115 |
+
## [3.1.6](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.5...v3.1.6) (2019-09-24)
|
116 |
+
|
117 |
+
|
118 |
+
### Bug Fixes
|
119 |
+
|
120 |
+
* remove license related options when deactivated ([02cd6ce](https://github.com/Codeinwp/themeisle-sdk/commit/02cd6ce))
|
121 |
+
* remove license related options when deactivated ([d3c1a1f](https://github.com/Codeinwp/themeisle-sdk/commit/d3c1a1f))
|
122 |
+
|
123 |
+
## [3.1.5](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.4...v3.1.5) (2019-09-11)
|
124 |
+
|
125 |
+
|
126 |
+
### Bug Fixes
|
127 |
+
|
128 |
+
* allow unloading certain module features ([2a2559a](https://github.com/Codeinwp/themeisle-sdk/commit/2a2559a))
|
129 |
+
* license activation workflow, show error message when failed to a… ([ade795c](https://github.com/Codeinwp/themeisle-sdk/commit/ade795c))
|
130 |
+
* license activation workflow, show error message when failed to activate ([2f5cbae](https://github.com/Codeinwp/themeisle-sdk/commit/2f5cbae))
|
131 |
+
|
132 |
+
## [3.1.4](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.3...v3.1.4) (2019-08-23)
|
133 |
+
|
134 |
+
|
135 |
+
### Bug Fixes
|
136 |
+
|
137 |
+
* license key was missing on get_version call ([365cde6](https://github.com/Codeinwp/themeisle-sdk/commit/365cde6))
|
138 |
+
* license key was missing on get_version call ([c02f225](https://github.com/Codeinwp/themeisle-sdk/commit/c02f225))
|
139 |
+
|
140 |
+
## [3.1.3](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.2...v3.1.3) (2019-08-20)
|
141 |
+
|
142 |
+
|
143 |
+
### Bug Fixes
|
144 |
+
|
145 |
+
* license deactivation behaviour https://github.com/Codeinwp/visua… ([59c4afe](https://github.com/Codeinwp/themeisle-sdk/commit/59c4afe))
|
146 |
+
* license deactivation behaviour https://github.com/Codeinwp/visualizer-pro/issues/192 ([f641e18](https://github.com/Codeinwp/themeisle-sdk/commit/f641e18))
|
147 |
+
|
148 |
+
## [3.1.2](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.1...v3.1.2) (2019-08-12)
|
149 |
+
|
150 |
+
|
151 |
+
### Bug Fixes
|
152 |
+
|
153 |
+
* phpunit test case ([efe851c](https://github.com/Codeinwp/themeisle-sdk/commit/efe851c))
|
154 |
+
* url format for license endpoint, improve changelog handling and license checks ([a492c68](https://github.com/Codeinwp/themeisle-sdk/commit/a492c68))
|
155 |
+
|
156 |
+
## [3.1.1](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.0...v3.1.1) (2019-08-08)
|
157 |
+
|
158 |
+
|
159 |
+
### Bug Fixes
|
160 |
+
|
161 |
+
* adds is_file for file existence check ([d1205c4](https://github.com/Codeinwp/themeisle-sdk/commit/d1205c4))
|
162 |
+
* adds is_file for file existence check ([be119c1](https://github.com/Codeinwp/themeisle-sdk/commit/be119c1))
|
163 |
+
|
164 |
+
# [3.1.0](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.10...v3.1.0) (2019-08-05)
|
165 |
+
|
166 |
+
|
167 |
+
### Bug Fixes
|
168 |
+
|
169 |
+
* adds extra comments for rest of the options, fix [#64](https://github.com/Codeinwp/themeisle-sdk/issues/64) ([018b22f](https://github.com/Codeinwp/themeisle-sdk/commit/018b22f))
|
170 |
+
* hide license key when active under a password mask, fix [#67](https://github.com/Codeinwp/themeisle-sdk/issues/67) ([c0633c2](https://github.com/Codeinwp/themeisle-sdk/commit/c0633c2))
|
171 |
+
* new uninstall feedback popup issues ([5bda4bd](https://github.com/Codeinwp/themeisle-sdk/commit/5bda4bd))
|
172 |
+
* phpcs indentation errors ([d59ed4f](https://github.com/Codeinwp/themeisle-sdk/commit/d59ed4f))
|
173 |
+
* undefined notices on license check, fix [#60](https://github.com/Codeinwp/themeisle-sdk/issues/60) ([7f56a97](https://github.com/Codeinwp/themeisle-sdk/commit/7f56a97))
|
174 |
+
* uninstall feedback popup placement [[#61](https://github.com/Codeinwp/themeisle-sdk/issues/61)] ([1102d6c](https://github.com/Codeinwp/themeisle-sdk/commit/1102d6c))
|
175 |
+
|
176 |
+
|
177 |
+
### Features
|
178 |
+
|
179 |
+
* new product feedback popup ([f0dbab3](https://github.com/Codeinwp/themeisle-sdk/commit/f0dbab3))
|
180 |
+
* new uninstall feedback form for themes ([8a29f21](https://github.com/Codeinwp/themeisle-sdk/commit/8a29f21))
|
181 |
+
|
182 |
+
## [3.0.10](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.9...v3.0.10) (2019-07-16)
|
183 |
+
|
184 |
+
|
185 |
+
### Bug Fixes
|
186 |
+
|
187 |
+
* compatibility with lower PHP versions ([065ac8e](https://github.com/Codeinwp/themeisle-sdk/commit/065ac8e))
|
188 |
+
* not loading licenser when SDK comes from theme [[#62](https://github.com/Codeinwp/themeisle-sdk/issues/62)] ([b706ca7](https://github.com/Codeinwp/themeisle-sdk/commit/b706ca7))
|
189 |
+
* not loading licenser when SDK comes from theme [[#65](https://github.com/Codeinwp/themeisle-sdk/issues/65) ([419d8e6](https://github.com/Codeinwp/themeisle-sdk/commit/419d8e6))
|
190 |
+
* preserve loaded when adding the licenser one ([cd50434](https://github.com/Codeinwp/themeisle-sdk/commit/cd50434))
|
191 |
+
|
192 |
+
## [3.0.9](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.8...v3.0.9) (2019-06-26)
|
193 |
+
|
194 |
+
|
195 |
+
### Bug Fixes
|
196 |
+
|
197 |
+
* adds new icon for dashboard widget ([de78068](https://github.com/Codeinwp/themeisle-sdk/commit/de78068))
|
198 |
+
* anchor element on license activation message which should link to the license field, fix [#57](https://github.com/Codeinwp/themeisle-sdk/issues/57) ([2e78856](https://github.com/Codeinwp/themeisle-sdk/commit/2e78856))
|
199 |
+
* change uninstall feedback logo with new version, fix [#58](https://github.com/Codeinwp/themeisle-sdk/issues/58) ([2554a4f](https://github.com/Codeinwp/themeisle-sdk/commit/2554a4f))
|
200 |
+
* remove soon to expire notice, fix https://github.com/Codeinwp/themeisle/issues/752 ([a126225](https://github.com/Codeinwp/themeisle-sdk/commit/a126225))
|
201 |
+
|
202 |
+
## [3.0.8](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.7...v3.0.8) (2019-05-28)
|
203 |
+
|
204 |
+
|
205 |
+
### Bug Fixes
|
206 |
+
|
207 |
+
* undefined class on diff module which should check the class on global namespace ([df6bb12](https://github.com/Codeinwp/themeisle-sdk/commit/df6bb12))
|
208 |
+
|
209 |
+
## [3.0.7](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.6...v3.0.7) (2019-05-27)
|
210 |
+
|
211 |
+
|
212 |
+
### Bug Fixes
|
213 |
+
|
214 |
+
* change store url with the new domain ([6bdbe1e](https://github.com/Codeinwp/themeisle-sdk/commit/6bdbe1e))
|
215 |
+
|
216 |
+
## [3.0.6](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.5...v3.0.6) (2019-05-21)
|
217 |
+
|
218 |
+
|
219 |
+
### Bug Fixes
|
220 |
+
|
221 |
+
* build php version for deployment stage ([a785699](https://github.com/Codeinwp/themeisle-sdk/commit/a785699))
|
222 |
+
* uninstall feedback should load only on the proper pages ([259e78f](https://github.com/Codeinwp/themeisle-sdk/commit/259e78f))
|
223 |
+
|
224 |
+
## [3.0.5](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.4...v3.0.5) (2019-03-07)
|
225 |
+
|
226 |
+
|
227 |
+
### Bug Fixes
|
228 |
+
|
229 |
+
* dashboard widget issues and recommended module inconsistency fix [#50](https://github.com/Codeinwp/themeisle-sdk/issues/50), [#49](https://github.com/Codeinwp/themeisle-sdk/issues/49), [#47](https://github.com/Codeinwp/themeisle-sdk/issues/47) ([757eb02](https://github.com/Codeinwp/themeisle-sdk/commit/757eb02))
|
230 |
+
|
231 |
+
## [3.0.4](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.3...v3.0.4) (2019-01-28)
|
232 |
+
|
233 |
+
|
234 |
+
### Bug Fixes
|
235 |
+
|
236 |
+
* uninstall feedback disclosure issues when one of the feedback fields is open ([4631eef](https://github.com/Codeinwp/themeisle-sdk/commit/4631eef))
|
237 |
+
|
238 |
+
## [3.0.3](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.2...v3.0.3) (2019-01-07)
|
239 |
+
|
240 |
+
|
241 |
+
### Bug Fixes
|
242 |
+
|
243 |
+
* **build:** fix exit code when is running outside wordpress context ([d298bb5](https://github.com/Codeinwp/themeisle-sdk/commit/d298bb5))
|
244 |
+
|
245 |
+
## [3.0.2](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.1...v3.0.2) (2018-12-28)
|
246 |
+
|
247 |
+
|
248 |
+
### Bug Fixes
|
249 |
+
|
250 |
+
* remove composer/installers from package requirements ([a0ad543](https://github.com/Codeinwp/themeisle-sdk/commit/a0ad543))
|
251 |
+
|
252 |
+
## [3.0.1](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.0...v3.0.1) (2018-12-24)
|
253 |
+
|
254 |
+
|
255 |
+
### Bug Fixes
|
256 |
+
|
257 |
+
* notifications setup triggers after all products register their n… ([999a944](https://github.com/Codeinwp/themeisle-sdk/commit/999a944))
|
258 |
+
* notifications setup triggers after all products register their notices ([ec3cacc](https://github.com/Codeinwp/themeisle-sdk/commit/ec3cacc))
|
259 |
+
|
260 |
+
# 1.0.0 (2018-12-21)
|
261 |
+
|
262 |
+
|
263 |
+
### Features
|
264 |
+
|
265 |
+
* adds uninstall feedback privacy policy info ([ed17943](https://github.com/Codeinwp/themeisle-sdk/commit/ed17943))
|
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/index.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// phpcs:ignoreFile
|
3 |
+
// Nothing here.
|
vendor/codeinwp/themeisle-sdk/load.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
14 |
+
return;
|
15 |
+
}
|
16 |
+
// Current SDK version and path.
|
17 |
+
$themeisle_sdk_version = '3.2.22';
|
18 |
+
$themeisle_sdk_path = dirname( __FILE__ );
|
19 |
+
|
20 |
+
global $themeisle_sdk_max_version;
|
21 |
+
global $themeisle_sdk_max_path;
|
22 |
+
|
23 |
+
// If this is the latest SDK and it comes from a theme, we should load licenser separately.
|
24 |
+
$themeisle_sdk_relative_licenser_path = '/src/Modules/Licenser.php';
|
25 |
+
|
26 |
+
global $themeisle_sdk_abs_licenser_path;
|
27 |
+
if ( ! is_file( $themeisle_sdk_path . $themeisle_sdk_relative_licenser_path ) && is_file( $themeisle_sdk_max_path . $themeisle_sdk_relative_licenser_path ) ) {
|
28 |
+
$themeisle_sdk_abs_licenser_path = $themeisle_sdk_max_path . $themeisle_sdk_relative_licenser_path;
|
29 |
+
add_filter( 'themeisle_sdk_required_files', 'themeisle_sdk_load_licenser_if_present' );
|
30 |
+
}
|
31 |
+
if ( version_compare( $themeisle_sdk_version, $themeisle_sdk_max_path ) == 0 &&
|
32 |
+
apply_filters( 'themeisle_sdk_should_overwrite_path', false, $themeisle_sdk_path, $themeisle_sdk_max_path ) ) {
|
33 |
+
$themeisle_sdk_max_path = $themeisle_sdk_path;
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( version_compare( $themeisle_sdk_version, $themeisle_sdk_max_version ) > 0 ) {
|
37 |
+
$themeisle_sdk_max_version = $themeisle_sdk_version;
|
38 |
+
$themeisle_sdk_max_path = $themeisle_sdk_path;
|
39 |
+
}
|
40 |
+
|
41 |
+
// load the latest sdk version from the active Themeisle products.
|
42 |
+
if ( ! function_exists( 'themeisle_sdk_load_licenser_if_present' ) ) :
|
43 |
+
/**
|
44 |
+
* Always load the licenser, if present.
|
45 |
+
*
|
46 |
+
* @param array $to_load Previously files to load.
|
47 |
+
*/
|
48 |
+
function themeisle_sdk_load_licenser_if_present( $to_load ) {
|
49 |
+
global $themeisle_sdk_abs_licenser_path;
|
50 |
+
$to_load[] = $themeisle_sdk_abs_licenser_path;
|
51 |
+
|
52 |
+
return $to_load;
|
53 |
+
}
|
54 |
+
endif;
|
55 |
+
|
56 |
+
// load the latest sdk version from the active Themeisle products.
|
57 |
+
if ( ! function_exists( 'themeisle_sdk_load_latest' ) ) :
|
58 |
+
/**
|
59 |
+
* Always load the latest sdk version.
|
60 |
+
*/
|
61 |
+
function themeisle_sdk_load_latest() {
|
62 |
+
/**
|
63 |
+
* Don't load the library if we are on < 5.4.
|
64 |
+
*/
|
65 |
+
if ( version_compare( PHP_VERSION, '5.4.32', '<' ) ) {
|
66 |
+
return;
|
67 |
+
}
|
68 |
+
global $themeisle_sdk_max_path;
|
69 |
+
require_once $themeisle_sdk_max_path . '/start.php';
|
70 |
+
}
|
71 |
+
endif;
|
72 |
+
add_action( 'init', 'themeisle_sdk_load_latest' );
|
vendor/codeinwp/themeisle-sdk/src/Common/Abstract_module.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The abstract class for module definition.
|
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 3.0.0
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace ThemeisleSDK\Common;
|
13 |
+
|
14 |
+
use ThemeisleSDK\Product;
|
15 |
+
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
exit;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Class Abstract_Module.
|
22 |
+
*
|
23 |
+
* @package ThemeisleSDK\Common
|
24 |
+
*/
|
25 |
+
abstract class Abstract_Module {
|
26 |
+
/**
|
27 |
+
* Product which use the module.
|
28 |
+
*
|
29 |
+
* @var Product $product Product object.
|
30 |
+
*/
|
31 |
+
protected $product = null;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Can load the module for the selected product.
|
35 |
+
*
|
36 |
+
* @param Product $product Product data.
|
37 |
+
*
|
38 |
+
* @return bool Should load module?
|
39 |
+
*/
|
40 |
+
abstract public function can_load( $product );
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Bootstrap the module.
|
44 |
+
*
|
45 |
+
* @param Product $product Product object.
|
46 |
+
*/
|
47 |
+
abstract public function load( $product );
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Check if the product is from partner.
|
51 |
+
*
|
52 |
+
* @param Product $product Product data.
|
53 |
+
*
|
54 |
+
* @return bool Is product from partner.
|
55 |
+
*/
|
56 |
+
public function is_from_partner( $product ) {
|
57 |
+
|
58 |
+
foreach ( Module_Factory::$domains as $partner_domain ) {
|
59 |
+
if ( strpos( $product->get_store_url(), $partner_domain ) !== false ) {
|
60 |
+
return true;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
return array_key_exists( $product->get_slug(), Module_Factory::$slugs );
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Wrapper for wp_remote_get on VIP environments.
|
69 |
+
*
|
70 |
+
* @param string $url Url to check.
|
71 |
+
* @param array $args Option params.
|
72 |
+
*
|
73 |
+
* @return array|\WP_Error
|
74 |
+
*/
|
75 |
+
public function safe_get( $url, $args = array() ) {
|
76 |
+
return function_exists( 'vip_safe_wp_remote_get' )
|
77 |
+
? vip_safe_wp_remote_get( $url )
|
78 |
+
: wp_remote_get( //phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get, Already used.
|
79 |
+
$url,
|
80 |
+
$args
|
81 |
+
);
|
82 |
+
}
|
83 |
+
}
|
vendor/codeinwp/themeisle-sdk/src/Common/Module_factory.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The module factory class.
|
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 3.0.0
|
10 |
+
*/
|
11 |
+
|
12 |
+
namespace ThemeisleSDK\Common;
|
13 |
+
|
14 |
+
use ThemeisleSDK\Product;
|
15 |
+
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
exit;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Class Job_Factory
|
22 |
+
*
|
23 |
+
* @package ThemeisleSDK\Common
|
24 |
+
*/
|
25 |
+
class Module_Factory {
|
26 |
+
/**
|
27 |
+
* Partners slugs.
|
28 |
+
*
|
29 |
+
* @var array $SLUGS Partners product slugs.
|
30 |
+
*/
|
31 |
+
public static $slugs = [
|
32 |
+
'zermatt' => true,
|
33 |
+
'neto' => true,
|
34 |
+
'olsen' => true,
|
35 |
+
'benson' => true,
|
36 |
+
'romero' => true,
|
37 |
+
'carmack' => true,
|
38 |
+
'puzzle' => true,
|
39 |
+
'broadsheet' => true,
|
40 |
+
'girlywp' => true,
|
41 |
+
'veggie' => true,
|
42 |
+
'zeko' => true,
|
43 |
+
'maishawp' => true,
|
44 |
+
'didi' => true,
|
45 |
+
'liber' => true,
|
46 |
+
'medicpress-pt' => true,
|
47 |
+
'adrenaline-pt' => true,
|
48 |
+
'consultpress-pt' => true,
|
49 |
+
'legalpress-pt' => true,
|
50 |
+
'gympress-pt' => true,
|
51 |
+
'readable-pt' => true,
|
52 |
+
'bolts-pt' => true,
|
53 |
+
];
|
54 |
+
/**
|
55 |
+
* Partners domains.
|
56 |
+
*
|
57 |
+
* @var array $DOMAINS Partners domains.
|
58 |
+
*/
|
59 |
+
public static $domains = [
|
60 |
+
'proteusthemes.com',
|
61 |
+
'anarieldesign.com',
|
62 |
+
'prothemedesign.com',
|
63 |
+
'cssigniter.com',
|
64 |
+
];
|
65 |
+
/**
|
66 |
+
* Map which contains all the modules loaded for each product.
|
67 |
+
*
|
68 |
+
* @var array Mapping array.
|
69 |
+
*/
|
70 |
+
private static $modules_attached = [];
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Load availabe modules for the selected product.
|
74 |
+
*
|
75 |
+
* @param Product $product Loaded product.
|
76 |
+
* @param array $modules List of modules.
|
77 |
+
*/
|
78 |
+
public static function attach( $product, $modules ) {
|
79 |
+
|
80 |
+
if ( ! isset( self::$modules_attached[ $product->get_slug() ] ) ) {
|
81 |
+
self::$modules_attached[ $product->get_slug() ] = [];
|
82 |
+
}
|
83 |
+
|
84 |
+
foreach ( $modules as $module ) {
|
85 |
+
$class = 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' );
|
86 |
+
/**
|
87 |
+
* Module object.
|
88 |
+
*
|
89 |
+
* @var Abstract_Module $module_object Module instance.
|
90 |
+
*/
|
91 |
+
$module_object = new $class( $product );
|
92 |
+
|
93 |
+
if ( ! $module_object->can_load( $product ) ) {
|
94 |
+
continue;
|
95 |
+
}
|
96 |
+
self::$modules_attached[ $product->get_slug() ][ $module ] = $module_object->load( $product );
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Products/Modules loaded map.
|
102 |
+
*
|
103 |
+
* @return array Modules map.
|
104 |
+
*/
|
105 |
+
public static function get_modules_map() {
|
106 |
+
return self::$modules_attached;
|
107 |
+
}
|
108 |
+
}
|
vendor/codeinwp/themeisle-sdk/src/Loader.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
12 |
+
namespace ThemeisleSDK;
|
13 |
+
|
14 |
+
use ThemeisleSDK\Common\Module_Factory;
|
15 |
+
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
exit;
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Singleton loader for ThemeIsle SDK.
|
23 |
+
*/
|
24 |
+
final class Loader {
|
25 |
+
/**
|
26 |
+
* Singleton instance.
|
27 |
+
*
|
28 |
+
* @var Loader instance The singleton instance
|
29 |
+
*/
|
30 |
+
private static $instance;
|
31 |
+
/**
|
32 |
+
* Current loader version.
|
33 |
+
*
|
34 |
+
* @var string $version The class version.
|
35 |
+
*/
|
36 |
+
private static $version = '2.0.0';
|
37 |
+
/**
|
38 |
+
* Holds registered products.
|
39 |
+
*
|
40 |
+
* @var array The products which use the SDK.
|
41 |
+
*/
|
42 |
+
private static $products = [];
|
43 |
+
/**
|
44 |
+
* Holds available modules to load.
|
45 |
+
*
|
46 |
+
* @var array The modules which SDK will be using.
|
47 |
+
*/
|
48 |
+
private static $available_modules = [
|
49 |
+
'dashboard_widget',
|
50 |
+
'rollback',
|
51 |
+
'uninstall_feedback',
|
52 |
+
'licenser',
|
53 |
+
'logger',
|
54 |
+
'translate',
|
55 |
+
'review',
|
56 |
+
'recommendation',
|
57 |
+
'notification',
|
58 |
+
|
59 |
+
];
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Initialize the sdk logic.
|
63 |
+
*/
|
64 |
+
public static function init() {
|
65 |
+
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Loader ) ) {
|
66 |
+
self::$instance = new Loader();
|
67 |
+
$modules = array_merge( self::$available_modules, apply_filters( 'themeisle_sdk_modules', [] ) );
|
68 |
+
foreach ( $modules as $key => $module ) {
|
69 |
+
if ( ! class_exists( 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' ) ) ) {
|
70 |
+
unset( $modules[ $key ] );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
self::$available_modules = $modules;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Get cache token used in API requests.
|
79 |
+
*
|
80 |
+
* @return string Cache token.
|
81 |
+
*/
|
82 |
+
public static function get_cache_token() {
|
83 |
+
$cache_token = get_transient( 'themeisle_sdk_cache_token' );
|
84 |
+
if ( false === $cache_token ) {
|
85 |
+
$cache_token = wp_generate_password( 6, false );
|
86 |
+
set_transient( $cache_token, WEEK_IN_SECONDS );
|
87 |
+
}
|
88 |
+
|
89 |
+
return $cache_token;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Clear cache token.
|
94 |
+
*/
|
95 |
+
public static function clear_cache_token() {
|
96 |
+
delete_transient( 'themeisle_sdk_cache_token' );
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Register product into SDK.
|
101 |
+
*
|
102 |
+
* @param string $base_file The product base file.
|
103 |
+
*
|
104 |
+
* @return Loader The singleton object.
|
105 |
+
*/
|
106 |
+
public static function add_product( $base_file ) {
|
107 |
+
|
108 |
+
if ( ! is_file( $base_file ) ) {
|
109 |
+
return self::$instance;
|
110 |
+
}
|
111 |
+
$product = new Product( $base_file );
|
112 |
+
|
113 |
+
Module_Factory::attach( $product, self::get_modules() );
|
114 |
+
|
115 |
+
self::$products[ $product->get_slug() ] = $product;
|
116 |
+
|
117 |
+
return self::$instance;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Get all registered modules by the SDK.
|
122 |
+
*
|
123 |
+
* @return array Modules available.
|
124 |
+
*/
|
125 |
+
public static function get_modules() {
|
126 |
+
return self::$available_modules;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Get all products using the SDK.
|
131 |
+
*
|
132 |
+
* @return array Products available.
|
133 |
+
*/
|
134 |
+
public static function get_products() {
|
135 |
+
return self::$products;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Get the version of the SDK.
|
140 |
+
*
|
141 |
+
* @return string The version.
|
142 |
+
*/
|
143 |
+
public static function get_version() {
|
144 |
+
return self::$version;
|
145 |
+
}
|
146 |
+
|
147 |
+
}
|
vendor/codeinwp/themeisle-sdk/src/Modules/Dashboard_widget.php
ADDED
@@ -0,0 +1,470 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The blog dashboard model class for ThemeIsle SDK
|
4 |
+
*
|
5 |
+
* @package ThemeIsleSDK
|
6 |
+
* @subpackage Modules
|
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 |
+
|
12 |
+
namespace ThemeisleSDK\Modules;
|
13 |
+
|
14 |
+
use ThemeisleSDK\Common\Abstract_Module;
|
15 |
+
use ThemeisleSDK\Product;
|
16 |
+
|
17 |
+
// Exit if accessed directly.
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Blog dashboard widget module for ThemeIsle SDK.
|
24 |
+
*/
|
25 |
+
class Dashboard_Widget extends Abstract_Module {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Fetched feeds items.
|
29 |
+
*
|
30 |
+
* @var array Feed items.
|
31 |
+
*/
|
32 |
+
private $items = array();
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Dashboard widget title.
|
36 |
+
*
|
37 |
+
* @var string $dashboard_name Dashboard name.
|
38 |
+
*/
|
39 |
+
private $dashboard_name = '';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Dashboard widget feed sources.
|
43 |
+
*
|
44 |
+
* @var array $feeds Feed url.
|
45 |
+
*/
|
46 |
+
private $feeds = [];
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Should we load this module.
|
50 |
+
*
|
51 |
+
* @param Product $product Product object.
|
52 |
+
*
|
53 |
+
* @return bool
|
54 |
+
*/
|
55 |
+
public function can_load( $product ) {
|
56 |
+
if ( $this->is_from_partner( $product ) ) {
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
|
60 |
+
if ( ! apply_filters( $product->get_slug() . '_load_dashboard_widget', true ) ) {
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
|
64 |
+
return true;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Registers the hooks.
|
69 |
+
*
|
70 |
+
* @param Product $product Product to load.
|
71 |
+
*
|
72 |
+
* @return Dashboard_Widget Module instance.
|
73 |
+
*/
|
74 |
+
public function load( $product ) {
|
75 |
+
if ( apply_filters( 'themeisle_sdk_hide_dashboard_widget', false ) ) {
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
$this->product = $product;
|
79 |
+
$this->dashboard_name = apply_filters( 'themeisle_sdk_dashboard_widget_name', 'WordPress Guides/Tutorials' );
|
80 |
+
$this->feeds = apply_filters(
|
81 |
+
'themeisle_sdk_dashboard_widget_feeds',
|
82 |
+
[
|
83 |
+
'https://themeisle.com/blog/feed',
|
84 |
+
]
|
85 |
+
);
|
86 |
+
add_action( 'wp_dashboard_setup', array( &$this, 'add_widget' ) );
|
87 |
+
add_action( 'wp_network_dashboard_setup', array( &$this, 'add_widget' ) );
|
88 |
+
add_filter( 'themeisle_sdk_recommend_plugin_or_theme', array( &$this, 'recommend_plugin_or_theme' ) );
|
89 |
+
|
90 |
+
return $this;
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Add widget to the dashboard
|
96 |
+
*
|
97 |
+
* @return string|void
|
98 |
+
*/
|
99 |
+
public function add_widget() {
|
100 |
+
global $wp_meta_boxes;
|
101 |
+
if ( isset( $wp_meta_boxes['dashboard']['normal']['core']['themeisle'] ) ) {
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
wp_add_dashboard_widget(
|
105 |
+
'themeisle',
|
106 |
+
$this->dashboard_name,
|
107 |
+
[
|
108 |
+
$this,
|
109 |
+
'render_dashboard_widget',
|
110 |
+
]
|
111 |
+
);
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Render widget content
|
116 |
+
*/
|
117 |
+
public function render_dashboard_widget() {
|
118 |
+
$this->setup_feeds();
|
119 |
+
if ( empty( $this->items ) || ! is_array( $this->items ) ) {
|
120 |
+
return;
|
121 |
+
}
|
122 |
+
?>
|
123 |
+
<style type="text/css">
|
124 |
+
#themeisle ul li.ti-dw-recommend-item {
|
125 |
+
padding-left: 7px;
|
126 |
+
border-top: 1px solid #eee;
|
127 |
+
margin-bottom: 0px;
|
128 |
+
padding-top: 6px;
|
129 |
+
}
|
130 |
+
|
131 |
+
#themeisle h2.hndle {
|
132 |
+
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABbCAMAAADncTNAAAAAtFBMVEVHcEyAgIB/f3+xsbGgoaGBgYGCgoKKioqAgIC1tbW5ubnFx8iAgIDU1taBgYGCgoKAgIC0tLXW19jW2NiAgIC3uLiBgYHLzMy4uLhycnLW19d/f3/T1NW0tLTX19mVlZWvr6+BgYHl5eWKiottbW5JSUnW2Nm5ubnh4eHT1NWVlZVjY2N4eHh9fX6pqqq+v79PT0/39/fu7u7Nzc7Z2ttYWFgBAQHDw8P////JysoZGRk0NTZqJc/sAAAAIXRSTlMA0FL7/oEnEPL6eibivm9gwJya76/enFq2CXI+2lFAyM8GATmPAAADj0lEQVR4Xu2YaW/iOhSGAwRCWDosnXa6znjJvm8svf//f12TuARyhiR2pfnUR6gSEnr0+uT4xK7yRb755pvhHePli5K7Bfpkuhoq8ozRJdMH+WWha6Z3sqYparCSLRJqspjImVbANJU03cNMMpofAwQZCGsmpQYyFvVM0Q00OQ9koMl5IPcCoro+RA1Dt2Ea9n9eZ0+YHJLkgIlkDywQx00wCTyaReiKH8LbNU9ybJOdkchV6QFxyCFLbVvdfaREqgUWg/tx2UbqIcK2Hex2TdGLwFTjIj3XP3YfCZFsb23KRZn/3263oymSFI0/a5S4PqUBjoBIJBDjeEhCN0wxQSRybIxtJ3K5SGzuE/vAwIQc8ZmMMJFAIM4oikZItfEFtorGgoE43FObwqHU68OtPCnOz8KZ2Jbl5LgkSW0Tc7YyIz/EFWmS4jMbiZU5mJOmKRaJpKGGyLZtDJh3iyaNUu/3+xyKnrtFL71EG+FTiMpENhQtxUQ8kSOXCIr2tnCNhg/gTX0SHYFp0t7TCwQZ7U841yoHrW6rtGroUwTWVnLMssxx+H4bgZcSOFf5MYx0Ae8FghomMDyC2EBNImBywPkNTDNqGLQpIg2TjUNU8tBy9DQMo0DAZF16rAi7vJAtFTIYFAHUc6hIRW6OuOhJgaCSwmDEAYK4oa7ro+qIEyJU/US7KTJKPNSFT9tFgVFBu0SF1y7yjX4masRA9Da7EFGj28R/BkQz6xGIOurkx38T/bKs9Uk8aIiMwm/Jw0VP1yLrJwt13xAxvABBgsK4KWLov35DkRF7ZaqgzuZ7MQ8MOntmVYyAqKTwaICKqvSUFnVccMN5sziEP/5+xGDTahbH5Q3ZB76zr8fI+nJtvUUU3t3ml5GKviK/npCg3CGodnuJ4JVkfRFJYGVDBZrqKnn9RLf+CzDTS5PaN5J38+auzX4ykU4Qoj0rdKfcYs5ijfo9OL/uRUgZyQr7NCWtWwiUSLc4arfJa7lpszTA1OJZAQ8w8dXFrR5YHzCWSnS3pZ18tOi4Ps4vl/c7i/6qomjRecN+UubrPyPGn/VEMU3T0UFHkaPzpgjxmJsnjmrtionlMDZiog0TsY/DPtn8SXtlBvbtxKtwopy7lqW3smQO+yoGE1Uu55GJ3pmI8ygoejZNnqj0vnIRCyTKfLstRdtStGQi09myUsvwvlkuzSUXbV+Xz5ryBebV33fln/A/moud69FZiEYAAAAASUVORK5CYII=');
|
133 |
+
background-repeat: no-repeat;
|
134 |
+
background-position: 92% 50%;
|
135 |
+
background-size: 25px;
|
136 |
+
}
|
137 |
+
|
138 |
+
#themeisle .inside {
|
139 |
+
padding: 0;
|
140 |
+
}
|
141 |
+
|
142 |
+
.ti-feed-list {
|
143 |
+
padding: 0 12px 5px;
|
144 |
+
margin-bottom: 10px;
|
145 |
+
border-bottom: 1px solid #eee;
|
146 |
+
}
|
147 |
+
|
148 |
+
.ti-dw-feed-item a {
|
149 |
+
display: flex;
|
150 |
+
align-items: center;
|
151 |
+
margin-bottom: 5px;
|
152 |
+
padding: 5px;
|
153 |
+
transition: .2s ease;
|
154 |
+
border-radius: 3px;
|
155 |
+
}
|
156 |
+
|
157 |
+
.ti-dw-feed-item a:hover {
|
158 |
+
background-color: #f8f8f8;
|
159 |
+
}
|
160 |
+
|
161 |
+
.ti-dw-feed-item a:hover .ti-dw-date-container {
|
162 |
+
opacity: .9;
|
163 |
+
}
|
164 |
+
|
165 |
+
.ti-dw-feed-item .ti-dw-month-container {
|
166 |
+
margin-top: -5px;
|
167 |
+
text-transform: uppercase;
|
168 |
+
font-size: 10px;
|
169 |
+
letter-spacing: 1px;
|
170 |
+
font-weight: 700;
|
171 |
+
}
|
172 |
+
|
173 |
+
.ti-dw-feed-item .ti-dw-date-container {
|
174 |
+
border-radius: 3px;
|
175 |
+
transition: .2s ease;
|
176 |
+
min-height: 35px;
|
177 |
+
margin-right: 5px;
|
178 |
+
min-width: 35px;
|
179 |
+
text-align: center;
|
180 |
+
border: 1px solid #2a6f97;
|
181 |
+
color: #fff;
|
182 |
+
background: #2ea2cc;
|
183 |
+
display: flex;
|
184 |
+
flex-direction: column;
|
185 |
+
justify-content: center;
|
186 |
+
}
|
187 |
+
|
188 |
+
.ti-dw-footer {
|
189 |
+
padding: 0 12px 5px;
|
190 |
+
text-align: center;
|
191 |
+
}
|
192 |
+
|
193 |
+
.ti-dw-recommend-item {
|
194 |
+
display: block;
|
195 |
+
}
|
196 |
+
|
197 |
+
.ti-dw-recommend-item span {
|
198 |
+
color: #72777c;
|
199 |
+
}
|
200 |
+
|
201 |
+
.ti-dw-powered-by {
|
202 |
+
font-size: 11px;
|
203 |
+
margin-top: 3px;
|
204 |
+
display: block;
|
205 |
+
color: #72777c;
|
206 |
+
}
|
207 |
+
|
208 |
+
.ti-dw-powered-by span {
|
209 |
+
font-weight: 600;
|
210 |
+
}
|
211 |
+
|
212 |
+
</style>
|
213 |
+
<?php do_action( 'themeisle_sdk_dashboard_widget_before', $this->product ); ?>
|
214 |
+
|
215 |
+
<ul class="ti-feed-list">
|
216 |
+
<?php
|
217 |
+
|
218 |
+
foreach ( $this->items as $item ) {
|
219 |
+
?>
|
220 |
+
<li class="ti-dw-feed-item">
|
221 |
+
<a href="
|
222 |
+
<?php
|
223 |
+
echo esc_url(
|
224 |
+
add_query_arg(
|
225 |
+
array(
|
226 |
+
'utm_source' => 'wpadmin',
|
227 |
+
'utm_campaign' => 'feed',
|
228 |
+
'utm_medium' => 'dashboard_widget',
|
229 |
+
),
|
230 |
+
$item['link']
|
231 |
+
)
|
232 |
+
);
|
233 |
+
?>
|
234 |
+
" target="_blank">
|
235 |
+
<span class="ti-dw-date-container"><span
|
236 |
+
class="ti-dw-day-container"><?php echo esc_attr( gmdate( 'd', $item['date'] ) ); ?></span> <span
|
237 |
+
class="ti-dw-month-container"><?php echo esc_attr( substr( gmdate( 'M', $item['date'] ), 0, 3 ) ); ?></span></span><?php echo esc_attr( $item['title'] ); ?>
|
238 |
+
</a>
|
239 |
+
</li>
|
240 |
+
<?php
|
241 |
+
}
|
242 |
+
?>
|
243 |
+
</ul>
|
244 |
+
<?php
|
245 |
+
$recommend = apply_filters( 'themeisle_sdk_recommend_plugin_or_theme', array() );
|
246 |
+
if ( ! is_array( $recommend ) || empty( $recommend ) ) {
|
247 |
+
return;
|
248 |
+
}
|
249 |
+
|
250 |
+
$type = $recommend['type'];
|
251 |
+
|
252 |
+
if ( ( 'theme' === $type && ! current_user_can( 'install_themes' ) ) ) {
|
253 |
+
return;
|
254 |
+
}
|
255 |
+
if ( ( 'plugin' === $type && ! current_user_can( 'install_plugins' ) ) ) {
|
256 |
+
return;
|
257 |
+
}
|
258 |
+
|
259 |
+
add_thickbox();
|
260 |
+
$url = add_query_arg(
|
261 |
+
[
|
262 |
+
'theme' => $recommend['slug'],
|
263 |
+
],
|
264 |
+
network_admin_url( 'theme-install.php' )
|
265 |
+
);
|
266 |
+
|
267 |
+
if ( 'plugin' === $type ) {
|
268 |
+
|
269 |
+
$url = add_query_arg(
|
270 |
+
array(
|
271 |
+
'tab' => 'plugin-information',
|
272 |
+
'plugin' => $recommend['slug'],
|
273 |
+
),
|
274 |
+
network_admin_url( 'plugin-install.php' )
|
275 |
+
);
|
276 |
+
}
|
277 |
+
?>
|
278 |
+
<div class="ti-dw-footer">
|
279 |
+
<span class="ti-dw-recommend-item ">
|
280 |
+
<span class="ti-dw-recommend"><?php echo esc_attr( apply_filters( 'themeisle_sdk_dashboard_popular_label', sprintf( 'Popular %s', ucwords( $type ) ) ) ); ?>
|
281 |
+
: </span>
|
282 |
+
<?php
|
283 |
+
echo esc_attr(
|
284 |
+
trim(
|
285 |
+
str_replace(
|
286 |
+
array(
|
287 |
+
'lite',
|
288 |
+
'Lite',
|
289 |
+
'(Lite)',
|
290 |
+
'(lite)',
|
291 |
+
),
|
292 |
+
'',
|
293 |
+
$recommend['name']
|
294 |
+
)
|
295 |
+
)
|
296 |
+
);
|
297 |
+
?>
|
298 |
+
(<a class="thickbox open-plugin-details-modal"
|
299 |
+
href="<?php echo esc_url( $url . '&TB_iframe=true&width=600&height=500' ); ?>"><?php echo esc_attr( apply_filters( 'themeisle_sdk_dashboard_install_label', 'Install' ) ); ?></a>)
|
300 |
+
</span>
|
301 |
+
<span class="ti-dw-powered-by"><span><?php echo esc_attr( apply_filters( 'themeisle_sdk_dashboard_widget_powered_by', sprintf( 'Powered by %s', $this->product->get_friendly_name() ) ) ); ?></span></span>
|
302 |
+
</div>
|
303 |
+
|
304 |
+
<?php
|
305 |
+
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Setup feed items.
|
310 |
+
*/
|
311 |
+
private function setup_feeds() {
|
312 |
+
if ( false === ( $items_normalized = get_transient( 'themeisle_sdk_feed_items' ) ) ) { //phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure
|
313 |
+
// Load SimplePie Instance.
|
314 |
+
$feed = fetch_feed( $this->feeds );
|
315 |
+
// TODO report error when is an error loading the feed.
|
316 |
+
if ( is_wp_error( $feed ) ) {
|
317 |
+
return;
|
318 |
+
}
|
319 |
+
|
320 |
+
$items = $feed->get_items( 0, 5 );
|
321 |
+
foreach ( (array) $items as $item ) {
|
322 |
+
$items_normalized[] = array(
|
323 |
+
'title' => $item->get_title(),
|
324 |
+
'date' => $item->get_date( 'U' ),
|
325 |
+
'link' => $item->get_permalink(),
|
326 |
+
);
|
327 |
+
}
|
328 |
+
set_transient( 'themeisle_sdk_feed_items', $items_normalized, 48 * HOUR_IN_SECONDS );
|
329 |
+
}
|
330 |
+
$this->items = $items_normalized;
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Either the current product is installed or not.
|
335 |
+
*
|
336 |
+
* @param array $val The current recommended product.
|
337 |
+
*
|
338 |
+
* @return bool Either we should exclude the plugin or not.
|
339 |
+
*/
|
340 |
+
public function remove_current_products( $val ) {
|
341 |
+
if ( 'theme' === $val['type'] ) {
|
342 |
+
$exist = wp_get_theme( $val['slug'] );
|
343 |
+
|
344 |
+
return ! $exist->exists();
|
345 |
+
} else {
|
346 |
+
$all_plugins = array_keys( get_plugins() );
|
347 |
+
foreach ( $all_plugins as $slug ) {
|
348 |
+
if ( strpos( $slug, $val['slug'] ) !== false ) {
|
349 |
+
return false;
|
350 |
+
}
|
351 |
+
}
|
352 |
+
|
353 |
+
return true;
|
354 |
+
}
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Contact the API and fetch the recommended plugins/themes
|
359 |
+
*/
|
360 |
+
public function recommend_plugin_or_theme() {
|
361 |
+
$products = $this->get_product_from_api();
|
362 |
+
if ( ! is_array( $products ) ) {
|
363 |
+
$products = array();
|
364 |
+
}
|
365 |
+
$products = array_filter( $products, array( $this, 'remove_current_products' ) );
|
366 |
+
$products = array_merge( $products );
|
367 |
+
if ( count( $products ) > 1 ) {
|
368 |
+
shuffle( $products );
|
369 |
+
$products = array_slice( $products, 0, 1 );
|
370 |
+
}
|
371 |
+
$to_recommend = isset( $products[0] ) ? $products[0] : $products;
|
372 |
+
|
373 |
+
return $to_recommend;
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Fetch products from the recomended section.
|
378 |
+
*
|
379 |
+
* @return array|mixed The list of products to use in recomended section.
|
380 |
+
*/
|
381 |
+
public function get_product_from_api() {
|
382 |
+
if ( false === ( $products = get_transient( 'themeisle_sdk_products' ) ) ) { //phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure
|
383 |
+
$products = array();
|
384 |
+
$all_themes = $this->get_themes_from_wporg( 'themeisle' );
|
385 |
+
$all_plugins = $this->get_plugins_from_wporg( 'themeisle' );
|
386 |
+
static $allowed_products = [
|
387 |
+
'hestia' => true,
|
388 |
+
'neve' => true,
|
389 |
+
'visualizer' => true,
|
390 |
+
'feedzy-rss-feeds' => true,
|
391 |
+
'wp-product-review' => true,
|
392 |
+
'otter-blocks' => true,
|
393 |
+
'themeisle-companion' => true,
|
394 |
+
];
|
395 |
+
foreach ( $all_themes as $theme ) {
|
396 |
+
if ( $theme->active_installs < 4999 ) {
|
397 |
+
continue;
|
398 |
+
}
|
399 |
+
if ( ! isset( $allowed_products[ $theme->slug ] ) ) {
|
400 |
+
continue;
|
401 |
+
}
|
402 |
+
$products[] = array(
|
403 |
+
'name' => $theme->name,
|
404 |
+
'type' => 'theme',
|
405 |
+
'slug' => $theme->slug,
|
406 |
+
'installs' => $theme->active_installs,
|
407 |
+
);
|
408 |
+
}
|
409 |
+
foreach ( $all_plugins as $plugin ) {
|
410 |
+
if ( $plugin->active_installs < 4999 ) {
|
411 |
+
continue;
|
412 |
+
}
|
413 |
+
if ( ! isset( $allowed_products[ $plugin->slug ] ) ) {
|
414 |
+
continue;
|
415 |
+
}
|
416 |
+
$products[] = array(
|
417 |
+
'name' => $plugin->name,
|
418 |
+
'type' => 'plugin',
|
419 |
+
'slug' => $plugin->slug,
|
420 |
+
'installs' => $plugin->active_installs,
|
421 |
+
);
|
422 |
+
}
|
423 |
+
set_transient( 'themeisle_sdk_products', $products, 6 * HOUR_IN_SECONDS );
|
424 |
+
}
|
425 |
+
|
426 |
+
return $products;
|
427 |
+
}
|
428 |
+
|
429 |
+
/**
|
430 |
+
* Fetch themes from wporg api.
|
431 |
+
*
|
432 |
+
* @param string $author The author name.
|
433 |
+
*
|
434 |
+
* @return array The list of themes.
|
435 |
+
*/
|
436 |
+
public function get_themes_from_wporg( $author ) {
|
437 |
+
$products = $this->safe_get(
|
438 |
+
'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[author]=' . $author . '&request[per_page]=30&request[fields][active_installs]=true'
|
439 |
+
);
|
440 |
+
$products = json_decode( wp_remote_retrieve_body( $products ) );
|
441 |
+
if ( is_object( $products ) ) {
|
442 |
+
$products = isset( $products->themes ) ? $products->themes : array();
|
443 |
+
} else {
|
444 |
+
$products = array();
|
445 |
+
}
|
446 |
+
|
447 |
+
return (array) $products;
|
448 |
+
}
|
449 |
+
|
450 |
+
/**
|
451 |
+
* Fetch plugin from wporg api.
|
452 |
+
*
|
453 |
+
* @param string $author The author slug.
|
454 |
+
*
|
455 |
+
* @return array The list of plugins for the selected author.
|
456 |
+
*/
|
457 |
+
public function get_plugins_from_wporg( $author ) {
|
458 |
+
$products = $this->safe_get(
|
459 |
+
'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[author]=' . $author . '&request[per_page]=40&request[fields][active_installs]=true'
|
460 |
+
);
|
461 |
+
$products = json_decode( wp_remote_retrieve_body( $products ) );
|
462 |
+
if ( is_object( $products ) ) {
|
463 |
+
$products = isset( $products->plugins ) ? $products->plugins : array();
|
464 |
+
} else {
|
465 |
+
$products = array();
|
466 |
+
}
|
467 |
+
|
468 |
+
return (array) $products;
|
469 |
+
}
|
470 |
+
}
|
vendor/codeinwp/themeisle-sdk/src/Modules/Licenser.php
ADDED
@@ -0,0 +1,1040 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The main loader class for license handling.
|
4 |
+
*
|
5 |
+
* @package ThemeIsleSDK
|
6 |
+
* @subpackage Modules
|
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 |
+
|
12 |
+
namespace ThemeisleSDK\Modules;
|
13 |
+
|
14 |
+
// Exit if accessed directly.
|
15 |
+
use ThemeisleSDK\Common\Abstract_Module;
|
16 |
+
use ThemeisleSDK\Loader;
|
17 |
+
use ThemeisleSDK\Product;
|
18 |
+
|
19 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
+
exit;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Licenser module for ThemeIsle SDK.
|
25 |
+
*/
|
26 |
+
class Licenser extends Abstract_Module {
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Number of max failed checks before showing the license message.
|
30 |
+
*
|
31 |
+
* @var int $max_failed Maximum failed checks allowed before show the notice
|
32 |
+
*/
|
33 |
+
private static $max_failed = 2;
|
34 |
+
/**
|
35 |
+
* License key string.
|
36 |
+
*
|
37 |
+
* @var string $license_key The license key string
|
38 |
+
*/
|
39 |
+
public $license_key;
|
40 |
+
/**
|
41 |
+
* This ensures that the custom API request only runs on the second time that WP fires the update check.
|
42 |
+
*
|
43 |
+
* @var bool $do_check Flag for request.
|
44 |
+
*/
|
45 |
+
private $do_check = false;
|
46 |
+
/**
|
47 |
+
* Number of failed checks to the api endpoint.
|
48 |
+
*
|
49 |
+
* @var bool $failed_checks
|
50 |
+
*/
|
51 |
+
private $failed_checks = 0;
|
52 |
+
/**
|
53 |
+
* The product update response key.
|
54 |
+
*
|
55 |
+
* @var string $product_key Product key.
|
56 |
+
*/
|
57 |
+
private $product_key;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Holds local license object.
|
61 |
+
*
|
62 |
+
* @var null Local license object.
|
63 |
+
*/
|
64 |
+
private $license_local = null;
|
65 |
+
/**
|
66 |
+
* Product namespace, used for fixed name filters/cli commands.
|
67 |
+
*
|
68 |
+
* @var string $namespace Product namespace.
|
69 |
+
*/
|
70 |
+
private $namespace = null;
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Disable wporg updates for premium products.
|
74 |
+
*
|
75 |
+
* @param string $r Update payload.
|
76 |
+
* @param string $url The api url.
|
77 |
+
*
|
78 |
+
* @return mixed List of themes to check for update.
|
79 |
+
*/
|
80 |
+
public function disable_wporg_update( $r, $url ) {
|
81 |
+
|
82 |
+
if ( 0 !== strpos( $url, 'https://api.wordpress.org/themes/update-check/' ) ) {
|
83 |
+
return $r;
|
84 |
+
}
|
85 |
+
|
86 |
+
// Decode the JSON response.
|
87 |
+
$themes = json_decode( $r['body']['themes'] );
|
88 |
+
|
89 |
+
unset( $themes->themes->{$this->product->get_slug()} );
|
90 |
+
|
91 |
+
// Encode the updated JSON response.
|
92 |
+
$r['body']['themes'] = wp_json_encode( $themes );
|
93 |
+
|
94 |
+
return $r;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Register the setting for the license of the product.
|
99 |
+
*
|
100 |
+
* @return bool
|
101 |
+
*/
|
102 |
+
public function register_settings() {
|
103 |
+
if ( ! is_admin() ) {
|
104 |
+
return false;
|
105 |
+
}
|
106 |
+
if ( apply_filters( $this->product->get_key() . '_hide_license_field', false ) ) {
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
add_settings_field(
|
110 |
+
$this->product->get_key() . '_license',
|
111 |
+
$this->product->get_name() . ' license',
|
112 |
+
array( $this, 'license_view' ),
|
113 |
+
'general'
|
114 |
+
);
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* The license view field.
|
119 |
+
*/
|
120 |
+
public function license_view() {
|
121 |
+
$status = $this->get_license_status();
|
122 |
+
$value = $this->license_key;
|
123 |
+
|
124 |
+
$activate_string = apply_filters( $this->product->get_key() . '_lc_activate_string', 'Activate' );
|
125 |
+
$deactivate_string = apply_filters( $this->product->get_key() . '_lc_deactivate_string', 'Deactivate' );
|
126 |
+
$valid_string = apply_filters( $this->product->get_key() . '_lc_valid_string', 'Valid' );
|
127 |
+
$invalid_string = apply_filters( $this->product->get_key() . '_lc_invalid_string', 'Invalid' );
|
128 |
+
$license_message = apply_filters( $this->product->get_key() . '_lc_license_message', 'Enter your license from %s purchase history in order to get %s updates' );
|
129 |
+
$error_message = $this->get_error();
|
130 |
+
?>
|
131 |
+
<style type="text/css">
|
132 |
+
input.themeisle-sdk-text-input-valid {
|
133 |
+
border: 1px solid #7ad03a;
|
134 |
+
}
|
135 |
+
|
136 |
+
input.themeisle-sdk-license-input {
|
137 |
+
width: 300px;
|
138 |
+
padding: 0 8px;
|
139 |
+
line-height: 2;
|
140 |
+
min-height: 30px;
|
141 |
+
}
|
142 |
+
|
143 |
+
.themeisle-sdk-license-deactivate-cta {
|
144 |
+
color: #fff;
|
145 |
+
background: #7ad03a;
|
146 |
+
display: inline-block;
|
147 |
+
text-decoration: none;
|
148 |
+
font-size: 13px;
|
149 |
+
line-height: 30px;
|
150 |
+
height: 26px;
|
151 |
+
margin-left: 5px;
|
152 |
+
padding: 0 10px 3px;
|
153 |
+
-webkit-border-radius: 3px;
|
154 |
+
border-radius: 3px;
|
155 |
+
}
|
156 |
+
|
157 |
+
.themeisle-sdk-license-activate-cta {
|
158 |
+
color: #fff;
|
159 |
+
background: #dd3d36;
|
160 |
+
display: inline-block;
|
161 |
+
text-decoration: none;
|
162 |
+
font-size: 13px;
|
163 |
+
line-height: 30px;
|
164 |
+
height: 26px;
|
165 |
+
margin-left: 5px;
|
166 |
+
padding: 0 10px 3px;
|
167 |
+
-webkit-border-radius: 3px;
|
168 |
+
border-radius: 3px;
|
169 |
+
}
|
170 |
+
|
171 |
+
button.button.themeisle-sdk-licenser-button-cta {
|
172 |
+
line-height: 26px;
|
173 |
+
height: 29px;
|
174 |
+
vertical-align: top;
|
175 |
+
}
|
176 |
+
|
177 |
+
</style>
|
178 |
+
<?php
|
179 |
+
echo sprintf(
|
180 |
+
'<p>%s<input class="themeisle-sdk-license-input %s" type="text" id="%s_license" name="%s_license" value="%s" /><a class="%s">%s</a> <button name="%s_btn_trigger" class="button button-primary themeisle-sdk-licenser-button-cta" value="yes" type="submit" >%s</button></p><p class="description">%s</p>%s',
|
181 |
+
( ( 'valid' === $status ) ? sprintf( '<input type="hidden" value="%s" name="%s_license" />', esc_attr( $value ), esc_attr( $this->product->get_key() ) ) : '' ),
|
182 |
+
( ( 'valid' === $status ) ? 'themeisle-sdk-text-input-valid' : '' ),
|
183 |
+
esc_attr( $this->product->get_key() ),
|
184 |
+
esc_attr( ( ( 'valid' === $status ) ? $this->product->get_key() . '_mask' : $this->product->get_key() ) ),
|
185 |
+
esc_attr( ( ( 'valid' === $status ) ? ( str_repeat( '*', 30 ) . substr( $value, - 5 ) ) : $value ) ),
|
186 |
+
esc_attr( ( 'valid' === $status ? 'themeisle-sdk-license-deactivate-cta' : 'themeisle-sdk-license-activate-cta' ) ),
|
187 |
+
esc_attr( 'valid' === $status ? $valid_string : $invalid_string ),
|
188 |
+
esc_attr( $this->product->get_key() ),
|
189 |
+
esc_attr( 'valid' === $status ? $deactivate_string : $activate_string ),
|
190 |
+
sprintf( wp_kses_data( $license_message ), '<a href="' . esc_url( $this->get_api_url() ) . '">' . esc_attr( $this->get_distributor_name() ) . '</a> ', esc_attr( $this->product->get_type() ) ),
|
191 |
+
wp_kses_data( empty( $error_message ) ? '' : sprintf( '<p style="color:#dd3d36">%s</p>', ( $error_message ) ) )
|
192 |
+
) . wp_nonce_field( $this->product->get_key() . 'nonce', $this->product->get_key() . 'nonce_field', false, false );//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
193 |
+
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Return the license status.
|
198 |
+
*
|
199 |
+
* @param bool $check_expiration Should check if license is valid, but expired.
|
200 |
+
*
|
201 |
+
* @return string The License status.
|
202 |
+
*/
|
203 |
+
public function get_license_status( $check_expiration = false ) {
|
204 |
+
|
205 |
+
$license_data = get_option( $this->product->get_key() . '_license_data', '' );
|
206 |
+
|
207 |
+
if ( '' === $license_data ) {
|
208 |
+
return get_option( $this->product->get_key() . '_license_status', 'not_active' );
|
209 |
+
}
|
210 |
+
$status = isset( $license_data->license ) ? $license_data->license : get_option( $this->product->get_key() . '_license_status', 'not_active' );
|
211 |
+
if ( false === $check_expiration ) {
|
212 |
+
return $status;
|
213 |
+
}
|
214 |
+
|
215 |
+
return ( 'valid' === $status && isset( $license_data->is_expired ) && 'yes' === $license_data->is_expired ) ? 'active_expired' : $status;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Return the last error message.
|
220 |
+
*
|
221 |
+
* @return mixed Error message.
|
222 |
+
*/
|
223 |
+
public function get_error() {
|
224 |
+
return get_transient( $this->product->get_key() . 'act_err' );
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Get remote api url.
|
229 |
+
*
|
230 |
+
* @return string Remote api url.
|
231 |
+
*/
|
232 |
+
public function get_api_url() {
|
233 |
+
if ( $this->is_from_partner( $this->product ) ) {
|
234 |
+
return 'https://themeisle.com';
|
235 |
+
}
|
236 |
+
|
237 |
+
return $this->product->get_store_url();
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Get remote api url.
|
242 |
+
*
|
243 |
+
* @return string Remote api url.
|
244 |
+
*/
|
245 |
+
public function get_distributor_name() {
|
246 |
+
if ( $this->is_from_partner( $this->product ) ) {
|
247 |
+
return 'Themeisle';
|
248 |
+
}
|
249 |
+
|
250 |
+
return $this->product->get_store_name();
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* License price id.
|
255 |
+
*
|
256 |
+
* @return int License plan.
|
257 |
+
*/
|
258 |
+
public function get_plan() {
|
259 |
+
$license_data = get_option( $this->product->get_key() . '_license_data', '' );
|
260 |
+
if ( ! isset( $license_data->price_id ) ) {
|
261 |
+
return - 1;
|
262 |
+
}
|
263 |
+
|
264 |
+
return (int) $license_data->price_id;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Show the admin notice regarding the license status.
|
269 |
+
*
|
270 |
+
* @return bool Should we show the notice ?
|
271 |
+
*/
|
272 |
+
public function show_notice() {
|
273 |
+
if ( ! is_admin() ) {
|
274 |
+
return false;
|
275 |
+
}
|
276 |
+
|
277 |
+
if ( apply_filters( $this->product->get_key() . '_hide_license_notices', false ) ) {
|
278 |
+
return false;
|
279 |
+
}
|
280 |
+
|
281 |
+
$status = $this->get_license_status( true );
|
282 |
+
$no_activations_string = apply_filters( $this->product->get_key() . '_lc_no_activations_string', 'No more activations left for %s. You need to upgrade your plan in order to use %s on more websites. If you need assistance, please get in touch with %s staff.' );
|
283 |
+
$no_valid_string = apply_filters( $this->product->get_key() . '_lc_no_valid_string', 'In order to benefit from updates and support for %s, please add your license code from your <a href="%s" target="_blank">purchase history</a> and validate it <a href="%s">here</a>. ' );
|
284 |
+
$expired_license_string = apply_filters( $this->product->get_key() . '_lc_expired_string', 'Your %s\'s License Key has expired. In order to continue receiving support and software updates you must <a href="%s" target="_blank">renew</a> your license key.' );
|
285 |
+
// No activations left for this license.
|
286 |
+
if ( 'valid' != $status && $this->check_activation() ) {
|
287 |
+
?>
|
288 |
+
<div class="error">
|
289 |
+
<p><strong>
|
290 |
+
<?php
|
291 |
+
echo sprintf(
|
292 |
+
wp_kses_data( $no_activations_string ),
|
293 |
+
esc_attr( $this->product->get_name() ),
|
294 |
+
esc_attr( $this->product->get_name() ),
|
295 |
+
'<a href="' . esc_url( $this->get_api_url() ) . '" target="_blank">' . esc_attr( $this->get_distributor_name() ) . '</a>'
|
296 |
+
);
|
297 |
+
?>
|
298 |
+
</strong>
|
299 |
+
</p>
|
300 |
+
</div>
|
301 |
+
<?php
|
302 |
+
return false;
|
303 |
+
}
|
304 |
+
|
305 |
+
// Invalid license key.
|
306 |
+
if ( 'active_expired' === $status ) {
|
307 |
+
?>
|
308 |
+
<div class="error">
|
309 |
+
<p>
|
310 |
+
<strong><?php echo sprintf( wp_kses_data( $expired_license_string ), esc_attr( $this->product->get_name() . ' ' . $this->product->get_type() ), esc_url( $this->get_api_url() . '?license=' . $this->license_key ) ); ?> </strong>
|
311 |
+
</p>
|
312 |
+
</div>
|
313 |
+
<?php
|
314 |
+
|
315 |
+
return false;
|
316 |
+
}
|
317 |
+
// Invalid license key.
|
318 |
+
if ( 'valid' != $status ) {
|
319 |
+
?>
|
320 |
+
<div class="error">
|
321 |
+
<p>
|
322 |
+
<strong><?php echo sprintf( wp_kses_data( $no_valid_string ), esc_attr( $this->product->get_name() . ' ' . $this->product->get_type() ), esc_url( $this->get_api_url() ), esc_url( admin_url( 'options-general.php' ) . '#' . $this->product->get_key() . '_license' ) ); ?> </strong>
|
323 |
+
</p>
|
324 |
+
</div>
|
325 |
+
<?php
|
326 |
+
|
327 |
+
return false;
|
328 |
+
}
|
329 |
+
|
330 |
+
return true;
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Check if the license is active or not.
|
335 |
+
*
|
336 |
+
* @return bool
|
337 |
+
*/
|
338 |
+
public function check_activation() {
|
339 |
+
$license_data = get_option( $this->product->get_key() . '_license_data', '' );
|
340 |
+
if ( '' === $license_data ) {
|
341 |
+
return false;
|
342 |
+
}
|
343 |
+
|
344 |
+
return isset( $license_data->license ) ? ( 'no_activations_left' == $license_data->license ) : false;
|
345 |
+
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Check if the license is about to expire in the next month.
|
350 |
+
*
|
351 |
+
* @return bool
|
352 |
+
*/
|
353 |
+
public function check_expiration() {
|
354 |
+
$license_data = get_option( $this->product->get_key() . '_license_data', '' );
|
355 |
+
if ( '' === $license_data ) {
|
356 |
+
return false;
|
357 |
+
}
|
358 |
+
if ( ! isset( $license_data->expires ) ) {
|
359 |
+
return false;
|
360 |
+
}
|
361 |
+
if ( strtotime( $license_data->expires ) - time() > 30 * 24 * 3600 ) {
|
362 |
+
return false;
|
363 |
+
}
|
364 |
+
|
365 |
+
return true;
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Return the renew url from the store used.
|
370 |
+
*
|
371 |
+
* @return string The renew url.
|
372 |
+
*/
|
373 |
+
public function renew_url() {
|
374 |
+
$license_data = get_option( $this->product->get_key() . '_license_data', '' );
|
375 |
+
if ( '' === $license_data ) {
|
376 |
+
return $this->get_api_url();
|
377 |
+
}
|
378 |
+
if ( ! isset( $license_data->download_id ) || ! isset( $license_data->key ) ) {
|
379 |
+
return $this->get_api_url();
|
380 |
+
}
|
381 |
+
|
382 |
+
return $this->get_api_url() . '/checkout/?edd_license_key=' . $license_data->key . '&download_id=' . $license_data->download_id;
|
383 |
+
}
|
384 |
+
|
385 |
+
/**
|
386 |
+
* Run the license check call.
|
387 |
+
*/
|
388 |
+
public function product_valid() {
|
389 |
+
if ( false !== ( $license = get_transient( $this->product->get_key() . '_license_data' ) ) ) { //phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure
|
390 |
+
return;
|
391 |
+
}
|
392 |
+
$license = $this->check_license();
|
393 |
+
set_transient( $this->product->get_key() . '_license_data', $license, 12 * HOUR_IN_SECONDS );
|
394 |
+
update_option( $this->product->get_key() . '_license_data', $license );
|
395 |
+
}
|
396 |
+
|
397 |
+
/**
|
398 |
+
* Check the license status.
|
399 |
+
*
|
400 |
+
* @return object The license data.
|
401 |
+
*/
|
402 |
+
public function check_license() {
|
403 |
+
$status = $this->get_license_status();
|
404 |
+
if ( 'not_active' === $status ) {
|
405 |
+
$license_data = new \stdClass();
|
406 |
+
$license_data->license = 'not_active';
|
407 |
+
|
408 |
+
return $license_data;
|
409 |
+
}
|
410 |
+
$license = trim( $this->license_key );
|
411 |
+
|
412 |
+
$response = $this->do_license_process( $license, 'check' );
|
413 |
+
|
414 |
+
if ( is_wp_error( $response ) ) {
|
415 |
+
$license_data = new \stdClass();
|
416 |
+
$license_data->license = 'invalid';
|
417 |
+
} else {
|
418 |
+
$license_data = $response;
|
419 |
+
}
|
420 |
+
|
421 |
+
$license_old = get_option( $this->product->get_key() . '_license_data', '' );
|
422 |
+
if ( 'valid' === $license_old->license && ( $license_data->license !== $license_old->license ) && $this->failed_checks <= self::$max_failed ) {
|
423 |
+
$this->increment_failed_checks();
|
424 |
+
|
425 |
+
return $license_old;
|
426 |
+
}
|
427 |
+
|
428 |
+
if ( ! isset( $license_data->key ) ) {
|
429 |
+
$license_data->key = isset( $license_old->key ) ? $license_old->key : '';
|
430 |
+
}
|
431 |
+
$this->reset_failed_checks();
|
432 |
+
|
433 |
+
return $license_data;
|
434 |
+
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Do license activation/deactivation.
|
439 |
+
*
|
440 |
+
* @param string $license License key.
|
441 |
+
* @param string $action What do to.
|
442 |
+
*
|
443 |
+
* @return bool|\WP_Error
|
444 |
+
*/
|
445 |
+
public function do_license_process( $license, $action = 'toggle' ) {
|
446 |
+
if ( strlen( $license ) < 10 ) {
|
447 |
+
return new \WP_Error( 'themeisle-license-invalid-format', 'Invalid license.' );
|
448 |
+
}
|
449 |
+
$status = $this->get_license_status();
|
450 |
+
|
451 |
+
if ( 'valid' === $status && 'activate' === $action ) {
|
452 |
+
return new \WP_Error( 'themeisle-license-already-active', 'License is already active.' );
|
453 |
+
}
|
454 |
+
if ( 'valid' !== $status && 'deactivate' === $action ) {
|
455 |
+
return new \WP_Error( 'themeisle-license-already-deactivate', 'License not active.' );
|
456 |
+
}
|
457 |
+
|
458 |
+
if ( 'toggle' === $action ) {
|
459 |
+
$action = ( 'valid' !== $status ? ( 'activate' ) : ( 'deactivate' ) );
|
460 |
+
}
|
461 |
+
|
462 |
+
// Call the custom API.
|
463 |
+
if ( 'check' === $action ) {
|
464 |
+
$response = $this->safe_get( sprintf( '%slicense/check/%s/%s/%s/%s', Product::API_URL, rawurlencode( $this->product->get_name() ), $license, rawurlencode( home_url() ), Loader::get_cache_token() ) );
|
465 |
+
} else {
|
466 |
+
$response = wp_remote_post(
|
467 |
+
sprintf( '%slicense/%s/%s/%s', Product::API_URL, $action, rawurlencode( $this->product->get_name() ), $license ),
|
468 |
+
array(
|
469 |
+
'body' => wp_json_encode(
|
470 |
+
array(
|
471 |
+
'url' => rawurlencode( home_url() ),
|
472 |
+
)
|
473 |
+
),
|
474 |
+
'headers' => array(
|
475 |
+
'Content-Type' => 'application/json',
|
476 |
+
),
|
477 |
+
)
|
478 |
+
);
|
479 |
+
}
|
480 |
+
|
481 |
+
// make sure the response came back okay.
|
482 |
+
if ( is_wp_error( $response ) ) {
|
483 |
+
return new \WP_Error( 'themeisle-license-500', sprintf( 'ERROR: Failed to connect to the license service. Please try again later. Reason: %s', $response->get_error_message() ) );
|
484 |
+
}
|
485 |
+
|
486 |
+
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
|
487 |
+
|
488 |
+
if ( ! is_object( $license_data ) ) {
|
489 |
+
return new \WP_Error( 'themeisle-license-404', 'ERROR: Failed to validate license. Please try again in one minute.' );
|
490 |
+
}
|
491 |
+
if ( 'check' === $action ) {
|
492 |
+
return $license_data;
|
493 |
+
}
|
494 |
+
|
495 |
+
Loader::clear_cache_token();
|
496 |
+
|
497 |
+
if ( ! isset( $license_data->license ) ) {
|
498 |
+
$license_data->license = 'invalid';
|
499 |
+
}
|
500 |
+
|
501 |
+
if ( ! isset( $license_data->key ) ) {
|
502 |
+
$license_data->key = $license;
|
503 |
+
}
|
504 |
+
if ( 'valid' === $license_data->license ) {
|
505 |
+
$this->reset_failed_checks();
|
506 |
+
}
|
507 |
+
|
508 |
+
if ( 'deactivate' === $action ) {
|
509 |
+
|
510 |
+
delete_option( $this->product->get_key() . '_license_data' );
|
511 |
+
delete_option( $this->product->get_key() . '_license_plan' );
|
512 |
+
delete_transient( $this->product->get_key() . '_license_data' );
|
513 |
+
|
514 |
+
return true;
|
515 |
+
}
|
516 |
+
if ( isset( $license_data->plan ) ) {
|
517 |
+
update_option( $this->product->get_key() . '_license_plan', $license_data->plan );
|
518 |
+
}
|
519 |
+
update_option( $this->product->get_key() . '_license_data', $license_data );
|
520 |
+
set_transient( $this->product->get_key() . '_license_data', $license_data, 12 * HOUR_IN_SECONDS );
|
521 |
+
if ( 'activate' === $action && 'valid' !== $license_data->license ) {
|
522 |
+
return new \WP_Error( 'themeisle-license-invalid', 'ERROR: Invalid license provided.' );
|
523 |
+
}
|
524 |
+
|
525 |
+
return true;
|
526 |
+
}
|
527 |
+
|
528 |
+
/**
|
529 |
+
* Reset the failed checks
|
530 |
+
*/
|
531 |
+
private function reset_failed_checks() {
|
532 |
+
$this->failed_checks = 1;
|
533 |
+
update_option( $this->product->get_key() . '_failed_checks', $this->failed_checks );
|
534 |
+
}
|
535 |
+
|
536 |
+
/**
|
537 |
+
* Increment the failed checks.
|
538 |
+
*/
|
539 |
+
private function increment_failed_checks() {
|
540 |
+
$this->failed_checks ++;
|
541 |
+
update_option( $this->product->get_key() . '_failed_checks', $this->failed_checks );
|
542 |
+
}
|
543 |
+
|
544 |
+
/**
|
545 |
+
* Activate the license remotely.
|
546 |
+
*/
|
547 |
+
public function process_license() {
|
548 |
+
// listen for our activate button to be clicked.
|
549 |
+
if ( ! isset( $_POST[ $this->product->get_key() . '_btn_trigger' ] ) ) {
|
550 |
+
return;
|
551 |
+
}
|
552 |
+
if ( ! isset( $_POST[ $this->product->get_key() . 'nonce_field' ] )
|
553 |
+
|| ! wp_verify_nonce( $_POST[ $this->product->get_key() . 'nonce_field' ], $this->product->get_key() . 'nonce' ) //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
554 |
+
) {
|
555 |
+
return;
|
556 |
+
}
|
557 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
558 |
+
return;
|
559 |
+
}
|
560 |
+
$license = isset( $_POST[ $this->product->get_key() . '_license' ] )
|
561 |
+
? sanitize_text_field( $_POST[ $this->product->get_key() . '_license' ] )
|
562 |
+
: '';
|
563 |
+
|
564 |
+
$response = $this->do_license_process( $license, 'toggle' );
|
565 |
+
if ( is_wp_error( $response ) ) {
|
566 |
+
$this->set_error( $response->get_error_message() );
|
567 |
+
|
568 |
+
return;
|
569 |
+
}
|
570 |
+
if ( true === $response ) {
|
571 |
+
$this->set_error( '' );
|
572 |
+
}
|
573 |
+
}
|
574 |
+
|
575 |
+
/**
|
576 |
+
* Set license validation error message.
|
577 |
+
*
|
578 |
+
* @param string $message Error message.
|
579 |
+
*/
|
580 |
+
public function set_error( $message = '' ) {
|
581 |
+
set_transient( $this->product->get_key() . 'act_err', $message, MINUTE_IN_SECONDS );
|
582 |
+
|
583 |
+
}
|
584 |
+
|
585 |
+
/**
|
586 |
+
* Load the Themes screen.
|
587 |
+
*/
|
588 |
+
public function load_themes_screen() {
|
589 |
+
add_thickbox();
|
590 |
+
add_action( 'admin_notices', array( &$this, 'update_nag' ) );
|
591 |
+
}
|
592 |
+
|
593 |
+
/**
|
594 |
+
* Alter the nag for themes update.
|
595 |
+
*/
|
596 |
+
public function update_nag() {
|
597 |
+
$theme = wp_get_theme( $this->product->get_slug() );
|
598 |
+
$api_response = get_transient( $this->product_key );
|
599 |
+
if ( false === $api_response || ! isset( $api_response->new_version ) ) {
|
600 |
+
return;
|
601 |
+
}
|
602 |
+
$update_url = wp_nonce_url( 'update.php?action=upgrade-theme&theme=' . urlencode( $this->product->get_slug() ), 'upgrade-theme_' . $this->product->get_slug() );
|
603 |
+
$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.' );
|
604 |
+
$update_onclick = ' onclick="if ( confirm(\'' . esc_js( $update_message ) . '\') ) {return true;}return false;"';
|
605 |
+
if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) {
|
606 |
+
echo '<div id="update-nag">';
|
607 |
+
printf(
|
608 |
+
'<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>.',
|
609 |
+
esc_attr( $theme->get( 'Name' ) ),
|
610 |
+
esc_attr( $api_response->new_version ),
|
611 |
+
esc_url( sprintf( '%s&TB_iframe=true&width=1024&height=800', $this->product->get_changelog() ) ),
|
612 |
+
esc_attr( $theme->get( 'Name' ) ),
|
613 |
+
esc_url( $update_url ),
|
614 |
+
$update_onclick // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Already escaped.
|
615 |
+
);
|
616 |
+
echo '</div>';
|
617 |
+
echo '<div id="' . esc_attr( $this->product->get_slug() ) . '_changelog" style="display:none;">';
|
618 |
+
echo wp_kses_data( wpautop( $api_response->sections['changelog'] ) );
|
619 |
+
echo '</div>';
|
620 |
+
}
|
621 |
+
}
|
622 |
+
|
623 |
+
/**
|
624 |
+
* Alter update transient.
|
625 |
+
*
|
626 |
+
* @param mixed $value The transient data.
|
627 |
+
*
|
628 |
+
* @return mixed
|
629 |
+
*/
|
630 |
+
public function theme_update_transient( $value ) {
|
631 |
+
$update_data = $this->check_for_update();
|
632 |
+
if ( $update_data ) {
|
633 |
+
$value->response[ $this->product->get_slug() ] = $update_data;
|
634 |
+
}
|
635 |
+
|
636 |
+
return $value;
|
637 |
+
}
|
638 |
+
|
639 |
+
/**
|
640 |
+
* Check for updates
|
641 |
+
*
|
642 |
+
* @return array|bool Either the update data or false in case of failure.
|
643 |
+
*/
|
644 |
+
public function check_for_update() {
|
645 |
+
$update_data = get_transient( $this->product_key );
|
646 |
+
|
647 |
+
if ( false === $update_data ) {
|
648 |
+
$failed = false;
|
649 |
+
$update_data = $this->get_version_data();
|
650 |
+
if ( empty( $update_data ) ) {
|
651 |
+
$failed = true;
|
652 |
+
}
|
653 |
+
// If the response failed, try again in 30 minutes.
|
654 |
+
if ( $failed ) {
|
655 |
+
$data = new \stdClass();
|
656 |
+
$data->new_version = $this->product->get_version();
|
657 |
+
set_transient( $this->product_key, $data, 30 * MINUTE_IN_SECONDS );
|
658 |
+
|
659 |
+
return false;
|
660 |
+
}
|
661 |
+
$update_data->sections = isset( $update_data->sections ) ? maybe_unserialize( $update_data->sections ) : null;
|
662 |
+
|
663 |
+
set_transient( $this->product_key, $update_data, 12 * HOUR_IN_SECONDS );
|
664 |
+
}
|
665 |
+
if ( ! isset( $update_data->new_version ) ) {
|
666 |
+
return false;
|
667 |
+
}
|
668 |
+
if ( version_compare( $this->product->get_version(), $update_data->new_version, '>=' ) ) {
|
669 |
+
return false;
|
670 |
+
}
|
671 |
+
|
672 |
+
return (array) $update_data;
|
673 |
+
}
|
674 |
+
|
675 |
+
/**
|
676 |
+
* Check remote api for latest version.
|
677 |
+
*
|
678 |
+
* @return bool|mixed Update api response.
|
679 |
+
*/
|
680 |
+
private function get_version_data() {
|
681 |
+
|
682 |
+
$response = $this->safe_get(
|
683 |
+
sprintf(
|
684 |
+
'%slicense/version/%s/%s/%s/%s',
|
685 |
+
Product::API_URL,
|
686 |
+
rawurlencode( $this->product->get_name() ),
|
687 |
+
( empty( $this->license_key ) ? 'free' : $this->license_key ),
|
688 |
+
$this->product->get_version(),
|
689 |
+
rawurlencode( home_url() )
|
690 |
+
),
|
691 |
+
array(
|
692 |
+
'timeout' => 15, //phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout, Inherited by wp_remote_get only, for vip environment we use defaults.
|
693 |
+
'sslverify' => false,
|
694 |
+
)
|
695 |
+
);
|
696 |
+
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
|
697 |
+
return false;
|
698 |
+
}
|
699 |
+
$update_data = json_decode( wp_remote_retrieve_body( $response ) );
|
700 |
+
if ( ! is_object( $update_data ) ) {
|
701 |
+
return false;
|
702 |
+
}
|
703 |
+
if ( isset( $update_data->slug ) ) {
|
704 |
+
$update_data->slug = $this->product->get_slug();
|
705 |
+
}
|
706 |
+
if ( isset( $update_data->icons ) ) {
|
707 |
+
$update_data->icons = (array) $update_data->icons;
|
708 |
+
}
|
709 |
+
if ( isset( $update_data->banners ) ) {
|
710 |
+
$update_data->banners = (array) $update_data->banners;
|
711 |
+
}
|
712 |
+
|
713 |
+
return $update_data;
|
714 |
+
}
|
715 |
+
|
716 |
+
/**
|
717 |
+
* Delete the update transient
|
718 |
+
*/
|
719 |
+
public function delete_theme_update_transient() {
|
720 |
+
return delete_transient( $this->product_key );
|
721 |
+
}
|
722 |
+
|
723 |
+
/**
|
724 |
+
* Check for Updates at the defined API endpoint and modify the update array.
|
725 |
+
*
|
726 |
+
* @param array $_transient_data Update array build by WordPress.
|
727 |
+
*
|
728 |
+
* @return mixed Modified update array with custom plugin data.
|
729 |
+
*/
|
730 |
+
public function pre_set_site_transient_update_plugins_filter( $_transient_data ) {
|
731 |
+
if ( empty( $_transient_data ) || ! $this->do_check ) {
|
732 |
+
$this->do_check = true;
|
733 |
+
|
734 |
+
return $_transient_data;
|
735 |
+
}
|
736 |
+
$api_response = $this->api_request();
|
737 |
+
if ( false !== $api_response && is_object( $api_response ) && isset( $api_response->new_version ) ) {
|
738 |
+
if ( ! isset( $api_response->plugin ) ) {
|
739 |
+
$api_response->plugin = $this->product->get_slug() . '/' . $this->product->get_file();
|
740 |
+
}
|
741 |
+
if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) {
|
742 |
+
$_transient_data->response[ $this->product->get_slug() . '/' . $this->product->get_file() ] = $api_response;
|
743 |
+
} else {
|
744 |
+
$_transient_data->no_update[ $this->product->get_slug() . '/' . $this->product->get_file() ] = $api_response;
|
745 |
+
}
|
746 |
+
}
|
747 |
+
|
748 |
+
return $_transient_data;
|
749 |
+
}
|
750 |
+
|
751 |
+
/**
|
752 |
+
* Calls the API and, if successfull, returns the object delivered by the API.
|
753 |
+
*
|
754 |
+
* @param string $_action The requested action.
|
755 |
+
* @param array $_data Parameters for the API action.
|
756 |
+
*
|
757 |
+
* @return false||object
|
758 |
+
*/
|
759 |
+
private function api_request( $_action = '', $_data = '' ) {
|
760 |
+
$update_data = $this->get_version_data();
|
761 |
+
if ( empty( $update_data ) ) {
|
762 |
+
return false;
|
763 |
+
}
|
764 |
+
if ( $update_data && isset( $update_data->sections ) ) {
|
765 |
+
$update_data->sections = maybe_unserialize( $update_data->sections );
|
766 |
+
}
|
767 |
+
|
768 |
+
return $update_data;
|
769 |
+
}
|
770 |
+
|
771 |
+
/**
|
772 |
+
* Updates information on the "View version x.x details" page with custom data.
|
773 |
+
*
|
774 |
+
* @param mixed $_data Plugin data.
|
775 |
+
* @param string $_action Action to send.
|
776 |
+
* @param object $_args Arguments to use.
|
777 |
+
*
|
778 |
+
* @return object $_data
|
779 |
+
*/
|
780 |
+
public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
|
781 |
+
if ( ( 'plugin_information' !== $_action ) || ! isset( $_args->slug ) || ( $_args->slug !== $this->product->get_slug() ) ) {
|
782 |
+
return $_data;
|
783 |
+
}
|
784 |
+
$api_response = $this->api_request();
|
785 |
+
if ( false !== $api_response ) {
|
786 |
+
$_data = $api_response;
|
787 |
+
}
|
788 |
+
|
789 |
+
return $_data;
|
790 |
+
}
|
791 |
+
|
792 |
+
/**
|
793 |
+
* Disable SSL verification in order to prevent download update failures.
|
794 |
+
*
|
795 |
+
* @param array $args Http args.
|
796 |
+
* @param string $url Url to check.
|
797 |
+
*
|
798 |
+
* @return array $array
|
799 |
+
*/
|
800 |
+
public function http_request_args( $args, $url ) {
|
801 |
+
// If it is an https request and we are performing a package download, disable ssl verification.
|
802 |
+
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
|
803 |
+
$args['sslverify'] = false;
|
804 |
+
}
|
805 |
+
|
806 |
+
return $args;
|
807 |
+
}
|
808 |
+
|
809 |
+
/**
|
810 |
+
* Check if we should load the module for this product.
|
811 |
+
*
|
812 |
+
* @param Product $product Product data.
|
813 |
+
*
|
814 |
+
* @return bool Should we load the module?
|
815 |
+
*/
|
816 |
+
public function can_load( $product ) {
|
817 |
+
|
818 |
+
if ( $product->is_wordpress_available() ) {
|
819 |
+
return false;
|
820 |
+
}
|
821 |
+
|
822 |
+
return ( apply_filters( $product->get_key() . '_enable_licenser', true ) === true );
|
823 |
+
|
824 |
+
}
|
825 |
+
|
826 |
+
/**
|
827 |
+
* Load module logic.
|
828 |
+
*
|
829 |
+
* @param Product $product Product to load the module for.
|
830 |
+
*
|
831 |
+
* @return Licenser Module object.
|
832 |
+
*/
|
833 |
+
public function load( $product ) {
|
834 |
+
$this->product = $product;
|
835 |
+
|
836 |
+
$this->product_key = $this->product->get_key() . '-update-response';
|
837 |
+
|
838 |
+
$this->license_key = $this->product->get_license();
|
839 |
+
if ( $this->product->requires_license() ) {
|
840 |
+
$this->failed_checks = intval( get_option( $this->product->get_key() . '_failed_checks', 0 ) );
|
841 |
+
$this->register_license_hooks();
|
842 |
+
}
|
843 |
+
|
844 |
+
$namespace = apply_filters( 'themesle_sdk_namespace_' . md5( $product->get_basefile() ), false );
|
845 |
+
|
846 |
+
if ( false !== $namespace ) {
|
847 |
+
$this->namespace = $namespace;
|
848 |
+
add_filter( 'themeisle_sdk_license_process_' . $namespace, [ $this, 'do_license_process' ], 10, 2 );
|
849 |
+
add_filter( 'product_' . $namespace . '_license_status', [ $this, 'get_license_status' ], PHP_INT_MAX );
|
850 |
+
add_filter( 'product_' . $namespace . '_license_key', [ $this->product, 'get_license' ] );
|
851 |
+
add_filter( 'product_' . $namespace . '_license_plan', [ $this, 'get_plan' ], PHP_INT_MAX );
|
852 |
+
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
853 |
+
\WP_CLI::add_command( $namespace . ' activate', [ $this, 'cli_activate' ] );
|
854 |
+
\WP_CLI::add_command( $namespace . ' deactivate', [ $this, 'cli_deactivate' ] );
|
855 |
+
\WP_CLI::add_command( $namespace . ' is-active', [ $this, 'cli_is_active' ] );
|
856 |
+
}
|
857 |
+
}
|
858 |
+
|
859 |
+
add_action( 'admin_head', [ $this, 'auto_activate' ] );
|
860 |
+
if ( $this->product->is_plugin() ) {
|
861 |
+
add_filter(
|
862 |
+
'pre_set_site_transient_update_plugins',
|
863 |
+
[
|
864 |
+
$this,
|
865 |
+
'pre_set_site_transient_update_plugins_filter',
|
866 |
+
]
|
867 |
+
);
|
868 |
+
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
|
869 |
+
add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
|
870 |
+
|
871 |
+
return $this;
|
872 |
+
}
|
873 |
+
if ( $this->product->is_theme() ) {
|
874 |
+
add_filter( 'site_transient_update_themes', array( &$this, 'theme_update_transient' ) );
|
875 |
+
add_action( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) );
|
876 |
+
add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) );
|
877 |
+
add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) );
|
878 |
+
add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) );
|
879 |
+
add_filter( 'http_request_args', array( $this, 'disable_wporg_update' ), 5, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
|
880 |
+
|
881 |
+
return $this;
|
882 |
+
|
883 |
+
}
|
884 |
+
|
885 |
+
return $this;
|
886 |
+
}
|
887 |
+
|
888 |
+
/**
|
889 |
+
* Register license fields for the products.
|
890 |
+
*/
|
891 |
+
public function register_license_hooks() {
|
892 |
+
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
893 |
+
add_action( 'admin_init', array( $this, 'process_license' ) );
|
894 |
+
add_action( 'admin_init', array( $this, 'product_valid' ), 99999999 );
|
895 |
+
add_action( 'admin_notices', array( $this, 'show_notice' ) );
|
896 |
+
add_filter( $this->product->get_key() . '_license_status', array( $this, 'get_license_status' ) );
|
897 |
+
}
|
898 |
+
|
899 |
+
/**
|
900 |
+
* Check license on filesystem.
|
901 |
+
*
|
902 |
+
* @return mixed License key.
|
903 |
+
*/
|
904 |
+
public function get_file_license() {
|
905 |
+
|
906 |
+
$license_file = dirname( $this->product->get_basefile() ) . '/license.json';
|
907 |
+
|
908 |
+
global $wp_filesystem;
|
909 |
+
if ( ! is_file( $license_file ) ) {
|
910 |
+
return false;
|
911 |
+
}
|
912 |
+
|
913 |
+
require_once ABSPATH . '/wp-admin/includes/file.php';
|
914 |
+
\WP_Filesystem();
|
915 |
+
$content = json_decode( $wp_filesystem->get_contents( $license_file ) );
|
916 |
+
if ( ! is_object( $content ) ) {
|
917 |
+
return false;
|
918 |
+
}
|
919 |
+
if ( ! isset( $content->key ) ) {
|
920 |
+
return false;
|
921 |
+
}
|
922 |
+
return $content->key;
|
923 |
+
}
|
924 |
+
/**
|
925 |
+
* Run license activation on plugin activate.
|
926 |
+
*/
|
927 |
+
public function auto_activate() {
|
928 |
+
$status = $this->get_license_status();
|
929 |
+
if ( 'not_active' !== $status ) {
|
930 |
+
return false;
|
931 |
+
}
|
932 |
+
|
933 |
+
if ( ! empty( $this->namespace ) ) {
|
934 |
+
$license_key = apply_filters( 'product_' . $this->namespace . '_license_key_constant', '' );
|
935 |
+
}
|
936 |
+
|
937 |
+
if ( empty( $license_key ) ) {
|
938 |
+
$license_key = $this->get_file_license();
|
939 |
+
}
|
940 |
+
if ( empty( $license_key ) ) {
|
941 |
+
return;
|
942 |
+
}
|
943 |
+
|
944 |
+
|
945 |
+
$this->license_local = $license_key;
|
946 |
+
$lock_key = $this->product->get_key() . '_autoactivated';
|
947 |
+
|
948 |
+
if ( 'yes' === get_option( $lock_key, '' ) ) {
|
949 |
+
return;
|
950 |
+
}
|
951 |
+
if ( 'yes' === get_transient( $lock_key ) ) {
|
952 |
+
return;
|
953 |
+
}
|
954 |
+
$response = $this->do_license_process( $license_key, 'activate' );
|
955 |
+
|
956 |
+
set_transient( $lock_key, 'yes', 6 * HOUR_IN_SECONDS );
|
957 |
+
|
958 |
+
if ( apply_filters( $this->product->get_key() . '_hide_license_notices', false ) ) {
|
959 |
+
return;
|
960 |
+
}
|
961 |
+
|
962 |
+
if ( true === $response ) {
|
963 |
+
add_action( 'admin_notices', [ $this, 'autoactivate_notice' ] );
|
964 |
+
}
|
965 |
+
}
|
966 |
+
|
967 |
+
/**
|
968 |
+
* Show auto-activate notice.
|
969 |
+
*/
|
970 |
+
public function autoactivate_notice() {
|
971 |
+
?>
|
972 |
+
<div class="notice notice-success is-dismissible">
|
973 |
+
<p><?php echo sprintf( '<strong>%s</strong> has been successfully activated using <strong>%s</strong> license !', esc_attr( $this->product->get_name() ), esc_attr( str_repeat( '*', 20 ) . substr( $this->license_local, - 10 ) ) ); ?></p>
|
974 |
+
</div>
|
975 |
+
<?php
|
976 |
+
}
|
977 |
+
|
978 |
+
/**
|
979 |
+
* Activate product license on this site.
|
980 |
+
*
|
981 |
+
* ## OPTIONS
|
982 |
+
*
|
983 |
+
* @param array $args Command args.
|
984 |
+
*
|
985 |
+
* [<license-key>]
|
986 |
+
* : Product license key.
|
987 |
+
*/
|
988 |
+
public function cli_activate( $args ) {
|
989 |
+
$license_key = isset( $args[0] ) ? trim( $args[0] ) : '';
|
990 |
+
$response = $this->do_license_process( $license_key, 'activate' );
|
991 |
+
if ( true !== $response ) {
|
992 |
+
\WP_CLI::error( $response->get_error_message() );
|
993 |
+
|
994 |
+
return;
|
995 |
+
}
|
996 |
+
|
997 |
+
\WP_CLI::success( 'Product successfully activated.' );
|
998 |
+
}
|
999 |
+
|
1000 |
+
/**
|
1001 |
+
* Deactivate product license on this site.
|
1002 |
+
*
|
1003 |
+
* @param array $args Command args.
|
1004 |
+
*
|
1005 |
+
* ## OPTIONS
|
1006 |
+
*
|
1007 |
+
* [<license-key>]
|
1008 |
+
* : Product license key.
|
1009 |
+
*/
|
1010 |
+
public function cli_deactivate( $args ) {
|
1011 |
+
$license_key = isset( $args[0] ) ? trim( $args[0] ) : '';
|
1012 |
+
$response = $this->do_license_process( $license_key, 'deactivate' );
|
1013 |
+
if ( true !== $response ) {
|
1014 |
+
\WP_CLI::error( $response->get_error_message() );
|
1015 |
+
|
1016 |
+
return;
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
\WP_CLI::success( 'Product successfully deactivated.' );
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
/**
|
1023 |
+
* Checks if product has license activated.
|
1024 |
+
*
|
1025 |
+
* @param array $args Command args.
|
1026 |
+
*
|
1027 |
+
* @subcommand is-active
|
1028 |
+
*/
|
1029 |
+
public function cli_is_active( $args ) {
|
1030 |
+
|
1031 |
+
$status = $this->get_license_status();
|
1032 |
+
if ( 'valid' === $status ) {
|
1033 |
+
\WP_CLI::halt( 0 );
|
1034 |
+
|
1035 |
+
return;
|
1036 |
+
}
|
1037 |
+
|
1038 |
+
\WP_CLI::halt( 1 );
|
1039 |
+
}
|
1040 |
+
}
|
vendor/codeinwp/themeisle-sdk/src/Modules/Logger.php
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The logger model class for ThemeIsle SDK
|
4 |
+
*
|
5 |
+
* @package ThemeIsleSDK
|
6 |
+
* @subpackage Modules
|
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 |
+
|
12 |
+
namespace ThemeisleSDK\Modules;
|
13 |
+
|
14 |
+
use ThemeisleSDK\Common\Abstract_Module;
|
15 |
+
use ThemeisleSDK\Loader;
|
16 |
+
use ThemeisleSDK\Product;
|
17 |
+
|
18 |
+
// Exit if accessed directly.
|
19 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
+
exit;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Logger module for ThemeIsle SDK.
|
25 |
+
*/
|
26 |
+
class Logger extends Abstract_Module {
|
27 |
+
/**
|
28 |
+
* Endpoint where to collect logs.
|
29 |
+
*/
|
30 |
+
const TRACKING_ENDPOINT = 'https://api.themeisle.com/tracking/log';
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Check if we should load the module for this product.
|
35 |
+
*
|
36 |
+
* @param Product $product Product to load the module for.
|
37 |
+
*
|
38 |
+
* @return bool Should we load ?
|
39 |
+
*/
|
40 |
+
public function can_load( $product ) {
|
41 |
+
|
42 |
+
return apply_filters( $product->get_slug() . '_sdk_enable_logger', true );
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Load module logic.
|
47 |
+
*
|
48 |
+
* @param Product $product Product to load.
|
49 |
+
*
|
50 |
+
* @return Logger Module object.
|
51 |
+
*/
|
52 |
+
public function load( $product ) {
|
53 |
+
$this->product = $product;
|
54 |
+
$this->setup_notification();
|
55 |
+
$this->setup_actions();
|
56 |
+
|
57 |
+
return $this;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Setup notification on admin.
|
62 |
+
*/
|
63 |
+
public function setup_notification() {
|
64 |
+
if ( ! $this->product->is_wordpress_available() ) {
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
|
68 |
+
add_filter( 'themeisle_sdk_registered_notifications', [ $this, 'add_notification' ] );
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Setup tracking actions.
|
74 |
+
*/
|
75 |
+
public function setup_actions() {
|
76 |
+
if ( ! $this->is_logger_active() ) {
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
$action_key = $this->product->get_key() . '_log_activity';
|
80 |
+
if ( ! wp_next_scheduled( $action_key ) ) {
|
81 |
+
wp_schedule_single_event( time() + ( wp_rand( 1, 24 ) * 3600 ), $action_key );
|
82 |
+
}
|
83 |
+
add_action( $action_key, array( $this, 'send_log' ) );
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Check if the logger is active.
|
89 |
+
*
|
90 |
+
* @return bool Is logger active?
|
91 |
+
*/
|
92 |
+
private function is_logger_active() {
|
93 |
+
$default = 'no';
|
94 |
+
|
95 |
+
if ( ! $this->product->is_wordpress_available() ) {
|
96 |
+
$default = 'yes';
|
97 |
+
} else {
|
98 |
+
$pro_slug = $this->product->get_pro_slug();
|
99 |
+
|
100 |
+
if ( ! empty( $pro_slug ) ) {
|
101 |
+
$all_products = Loader::get_products();
|
102 |
+
if ( isset( $all_products[ $pro_slug ] ) ) {
|
103 |
+
$default = 'yes';
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
return ( get_option( $this->product->get_key() . '_logger_flag', $default ) === 'yes' );
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Add notification to queue.
|
113 |
+
*
|
114 |
+
* @param array $all_notifications Previous notification.
|
115 |
+
*
|
116 |
+
* @return array All notifications.
|
117 |
+
*/
|
118 |
+
public function add_notification( $all_notifications ) {
|
119 |
+
|
120 |
+
$message = apply_filters( $this->product->get_key() . '_logger_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.' );
|
121 |
+
|
122 |
+
$message = str_replace(
|
123 |
+
array( '{product}' ),
|
124 |
+
$this->product->get_friendly_name(),
|
125 |
+
$message
|
126 |
+
);
|
127 |
+
$button_submit = apply_filters( $this->product->get_key() . '_logger_button_submit', 'Sure, I would love to help.' );
|
128 |
+
$button_cancel = apply_filters( $this->product->get_key() . '_logger_button_cancel', 'No, thanks.' );
|
129 |
+
|
130 |
+
$all_notifications[] = [
|
131 |
+
'id' => $this->product->get_key() . '_logger_flag',
|
132 |
+
'message' => $message,
|
133 |
+
'ctas' => [
|
134 |
+
'confirm' => [
|
135 |
+
'link' => '#',
|
136 |
+
'text' => $button_submit,
|
137 |
+
],
|
138 |
+
'cancel' => [
|
139 |
+
'link' => '#',
|
140 |
+
'text' => $button_cancel,
|
141 |
+
],
|
142 |
+
],
|
143 |
+
];
|
144 |
+
|
145 |
+
return $all_notifications;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Send the statistics to the api endpoint.
|
150 |
+
*/
|
151 |
+
public function send_log() {
|
152 |
+
$environment = array();
|
153 |
+
$theme = wp_get_theme();
|
154 |
+
$environment['theme'] = array();
|
155 |
+
$environment['theme']['name'] = $theme->get( 'Name' );
|
156 |
+
$environment['theme']['author'] = $theme->get( 'Author' );
|
157 |
+
$environment['theme']['parent'] = $theme->parent() !== false ? $theme->parent()->get( 'Name' ) : $theme->get( 'Name' );
|
158 |
+
$environment['plugins'] = get_option( 'active_plugins' );
|
159 |
+
global $wp_version;
|
160 |
+
wp_remote_post(
|
161 |
+
self::TRACKING_ENDPOINT,
|
162 |
+
array(
|
163 |
+
'method' => 'POST',
|
164 |
+
'timeout' => 3,
|
165 |
+
'redirection' => 5,
|
166 |
+
'body' => array(
|
167 |
+
'site' => get_site_url(),
|
168 |
+
'slug' => $this->product->get_slug(),
|
169 |
+
'version' => $this->product->get_version(),
|
170 |
+
'wp_version' => $wp_version,
|
171 |
+
'locale' => get_locale(),
|
172 |
+
'data' => apply_filters( $this->product->get_key() . '_logger_data', array() ),
|
173 |
+
'environment' => $environment,
|
174 |
+
'license' => apply_filters( $this->product->get_key() . '_license_status', '' ),
|
175 |
+
),
|
176 |
+
)
|
177 |
+
);
|
178 |
+
}
|
179 |
+
}
|
vendor/codeinwp/themeisle-sdk/src/Modules/Notification.php
ADDED
@@ -0,0 +1,463 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The notification model class for ThemeIsle SDK
|
4 |
+
*
|
5 |
+
* @package ThemeIsleSDK
|
6 |
+
* @subpackage Modules
|
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 |
+
|
12 |
+
namespace ThemeisleSDK\Modules;
|
13 |
+
|
14 |
+
use ThemeisleSDK\Common\Abstract_Module;
|
15 |
+
use ThemeisleSDK\Product;
|
16 |
+
|
17 |
+
// Exit if accessed directly.
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Notification module for ThemeIsle SDK.
|
24 |
+
*/
|
25 |
+
class Notification extends Abstract_Module {
|
26 |
+
/**
|
27 |
+
* Show notifications only after the user has the product installed after this amount of time, in hours.
|
28 |
+
*/
|
29 |
+
const MIN_INSTALL_TIME = 100;
|
30 |
+
/**
|
31 |
+
* How much time should we show the notification, in days.
|
32 |
+
*/
|
33 |
+
const MAX_TIME_TO_LIVE = 7;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Number of days between notifications.
|
37 |
+
*/
|
38 |
+
const TIME_BETWEEN_NOTIFICATIONS = 5;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Holds a possible notification list.
|
42 |
+
*
|
43 |
+
* @var array Notifications list.
|
44 |
+
*/
|
45 |
+
private static $notifications = [];
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Show notification data.
|
49 |
+
*/
|
50 |
+
public static function show_notification() {
|
51 |
+
|
52 |
+
$current_notification = self::get_last_notification();
|
53 |
+
|
54 |
+
$notification_details = [];
|
55 |
+
// Check if the saved notification is still present among the possible ones.
|
56 |
+
if ( ! empty( $current_notification ) ) {
|
57 |
+
$notification_details = self::get_notification_details( $current_notification );
|
58 |
+
if ( empty( $notification_details ) ) {
|
59 |
+
$current_notification = [];
|
60 |
+
}
|
61 |
+
}
|
62 |
+
// Check if the notificatin is expired.
|
63 |
+
if ( ! empty( $current_notification ) && self::is_notification_expired( $current_notification ) ) {
|
64 |
+
update_option( $current_notification['id'], 'no' );
|
65 |
+
self::set_last_active_notification_timestamp();
|
66 |
+
$current_notification = [];
|
67 |
+
}
|
68 |
+
// If we don't have any saved notification, get a new one.
|
69 |
+
if ( empty( $current_notification ) ) {
|
70 |
+
$notification_details = self::get_random_notification();
|
71 |
+
if ( empty( $notification_details ) ) {
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
self::set_active_notification(
|
75 |
+
[
|
76 |
+
'id' => $notification_details['id'],
|
77 |
+
'display_at' => time(),
|
78 |
+
]
|
79 |
+
);
|
80 |
+
}
|
81 |
+
if ( empty( $notification_details ) ) {
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
$notification_html = self::get_notification_html( $notification_details );
|
85 |
+
do_action( $notification_details['id'] . '_before_render' );
|
86 |
+
|
87 |
+
echo $notification_html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, already escaped internally.
|
88 |
+
|
89 |
+
do_action( $notification_details['id'] . '_after_render' );
|
90 |
+
self::render_snippets();
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Get last notification details.
|
95 |
+
*
|
96 |
+
* @return array Last notification details.
|
97 |
+
*/
|
98 |
+
private static function get_last_notification() {
|
99 |
+
$notification = self::get_notifications_metadata();
|
100 |
+
|
101 |
+
return isset( $notification['last_notification'] ) ? $notification['last_notification'] : [];
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Get notification center details.
|
106 |
+
*
|
107 |
+
* @return array Notification center details.
|
108 |
+
*/
|
109 |
+
private static function get_notifications_metadata() {
|
110 |
+
|
111 |
+
$data = get_option(
|
112 |
+
'themeisle_sdk_notifications',
|
113 |
+
[
|
114 |
+
'last_notification' => [],
|
115 |
+
'last_notification_active' => 0,
|
116 |
+
]
|
117 |
+
);
|
118 |
+
|
119 |
+
return $data;
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Check if the notification is still possible.
|
125 |
+
*
|
126 |
+
* @param array $notification Notification to check.
|
127 |
+
*
|
128 |
+
* @return array Either is still active or not.
|
129 |
+
*/
|
130 |
+
private static function get_notification_details( $notification ) {
|
131 |
+
$notifications = array_filter(
|
132 |
+
self::$notifications,
|
133 |
+
function ( $value ) use ( $notification ) {
|
134 |
+
if ( isset( $value['id'] ) && isset( $notification['id'] ) && $value['id'] === $notification['id'] ) {
|
135 |
+
return true;
|
136 |
+
}
|
137 |
+
|
138 |
+
return false;
|
139 |
+
}
|
140 |
+
);
|
141 |
+
|
142 |
+
return ! empty( $notifications ) ? reset( $notifications ) : [];
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Check if the notification is expired.
|
147 |
+
*
|
148 |
+
* @param array $notification Notification to check.
|
149 |
+
*
|
150 |
+
* @return bool Either the notification is due.
|
151 |
+
*/
|
152 |
+
private static function is_notification_expired( $notification ) {
|
153 |
+
if ( ! isset( $notification['display_at'] ) ) {
|
154 |
+
return true;
|
155 |
+
}
|
156 |
+
|
157 |
+
$notifications = array_filter(
|
158 |
+
self::$notifications,
|
159 |
+
function ( $value ) use ( $notification ) {
|
160 |
+
if ( isset( $value['id'] ) && isset( $notification['id'] ) && $value['id'] === $notification['id'] ) {
|
161 |
+
return true;
|
162 |
+
}
|
163 |
+
|
164 |
+
return false;
|
165 |
+
}
|
166 |
+
);
|
167 |
+
|
168 |
+
if ( empty( $notifications ) ) {
|
169 |
+
return true;
|
170 |
+
}
|
171 |
+
$notification_definition = reset( $notifications );
|
172 |
+
|
173 |
+
$when_to_expire = isset( $notification_definition['expires_at'] )
|
174 |
+
? $notification_definition['expires_at'] :
|
175 |
+
( isset( $notification_definition['expires'] )
|
176 |
+
? ( $notification['display_at'] + $notification_definition['expires'] ) :
|
177 |
+
( $notification['display_at'] + self::MAX_TIME_TO_LIVE * DAY_IN_SECONDS )
|
178 |
+
);
|
179 |
+
|
180 |
+
return ( $when_to_expire - time() ) < 0;
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Set last notification details.
|
185 |
+
*/
|
186 |
+
private static function set_last_active_notification_timestamp() {
|
187 |
+
$metadata = self::get_notifications_metadata();
|
188 |
+
$metadata['last_notification_active'] = time();
|
189 |
+
update_option( 'themeisle_sdk_notifications', $metadata );
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Return notification to show.
|
194 |
+
*
|
195 |
+
* @return array Notification data.
|
196 |
+
*/
|
197 |
+
public static function get_random_notification() {
|
198 |
+
if ( ( time() - self::get_last_active_notification_timestamp() ) < self::TIME_BETWEEN_NOTIFICATIONS * DAY_IN_SECONDS ) {
|
199 |
+
return [];
|
200 |
+
}
|
201 |
+
|
202 |
+
$notifications = self::$notifications;
|
203 |
+
$notifications = array_filter(
|
204 |
+
$notifications,
|
205 |
+
function ( $value ) {
|
206 |
+
if ( isset( $value['sticky'] ) && true === $value['sticky'] ) {
|
207 |
+
return true;
|
208 |
+
}
|
209 |
+
|
210 |
+
return false;
|
211 |
+
}
|
212 |
+
);
|
213 |
+
// No priority notifications, use all.
|
214 |
+
if ( empty( $notifications ) ) {
|
215 |
+
$notifications = self::$notifications;
|
216 |
+
}
|
217 |
+
if ( empty( $notifications ) ) {
|
218 |
+
return [];
|
219 |
+
}
|
220 |
+
$notifications = array_values( $notifications );
|
221 |
+
|
222 |
+
return $notifications[ array_rand( $notifications, 1 ) ];
|
223 |
+
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Get last notification details.
|
228 |
+
*
|
229 |
+
* @return int Last notification details.
|
230 |
+
*/
|
231 |
+
private static function get_last_active_notification_timestamp() {
|
232 |
+
$notification = self::get_notifications_metadata();
|
233 |
+
|
234 |
+
return isset( $notification['last_notification_active'] ) ? $notification['last_notification_active'] : 0;
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Get last notification details.
|
239 |
+
*
|
240 |
+
* @param array $notification Notification data.
|
241 |
+
*/
|
242 |
+
private static function set_active_notification( $notification ) {
|
243 |
+
$metadata = self::get_notifications_metadata();
|
244 |
+
$metadata['last_notification'] = $notification;
|
245 |
+
update_option( 'themeisle_sdk_notifications', $metadata );
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Get notification html.
|
250 |
+
*
|
251 |
+
* @param array $notification_details Notification details.
|
252 |
+
*
|
253 |
+
* @return string Html for notice.
|
254 |
+
*/
|
255 |
+
public static function get_notification_html( $notification_details ) {
|
256 |
+
$default = [
|
257 |
+
'id' => '',
|
258 |
+
'heading' => '',
|
259 |
+
'message' => '',
|
260 |
+
'ctas' => [
|
261 |
+
'confirm' => [
|
262 |
+
'link' => '#',
|
263 |
+
'text' => '',
|
264 |
+
],
|
265 |
+
'cancel' => [
|
266 |
+
'link' => '#',
|
267 |
+
'text' => '',
|
268 |
+
],
|
269 |
+
],
|
270 |
+
];
|
271 |
+
$notification_details = wp_parse_args( $notification_details, $default );
|
272 |
+
|
273 |
+
$notification_html = '<div class="notice notice-success is-dismissible themeisle-sdk-notice" data-notification-id="' . esc_attr( $notification_details['id'] ) . '" id="' . esc_attr( $notification_details['id'] ) . '-notification"> <div class="themeisle-sdk-notification-box">';
|
274 |
+
|
275 |
+
if ( ! empty( $notification_details['heading'] ) ) {
|
276 |
+
$notification_html .= sprintf( '<h4>%s</h4>', wp_kses_post( $notification_details['heading'] ) );
|
277 |
+
}
|
278 |
+
if ( ! empty( $notification_details['message'] ) ) {
|
279 |
+
$notification_html .= wp_kses_post( $notification_details['message'] );
|
280 |
+
}
|
281 |
+
$notification_html .= '<div class="actions">';
|
282 |
+
|
283 |
+
if ( ! empty( $notification_details['ctas']['confirm']['text'] ) ) {
|
284 |
+
$notification_html .= sprintf(
|
285 |
+
'<a href="%s" target="_blank" class=" button button-primary %s" data-confirm="yes" >%s</a>',
|
286 |
+
esc_url( $notification_details['ctas']['confirm']['link'] ),
|
287 |
+
esc_attr( $notification_details['id'] . '_confirm' ),
|
288 |
+
wp_kses_post( $notification_details['ctas']['confirm']['text'] )
|
289 |
+
);
|
290 |
+
}
|
291 |
+
|
292 |
+
if ( ! empty( $notification_details['ctas']['cancel']['text'] ) ) {
|
293 |
+
$notification_html .= sprintf(
|
294 |
+
'<a href="%s" class=" button %s" data-confirm="no">%s</a>',
|
295 |
+
esc_url( $notification_details['ctas']['cancel']['link'] ),
|
296 |
+
esc_attr( $notification_details['id'] ) . '_cancel',
|
297 |
+
wp_kses_post( $notification_details['ctas']['cancel']['text'] )
|
298 |
+
);
|
299 |
+
}
|
300 |
+
|
301 |
+
$notification_html .= '</div>';
|
302 |
+
$notification_html .= ' </div>';
|
303 |
+
$notification_html .= ' </div>';
|
304 |
+
|
305 |
+
return $notification_html;
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Adds js snippet for hiding the notice.
|
310 |
+
*/
|
311 |
+
public static function render_snippets() {
|
312 |
+
|
313 |
+
?>
|
314 |
+
<style type="text/css">
|
315 |
+
.themeisle-sdk-notification-box {
|
316 |
+
padding: 3px;
|
317 |
+
}
|
318 |
+
|
319 |
+
.themeisle-sdk-notification-box .actions {
|
320 |
+
margin-top: 6px;
|
321 |
+
margin-bottom: 4px;
|
322 |
+
}
|
323 |
+
|
324 |
+
.themeisle-sdk-notification-box .button {
|
325 |
+
margin-right: 5px;
|
326 |
+
}
|
327 |
+
</style>
|
328 |
+
<script type="text/javascript">
|
329 |
+
(function ($) {
|
330 |
+
$(document).ready(function () {
|
331 |
+
$('#wpbody-content').on('click', ".themeisle-sdk-notice a.button, .themeisle-sdk-notice .notice-dismiss", function (e) {
|
332 |
+
|
333 |
+
var container = $('.themeisle-sdk-notice');
|
334 |
+
var link = $(this);
|
335 |
+
var notification_id = container.attr('data-notification-id');
|
336 |
+
var confirm = link.attr('data-confirm');
|
337 |
+
if (typeof confirm === "undefined") {
|
338 |
+
confirm = 'no';
|
339 |
+
}
|
340 |
+
$.post(
|
341 |
+
ajaxurl,
|
342 |
+
{
|
343 |
+
'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>',
|
344 |
+
'action': 'themeisle_sdk_dismiss_notice',
|
345 |
+
'id': notification_id,
|
346 |
+
'confirm': confirm
|
347 |
+
}
|
348 |
+
);
|
349 |
+
if (confirm === 'yes') {
|
350 |
+
$(this).trigger('themeisle-sdk:confirmed');
|
351 |
+
} else {
|
352 |
+
$(this).trigger('themeisle-sdk:canceled');
|
353 |
+
}
|
354 |
+
container.hide();
|
355 |
+
if (link.attr('href') === '#') {
|
356 |
+
return false;
|
357 |
+
}
|
358 |
+
});
|
359 |
+
});
|
360 |
+
})(jQuery);
|
361 |
+
</script>
|
362 |
+
<?php
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Dismiss the notification.
|
367 |
+
*/
|
368 |
+
public static function dismiss() {
|
369 |
+
check_ajax_referer( (string) __CLASS__, 'nonce' );
|
370 |
+
|
371 |
+
$id = isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : '';
|
372 |
+
$confirm = isset( $_POST['confirm'] ) ? sanitize_text_field( $_POST['confirm'] ) : 'no';
|
373 |
+
|
374 |
+
if ( empty( $id ) ) {
|
375 |
+
wp_send_json( [] );
|
376 |
+
}
|
377 |
+
$ids = wp_list_pluck( self::$notifications, 'id' );
|
378 |
+
if ( ! in_array( $id, $ids, true ) ) {
|
379 |
+
wp_send_json( [] );
|
380 |
+
}
|
381 |
+
self::set_last_active_notification_timestamp();
|
382 |
+
update_option( $id, $confirm );
|
383 |
+
do_action( $id . '_process_confirm', $confirm );
|
384 |
+
wp_send_json( [] );
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Check if we should load the notification module.
|
389 |
+
*
|
390 |
+
* @param Product $product Product to check.
|
391 |
+
*
|
392 |
+
* @return bool Should we load this?
|
393 |
+
*/
|
394 |
+
public function can_load( $product ) {
|
395 |
+
|
396 |
+
if ( $this->is_from_partner( $product ) ) {
|
397 |
+
return false;
|
398 |
+
}
|
399 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
400 |
+
return false;
|
401 |
+
}
|
402 |
+
if ( ( time() - $product->get_install_time() ) < ( self::MIN_INSTALL_TIME * HOUR_IN_SECONDS ) ) {
|
403 |
+
return false;
|
404 |
+
}
|
405 |
+
|
406 |
+
return true;
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Setup notifications queue.
|
411 |
+
*/
|
412 |
+
public static function setup_notifications() {
|
413 |
+
$notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] );
|
414 |
+
$notifications = array_filter(
|
415 |
+
$notifications,
|
416 |
+
function ( $value ) {
|
417 |
+
if ( ! isset( $value['id'] ) ) {
|
418 |
+
return false;
|
419 |
+
}
|
420 |
+
if ( get_option( $value['id'], '' ) !== '' ) {
|
421 |
+
return false;
|
422 |
+
}
|
423 |
+
|
424 |
+
return apply_filters( $value['id'] . '_should_show', true );
|
425 |
+
}
|
426 |
+
);
|
427 |
+
self::$notifications = $notifications;
|
428 |
+
}
|
429 |
+
/**
|
430 |
+
* Load the module logic.
|
431 |
+
*
|
432 |
+
* @param Product $product Product to load the module for.
|
433 |
+
*
|
434 |
+
* @return Notification Module instance.
|
435 |
+
*/
|
436 |
+
public function load( $product ) {
|
437 |
+
if ( apply_filters( 'themeisle_sdk_hide_notifications', false ) ) {
|
438 |
+
return;
|
439 |
+
}
|
440 |
+
$this->product = $product;
|
441 |
+
|
442 |
+
$notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] );
|
443 |
+
$notifications = array_filter(
|
444 |
+
$notifications,
|
445 |
+
function ( $value ) {
|
446 |
+
if ( ! isset( $value['id'] ) ) {
|
447 |
+
return false;
|
448 |
+
}
|
449 |
+
if ( get_option( $value['id'], '' ) !== '' ) {
|
450 |
+
return false;
|
451 |
+
}
|
452 |
+
|
453 |
+
return apply_filters( $value['id'] . '_should_show', true );
|
454 |
+
}
|
455 |
+
);
|
456 |
+
self::$notifications = $notifications;
|
457 |
+
add_action( 'admin_notices', array( __CLASS__, 'show_notification' ) );
|
458 |
+
add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', array( __CLASS__, 'dismiss' ) );
|
459 |
+
add_action( 'admin_head', array( __CLASS__, 'setup_notifications' ) );
|
460 |
+
|
461 |
+
return $this;
|
462 |
+
}
|
463 |
+
}
|
vendor/codeinwp/themeisle-sdk/src/Modules/Recommendation.php
ADDED
@@ -0,0 +1,377 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The class that exposes hooks for recommend.
|
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 |
+
|
12 |
+
namespace ThemeisleSDK\Modules;
|
13 |
+
|
14 |
+
// Exit if accessed directly.
|
15 |
+
use ThemeisleSDK\Common\Abstract_Module;
|
16 |
+
use ThemeisleSDK\Product;
|
17 |
+
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Expose endpoints for ThemeIsle SDK.
|
24 |
+
*/
|
25 |
+
class Recommendation extends Abstract_Module {
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Load module logic.
|
30 |
+
*
|
31 |
+
* @param Product $product Product to load.
|
32 |
+
*/
|
33 |
+
public function load( $product ) {
|
34 |
+
$this->product = $product;
|
35 |
+
$this->setup_hooks();
|
36 |
+
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Setup endpoints.
|
42 |
+
*/
|
43 |
+
private function setup_hooks() {
|
44 |
+
add_action( $this->product->get_key() . '_recommend_products', array( $this, 'render_products_box' ), 10, 4 );
|
45 |
+
add_action( 'admin_head', array( $this, 'enqueue' ) );
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Check if we should load the module for this product.
|
50 |
+
*
|
51 |
+
* @param Product $product Product data.
|
52 |
+
*
|
53 |
+
* @return bool Should we load the module?
|
54 |
+
*/
|
55 |
+
public function can_load( $product ) {
|
56 |
+
return true;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Render products box content.
|
61 |
+
*
|
62 |
+
* @param array $plugins_list - list of useful plugins (in slug => nicename format).
|
63 |
+
* @param array $themes_list - list of useful themes (in slug => nicename format).
|
64 |
+
* @param array $strings - list of translated strings.
|
65 |
+
* @param array $preferences - list of preferences.
|
66 |
+
*/
|
67 |
+
public function render_products_box( $plugins_list, $themes_list, $strings, $preferences = array() ) {
|
68 |
+
|
69 |
+
if ( empty( $plugins_list ) && empty( $themes_list ) ) {
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( ! empty( $plugins_list ) && ! current_user_can( 'install_plugins' ) ) {
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
if ( ! empty( $themes_list ) && ! current_user_can( 'install_themes' ) ) {
|
78 |
+
return;
|
79 |
+
}
|
80 |
+
|
81 |
+
add_thickbox();
|
82 |
+
|
83 |
+
if ( ! empty( $themes_list ) ) {
|
84 |
+
$list = $this->get_themes( $themes_list, $preferences );
|
85 |
+
|
86 |
+
if ( has_action( $this->product->get_key() . '_recommend_products_theme_template' ) ) {
|
87 |
+
do_action( $this->product->get_key() . '_recommend_products_theme_template', $list, $strings, $preferences );
|
88 |
+
} else {
|
89 |
+
echo '<div class="recommend-product">';
|
90 |
+
|
91 |
+
foreach ( $list as $theme ) {
|
92 |
+
echo '<div class="plugin_box">';
|
93 |
+
echo ' <img class="theme-banner" src="' . esc_url( $theme->screenshot_url ) . '">';
|
94 |
+
echo ' <div class="title-action-wrapper">';
|
95 |
+
echo ' <span class="plugin-name">' . esc_html( $theme->custom_name ) . '</span>';
|
96 |
+
if ( ! isset( $preferences['description'] ) || ( isset( $preferences['description'] ) && $preferences['description'] ) ) {
|
97 |
+
echo '<span class="plugin-desc">' . esc_html( substr( $theme->description, 0, strpos( $theme->description, '.' ) ) ) . '.</span>';
|
98 |
+
}
|
99 |
+
echo ' </div>';
|
100 |
+
echo '<div class="plugin-box-footer">';
|
101 |
+
echo ' <div class="button-wrap">';
|
102 |
+
echo ' <a class="button button-primary " href="' . esc_url( $theme->custom_url ) . '"><span class="dashicons dashicons-external"></span>' . esc_html( $strings['install'] ) . '</a>';
|
103 |
+
echo ' </div>';
|
104 |
+
echo ' </div>';
|
105 |
+
echo '</div>';
|
106 |
+
}
|
107 |
+
|
108 |
+
echo '</div>';
|
109 |
+
}
|
110 |
+
}
|
111 |
+
if ( ! empty( $plugins_list ) ) {
|
112 |
+
$list = $this->get_plugins( $plugins_list, $preferences );
|
113 |
+
|
114 |
+
if ( has_action( $this->product->get_key() . '_recommend_products_plugin_template' ) ) {
|
115 |
+
do_action( $this->product->get_key() . '_recommend_products_plugin_template', $list, $strings, $preferences );
|
116 |
+
} else {
|
117 |
+
echo '<div class="recommend-product">';
|
118 |
+
|
119 |
+
foreach ( $list as $current_plugin ) {
|
120 |
+
echo '<div class="plugin_box">';
|
121 |
+
echo ' <img class="plugin-banner" src="' . esc_url( $current_plugin->custom_image ) . '">';
|
122 |
+
echo ' <div class="title-action-wrapper">';
|
123 |
+
echo ' <span class="plugin-name">' . esc_html( $current_plugin->custom_name ) . '</span>';
|
124 |
+
if ( ! isset( $preferences['description'] ) || ( isset( $preferences['description'] ) && $preferences['description'] ) ) {
|
125 |
+
echo '<span class="plugin-desc">' . esc_html( substr( $current_plugin->short_description, 0, strpos( $current_plugin->short_description, '.' ) ) ) . '. </span>';
|
126 |
+
}
|
127 |
+
echo ' </div>';
|
128 |
+
echo ' <div class="plugin-box-footer">';
|
129 |
+
echo ' <a class="button button-primary thickbox open-plugin-details-modal" href="' . esc_url( $current_plugin->custom_url ) . '"><span class="dashicons dashicons-external"></span>' . esc_html( $strings['install'] ) . '</a>';
|
130 |
+
echo ' </div>';
|
131 |
+
echo '</div>';
|
132 |
+
}
|
133 |
+
|
134 |
+
echo '</div>';
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Collect all the information for the themes list.
|
142 |
+
*
|
143 |
+
* @param array $themes_list - list of useful themes (in slug => nicename format).
|
144 |
+
* @param array $preferences - list of preferences.
|
145 |
+
*
|
146 |
+
* @return array
|
147 |
+
*/
|
148 |
+
private function get_themes( $themes_list, $preferences ) {
|
149 |
+
$list = array();
|
150 |
+
foreach ( $themes_list as $slug => $nicename ) {
|
151 |
+
$theme = $this->call_theme_api( $slug );
|
152 |
+
if ( ! $theme ) {
|
153 |
+
continue;
|
154 |
+
}
|
155 |
+
|
156 |
+
$url = add_query_arg(
|
157 |
+
array(
|
158 |
+
'theme' => $theme->slug,
|
159 |
+
),
|
160 |
+
network_admin_url( 'theme-install.php' )
|
161 |
+
);
|
162 |
+
|
163 |
+
$name = empty( $nicename ) ? $theme->name : $nicename;
|
164 |
+
|
165 |
+
$theme->custom_url = $url;
|
166 |
+
$theme->custom_name = $name;
|
167 |
+
|
168 |
+
$list[] = $theme;
|
169 |
+
}
|
170 |
+
|
171 |
+
return $list;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Call theme api
|
176 |
+
*
|
177 |
+
* @param string $slug theme slug.
|
178 |
+
*
|
179 |
+
* @return array|mixed|object
|
180 |
+
*/
|
181 |
+
private function call_theme_api( $slug ) {
|
182 |
+
$theme = get_transient( 'ti_theme_info_' . $slug );
|
183 |
+
|
184 |
+
if ( false !== $theme ) {
|
185 |
+
return $theme;
|
186 |
+
}
|
187 |
+
|
188 |
+
$products = $this->safe_get(
|
189 |
+
'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[theme]=' . $slug . '&request[per_page]=1'
|
190 |
+
);
|
191 |
+
$products = json_decode( wp_remote_retrieve_body( $products ) );
|
192 |
+
if ( is_object( $products ) ) {
|
193 |
+
$theme = $products->themes[0];
|
194 |
+
set_transient( 'ti_theme_info_' . $slug, $theme, 6 * HOUR_IN_SECONDS );
|
195 |
+
}
|
196 |
+
|
197 |
+
return $theme;
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Collect all the information for the plugins list.
|
202 |
+
*
|
203 |
+
* @param array $plugins_list - list of useful plugins (in slug => nicename format).
|
204 |
+
* @param array $preferences - list of preferences.
|
205 |
+
*
|
206 |
+
* @return array
|
207 |
+
*/
|
208 |
+
private function get_plugins( $plugins_list, $preferences ) {
|
209 |
+
$list = array();
|
210 |
+
foreach ( $plugins_list as $plugin => $nicename ) {
|
211 |
+
$current_plugin = $this->call_plugin_api( $plugin );
|
212 |
+
|
213 |
+
$name = empty( $nicename ) ? $current_plugin->name : $nicename;
|
214 |
+
|
215 |
+
$image = $current_plugin->banners['low'];
|
216 |
+
if ( isset( $preferences['image'] ) && 'icon' === $preferences['image'] ) {
|
217 |
+
$image = $current_plugin->icons['1x'];
|
218 |
+
}
|
219 |
+
|
220 |
+
$url = add_query_arg(
|
221 |
+
array(
|
222 |
+
'tab' => 'plugin-information',
|
223 |
+
'plugin' => $current_plugin->slug,
|
224 |
+
'TB_iframe' => true,
|
225 |
+
'width' => 800,
|
226 |
+
'height' => 800,
|
227 |
+
),
|
228 |
+
network_admin_url( 'plugin-install.php' )
|
229 |
+
);
|
230 |
+
|
231 |
+
$current_plugin->custom_url = $url;
|
232 |
+
$current_plugin->custom_name = $name;
|
233 |
+
$current_plugin->custom_image = $image;
|
234 |
+
|
235 |
+
$list[] = $current_plugin;
|
236 |
+
}
|
237 |
+
|
238 |
+
return $list;
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Call plugin api
|
243 |
+
*
|
244 |
+
* @param string $slug plugin slug.
|
245 |
+
*
|
246 |
+
* @return array|mixed|object
|
247 |
+
*/
|
248 |
+
private function call_plugin_api( $slug ) {
|
249 |
+
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
250 |
+
|
251 |
+
$call_api = get_transient( 'ti_plugin_info_' . $slug );
|
252 |
+
|
253 |
+
if ( false === $call_api ) {
|
254 |
+
$call_api = plugins_api(
|
255 |
+
'plugin_information',
|
256 |
+
array(
|
257 |
+
'slug' => $slug,
|
258 |
+
'fields' => array(
|
259 |
+
'downloaded' => false,
|
260 |
+
'rating' => false,
|
261 |
+
'description' => false,
|
262 |
+
'short_description' => true,
|
263 |
+
'donate_link' => false,
|
264 |
+
'tags' => false,
|
265 |
+
'sections' => true,
|
266 |
+
'homepage' => true,
|
267 |
+
'added' => false,
|
268 |
+
'last_updated' => false,
|
269 |
+
'compatibility' => false,
|
270 |
+
'tested' => false,
|
271 |
+
'requires' => false,
|
272 |
+
'downloadlink' => false,
|
273 |
+
'icons' => true,
|
274 |
+
'banners' => true,
|
275 |
+
),
|
276 |
+
)
|
277 |
+
);
|
278 |
+
set_transient( 'ti_plugin_info_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS );
|
279 |
+
}
|
280 |
+
|
281 |
+
return $call_api;
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Load css and scripts for the plugin recommend page.
|
286 |
+
*/
|
287 |
+
public function enqueue() {
|
288 |
+
$screen = get_current_screen();
|
289 |
+
|
290 |
+
if ( ! isset( $screen->id ) ) {
|
291 |
+
return;
|
292 |
+
}
|
293 |
+
if ( false === apply_filters( $this->product->get_key() . '_enqueue_recommend', false, $screen->id ) ) {
|
294 |
+
return;
|
295 |
+
}
|
296 |
+
|
297 |
+
?>
|
298 |
+
<style type="text/css">
|
299 |
+
.recommend-product {
|
300 |
+
display: flex;
|
301 |
+
justify-content: space-between;
|
302 |
+
flex-wrap: wrap;
|
303 |
+
}
|
304 |
+
|
305 |
+
.recommend-product .theme-banner {
|
306 |
+
width: 200px;
|
307 |
+
margin: auto;
|
308 |
+
}
|
309 |
+
|
310 |
+
.recommend-product .plugin-banner {
|
311 |
+
width: 100px;
|
312 |
+
margin: auto;
|
313 |
+
}
|
314 |
+
|
315 |
+
.recommend-product .plugin_box .button span {
|
316 |
+
|
317 |
+
margin-top: 2px;
|
318 |
+
margin-right: 7px;
|
319 |
+
}
|
320 |
+
|
321 |
+
.recommend-product .plugin_box .button {
|
322 |
+
margin-bottom: 10px;
|
323 |
+
}
|
324 |
+
|
325 |
+
.recommend-product .plugin_box {
|
326 |
+
margin-bottom: 20px;
|
327 |
+
padding-top: 5px;
|
328 |
+
display: flex;
|
329 |
+
box-shadow: 0px 0px 10px -5px rgba(0, 0, 0, 0.55);
|
330 |
+
background: #fff;
|
331 |
+
border-radius: 5px;
|
332 |
+
flex-direction: column;
|
333 |
+
justify-content: flex-start;
|
334 |
+
width: 95%;
|
335 |
+
}
|
336 |
+
|
337 |
+
.recommend-product .title-action-wrapper {
|
338 |
+
padding: 15px 20px 5px 20px;
|
339 |
+
}
|
340 |
+
|
341 |
+
.recommend-product .plugin-name {
|
342 |
+
font-size: 18px;
|
343 |
+
display: block;
|
344 |
+
white-space: nowrap;
|
345 |
+
text-overflow: ellipsis;
|
346 |
+
margin-bottom: 10px;
|
347 |
+
overflow: hidden;
|
348 |
+
line-height: normal;
|
349 |
+
}
|
350 |
+
|
351 |
+
|
352 |
+
.recommend-product .plugin-desc {
|
353 |
+
display: block;
|
354 |
+
margin-bottom: 10px;
|
355 |
+
font-size: 13px;
|
356 |
+
color: #777;
|
357 |
+
line-height: 1.6;
|
358 |
+
}
|
359 |
+
|
360 |
+
.recommend-product .button-wrap > div {
|
361 |
+
padding: 0;
|
362 |
+
margin: 0;
|
363 |
+
}
|
364 |
+
|
365 |
+
.plugin-box-footer {
|
366 |
+
display: flex;
|
367 |
+
justify-content: space-around;
|
368 |
+
vertical-align: middle;
|
369 |
+
align-items: center;
|
370 |
+
padding: 0px 10px 5px;
|
371 |
+
flex: 1;
|
372 |
+
margin-top: auto;
|
373 |
+
}
|
374 |
+
</style>
|
375 |
+
<?php
|
376 |
+
}
|
377 |
+
}
|
vendor/codeinwp/themeisle-sdk/src/Modules/Review.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The Review model class for ThemeIsle SDK
|
4 |
+
*
|
5 |
+
* @package ThemeIsleSDK
|
6 |
+
* @subpackage Modules
|
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 |
+
|
12 |
+
namespace ThemeisleSDK\Modules;
|
13 |
+
|
14 |
+
use ThemeisleSDK\Common\Abstract_Module;
|
15 |
+
use ThemeisleSDK\Product;
|
16 |
+
|
17 |
+
// Exit if accessed directly.
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Review module for ThemeIsle SDK.
|
24 |
+
*/
|
25 |
+
class Review extends Abstract_Module {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Check if we should load module for this.
|
29 |
+
*
|
30 |
+
* @param Product $product Product to check.
|
31 |
+
*
|
32 |
+
* @return bool Should load ?
|
33 |
+
*/
|
34 |
+
public function can_load( $product ) {
|
35 |
+
if ( $this->is_from_partner( $product ) ) {
|
36 |
+
return false;
|
37 |
+
}
|
38 |
+
if ( ! $product->is_wordpress_available() ) {
|
39 |
+
return false;
|
40 |
+
}
|
41 |
+
|
42 |
+
return apply_filters( $product->get_slug() . '_sdk_should_review', true );
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Add notification to queue.
|
48 |
+
*
|
49 |
+
* @param array $all_notifications Previous notification.
|
50 |
+
*
|
51 |
+
* @return array All notifications.
|
52 |
+
*/
|
53 |
+
public function add_notification( $all_notifications ) {
|
54 |
+
|
55 |
+
$developers = [
|
56 |
+
'Bogdan',
|
57 |
+
'Marius',
|
58 |
+
'Hardeep',
|
59 |
+
'Rodica',
|
60 |
+
'Stefan',
|
61 |
+
'Uriahs',
|
62 |
+
'Madalin',
|
63 |
+
'Cristi',
|
64 |
+
'Silviu',
|
65 |
+
'Andrei',
|
66 |
+
];
|
67 |
+
|
68 |
+
$link = 'https://wordpress.org/support/' . $this->product->get_type() . '/' . $this->product->get_slug() . '/reviews/#wporg-footer';
|
69 |
+
|
70 |
+
$message = apply_filters( $this->product->get_key() . '_feedback_review_message', '<p>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}</p>' );
|
71 |
+
|
72 |
+
$button_submit = apply_filters( $this->product->get_key() . '_feedback_review_button_do', 'Ok, I will gladly help.' );
|
73 |
+
$button_cancel = apply_filters( $this->product->get_key() . '_feedback_review_button_cancel', 'No, thanks.' );
|
74 |
+
$message = str_replace(
|
75 |
+
[ '{product}', '{developer}' ],
|
76 |
+
[
|
77 |
+
$this->product->get_friendly_name(),
|
78 |
+
$developers[ strlen( get_site_url() ) % 10 ],
|
79 |
+
],
|
80 |
+
$message
|
81 |
+
);
|
82 |
+
|
83 |
+
$all_notifications[] = [
|
84 |
+
'id' => $this->product->get_key() . '_review_flag',
|
85 |
+
'message' => $message,
|
86 |
+
'ctas' => [
|
87 |
+
'confirm' => [
|
88 |
+
'link' => $link,
|
89 |
+
'text' => $button_submit,
|
90 |
+
],
|
91 |
+
'cancel' => [
|
92 |
+
'link' => '#',
|
93 |
+
'text' => $button_cancel,
|
94 |
+
],
|
95 |
+
],
|
96 |
+
];
|
97 |
+
|
98 |
+
return $all_notifications;
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Load module logic.
|
104 |
+
*
|
105 |
+
* @param Product $product Product to load.
|
106 |
+
*
|
107 |
+
* @return Review Module instance.
|
108 |
+
*/
|
109 |
+
public function load( $product ) {
|
110 |
+
|
111 |
+
$this->product = $product;
|
112 |
+
|
113 |
+
add_filter( 'themeisle_sdk_registered_notifications', [ $this, 'add_notification' ] );
|
114 |
+
|
115 |
+
return $this;
|
116 |
+
}
|
117 |
+
}
|
vendor/codeinwp/themeisle-sdk/src/Modules/Rollback.php
ADDED
@@ -0,0 +1,384 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
12 |
+
namespace ThemeisleSDK\Modules;
|
13 |
+
|
14 |
+
// Exit if accessed directly.
|
15 |
+
use ThemeisleSDK\Common\Abstract_Module;
|
16 |
+
use ThemeisleSDK\Product;
|
17 |
+
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Rollback for ThemeIsle SDK.
|
24 |
+
*/
|
25 |
+
class Rollback extends Abstract_Module {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Add js scripts for themes rollback.
|
29 |
+
*/
|
30 |
+
public function add_footer() {
|
31 |
+
$screen = get_current_screen();
|
32 |
+
if ( ! isset( $screen->parent_file ) ) {
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
if ( 'themes.php' !== $screen->parent_file ) {
|
36 |
+
return;
|
37 |
+
}
|
38 |
+
if ( ! $this->product->is_theme() ) {
|
39 |
+
return;
|
40 |
+
}
|
41 |
+
$version = $this->get_rollback();
|
42 |
+
if ( empty( $version ) ) {
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
?>
|
46 |
+
<script type="text/javascript">
|
47 |
+
jQuery(document).ready(function ($) {
|
48 |
+
setInterval(checkTheme, 500);
|
49 |
+
|
50 |
+
function checkTheme() {
|
51 |
+
var theme = '<?php echo esc_attr( $this->product->get_slug() ); ?>-action';
|
52 |
+
|
53 |
+
if (jQuery('#' + theme).length > 0) {
|
54 |
+
if (jQuery('.theme-overlay.active').is(':visible')) {
|
55 |
+
if (jQuery('#' + theme + '-rollback').length === 0) {
|
56 |
+
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>')
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
}
|
61 |
+
}
|
62 |
+
})
|
63 |
+
|
64 |
+
</script>
|
65 |
+
<?php
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Get the last rollback for this product.
|
71 |
+
*
|
72 |
+
* @return array The rollback version.
|
73 |
+
*/
|
74 |
+
public function get_rollback() {
|
75 |
+
$rollback = array();
|
76 |
+
$versions = $this->get_api_versions();
|
77 |
+
$versions = apply_filters( $this->product->get_key() . '_rollbacks', $versions );
|
78 |
+
if ( empty( $versions ) ) {
|
79 |
+
return $rollback;
|
80 |
+
}
|
81 |
+
if ( $versions ) {
|
82 |
+
usort( $versions, array( $this, 'sort_rollback_array' ) );
|
83 |
+
foreach ( $versions as $version ) {
|
84 |
+
if ( isset( $version['version'] ) && isset( $version['url'] ) && version_compare( $this->product->get_version(), $version['version'], '>' ) ) {
|
85 |
+
$rollback = $version;
|
86 |
+
break;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
return $rollback;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Get versions array from wp.org
|
96 |
+
*
|
97 |
+
* @return array Array of versions.
|
98 |
+
*/
|
99 |
+
private function get_api_versions() {
|
100 |
+
|
101 |
+
$cache_key = $this->product->get_key() . '_' . preg_replace( '/[^0-9a-zA-Z ]/m', '', $this->product->get_version() ) . 'versions';
|
102 |
+
$cache_versions = get_transient( $cache_key );
|
103 |
+
if ( false === $cache_versions ) {
|
104 |
+
$versions = $this->get_remote_versions();
|
105 |
+
set_transient( $cache_key, $versions, 5 * DAY_IN_SECONDS );
|
106 |
+
} else {
|
107 |
+
$versions = is_array( $cache_versions ) ? $cache_versions : array();
|
108 |
+
}
|
109 |
+
|
110 |
+
return $versions;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Get remote versions zips.
|
115 |
+
*
|
116 |
+
* @return array Array of available versions.
|
117 |
+
*/
|
118 |
+
private function get_remote_versions() {
|
119 |
+
$url = $this->get_versions_api_url();
|
120 |
+
if ( empty( $url ) ) {
|
121 |
+
return [];
|
122 |
+
}
|
123 |
+
$response = function_exists( 'wp_remote_get_wp_remote_get' )
|
124 |
+
? wp_remote_get_wp_remote_get( $url )
|
125 |
+
: wp_remote_get( $url ); //phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get
|
126 |
+
if ( is_wp_error( $response ) ) {
|
127 |
+
return array();
|
128 |
+
}
|
129 |
+
$response = wp_remote_retrieve_body( $response );
|
130 |
+
|
131 |
+
if ( is_serialized( $response ) ) {
|
132 |
+
$response = maybe_unserialize( $response );
|
133 |
+
} else {
|
134 |
+
$response = json_decode( $response );
|
135 |
+
}
|
136 |
+
|
137 |
+
if ( ! is_object( $response ) ) {
|
138 |
+
return array();
|
139 |
+
}
|
140 |
+
if ( ! isset( $response->versions ) ) {
|
141 |
+
return array();
|
142 |
+
}
|
143 |
+
|
144 |
+
$versions = array();
|
145 |
+
foreach ( $response->versions as $key => $value ) {
|
146 |
+
$versions[] = array(
|
147 |
+
'version' => is_object( $value ) ? $value->version : $key,
|
148 |
+
'url' => is_object( $value ) ? $value->file : $value,
|
149 |
+
);
|
150 |
+
}
|
151 |
+
|
152 |
+
return $versions;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Return url where to check for versions.
|
157 |
+
*
|
158 |
+
* @return string Url where to check for versions.
|
159 |
+
*/
|
160 |
+
private function get_versions_api_url() {
|
161 |
+
if ( $this->product->is_wordpress_available() && $this->product->is_plugin() ) {
|
162 |
+
return sprintf( 'https://api.wordpress.org/plugins/info/1.0/%s', $this->product->get_slug() );
|
163 |
+
}
|
164 |
+
if ( $this->product->is_wordpress_available() && $this->product->is_theme() ) {
|
165 |
+
return sprintf( 'https://api.wordpress.org/themes/info/1.1/?action=theme_information&request[slug]=%s&request[fields][versions]=true', $this->product->get_slug() );
|
166 |
+
}
|
167 |
+
$license = $this->product->get_license();
|
168 |
+
if ( $this->product->requires_license() && strlen( $license ) < 10 ) {
|
169 |
+
return '';
|
170 |
+
}
|
171 |
+
|
172 |
+
return sprintf( '%slicense/versions/%s/%s/%s/%s', Product::API_URL, rawurlencode( $this->product->get_name() ), $license, urlencode( get_site_url() ), $this->product->get_version() );
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Show the rollback links in the plugin page.
|
177 |
+
*
|
178 |
+
* @param array $links Plugin links.
|
179 |
+
*
|
180 |
+
* @return array $links Altered links.
|
181 |
+
*/
|
182 |
+
public function add_rollback_link( $links ) {
|
183 |
+
$version = $this->get_rollback();
|
184 |
+
if ( empty( $version ) ) {
|
185 |
+
return $links;
|
186 |
+
}
|
187 |
+
$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>';
|
188 |
+
|
189 |
+
return $links;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Start the rollback operation.
|
194 |
+
*/
|
195 |
+
public function start_rollback() {
|
196 |
+
if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], $this->product->get_key() . '_rollback' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
197 |
+
wp_nonce_ays( '' );
|
198 |
+
}
|
199 |
+
|
200 |
+
if ( $this->product->is_plugin() ) {
|
201 |
+
$this->start_rollback_plugin();
|
202 |
+
|
203 |
+
return;
|
204 |
+
}
|
205 |
+
if ( $this->product->is_theme() ) {
|
206 |
+
$this->start_rollback_theme();
|
207 |
+
|
208 |
+
return;
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Start the rollback operation for the plugin.
|
214 |
+
*/
|
215 |
+
private function start_rollback_plugin() {
|
216 |
+
$rollback = $this->get_rollback();
|
217 |
+
$plugin_transient = get_site_transient( 'update_plugins' );
|
218 |
+
$plugin_folder = $this->product->get_slug();
|
219 |
+
$plugin_file = $this->product->get_file();
|
220 |
+
$version = $rollback['version'];
|
221 |
+
$temp_array = array(
|
222 |
+
'slug' => $plugin_folder,
|
223 |
+
'new_version' => $version,
|
224 |
+
'package' => $rollback['url'],
|
225 |
+
);
|
226 |
+
|
227 |
+
$temp_object = (object) $temp_array;
|
228 |
+
$plugin_transient->response[ $plugin_folder . '/' . $plugin_file ] = $temp_object;
|
229 |
+
set_site_transient( 'update_plugins', $plugin_transient );
|
230 |
+
|
231 |
+
$transient = get_transient( $this->product->get_key() . '_warning_rollback' );
|
232 |
+
|
233 |
+
// Style fix for the api link that gets outside the content.
|
234 |
+
echo '<style>body#error-page{word-break:break-word;}</style>';
|
235 |
+
|
236 |
+
if ( false === $transient ) {
|
237 |
+
set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
|
238 |
+
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
239 |
+
$title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
|
240 |
+
$plugin = $plugin_folder . '/' . $plugin_file;
|
241 |
+
$nonce = 'upgrade-plugin_' . $plugin;
|
242 |
+
$url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );
|
243 |
+
$upgrader_skin = new \Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) );
|
244 |
+
$upgrader = new \Plugin_Upgrader( $upgrader_skin );
|
245 |
+
$upgrader->upgrade( $plugin );
|
246 |
+
delete_transient( $this->product->get_key() . '_warning_rollback' );
|
247 |
+
wp_die(
|
248 |
+
'',
|
249 |
+
esc_attr( $title ),
|
250 |
+
array(
|
251 |
+
'response' => 200,
|
252 |
+
)
|
253 |
+
);
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Start the rollback operation for the theme.
|
259 |
+
*/
|
260 |
+
private function start_rollback_theme() {
|
261 |
+
add_filter( 'update_theme_complete_actions', array( $this, 'alter_links_theme_upgrade' ) );
|
262 |
+
$rollback = $this->get_rollback();
|
263 |
+
$transient = get_site_transient( 'update_themes' );
|
264 |
+
$folder = $this->product->get_slug();
|
265 |
+
$version = $rollback['version'];
|
266 |
+
$temp_array = array(
|
267 |
+
'new_version' => $version,
|
268 |
+
'package' => $rollback['url'],
|
269 |
+
);
|
270 |
+
|
271 |
+
$transient->response[ $folder . '/style.css' ] = $temp_array;
|
272 |
+
set_site_transient( 'update_themes', $transient );
|
273 |
+
|
274 |
+
$transient = get_transient( $this->product->get_key() . '_warning_rollback' );
|
275 |
+
|
276 |
+
// Style fix for the api link that gets outside the content.
|
277 |
+
echo '<style>body#error-page{word-break:break-word;}</style>';
|
278 |
+
|
279 |
+
if ( false === $transient ) {
|
280 |
+
set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
|
281 |
+
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
282 |
+
$title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
|
283 |
+
$theme = $folder . '/style.css';
|
284 |
+
$nonce = 'upgrade-theme_' . $theme;
|
285 |
+
$url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme );
|
286 |
+
|
287 |
+
$upgrader = new \Theme_Upgrader( new \Theme_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'theme' ) ) );
|
288 |
+
$upgrader->upgrade( $theme );
|
289 |
+
delete_transient( $this->product->get_key() . '_warning_rollback' );
|
290 |
+
wp_die(
|
291 |
+
'',
|
292 |
+
esc_attr( $title ),
|
293 |
+
array(
|
294 |
+
'response' => 200,
|
295 |
+
)
|
296 |
+
);
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Alter links and remove duplicate customize message.
|
302 |
+
*
|
303 |
+
* @param array $links Array of old links.
|
304 |
+
*
|
305 |
+
* @return mixed Array of links.
|
306 |
+
*/
|
307 |
+
public function alter_links_theme_upgrade( $links ) {
|
308 |
+
if ( isset( $links['preview'] ) ) {
|
309 |
+
$links['preview'] = str_replace( '<span aria-hidden="true">Customize</span>', '', $links['preview'] );
|
310 |
+
}
|
311 |
+
|
312 |
+
return $links;
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Loads product object.
|
317 |
+
*
|
318 |
+
* @param Product $product Product object.
|
319 |
+
*
|
320 |
+
* @return bool Should we load the module?
|
321 |
+
*/
|
322 |
+
public function can_load( $product ) {
|
323 |
+
if ( $this->is_from_partner( $product ) ) {
|
324 |
+
return false;
|
325 |
+
}
|
326 |
+
if ( $product->is_theme() && ! current_user_can( 'switch_themes' ) ) {
|
327 |
+
return false;
|
328 |
+
}
|
329 |
+
|
330 |
+
if ( $product->is_plugin() && ! current_user_can( 'install_plugins' ) ) {
|
331 |
+
return false;
|
332 |
+
}
|
333 |
+
|
334 |
+
return true;
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Sort the rollbacks array in descending order.
|
339 |
+
*
|
340 |
+
* @param mixed $a First version to compare.
|
341 |
+
* @param mixed $b Second version to compare.
|
342 |
+
*
|
343 |
+
* @return bool Which version is greater?
|
344 |
+
*/
|
345 |
+
public function sort_rollback_array( $a, $b ) {
|
346 |
+
return version_compare( $b['version'], $a['version'] );
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Load module logic.
|
351 |
+
*
|
352 |
+
* @param Product $product Product object.
|
353 |
+
*
|
354 |
+
* @return $this Module object.
|
355 |
+
*/
|
356 |
+
public function load( $product ) {
|
357 |
+
$this->product = $product;
|
358 |
+
$this->show_link();
|
359 |
+
$this->add_hooks();
|
360 |
+
|
361 |
+
return $this;
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* If product can be rolled back, show the link to rollback.
|
366 |
+
*/
|
367 |
+
private function show_link() {
|
368 |
+
add_filter(
|
369 |
+
'plugin_action_links_' . plugin_basename( $this->product->get_basefile() ),
|
370 |
+
array(
|
371 |
+
$this,
|
372 |
+
'add_rollback_link',
|
373 |
+
)
|
374 |
+
);
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* 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.
|
379 |
+
*/
|
380 |
+
public function add_hooks() {
|
381 |
+
add_action( 'admin_post_' . $this->product->get_key() . '_rollback', array( $this, 'start_rollback' ) );
|
382 |
+
add_action( 'admin_footer', array( $this, 'add_footer' ) );
|
383 |
+
}
|
384 |
+
}
|
vendor/codeinwp/themeisle-sdk/src/Modules/Translate.php
ADDED
@@ -0,0 +1,918 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The translate model class for ThemeIsle SDK
|
4 |
+
*
|
5 |
+
* @package ThemeIsleSDK
|
6 |
+
* @subpackage Modules
|
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 |
+
|
12 |
+
namespace ThemeisleSDK\Modules;
|
13 |
+
|
14 |
+
use ThemeisleSDK\Common\Abstract_Module;
|
15 |
+
use ThemeisleSDK\Product;
|
16 |
+
|
17 |
+
// Exit if accessed directly.
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Translate module for ThemeIsle SDK.
|
24 |
+
*/
|
25 |
+
class Translate extends Abstract_Module {
|
26 |
+
/**
|
27 |
+
* List of available locales.
|
28 |
+
*
|
29 |
+
* @var array Array of available locals.
|
30 |
+
*/
|
31 |
+
private static $locales = array(
|
32 |
+
'af' => array(
|
33 |
+
'slug' => 'af',
|
34 |
+
'name' => 'Afrikaans',
|
35 |
+
),
|
36 |
+
'ak' => array(
|
37 |
+
'slug' => 'ak',
|
38 |
+
'name' => 'Akan',
|
39 |
+
),
|
40 |
+
'am' => array(
|
41 |
+
'slug' => 'am',
|
42 |
+
'name' => 'Amharic',
|
43 |
+
),
|
44 |
+
'ar' => array(
|
45 |
+
'slug' => 'ar',
|
46 |
+
'name' => 'Arabic',
|
47 |
+
),
|
48 |
+
'arq' => array(
|
49 |
+
'slug' => 'arq',
|
50 |
+
'name' => 'Algerian Arabic',
|
51 |
+
),
|
52 |
+
'ary' => array(
|
53 |
+
'slug' => 'ary',
|
54 |
+
'name' => 'Moroccan Arabic',
|
55 |
+
),
|
56 |
+
'as' => array(
|
57 |
+
'slug' => 'as',
|
58 |
+
'name' => 'Assamese',
|
59 |
+
),
|
60 |
+
'ast' => array(
|
61 |
+
'slug' => 'ast',
|
62 |
+
'name' => 'Asturian',
|
63 |
+
),
|
64 |
+
'az' => array(
|
65 |
+
'slug' => 'az',
|
66 |
+
'name' => 'Azerbaijani',
|
67 |
+
),
|
68 |
+
'azb' => array(
|
69 |
+
'slug' => 'azb',
|
70 |
+
'name' => 'South Azerbaijani',
|
71 |
+
),
|
72 |
+
'az_TR' => array(
|
73 |
+
'slug' => 'az-tr',
|
74 |
+
'name' => 'Azerbaijani (Turkey)',
|
75 |
+
),
|
76 |
+
'ba' => array(
|
77 |
+
'slug' => 'ba',
|
78 |
+
'name' => 'Bashkir',
|
79 |
+
),
|
80 |
+
'bal' => array(
|
81 |
+
'slug' => 'bal',
|
82 |
+
'name' => 'Catalan (Balear)',
|
83 |
+
),
|
84 |
+
'bcc' => array(
|
85 |
+
'slug' => 'bcc',
|
86 |
+
'name' => 'Balochi Southern',
|
87 |
+
),
|
88 |
+
'bel' => array(
|
89 |
+
'slug' => 'bel',
|
90 |
+
'name' => 'Belarusian',
|
91 |
+
),
|
92 |
+
'bg_BG' => array(
|
93 |
+
'slug' => 'bg',
|
94 |
+
'name' => 'Bulgarian',
|
95 |
+
),
|
96 |
+
'bn_BD' => array(
|
97 |
+
'slug' => 'bn',
|
98 |
+
'name' => 'Bengali',
|
99 |
+
),
|
100 |
+
'bo' => array(
|
101 |
+
'slug' => 'bo',
|
102 |
+
'name' => 'Tibetan',
|
103 |
+
),
|
104 |
+
'bre' => array(
|
105 |
+
'slug' => 'br',
|
106 |
+
'name' => 'Breton',
|
107 |
+
),
|
108 |
+
'bs_BA' => array(
|
109 |
+
'slug' => 'bs',
|
110 |
+
'name' => 'Bosnian',
|
111 |
+
),
|
112 |
+
'ca' => array(
|
113 |
+
'slug' => 'ca',
|
114 |
+
'name' => 'Catalan',
|
115 |
+
),
|
116 |
+
'ceb' => array(
|
117 |
+
'slug' => 'ceb',
|
118 |
+
'name' => 'Cebuano',
|
119 |
+
),
|
120 |
+
'ckb' => array(
|
121 |
+
'slug' => 'ckb',
|
122 |
+
'name' => 'Kurdish (Sorani)',
|
123 |
+
),
|
124 |
+
'co' => array(
|
125 |
+
'slug' => 'co',
|
126 |
+
'name' => 'Corsican',
|
127 |
+
),
|
128 |
+
'cs_CZ' => array(
|
129 |
+
'slug' => 'cs',
|
130 |
+
'name' => 'Czech',
|
131 |
+
),
|
132 |
+
'cy' => array(
|
133 |
+
'slug' => 'cy',
|
134 |
+
'name' => 'Welsh',
|
135 |
+
),
|
136 |
+
'da_DK' => array(
|
137 |
+
'slug' => 'da',
|
138 |
+
'name' => 'Danish',
|
139 |
+
),
|
140 |
+
'de_DE' => array(
|
141 |
+
'slug' => 'de',
|
142 |
+
'name' => 'German',
|
143 |
+
),
|
144 |
+
'de_CH' => array(
|
145 |
+
'slug' => 'de-ch',
|
146 |
+
'name' => 'German (Switzerland)',
|
147 |
+
),
|
148 |
+
'dv' => array(
|
149 |
+
'slug' => 'dv',
|
150 |
+
'name' => 'Dhivehi',
|
151 |
+
),
|
152 |
+
'dzo' => array(
|
153 |
+
'slug' => 'dzo',
|
154 |
+
'name' => 'Dzongkha',
|
155 |
+
),
|
156 |
+
'el' => array(
|
157 |
+
'slug' => 'el',
|
158 |
+
'name' => 'Greek',
|
159 |
+
),
|
160 |
+
'art_xemoji' => array(
|
161 |
+
'slug' => 'art-xemoji',
|
162 |
+
'name' => 'Emoji',
|
163 |
+
),
|
164 |
+
'en_US' => array(
|
165 |
+
'slug' => 'en',
|
166 |
+
'name' => 'English',
|
167 |
+
),
|
168 |
+
'en_AU' => array(
|
169 |
+
'slug' => 'en-au',
|
170 |
+
'name' => 'English (Australia)',
|
171 |
+
),
|
172 |
+
'en_CA' => array(
|
173 |
+
'slug' => 'en-ca',
|
174 |
+
'name' => 'English (Canada)',
|
175 |
+
),
|
176 |
+
'en_GB' => array(
|
177 |
+
'slug' => 'en-gb',
|
178 |
+
'name' => 'English (UK)',
|
179 |
+
),
|
180 |
+
'en_NZ' => array(
|
181 |
+
'slug' => 'en-nz',
|
182 |
+
'name' => 'English (New Zealand)',
|
183 |
+
),
|
184 |
+
'en_ZA' => array(
|
185 |
+
'slug' => 'en-za',
|
186 |
+
'name' => 'English (South Africa)',
|
187 |
+
),
|
188 |
+
'eo' => array(
|
189 |
+
'slug' => 'eo',
|
190 |
+
'name' => 'Esperanto',
|
191 |
+
),
|
192 |
+
'es_ES' => array(
|
193 |
+
'slug' => 'es',
|
194 |
+
'name' => 'Spanish (Spain)',
|
195 |
+
),
|
196 |
+
'es_AR' => array(
|
197 |
+
'slug' => 'es-ar',
|
198 |
+
'name' => 'Spanish (Argentina)',
|
199 |
+
),
|
200 |
+
'es_CL' => array(
|
201 |
+
'slug' => 'es-cl',
|
202 |
+
'name' => 'Spanish (Chile)',
|
203 |
+
),
|
204 |
+
'es_CO' => array(
|
205 |
+
'slug' => 'es-co',
|
206 |
+
'name' => 'Spanish (Colombia)',
|
207 |
+
),
|
208 |
+
'es_CR' => array(
|
209 |
+
'slug' => 'es-cr',
|
210 |
+
'name' => 'Spanish (Costa Rica)',
|
211 |
+
),
|
212 |
+
'es_GT' => array(
|
213 |
+
'slug' => 'es-gt',
|
214 |
+
'name' => 'Spanish (Guatemala)',
|
215 |
+
),
|
216 |
+
'es_MX' => array(
|
217 |
+
'slug' => 'es-mx',
|
218 |
+
'name' => 'Spanish (Mexico)',
|
219 |
+
),
|
220 |
+
'es_PE' => array(
|
221 |
+
'slug' => 'es-pe',
|
222 |
+
'name' => 'Spanish (Peru)',
|
223 |
+
),
|
224 |
+
'es_PR' => array(
|
225 |
+
'slug' => 'es-pr',
|
226 |
+
'name' => 'Spanish (Puerto Rico)',
|
227 |
+
),
|
228 |
+
'es_VE' => array(
|
229 |
+
'slug' => 'es-ve',
|
230 |
+
'name' => 'Spanish (Venezuela)',
|
231 |
+
),
|
232 |
+
'et' => array(
|
233 |
+
'slug' => 'et',
|
234 |
+
'name' => 'Estonian',
|
235 |
+
),
|
236 |
+
'eu' => array(
|
237 |
+
'slug' => 'eu',
|
238 |
+
'name' => 'Basque',
|
239 |
+
),
|
240 |
+
'fa_IR' => array(
|
241 |
+
'slug' => 'fa',
|
242 |
+
'name' => 'Persian',
|
243 |
+
),
|
244 |
+
'fa_AF' => array(
|
245 |
+
'slug' => 'fa-af',
|
246 |
+
'name' => 'Persian (Afghanistan)',
|
247 |
+
),
|
248 |
+
'fuc' => array(
|
249 |
+
'slug' => 'fuc',
|
250 |
+
'name' => 'Fulah',
|
251 |
+
),
|
252 |
+
'fi' => array(
|
253 |
+
'slug' => 'fi',
|
254 |
+
'name' => 'Finnish',
|
255 |
+
),
|
256 |
+
'fo' => array(
|
257 |
+
'slug' => 'fo',
|
258 |
+
'name' => 'Faroese',
|
259 |
+
),
|
260 |
+
'fr_FR' => array(
|
261 |
+
'slug' => 'fr',
|
262 |
+
'name' => 'French (France)',
|
263 |
+
),
|
264 |
+
'fr_BE' => array(
|
265 |
+
'slug' => 'fr-be',
|
266 |
+
'name' => 'French (Belgium)',
|
267 |
+
),
|
268 |
+
'fr_CA' => array(
|
269 |
+
'slug' => 'fr-ca',
|
270 |
+
'name' => 'French (Canada)',
|
271 |
+
),
|
272 |
+
'frp' => array(
|
273 |
+
'slug' => 'frp',
|
274 |
+
'name' => 'Arpitan',
|
275 |
+
),
|
276 |
+
'fur' => array(
|
277 |
+
'slug' => 'fur',
|
278 |
+
'name' => 'Friulian',
|
279 |
+
),
|
280 |
+
'fy' => array(
|
281 |
+
'slug' => 'fy',
|
282 |
+
'name' => 'Frisian',
|
283 |
+
),
|
284 |
+
'ga' => array(
|
285 |
+
'slug' => 'ga',
|
286 |
+
'name' => 'Irish',
|
287 |
+
),
|
288 |
+
'gd' => array(
|
289 |
+
'slug' => 'gd',
|
290 |
+
'name' => 'Scottish Gaelic',
|
291 |
+
),
|
292 |
+
'gl_ES' => array(
|
293 |
+
'slug' => 'gl',
|
294 |
+
'name' => 'Galician',
|
295 |
+
),
|
296 |
+
'gn' => array(
|
297 |
+
'slug' => 'gn',
|
298 |
+
'name' => 'Guarani',
|
299 |
+
),
|
300 |
+
'gsw' => array(
|
301 |
+
'slug' => 'gsw',
|
302 |
+
'name' => 'Swiss German',
|
303 |
+
),
|
304 |
+
'gu' => array(
|
305 |
+
'slug' => 'gu',
|
306 |
+
'name' => 'Gujarati',
|
307 |
+
),
|
308 |
+
'hat' => array(
|
309 |
+
'slug' => 'hat',
|
310 |
+
'name' => 'Haitian Creole',
|
311 |
+
),
|
312 |
+
'hau' => array(
|
313 |
+
'slug' => 'hau',
|
314 |
+
'name' => 'Hausa',
|
315 |
+
),
|
316 |
+
'haw_US' => array(
|
317 |
+
'slug' => 'haw',
|
318 |
+
'name' => 'Hawaiian',
|
319 |
+
),
|
320 |
+
'haz' => array(
|
321 |
+
'slug' => 'haz',
|
322 |
+
'name' => 'Hazaragi',
|
323 |
+
),
|
324 |
+
'he_IL' => array(
|
325 |
+
'slug' => 'he',
|
326 |
+
'name' => 'Hebrew',
|
327 |
+
),
|
328 |
+
'hi_IN' => array(
|
329 |
+
'slug' => 'hi',
|
330 |
+
'name' => 'Hindi',
|
331 |
+
),
|
332 |
+
'hr' => array(
|
333 |
+
'slug' => 'hr',
|
334 |
+
'name' => 'Croatian',
|
335 |
+
),
|
336 |
+
'hu_HU' => array(
|
337 |
+
'slug' => 'hu',
|
338 |
+
'name' => 'Hungarian',
|
339 |
+
),
|
340 |
+
'hy' => array(
|
341 |
+
'slug' => 'hy',
|
342 |
+
'name' => 'Armenian',
|
343 |
+
),
|
344 |
+
'id_ID' => array(
|
345 |
+
'slug' => 'id',
|
346 |
+
'name' => 'Indonesian',
|
347 |
+
),
|
348 |
+
'ido' => array(
|
349 |
+
'slug' => 'ido',
|
350 |
+
'name' => 'Ido',
|
351 |
+
),
|
352 |
+
'is_IS' => array(
|
353 |
+
'slug' => 'is',
|
354 |
+
'name' => 'Icelandic',
|
355 |
+
),
|
356 |
+
'it_IT' => array(
|
357 |
+
'slug' => 'it',
|
358 |
+
'name' => 'Italian',
|
359 |
+
),
|
360 |
+
'ja' => array(
|
361 |
+
'slug' => 'ja',
|
362 |
+
'name' => 'Japanese',
|
363 |
+
),
|
364 |
+
'jv_ID' => array(
|
365 |
+
'slug' => 'jv',
|
366 |
+
'name' => 'Javanese',
|
367 |
+
),
|
368 |
+
'ka_GE' => array(
|
369 |
+
'slug' => 'ka',
|
370 |
+
'name' => 'Georgian',
|
371 |
+
),
|
372 |
+
'kab' => array(
|
373 |
+
'slug' => 'kab',
|
374 |
+
'name' => 'Kabyle',
|
375 |
+
),
|
376 |
+
'kal' => array(
|
377 |
+
'slug' => 'kal',
|
378 |
+
'name' => 'Greenlandic',
|
379 |
+
),
|
380 |
+
'kin' => array(
|
381 |
+
'slug' => 'kin',
|
382 |
+
'name' => 'Kinyarwanda',
|
383 |
+
),
|
384 |
+
'kk' => array(
|
385 |
+
'slug' => 'kk',
|
386 |
+
'name' => 'Kazakh',
|
387 |
+
),
|
388 |
+
'km' => array(
|
389 |
+
'slug' => 'km',
|
390 |
+
'name' => 'Khmer',
|
391 |
+
),
|
392 |
+
'kn' => array(
|
393 |
+
'slug' => 'kn',
|
394 |
+
'name' => 'Kannada',
|
395 |
+
),
|
396 |
+
'ko_KR' => array(
|
397 |
+
'slug' => 'ko',
|
398 |
+
'name' => 'Korean',
|
399 |
+
),
|
400 |
+
'kir' => array(
|
401 |
+
'slug' => 'kir',
|
402 |
+
'name' => 'Kyrgyz',
|
403 |
+
),
|
404 |
+
'lb_LU' => array(
|
405 |
+
'slug' => 'lb',
|
406 |
+
'name' => 'Luxembourgish',
|
407 |
+
),
|
408 |
+
'li' => array(
|
409 |
+
'slug' => 'li',
|
410 |
+
'name' => 'Limburgish',
|
411 |
+
),
|
412 |
+
'lin' => array(
|
413 |
+
'slug' => 'lin',
|
414 |
+
'name' => 'Lingala',
|
415 |
+
),
|
416 |
+
'lo' => array(
|
417 |
+
'slug' => 'lo',
|
418 |
+
'name' => 'Lao',
|
419 |
+
),
|
420 |
+
'lt_LT' => array(
|
421 |
+
'slug' => 'lt',
|
422 |
+
'name' => 'Lithuanian',
|
423 |
+
),
|
424 |
+
'lv' => array(
|
425 |
+
'slug' => 'lv',
|
426 |
+
'name' => 'Latvian',
|
427 |
+
),
|
428 |
+
'me_ME' => array(
|
429 |
+
'slug' => 'me',
|
430 |
+
'name' => 'Montenegrin',
|
431 |
+
),
|
432 |
+
'mg_MG' => array(
|
433 |
+
'slug' => 'mg',
|
434 |
+
'name' => 'Malagasy',
|
435 |
+
),
|
436 |
+
'mk_MK' => array(
|
437 |
+
'slug' => 'mk',
|
438 |
+
'name' => 'Macedonian',
|
439 |
+
),
|
440 |
+
'ml_IN' => array(
|
441 |
+
'slug' => 'ml',
|
442 |
+
'name' => 'Malayalam',
|
443 |
+
),
|
444 |
+
'mlt' => array(
|
445 |
+
'slug' => 'mlt',
|
446 |
+
'name' => 'Maltese',
|
447 |
+
),
|
448 |
+
'mn' => array(
|
449 |
+
'slug' => 'mn',
|
450 |
+
'name' => 'Mongolian',
|
451 |
+
),
|
452 |
+
'mr' => array(
|
453 |
+
'slug' => 'mr',
|
454 |
+
'name' => 'Marathi',
|
455 |
+
),
|
456 |
+
'mri' => array(
|
457 |
+
'slug' => 'mri',
|
458 |
+
'name' => 'Maori',
|
459 |
+
),
|
460 |
+
'ms_MY' => array(
|
461 |
+
'slug' => 'ms',
|
462 |
+
'name' => 'Malay',
|
463 |
+
),
|
464 |
+
'my_MM' => array(
|
465 |
+
'slug' => 'mya',
|
466 |
+
'name' => 'Myanmar (Burmese)',
|
467 |
+
),
|
468 |
+
'ne_NP' => array(
|
469 |
+
'slug' => 'ne',
|
470 |
+
'name' => 'Nepali',
|
471 |
+
),
|
472 |
+
'nb_NO' => array(
|
473 |
+
'slug' => 'nb',
|
474 |
+
'name' => 'Norwegian (Bokmal)',
|
475 |
+
),
|
476 |
+
'nl_NL' => array(
|
477 |
+
'slug' => 'nl',
|
478 |
+
'name' => 'Dutch',
|
479 |
+
),
|
480 |
+
'nl_BE' => array(
|
481 |
+
'slug' => 'nl-be',
|
482 |
+
'name' => 'Dutch (Belgium)',
|
483 |
+
),
|
484 |
+
'nn_NO' => array(
|
485 |
+
'slug' => 'nn',
|
486 |
+
'name' => 'Norwegian (Nynorsk)',
|
487 |
+
),
|
488 |
+
'oci' => array(
|
489 |
+
'slug' => 'oci',
|
490 |
+
'name' => 'Occitan',
|
491 |
+
),
|
492 |
+
'ory' => array(
|
493 |
+
'slug' => 'ory',
|
494 |
+
'name' => 'Oriya',
|
495 |
+
),
|
496 |
+
'os' => array(
|
497 |
+
'slug' => 'os',
|
498 |
+
'name' => 'Ossetic',
|
499 |
+
),
|
500 |
+
'pa_IN' => array(
|
501 |
+
'slug' => 'pa',
|
502 |
+
'name' => 'Punjabi',
|
503 |
+
),
|
504 |
+
'pl_PL' => array(
|
505 |
+
'slug' => 'pl',
|
506 |
+
'name' => 'Polish',
|
507 |
+
),
|
508 |
+
'pt_BR' => array(
|
509 |
+
'slug' => 'pt-br',
|
510 |
+
'name' => 'Portuguese (Brazil)',
|
511 |
+
),
|
512 |
+
'pt_PT' => array(
|
513 |
+
'slug' => 'pt',
|
514 |
+
'name' => 'Portuguese (Portugal)',
|
515 |
+
),
|
516 |
+
'ps' => array(
|
517 |
+
'slug' => 'ps',
|
518 |
+
'name' => 'Pashto',
|
519 |
+
),
|
520 |
+
'rhg' => array(
|
521 |
+
'slug' => 'rhg',
|
522 |
+
'name' => 'Rohingya',
|
523 |
+
),
|
524 |
+
'ro_RO' => array(
|
525 |
+
'slug' => 'ro',
|
526 |
+
'name' => 'Romanian',
|
527 |
+
),
|
528 |
+
'roh' => array(
|
529 |
+
'slug' => 'roh',
|
530 |
+
'name' => 'Romansh',
|
531 |
+
),
|
532 |
+
'ru_RU' => array(
|
533 |
+
'slug' => 'ru',
|
534 |
+
'name' => 'Russian',
|
535 |
+
),
|
536 |
+
'rue' => array(
|
537 |
+
'slug' => 'rue',
|
538 |
+
'name' => 'Rusyn',
|
539 |
+
),
|
540 |
+
'rup_MK' => array(
|
541 |
+
'slug' => 'rup',
|
542 |
+
'name' => 'Aromanian',
|
543 |
+
),
|
544 |
+
'sah' => array(
|
545 |
+
'slug' => 'sah',
|
546 |
+
'name' => 'Sakha',
|
547 |
+
),
|
548 |
+
'sa_IN' => array(
|
549 |
+
'slug' => 'sa-in',
|
550 |
+
'name' => 'Sanskrit',
|
551 |
+
),
|
552 |
+
'scn' => array(
|
553 |
+
'slug' => 'scn',
|
554 |
+
'name' => 'Sicilian',
|
555 |
+
),
|
556 |
+
'si_LK' => array(
|
557 |
+
'slug' => 'si',
|
558 |
+
'name' => 'Sinhala',
|
559 |
+
),
|
560 |
+
'sk_SK' => array(
|
561 |
+
'slug' => 'sk',
|
562 |
+
'name' => 'Slovak',
|
563 |
+
),
|
564 |
+
'sl_SI' => array(
|
565 |
+
'slug' => 'sl',
|
566 |
+
'name' => 'Slovenian',
|
567 |
+
),
|
568 |
+
'sna' => array(
|
569 |
+
'slug' => 'sna',
|
570 |
+
'name' => 'Shona',
|
571 |
+
),
|
572 |
+
'snd' => array(
|
573 |
+
'slug' => 'snd',
|
574 |
+
'name' => 'Sindhi',
|
575 |
+
),
|
576 |
+
'so_SO' => array(
|
577 |
+
'slug' => 'so',
|
578 |
+
'name' => 'Somali',
|
579 |
+
),
|
580 |
+
'sq' => array(
|
581 |
+
'slug' => 'sq',
|
582 |
+
'name' => 'Albanian',
|
583 |
+
),
|
584 |
+
'sq_XK' => array(
|
585 |
+
'slug' => 'sq-xk',
|
586 |
+
'name' => 'Shqip (Kosovo)',
|
587 |
+
),
|
588 |
+
'sr_RS' => array(
|
589 |
+
'slug' => 'sr',
|
590 |
+
'name' => 'Serbian',
|
591 |
+
),
|
592 |
+
'srd' => array(
|
593 |
+
'slug' => 'srd',
|
594 |
+
'name' => 'Sardinian',
|
595 |
+
),
|
596 |
+
'su_ID' => array(
|
597 |
+
'slug' => 'su',
|
598 |
+
'name' => 'Sundanese',
|
599 |
+
),
|
600 |
+
'sv_SE' => array(
|
601 |
+
'slug' => 'sv',
|
602 |
+
'name' => 'Swedish',
|
603 |
+
),
|
604 |
+
'sw' => array(
|
605 |
+
'slug' => 'sw',
|
606 |
+
'name' => 'Swahili',
|
607 |
+
),
|
608 |
+
'syr' => array(
|
609 |
+
'slug' => 'syr',
|
610 |
+
'name' => 'Syriac',
|
611 |
+
),
|
612 |
+
'szl' => array(
|
613 |
+
'slug' => 'szl',
|
614 |
+
'name' => 'Silesian',
|
615 |
+
),
|
616 |
+
'ta_IN' => array(
|
617 |
+
'slug' => 'ta',
|
618 |
+
'name' => 'Tamil',
|
619 |
+
),
|
620 |
+
'ta_LK' => array(
|
621 |
+
'slug' => 'ta-lk',
|
622 |
+
'name' => 'Tamil (Sri Lanka)',
|
623 |
+
),
|
624 |
+
'tah' => array(
|
625 |
+
'slug' => 'tah',
|
626 |
+
'name' => 'Tahitian',
|
627 |
+
),
|
628 |
+
'te' => array(
|
629 |
+
'slug' => 'te',
|
630 |
+
'name' => 'Telugu',
|
631 |
+
),
|
632 |
+
'tg' => array(
|
633 |
+
'slug' => 'tg',
|
634 |
+
'name' => 'Tajik',
|
635 |
+
),
|
636 |
+
'th' => array(
|
637 |
+
'slug' => 'th',
|
638 |
+
'name' => 'Thai',
|
639 |
+
),
|
640 |
+
'tir' => array(
|
641 |
+
'slug' => 'tir',
|
642 |
+
'name' => 'Tigrinya',
|
643 |
+
),
|
644 |
+
'tl' => array(
|
645 |
+
'slug' => 'tl',
|
646 |
+
'name' => 'Tagalog',
|
647 |
+
),
|
648 |
+
'tr_TR' => array(
|
649 |
+
'slug' => 'tr',
|
650 |
+
'name' => 'Turkish',
|
651 |
+
),
|
652 |
+
'tt_RU' => array(
|
653 |
+
'slug' => 'tt',
|
654 |
+
'name' => 'Tatar',
|
655 |
+
),
|
656 |
+
'tuk' => array(
|
657 |
+
'slug' => 'tuk',
|
658 |
+
'name' => 'Turkmen',
|
659 |
+
),
|
660 |
+
'twd' => array(
|
661 |
+
'slug' => 'twd',
|
662 |
+
'name' => 'Tweants',
|
663 |
+
),
|
664 |
+
'tzm' => array(
|
665 |
+
'slug' => 'tzm',
|
666 |
+
'name' => 'Tamazight (Central Atlas)',
|
667 |
+
),
|
668 |
+
'ug_CN' => array(
|
669 |
+
'slug' => 'ug',
|
670 |
+
'name' => 'Uighur',
|
671 |
+
),
|
672 |
+
'uk' => array(
|
673 |
+
'slug' => 'uk',
|
674 |
+
'name' => 'Ukrainian',
|
675 |
+
),
|
676 |
+
'ur' => array(
|
677 |
+
'slug' => 'ur',
|
678 |
+
'name' => 'Urdu',
|
679 |
+
),
|
680 |
+
'uz_UZ' => array(
|
681 |
+
'slug' => 'uz',
|
682 |
+
'name' => 'Uzbek',
|
683 |
+
),
|
684 |
+
'vi' => array(
|
685 |
+
'slug' => 'vi',
|
686 |
+
'name' => 'Vietnamese',
|
687 |
+
),
|
688 |
+
'wa' => array(
|
689 |
+
'slug' => 'wa',
|
690 |
+
'name' => 'Walloon',
|
691 |
+
),
|
692 |
+
'xho' => array(
|
693 |
+
'slug' => 'xho',
|
694 |
+
'name' => 'Xhosa',
|
695 |
+
),
|
696 |
+
'xmf' => array(
|
697 |
+
'slug' => 'xmf',
|
698 |
+
'name' => 'Mingrelian',
|
699 |
+
),
|
700 |
+
'yor' => array(
|
701 |
+
'slug' => 'yor',
|
702 |
+
'name' => 'Yoruba',
|
703 |
+
),
|
704 |
+
'zh_CN' => array(
|
705 |
+
'slug' => 'zh-cn',
|
706 |
+
'name' => 'Chinese (China)',
|
707 |
+
),
|
708 |
+
'zh_HK' => array(
|
709 |
+
'slug' => 'zh-hk',
|
710 |
+
'name' => 'Chinese (Hong Kong)',
|
711 |
+
),
|
712 |
+
'zh_TW' => array(
|
713 |
+
'slug' => 'zh-tw',
|
714 |
+
'name' => 'Chinese (Taiwan)',
|
715 |
+
),
|
716 |
+
'de_DE_formal' => array(
|
717 |
+
'slug' => 'de/formal',
|
718 |
+
'name' => 'German (Formal)',
|
719 |
+
),
|
720 |
+
'nl_NL_formal' => array(
|
721 |
+
'slug' => 'nl/formal',
|
722 |
+
'name' => 'Dutch (Formal)',
|
723 |
+
),
|
724 |
+
'de_CH_informal' => array(
|
725 |
+
'slug' => 'de-ch/informal',
|
726 |
+
'name' => 'Chinese (Taiwan)',
|
727 |
+
),
|
728 |
+
'pt_PT_ao90' => array(
|
729 |
+
'slug' => 'pt/ao90',
|
730 |
+
'name' => 'Portuguese (Portugal, AO90)',
|
731 |
+
),
|
732 |
+
);
|
733 |
+
|
734 |
+
/**
|
735 |
+
* Check if we should load module for this.
|
736 |
+
*
|
737 |
+
* @param Product $product Product to check.
|
738 |
+
*
|
739 |
+
* @return bool Should load ?
|
740 |
+
*/
|
741 |
+
public function can_load( $product ) {
|
742 |
+
if ( $this->is_from_partner( $product ) ) {
|
743 |
+
return false;
|
744 |
+
}
|
745 |
+
if ( ! $product->is_wordpress_available() ) {
|
746 |
+
return false;
|
747 |
+
}
|
748 |
+
|
749 |
+
$lang = $this->get_user_locale();
|
750 |
+
|
751 |
+
if ( 'en_US' === $lang ) {
|
752 |
+
return false;
|
753 |
+
}
|
754 |
+
|
755 |
+
$languages = $this->get_translations( $product );
|
756 |
+
|
757 |
+
if ( ! is_array( $languages ) ) {
|
758 |
+
return false;
|
759 |
+
}
|
760 |
+
|
761 |
+
if ( ! isset( $languages['translations'] ) ) {
|
762 |
+
return false;
|
763 |
+
}
|
764 |
+
|
765 |
+
$languages = $languages['translations'];
|
766 |
+
|
767 |
+
$available = wp_list_pluck( $languages, 'language' );
|
768 |
+
|
769 |
+
if ( in_array( $lang, $available ) ) {
|
770 |
+
return false;
|
771 |
+
}
|
772 |
+
|
773 |
+
if ( ! isset( self::$locales[ $lang ] ) ) {
|
774 |
+
return false;
|
775 |
+
}
|
776 |
+
|
777 |
+
return apply_filters( $product->get_slug() . '_sdk_enable_translate', true );
|
778 |
+
}
|
779 |
+
|
780 |
+
/**
|
781 |
+
* Get the user's locale.
|
782 |
+
*/
|
783 |
+
private function get_user_locale() {
|
784 |
+
global $wp_version;
|
785 |
+
if ( version_compare( $wp_version, '4.7.0', '>=' ) ) {
|
786 |
+
return get_user_locale();
|
787 |
+
}
|
788 |
+
$user = wp_get_current_user();
|
789 |
+
if ( $user ) {
|
790 |
+
$locale = $user->locale;
|
791 |
+
}
|
792 |
+
|
793 |
+
return $locale ? $locale : get_locale();
|
794 |
+
}
|
795 |
+
|
796 |
+
/**
|
797 |
+
* Fetch translations from api.
|
798 |
+
*
|
799 |
+
* @param Product $product Product to check.
|
800 |
+
*
|
801 |
+
* @return mixed Translation array.
|
802 |
+
*/
|
803 |
+
private function get_translations( $product ) {
|
804 |
+
$cache_key = $product->get_key() . '_all_languages';
|
805 |
+
$translations = get_transient( $cache_key );
|
806 |
+
|
807 |
+
if ( false === $translations ) {
|
808 |
+
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
|
809 |
+
$translations = translations_api(
|
810 |
+
$product->get_type() . 's',
|
811 |
+
array(
|
812 |
+
'slug' => $product->get_slug(),
|
813 |
+
'version' => $product->get_version(),
|
814 |
+
)
|
815 |
+
);
|
816 |
+
set_transient( $cache_key, $translations, WEEK_IN_SECONDS );
|
817 |
+
}
|
818 |
+
|
819 |
+
return $translations;
|
820 |
+
|
821 |
+
}
|
822 |
+
|
823 |
+
/**
|
824 |
+
* Add notification to queue.
|
825 |
+
*
|
826 |
+
* @param array $all_notifications Previous notification.
|
827 |
+
*
|
828 |
+
* @return array All notifications.
|
829 |
+
*/
|
830 |
+
public function add_notification( $all_notifications ) {
|
831 |
+
|
832 |
+
$lang = $this->get_user_locale();
|
833 |
+
$link = $this->get_locale_paths( $lang );
|
834 |
+
$language_meta = self::$locales[ $lang ];
|
835 |
+
|
836 |
+
$heading = apply_filters( $this->product->get_key() . '_feedback_translate_heading', 'Improve {product}' );
|
837 |
+
$heading = str_replace(
|
838 |
+
array( '{product}' ),
|
839 |
+
$this->product->get_friendly_name(),
|
840 |
+
$heading
|
841 |
+
);
|
842 |
+
$message = apply_filters(
|
843 |
+
$this->product->get_key() . '_feedback_translation',
|
844 |
+
'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.
|
845 |
+
The process is easy, and you can join by following the link below!'
|
846 |
+
);
|
847 |
+
|
848 |
+
$message = str_replace(
|
849 |
+
[ '{product}', '{language}' ],
|
850 |
+
[
|
851 |
+
$this->product->get_friendly_name(),
|
852 |
+
$language_meta['name'],
|
853 |
+
],
|
854 |
+
$message
|
855 |
+
);
|
856 |
+
|
857 |
+
$button_submit = apply_filters( $this->product->get_key() . '_feedback_translate_button_do', 'Ok, I will gladly help.' );
|
858 |
+
$button_cancel = apply_filters( $this->product->get_key() . '_feedback_translate_button_cancel', 'No, thanks.' );
|
859 |
+
|
860 |
+
$all_notifications[] = [
|
861 |
+
'id' => $this->product->get_key() . '_translate_flag',
|
862 |
+
'heading' => $heading,
|
863 |
+
'message' => $message,
|
864 |
+
'ctas' => [
|
865 |
+
'confirm' => [
|
866 |
+
'link' => $link,
|
867 |
+
'text' => $button_submit,
|
868 |
+
],
|
869 |
+
'cancel' => [
|
870 |
+
'link' => '#',
|
871 |
+
'text' => $button_cancel,
|
872 |
+
],
|
873 |
+
],
|
874 |
+
];
|
875 |
+
|
876 |
+
return $all_notifications;
|
877 |
+
}
|
878 |
+
|
879 |
+
/**
|
880 |
+
* Return the locale path.
|
881 |
+
*
|
882 |
+
* @param string $locale Locale code.
|
883 |
+
*
|
884 |
+
* @return string Locale path.
|
885 |
+
*/
|
886 |
+
private function get_locale_paths( $locale ) {
|
887 |
+
if ( empty( $locale ) ) {
|
888 |
+
return '';
|
889 |
+
}
|
890 |
+
|
891 |
+
$slug = isset( self::$locales[ $locale ] ) ? self::$locales[ $locale ]['slug'] : '';
|
892 |
+
if ( empty( $slug ) ) {
|
893 |
+
return '';
|
894 |
+
}
|
895 |
+
if ( strpos( $slug, '/' ) === false ) {
|
896 |
+
$slug .= '/default';
|
897 |
+
}
|
898 |
+
$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';
|
899 |
+
|
900 |
+
return $url;
|
901 |
+
}
|
902 |
+
|
903 |
+
/**
|
904 |
+
* Load module logic.
|
905 |
+
*
|
906 |
+
* @param Product $product Product to load.
|
907 |
+
*
|
908 |
+
* @return Translate Module instance.
|
909 |
+
*/
|
910 |
+
public function load( $product ) {
|
911 |
+
|
912 |
+
$this->product = $product;
|
913 |
+
|
914 |
+
add_filter( 'themeisle_sdk_registered_notifications', [ $this, 'add_notification' ] );
|
915 |
+
|
916 |
+
return $this;
|
917 |
+
}
|
918 |
+
}
|
vendor/codeinwp/themeisle-sdk/src/Modules/Uninstall_feedback.php
ADDED
@@ -0,0 +1,858 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
12 |
+
namespace ThemeisleSDK\Modules;
|
13 |
+
|
14 |
+
use ThemeisleSDK\Common\Abstract_Module;
|
15 |
+
use ThemeisleSDK\Product;
|
16 |
+
|
17 |
+
// Exit if accessed directly.
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Uninstall feedback module for ThemeIsle SDK.
|
24 |
+
*/
|
25 |
+
class Uninstall_Feedback extends Abstract_Module {
|
26 |
+
/**
|
27 |
+
* How many seconds before the deactivation window is triggered for themes?
|
28 |
+
*
|
29 |
+
* @var int Number of days.
|
30 |
+
*/
|
31 |
+
const AUTO_TRIGGER_DEACTIVATE_WINDOW_SECONDS = 3;
|
32 |
+
/**
|
33 |
+
* How many days before the deactivation window pops up again for the theme?
|
34 |
+
*
|
35 |
+
* @var int Number of days.
|
36 |
+
*/
|
37 |
+
const PAUSE_DEACTIVATE_WINDOW_DAYS = 100;
|
38 |
+
/**
|
39 |
+
* Where to send the data.
|
40 |
+
*
|
41 |
+
* @var string Endpoint url.
|
42 |
+
*/
|
43 |
+
const FEEDBACK_ENDPOINT = 'https://api.themeisle.com/tracking/uninstall';
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Default options for plugins.
|
47 |
+
*
|
48 |
+
* @var array $options_plugin The main options list for plugins.
|
49 |
+
*/
|
50 |
+
private $options_plugin = array(
|
51 |
+
'I found a better plugin' => array(
|
52 |
+
'id' => 3,
|
53 |
+
'type' => 'text',
|
54 |
+
'placeholder' => 'What\'s the plugin\'s name?',
|
55 |
+
),
|
56 |
+
'I could not get the plugin to work' => array(
|
57 |
+
'type' => 'textarea',
|
58 |
+
'placeholder' => 'What problem are you experiencing?',
|
59 |
+
'id' => 4,
|
60 |
+
),
|
61 |
+
'I no longer need the plugin' => array(
|
62 |
+
'id' => 5,
|
63 |
+
'type' => 'textarea',
|
64 |
+
'placeholder' => 'If you could improve one thing about our product, what would it be?',
|
65 |
+
),
|
66 |
+
'It\'s a temporary deactivation. I\'m just debugging an issue.' => array(
|
67 |
+
'type' => 'textarea',
|
68 |
+
'placeholder' => 'What problem are you experiencing?',
|
69 |
+
'id' => 6,
|
70 |
+
),
|
71 |
+
);
|
72 |
+
/**
|
73 |
+
* Default options for theme.
|
74 |
+
*
|
75 |
+
* @var array $options_theme The main options list for themes.
|
76 |
+
*/
|
77 |
+
private $options_theme = array(
|
78 |
+
'I don\'t know how to make it look like demo' => array(
|
79 |
+
'id' => 7,
|
80 |
+
),
|
81 |
+
'It lacks options' => array(
|
82 |
+
'placeholder' => 'What option is missing?',
|
83 |
+
'type' => 'text',
|
84 |
+
'id' => 8,
|
85 |
+
),
|
86 |
+
'Is not working with a plugin that I need' => array(
|
87 |
+
'id' => 9,
|
88 |
+
'type' => 'text',
|
89 |
+
'placeholder' => 'What is the name of the plugin',
|
90 |
+
),
|
91 |
+
'I want to try a new design, I don\'t like {theme} style' => array(
|
92 |
+
'id' => 10,
|
93 |
+
),
|
94 |
+
);
|
95 |
+
/**
|
96 |
+
* Default other option.
|
97 |
+
*
|
98 |
+
* @var array $other The other option
|
99 |
+
*/
|
100 |
+
private $other = array(
|
101 |
+
'Other' => array(
|
102 |
+
'id' => 999,
|
103 |
+
'type' => 'textarea',
|
104 |
+
'placeholder' => 'What can we do better?',
|
105 |
+
),
|
106 |
+
);
|
107 |
+
/**
|
108 |
+
* Default heading for plugin.
|
109 |
+
*
|
110 |
+
* @var string $heading_plugin The heading of the modal
|
111 |
+
*/
|
112 |
+
private $heading_plugin = 'What\'s wrong?';
|
113 |
+
/**
|
114 |
+
* Default heading for theme.
|
115 |
+
*
|
116 |
+
* @var string $heading_theme The heading of the modal
|
117 |
+
*/
|
118 |
+
private $heading_theme = 'What does not work for you in {theme}?';
|
119 |
+
/**
|
120 |
+
* Default submit button action text.
|
121 |
+
*
|
122 |
+
* @var string $button_submit The text of the deactivate button
|
123 |
+
*/
|
124 |
+
private $button_submit = 'Submit & Deactivate';
|
125 |
+
/**
|
126 |
+
* Default cancel button.
|
127 |
+
*
|
128 |
+
* @var string $button_cancel The text of the cancel button
|
129 |
+
*/
|
130 |
+
private $button_cancel = 'Skip & Deactivate';
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Loads the additional resources
|
134 |
+
*/
|
135 |
+
public function load_resources() {
|
136 |
+
$screen = get_current_screen();
|
137 |
+
|
138 |
+
if ( ! $screen || ! in_array( $screen->id, array( 'theme-install', 'plugins' ) ) ) {
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
$this->add_feedback_popup_style();
|
143 |
+
|
144 |
+
if ( $this->product->get_type() === 'theme' ) {
|
145 |
+
$this->add_theme_feedback_drawer_js();
|
146 |
+
$this->render_theme_feedback_popup();
|
147 |
+
|
148 |
+
return;
|
149 |
+
}
|
150 |
+
$this->add_plugin_feedback_popup_js();
|
151 |
+
$this->render_plugin_feedback_popup();
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Render theme feedback drawer.
|
156 |
+
*/
|
157 |
+
private function render_theme_feedback_popup() {
|
158 |
+
$heading = str_replace( '{theme}', $this->product->get_name(), $this->heading_theme );
|
159 |
+
$button_submit = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_submit', 'Submit' );
|
160 |
+
$options = $this->options_theme;
|
161 |
+
$options = $this->randomize_options( apply_filters( $this->product->get_key() . '_feedback_deactivate_options', $options ) );
|
162 |
+
$info_disclosure_link = '<a href="#" class="info-disclosure-link">' . apply_filters( $this->product->get_slug() . '_themeisle_sdk_info_collect_cta', 'What info do we collect?' ) . '</a>';
|
163 |
+
|
164 |
+
$options += $this->other;
|
165 |
+
|
166 |
+
?>
|
167 |
+
<div class="ti-theme-uninstall-feedback-drawer ti-feedback">
|
168 |
+
<div class="popup--header">
|
169 |
+
<h5><?php echo wp_kses( $heading, array( 'span' => true ) ); ?> </h5>
|
170 |
+
<button class="toggle"><span>×</span></button>
|
171 |
+
</div><!--/.popup--header-->
|
172 |
+
<div class="popup--body">
|
173 |
+
<?php $this->render_options_list( $options ); ?>
|
174 |
+
</div><!--/.popup--body-->
|
175 |
+
<div class="popup--footer">
|
176 |
+
<div class="actions">
|
177 |
+
<?php
|
178 |
+
echo wp_kses_post( $info_disclosure_link );
|
179 |
+
echo wp_kses_post( $this->get_disclosure_labels() );
|
180 |
+
echo '<div class="buttons">';
|
181 |
+
echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function has an internal sanitization.
|
182 |
+
$button_submit,
|
183 |
+
'secondary',
|
184 |
+
$this->product->get_key() . 'ti-deactivate-yes',
|
185 |
+
false,
|
186 |
+
array(
|
187 |
+
'data-after-text' => $button_submit,
|
188 |
+
'disabled' => true,
|
189 |
+
)
|
190 |
+
);
|
191 |
+
echo '</div>';
|
192 |
+
?>
|
193 |
+
</div><!--/.actions-->
|
194 |
+
</div><!--/.popup--footer-->
|
195 |
+
</div>
|
196 |
+
<?php
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Add feedback styles.
|
201 |
+
*/
|
202 |
+
private function add_feedback_popup_style() {
|
203 |
+
?>
|
204 |
+
<style>
|
205 |
+
.ti-feedback {
|
206 |
+
background: #fff;
|
207 |
+
max-width: 400px;
|
208 |
+
z-index: 10000;
|
209 |
+
box-shadow: 0 0 15px -5px rgba(0, 0, 0, .5);
|
210 |
+
transition: all .3s ease-out;
|
211 |
+
}
|
212 |
+
|
213 |
+
|
214 |
+
.ti-feedback .popup--header {
|
215 |
+
position: relative;
|
216 |
+
background-color: #23A1CE;
|
217 |
+
}
|
218 |
+
|
219 |
+
.ti-feedback .popup--header h5 {
|
220 |
+
margin: 0;
|
221 |
+
font-size: 16px;
|
222 |
+
padding: 15px;
|
223 |
+
color: #fff;
|
224 |
+
font-weight: 600;
|
225 |
+
text-align: center;
|
226 |
+
letter-spacing: .3px;
|
227 |
+
}
|
228 |
+
|
229 |
+
.ti-feedback .popup--body {
|
230 |
+
padding: 15px;
|
231 |
+
}
|
232 |
+
|
233 |
+
.ti-feedback .popup--form {
|
234 |
+
margin: 0;
|
235 |
+
font-size: 13px;
|
236 |
+
}
|
237 |
+
|
238 |
+
.ti-feedback .popup--form input[type="radio"] {
|
239 |
+
<?php echo is_rtl() ? 'margin: 0 0 0 10px;' : 'margin: 0 10px 0 0;'; ?>
|
240 |
+
}
|
241 |
+
|
242 |
+
.ti-feedback .popup--form input[type="radio"]:checked ~ textarea {
|
243 |
+
display: block;
|
244 |
+
}
|
245 |
+
|
246 |
+
.ti-feedback .popup--form textarea {
|
247 |
+
width: 100%;
|
248 |
+
margin: 10px 0 0;
|
249 |
+
display: none;
|
250 |
+
max-height: 150px;
|
251 |
+
}
|
252 |
+
|
253 |
+
.ti-feedback li {
|
254 |
+
display: flex;
|
255 |
+
align-items: center;
|
256 |
+
margin-bottom: 15px;
|
257 |
+
flex-wrap: wrap;
|
258 |
+
}
|
259 |
+
|
260 |
+
.ti-feedback li label {
|
261 |
+
max-width: 90%;
|
262 |
+
}
|
263 |
+
|
264 |
+
.ti-feedback li:last-child {
|
265 |
+
margin-bottom: 0;
|
266 |
+
}
|
267 |
+
|
268 |
+
.ti-feedback .popup--footer {
|
269 |
+
padding: 0 15px 15px;
|
270 |
+
}
|
271 |
+
|
272 |
+
.ti-feedback .actions {
|
273 |
+
display: flex;
|
274 |
+
flex-wrap: wrap;
|
275 |
+
}
|
276 |
+
|
277 |
+
.info-disclosure-link {
|
278 |
+
width: 100%;
|
279 |
+
margin-bottom: 15px;
|
280 |
+
}
|
281 |
+
|
282 |
+
.ti-feedback .info-disclosure-content {
|
283 |
+
max-height: 0;
|
284 |
+
overflow: hidden;
|
285 |
+
width: 100%;
|
286 |
+
transition: .3s ease;
|
287 |
+
}
|
288 |
+
|
289 |
+
.ti-feedback .info-disclosure-content.active {
|
290 |
+
max-height: 300px;
|
291 |
+
}
|
292 |
+
|
293 |
+
.ti-feedback .info-disclosure-content p {
|
294 |
+
margin: 0;
|
295 |
+
}
|
296 |
+
|
297 |
+
.ti-feedback .info-disclosure-content ul {
|
298 |
+
margin: 10px 0;
|
299 |
+
border-radius: 3px;
|
300 |
+
}
|
301 |
+
|
302 |
+
.ti-feedback .info-disclosure-content ul li {
|
303 |
+
display: flex;
|
304 |
+
align-items: center;
|
305 |
+
justify-content: space-between;
|
306 |
+
margin-bottom: 0;
|
307 |
+
padding: 5px 0;
|
308 |
+
border-bottom: 1px solid #ccc;
|
309 |
+
}
|
310 |
+
|
311 |
+
.ti-feedback .buttons {
|
312 |
+
display: flex;
|
313 |
+
width: 100%;
|
314 |
+
}
|
315 |
+
|
316 |
+
.ti-feedback .buttons input:last-child {
|
317 |
+
<?php echo is_rtl() ? 'margin-right: auto;' : 'margin-left: auto;'; ?>
|
318 |
+
}
|
319 |
+
|
320 |
+
.ti-theme-uninstall-feedback-drawer {
|
321 |
+
border-top-left-radius: 5px;
|
322 |
+
position: fixed;
|
323 |
+
top: 100%;
|
324 |
+
right: 15px;
|
325 |
+
}
|
326 |
+
|
327 |
+
.ti-theme-uninstall-feedback-drawer.active {
|
328 |
+
transform: translateY(-100%);
|
329 |
+
}
|
330 |
+
|
331 |
+
.ti-theme-uninstall-feedback-drawer .popup--header {
|
332 |
+
border-top-left-radius: 5px;
|
333 |
+
}
|
334 |
+
|
335 |
+
.ti-theme-uninstall-feedback-drawer .popup--header .toggle {
|
336 |
+
position: absolute;
|
337 |
+
padding: 3px 0;
|
338 |
+
width: 30px;
|
339 |
+
top: -26px;
|
340 |
+
right: 0;
|
341 |
+
cursor: pointer;
|
342 |
+
border-top-left-radius: 5px;
|
343 |
+
border-top-right-radius: 5px;
|
344 |
+
font-size: 20px;
|
345 |
+
background-color: #23A1CE;
|
346 |
+
color: #fff;
|
347 |
+
border: none;
|
348 |
+
line-height: 20px;
|
349 |
+
}
|
350 |
+
|
351 |
+
.ti-theme-uninstall-feedback-drawer .toggle span {
|
352 |
+
margin: 0;
|
353 |
+
display: inline-block;
|
354 |
+
}
|
355 |
+
|
356 |
+
.ti-theme-uninstall-feedback-drawer:not(.active) .toggle span {
|
357 |
+
transform: rotate(45deg);
|
358 |
+
}
|
359 |
+
|
360 |
+
.ti-theme-uninstall-feedback-drawer .popup--header .toggle:hover {
|
361 |
+
background-color: #1880a5;
|
362 |
+
}
|
363 |
+
|
364 |
+
|
365 |
+
.ti-plugin-uninstall-feedback-popup .popup--header:before {
|
366 |
+
content: "";
|
367 |
+
display: block;
|
368 |
+
position: absolute;
|
369 |
+
top: 50%;
|
370 |
+
transform: translateY(-50%);
|
371 |
+
<?php
|
372 |
+
echo is_rtl() ?
|
373 |
+
'right: -10px;
|
374 |
+
border-top: 20px solid transparent;
|
375 |
+
border-left: 20px solid #23A1CE;
|
376 |
+
border-bottom: 20px solid transparent;' :
|
377 |
+
'left: -10px;
|
378 |
+
border-top: 20px solid transparent;
|
379 |
+
border-right: 20px solid #23A1CE;
|
380 |
+
border-bottom: 20px solid transparent;';
|
381 |
+
?>
|
382 |
+
}
|
383 |
+
|
384 |
+
.ti-plugin-uninstall-feedback-popup {
|
385 |
+
display: none;
|
386 |
+
position: absolute;
|
387 |
+
white-space: normal;
|
388 |
+
width: 400px;
|
389 |
+
<?php echo is_rtl() ? 'right: calc( 100% + 15px );' : 'left: calc( 100% + 15px );'; ?>
|
390 |
+
top: -15px;
|
391 |
+
}
|
392 |
+
|
393 |
+
.ti-plugin-uninstall-feedback-popup.sending-feedback .popup--body i {
|
394 |
+
animation: rotation 2s infinite linear;
|
395 |
+
display: block;
|
396 |
+
float: none;
|
397 |
+
align-items: center;
|
398 |
+
width: 100%;
|
399 |
+
margin: 0 auto;
|
400 |
+
height: 100%;
|
401 |
+
background: transparent;
|
402 |
+
padding: 0;
|
403 |
+
}
|
404 |
+
|
405 |
+
.ti-plugin-uninstall-feedback-popup.sending-feedback .popup--body i:before {
|
406 |
+
padding: 0;
|
407 |
+
background: transparent;
|
408 |
+
box-shadow: none;
|
409 |
+
color: #b4b9be
|
410 |
+
}
|
411 |
+
|
412 |
+
|
413 |
+
.ti-plugin-uninstall-feedback-popup.active {
|
414 |
+
display: block;
|
415 |
+
}
|
416 |
+
|
417 |
+
tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>"] .deactivate {
|
418 |
+
position: relative;
|
419 |
+
}
|
420 |
+
|
421 |
+
body.ti-feedback-open .ti-feedback-overlay {
|
422 |
+
content: "";
|
423 |
+
display: block;
|
424 |
+
background-color: rgba(0, 0, 0, 0.5);
|
425 |
+
top: 0;
|
426 |
+
bottom: 0;
|
427 |
+
right: 0;
|
428 |
+
left: 0;
|
429 |
+
z-index: 10000;
|
430 |
+
position: fixed;
|
431 |
+
}
|
432 |
+
|
433 |
+
@media (max-width: 768px) {
|
434 |
+
.ti-plugin-uninstall-feedback-popup {
|
435 |
+
position: fixed;
|
436 |
+
max-width: 100%;
|
437 |
+
margin: 0 auto;
|
438 |
+
left: 50%;
|
439 |
+
top: 50px;
|
440 |
+
transform: translateX(-50%);
|
441 |
+
}
|
442 |
+
|
443 |
+
.ti-plugin-uninstall-feedback-popup .popup--header:before {
|
444 |
+
display: none;
|
445 |
+
}
|
446 |
+
}
|
447 |
+
</style>
|
448 |
+
<?php
|
449 |
+
}
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Theme feedback drawer JS.
|
453 |
+
*/
|
454 |
+
private function add_theme_feedback_drawer_js() {
|
455 |
+
$key = $this->product->get_key();
|
456 |
+
?>
|
457 |
+
<script type="text/javascript" id="ti-deactivate-js">
|
458 |
+
(function ($) {
|
459 |
+
$(document).ready(function () {
|
460 |
+
setTimeout(function () {
|
461 |
+
$('.ti-theme-uninstall-feedback-drawer').addClass('active');
|
462 |
+
}, <?php echo absint( self::AUTO_TRIGGER_DEACTIVATE_WINDOW_SECONDS * 1000 ); ?> );
|
463 |
+
|
464 |
+
$('.ti-theme-uninstall-feedback-drawer .toggle').on('click', function (e) {
|
465 |
+
e.preventDefault();
|
466 |
+
$('.ti-theme-uninstall-feedback-drawer').toggleClass('active');
|
467 |
+
});
|
468 |
+
|
469 |
+
$('.info-disclosure-link').on('click', function (e) {
|
470 |
+
e.preventDefault();
|
471 |
+
$('.info-disclosure-content').toggleClass('active');
|
472 |
+
});
|
473 |
+
|
474 |
+
$('.ti-theme-uninstall-feedback-drawer input[type="radio"]').on('change', function () {
|
475 |
+
var radio = $(this);
|
476 |
+
if (radio.parent().find('textarea').length > 0 &&
|
477 |
+
radio.parent().find('textarea').val().length === 0) {
|
478 |
+
$('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled');
|
479 |
+
radio.parent().find('textarea').on('keyup', function (e) {
|
480 |
+
if ($(this).val().length === 0) {
|
481 |
+
$('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled');
|
482 |
+
} else {
|
483 |
+
$('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled');
|
484 |
+
}
|
485 |
+
});
|
486 |
+
} else {
|
487 |
+
$('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled');
|
488 |
+
}
|
489 |
+
});
|
490 |
+
|
491 |
+
$('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) {
|
492 |
+
e.preventDefault();
|
493 |
+
e.stopPropagation();
|
494 |
+
|
495 |
+
var selectedOption = $(
|
496 |
+
'.ti-theme-uninstall-feedback-drawer input[name="ti-deactivate-option"]:checked');
|
497 |
+
$.post(ajaxurl, {
|
498 |
+
'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>',
|
499 |
+
'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>',
|
500 |
+
'id': selectedOption.parent().attr('ti-option-id'),
|
501 |
+
'msg': selectedOption.parent().find('textarea').val(),
|
502 |
+
'type': 'theme',
|
503 |
+
'key': '<?php echo esc_attr( $key ); ?>'
|
504 |
+
});
|
505 |
+
$('.ti-theme-uninstall-feedback-drawer').fadeOut();
|
506 |
+
});
|
507 |
+
});
|
508 |
+
})(jQuery);
|
509 |
+
|
510 |
+
</script>
|
511 |
+
<?php
|
512 |
+
do_action( $this->product->get_key() . '_uninstall_feedback_after_js' );
|
513 |
+
}
|
514 |
+
|
515 |
+
/**
|
516 |
+
* Render the options list.
|
517 |
+
*
|
518 |
+
* @param array $options the options for the feedback form.
|
519 |
+
*/
|
520 |
+
private function render_options_list( $options ) {
|
521 |
+
$key = $this->product->get_key();
|
522 |
+
$inputs_row_map = [
|
523 |
+
'text' => 1,
|
524 |
+
'textarea' => 2,
|
525 |
+
];
|
526 |
+
?>
|
527 |
+
<ul class="popup--form">
|
528 |
+
<?php foreach ( $options as $title => $attributes ) { ?>
|
529 |
+
<li ti-option-id="<?php echo esc_attr( $attributes['id'] ); ?>">
|
530 |
+
<input type="radio" name="ti-deactivate-option" id="<?php echo esc_attr( $key . $attributes['id'] ); ?>">
|
531 |
+
<label for="<?php echo esc_attr( $key . $attributes['id'] ); ?>">
|
532 |
+
<?php echo esc_attr( str_replace( '{theme}', $this->product->get_name(), $title ) ); ?>
|
533 |
+
</label>
|
534 |
+
<?php
|
535 |
+
if ( array_key_exists( 'type', $attributes ) ) {
|
536 |
+
$placeholder = array_key_exists( 'placeholder', $attributes ) ? $attributes['placeholder'] : '';
|
537 |
+
echo '<textarea width="100%" rows="' . esc_attr( $inputs_row_map[ $attributes['type'] ] ) . '" name="comments" placeholder="' . esc_attr( $placeholder ) . '"></textarea>';
|
538 |
+
}
|
539 |
+
?>
|
540 |
+
</li>
|
541 |
+
<?php } ?>
|
542 |
+
</ul>
|
543 |
+
<?php
|
544 |
+
}
|
545 |
+
|
546 |
+
/**
|
547 |
+
* Render plugin feedback popup.
|
548 |
+
*/
|
549 |
+
private function render_plugin_feedback_popup() {
|
550 |
+
$button_cancel = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_cancel', $this->button_cancel );
|
551 |
+
$button_submit = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_submit', $this->button_submit );
|
552 |
+
$options = $this->randomize_options( apply_filters( $this->product->get_key() . '_feedback_deactivate_options', $this->options_plugin ) );
|
553 |
+
$info_disclosure_link = '<a href="#" class="info-disclosure-link">' . apply_filters( $this->product->get_slug() . '_themeisle_sdk_info_collect_cta', 'What info do we collect?' ) . '</a>';
|
554 |
+
|
555 |
+
$options += $this->other;
|
556 |
+
?>
|
557 |
+
<div class="ti-plugin-uninstall-feedback-popup ti-feedback" id="<?php echo esc_attr( $this->product->get_slug() . '_uninstall_feedback_popup' ); ?>">
|
558 |
+
<div class="popup--header">
|
559 |
+
<h5><?php echo wp_kses( $this->heading_plugin, array( 'span' => true ) ); ?> </h5>
|
560 |
+
</div><!--/.popup--header-->
|
561 |
+
<div class="popup--body">
|
562 |
+
<?php $this->render_options_list( $options ); ?>
|
563 |
+
</div><!--/.popup--body-->
|
564 |
+
<div class="popup--footer">
|
565 |
+
<div class="actions">
|
566 |
+
<?php
|
567 |
+
echo wp_kses_post( $info_disclosure_link );
|
568 |
+
echo wp_kses_post( $this->get_disclosure_labels() );
|
569 |
+
echo '<div class="buttons">';
|
570 |
+
echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped.
|
571 |
+
$button_cancel,
|
572 |
+
'secondary',
|
573 |
+
$this->product->get_key() . 'ti-deactivate-no',
|
574 |
+
false
|
575 |
+
);
|
576 |
+
echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped.
|
577 |
+
$button_submit,
|
578 |
+
'primary',
|
579 |
+
$this->product->get_key() . 'ti-deactivate-yes',
|
580 |
+
false,
|
581 |
+
array(
|
582 |
+
'data-after-text' => $button_submit,
|
583 |
+
'disabled' => true,
|
584 |
+
)
|
585 |
+
);
|
586 |
+
echo '</div>';
|
587 |
+
?>
|
588 |
+
</div><!--/.actions-->
|
589 |
+
</div><!--/.popup--footer-->
|
590 |
+
</div>
|
591 |
+
|
592 |
+
<?php
|
593 |
+
}
|
594 |
+
|
595 |
+
/**
|
596 |
+
* Add plugin feedback popup JS
|
597 |
+
*/
|
598 |
+
private function add_plugin_feedback_popup_js() {
|
599 |
+
$popup_id = '#' . $this->product->get_slug() . '_uninstall_feedback_popup';
|
600 |
+
$key = $this->product->get_key();
|
601 |
+
?>
|
602 |
+
<script type="text/javascript" id="ti-deactivate-js">
|
603 |
+
(function ($) {
|
604 |
+
$(document).ready(function () {
|
605 |
+
var targetElement = 'tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>/"] span.deactivate a';
|
606 |
+
var redirectUrl = $(targetElement).attr('href');
|
607 |
+
if ($('.ti-feedback-overlay').length === 0) {
|
608 |
+
$('body').prepend('<div class="ti-feedback-overlay"></div>');
|
609 |
+
}
|
610 |
+
$('<?php echo esc_attr( $popup_id ); ?> ').appendTo($(targetElement).parent());
|
611 |
+
|
612 |
+
$(targetElement).on('click', function (e) {
|
613 |
+
e.preventDefault();
|
614 |
+
$('<?php echo esc_attr( $popup_id ); ?> ').addClass('active');
|
615 |
+
$('body').addClass('ti-feedback-open');
|
616 |
+
$('.ti-feedback-overlay').on('click', function () {
|
617 |
+
$('<?php echo esc_attr( $popup_id ); ?> ').removeClass('active');
|
618 |
+
$('body').removeClass('ti-feedback-open');
|
619 |
+
});
|
620 |
+
});
|
621 |
+
|
622 |
+
$('<?php echo esc_attr( $popup_id ); ?> .info-disclosure-link').on('click', function (e) {
|
623 |
+
e.preventDefault();
|
624 |
+
$(this).parent().find('.info-disclosure-content').toggleClass('active');
|
625 |
+
});
|
626 |
+
|
627 |
+
$('<?php echo esc_attr( $popup_id ); ?> input[type="radio"]').on('change', function () {
|
628 |
+
var radio = $(this);
|
629 |
+
if (radio.parent().find('textarea').length > 0 &&
|
630 |
+
radio.parent().find('textarea').val().length === 0) {
|
631 |
+
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled');
|
632 |
+
radio.parent().find('textarea').on('keyup', function (e) {
|
633 |
+
if ($(this).val().length === 0) {
|
634 |
+
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled');
|
635 |
+
} else {
|
636 |
+
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled');
|
637 |
+
}
|
638 |
+
});
|
639 |
+
} else {
|
640 |
+
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled');
|
641 |
+
}
|
642 |
+
});
|
643 |
+
|
644 |
+
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-no').on('click', function (e) {
|
645 |
+
e.preventDefault();
|
646 |
+
e.stopPropagation();
|
647 |
+
$(targetElement).unbind('click');
|
648 |
+
$('body').removeClass('ti-feedback-open');
|
649 |
+
$('<?php echo esc_attr( $popup_id ); ?>').remove();
|
650 |
+
if (redirectUrl !== '') {
|
651 |
+
location.href = redirectUrl;
|
652 |
+
}
|
653 |
+
});
|
654 |
+
|
655 |
+
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) {
|
656 |
+
e.preventDefault();
|
657 |
+
e.stopPropagation();
|
658 |
+
$(targetElement).unbind('click');
|
659 |
+
var selectedOption = $(
|
660 |
+
'<?php echo esc_attr( $popup_id ); ?> input[name="ti-deactivate-option"]:checked');
|
661 |
+
var data = {
|
662 |
+
'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>',
|
663 |
+
'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>',
|
664 |
+
'id': selectedOption.parent().attr('ti-option-id'),
|
665 |
+
'msg': selectedOption.parent().find('textarea').val(),
|
666 |
+
'type': 'plugin',
|
667 |
+
'key': '<?php echo esc_attr( $key ); ?>'
|
668 |
+
};
|
669 |
+
$.ajax({
|
670 |
+
type: 'POST',
|
671 |
+
url: ajaxurl,
|
672 |
+
data: data,
|
673 |
+
complete() {
|
674 |
+
$('body').removeClass('ti-feedback-open');
|
675 |
+
$('<?php echo esc_attr( $popup_id ); ?>').remove();
|
676 |
+
if (redirectUrl !== '') {
|
677 |
+
location.href = redirectUrl;
|
678 |
+
}
|
679 |
+
},
|
680 |
+
beforeSend() {
|
681 |
+
$('<?php echo esc_attr( $popup_id ); ?>').addClass('sending-feedback');
|
682 |
+
$('<?php echo esc_attr( $popup_id ); ?> .popup--footer').remove();
|
683 |
+
$('<?php echo esc_attr( $popup_id ); ?> .popup--body').html('<i class="dashicons dashicons-update-alt"></i>');
|
684 |
+
}
|
685 |
+
});
|
686 |
+
});
|
687 |
+
});
|
688 |
+
})(jQuery);
|
689 |
+
|
690 |
+
</script>
|
691 |
+
<?php
|
692 |
+
do_action( $this->product->get_key() . '_uninstall_feedback_after_js' );
|
693 |
+
}
|
694 |
+
|
695 |
+
/**
|
696 |
+
* Get the disclosure labels markup.
|
697 |
+
*
|
698 |
+
* @return string
|
699 |
+
*/
|
700 |
+
private function get_disclosure_labels() {
|
701 |
+
$disclosure_new_labels = apply_filters( $this->product->get_slug() . '_themeisle_sdk_disclosure_content_labels', [], $this->product );
|
702 |
+
$disclosure_labels = array_merge(
|
703 |
+
[
|
704 |
+
'title' => 'Below is a detailed view of all data that ThemeIsle will receive if you fill in this survey. No domain name, email address or IP addresses are transmited after you submit the survey.',
|
705 |
+
'items' => [
|
706 |
+
sprintf( '%s %s version %s %s %s %s', '<strong>', ucwords( $this->product->get_type() ), '</strong>', '<code>', $this->product->get_version(), '</code>' ),
|
707 |
+
sprintf( '%sCurrent website:%s %s %s %s', '<strong>', '</strong>', '<code>', get_site_url(), '</code>' ),
|
708 |
+
sprintf( '%s Uninstall reason %s %s Selected reason from the above survey %s ', '<strong>', '</strong>', '<i>', '</i>' ),
|
709 |
+
],
|
710 |
+
],
|
711 |
+
$disclosure_new_labels
|
712 |
+
);
|
713 |
+
|
714 |
+
$info_disclosure_content = '<div class="info-disclosure-content"><p>' . wp_kses_post( $disclosure_labels['title'] ) . '</p><ul>';
|
715 |
+
foreach ( $disclosure_labels['items'] as $disclosure_item ) {
|
716 |
+
$info_disclosure_content .= sprintf( '<li>%s</li>', wp_kses_post( $disclosure_item ) );
|
717 |
+
}
|
718 |
+
$info_disclosure_content .= '</ul></div>';
|
719 |
+
|
720 |
+
return $info_disclosure_content;
|
721 |
+
}
|
722 |
+
|
723 |
+
/**
|
724 |
+
* Randomizes the options array.
|
725 |
+
*
|
726 |
+
* @param array $options The options array.
|
727 |
+
*/
|
728 |
+
public function randomize_options( $options ) {
|
729 |
+
$new = array();
|
730 |
+
$keys = array_keys( $options );
|
731 |
+
shuffle( $keys );
|
732 |
+
|
733 |
+
foreach ( $keys as $key ) {
|
734 |
+
$new[ $key ] = $options[ $key ];
|
735 |
+
}
|
736 |
+
|
737 |
+
return $new;
|
738 |
+
}
|
739 |
+
|
740 |
+
/**
|
741 |
+
* Called when the deactivate button is clicked.
|
742 |
+
*/
|
743 |
+
public function post_deactivate() {
|
744 |
+
check_ajax_referer( (string) __CLASS__, 'nonce' );
|
745 |
+
|
746 |
+
$this->post_deactivate_or_cancel();
|
747 |
+
|
748 |
+
if ( empty( $_POST['id'] ) ) {
|
749 |
+
|
750 |
+
wp_send_json( [] );
|
751 |
+
|
752 |
+
return;
|
753 |
+
}
|
754 |
+
$this->call_api(
|
755 |
+
array(
|
756 |
+
'type' => 'deactivate',
|
757 |
+
'id' => sanitize_key( $_POST['id'] ),
|
758 |
+
'comment' => isset( $_POST['msg'] ) ? sanitize_textarea_field( $_POST['msg'] ) : '',
|
759 |
+
)
|
760 |
+
);
|
761 |
+
wp_send_json( [] );
|
762 |
+
|
763 |
+
}
|
764 |
+
|
765 |
+
/**
|
766 |
+
* Called when the deactivate/cancel button is clicked.
|
767 |
+
*/
|
768 |
+
private function post_deactivate_or_cancel() {
|
769 |
+
if ( ! isset( $_POST['type'] ) || ! isset( $_POST['key'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function.
|
770 |
+
return;
|
771 |
+
}
|
772 |
+
if ( 'theme' !== $_POST['type'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function.
|
773 |
+
return;
|
774 |
+
}
|
775 |
+
|
776 |
+
set_transient( 'ti_sdk_pause_' . sanitize_text_field( $_POST['key'] ), true, self::PAUSE_DEACTIVATE_WINDOW_DAYS * DAY_IN_SECONDS );//phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function.
|
777 |
+
|
778 |
+
}
|
779 |
+
|
780 |
+
/**
|
781 |
+
* Calls the API
|
782 |
+
*
|
783 |
+
* @param array $attributes The attributes of the post body.
|
784 |
+
*
|
785 |
+
* @return bool Is the request succesfull?
|
786 |
+
*/
|
787 |
+
protected function call_api( $attributes ) {
|
788 |
+
$slug = $this->product->get_slug();
|
789 |
+
$version = $this->product->get_version();
|
790 |
+
$attributes['slug'] = $slug;
|
791 |
+
$attributes['version'] = $version;
|
792 |
+
$attributes['url'] = get_site_url();
|
793 |
+
|
794 |
+
$response = wp_remote_post(
|
795 |
+
self::FEEDBACK_ENDPOINT,
|
796 |
+
array(
|
797 |
+
'body' => $attributes,
|
798 |
+
)
|
799 |
+
);
|
800 |
+
|
801 |
+
return is_wp_error( $response );
|
802 |
+
}
|
803 |
+
|
804 |
+
/**
|
805 |
+
* Should we load this object?.
|
806 |
+
*
|
807 |
+
* @param Product $product Product object.
|
808 |
+
*
|
809 |
+
* @return bool Should we load the module?
|
810 |
+
*/
|
811 |
+
public function can_load( $product ) {
|
812 |
+
if ( $this->is_from_partner( $product ) ) {
|
813 |
+
return false;
|
814 |
+
}
|
815 |
+
if ( $product->is_theme() && ( false !== get_transient( 'ti_sdk_pause_' . $product->get_key(), false ) ) ) {
|
816 |
+
return false;
|
817 |
+
}
|
818 |
+
|
819 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
820 |
+
return true;
|
821 |
+
}
|
822 |
+
global $pagenow;
|
823 |
+
|
824 |
+
if ( ! isset( $pagenow ) || empty( $pagenow ) ) {
|
825 |
+
return false;
|
826 |
+
}
|
827 |
+
|
828 |
+
if ( $product->is_plugin() && 'plugins.php' !== $pagenow ) {
|
829 |
+
return false;
|
830 |
+
|
831 |
+
}
|
832 |
+
if ( $product->is_theme() && 'theme-install.php' !== $pagenow ) {
|
833 |
+
return false;
|
834 |
+
}
|
835 |
+
|
836 |
+
return true;
|
837 |
+
}
|
838 |
+
|
839 |
+
/**
|
840 |
+
* Loads module hooks.
|
841 |
+
*
|
842 |
+
* @param Product $product Product details.
|
843 |
+
*
|
844 |
+
* @return Uninstall_Feedback Current module instance.
|
845 |
+
*/
|
846 |
+
public function load( $product ) {
|
847 |
+
|
848 |
+
if ( apply_filters( $product->get_key() . '_hide_uninstall_feedback', false ) ) {
|
849 |
+
return;
|
850 |
+
}
|
851 |
+
|
852 |
+
$this->product = $product;
|
853 |
+
add_action( 'admin_head', array( $this, 'load_resources' ) );
|
854 |
+
add_action( 'wp_ajax_' . $this->product->get_key() . '_uninstall_feedback', array( $this, 'post_deactivate' ) );
|
855 |
+
|
856 |
+
return $this;
|
857 |
+
}
|
858 |
+
}
|
vendor/codeinwp/themeisle-sdk/src/Product.php
ADDED
@@ -0,0 +1,421 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
12 |
+
namespace ThemeisleSDK;
|
13 |
+
|
14 |
+
// Exit if accessed directly.
|
15 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
16 |
+
exit;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Product model for ThemeIsle SDK.
|
21 |
+
*/
|
22 |
+
class Product {
|
23 |
+
/**
|
24 |
+
* Define plugin type string.
|
25 |
+
*/
|
26 |
+
const PLUGIN_TYPE = 'plugin';
|
27 |
+
/**
|
28 |
+
* Define theme type string.
|
29 |
+
*/
|
30 |
+
const THEME_TYPE = 'theme';
|
31 |
+
/**
|
32 |
+
* If the product has a pro version, contains the pro slug.
|
33 |
+
*
|
34 |
+
* @var string $pro_slug Pro slug, if available.
|
35 |
+
*/
|
36 |
+
public $pro_slug;
|
37 |
+
/**
|
38 |
+
* Current product slug.
|
39 |
+
*
|
40 |
+
* @var string $slug THe product slug.
|
41 |
+
*/
|
42 |
+
private $slug;
|
43 |
+
/**
|
44 |
+
* Product basefile, with the proper metadata.
|
45 |
+
*
|
46 |
+
* @var string $basefile The file with headers.
|
47 |
+
*/
|
48 |
+
private $basefile;
|
49 |
+
/**
|
50 |
+
* Type of the product.
|
51 |
+
*
|
52 |
+
* @var string $type The product type ( plugin | theme ).
|
53 |
+
*/
|
54 |
+
private $type;
|
55 |
+
/**
|
56 |
+
* The file name.
|
57 |
+
*
|
58 |
+
* @var string $file The file name.
|
59 |
+
*/
|
60 |
+
private $file;
|
61 |
+
/**
|
62 |
+
* Product name, fetched from the file headers.
|
63 |
+
*
|
64 |
+
* @var string $name The product name.
|
65 |
+
*/
|
66 |
+
private $name;
|
67 |
+
/**
|
68 |
+
* Product normalized key.
|
69 |
+
*
|
70 |
+
* @var string $key The product ready key.
|
71 |
+
*/
|
72 |
+
private $key;
|
73 |
+
/**
|
74 |
+
* Product store url.
|
75 |
+
*
|
76 |
+
* @var string $store_url The store url.
|
77 |
+
*/
|
78 |
+
private $store_url;
|
79 |
+
/**
|
80 |
+
* Product install timestamp.
|
81 |
+
*
|
82 |
+
* @var int $install The date of install.
|
83 |
+
*/
|
84 |
+
private $install;
|
85 |
+
/**
|
86 |
+
* Product store/author name.
|
87 |
+
*
|
88 |
+
* @var string $store_name The store name.
|
89 |
+
*/
|
90 |
+
private $store_name;
|
91 |
+
/**
|
92 |
+
* Does the product requires license.
|
93 |
+
*
|
94 |
+
* @var bool $requires_license Either user needs to activate it with license.
|
95 |
+
*/
|
96 |
+
private $requires_license;
|
97 |
+
/**
|
98 |
+
* Is the product available on wordpress.org
|
99 |
+
*
|
100 |
+
* @var bool $wordpress_available Either is available on WordPress or not.
|
101 |
+
*/
|
102 |
+
private $wordpress_available;
|
103 |
+
/**
|
104 |
+
* Current version of the product.
|
105 |
+
*
|
106 |
+
* @var string $version The product version.
|
107 |
+
*/
|
108 |
+
private $version;
|
109 |
+
/**
|
110 |
+
* Root api endpoint.
|
111 |
+
*/
|
112 |
+
const API_URL = 'https://api.themeisle.com/';
|
113 |
+
/**
|
114 |
+
* ThemeIsle_SDK_Product constructor.
|
115 |
+
*
|
116 |
+
* @param string $basefile Product basefile.
|
117 |
+
*/
|
118 |
+
public function __construct( $basefile ) {
|
119 |
+
if ( ! empty( $basefile ) ) {
|
120 |
+
if ( is_file( $basefile ) ) {
|
121 |
+
$this->basefile = $basefile;
|
122 |
+
$this->setup_from_path();
|
123 |
+
$this->setup_from_fileheaders();
|
124 |
+
}
|
125 |
+
}
|
126 |
+
$install = get_option( $this->get_key() . '_install', 0 );
|
127 |
+
if ( 0 === $install ) {
|
128 |
+
$install = time();
|
129 |
+
update_option( $this->get_key() . '_install', time() );
|
130 |
+
}
|
131 |
+
$this->install = $install;
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Setup props from path.
|
137 |
+
*/
|
138 |
+
public function setup_from_path() {
|
139 |
+
$this->file = basename( $this->basefile );
|
140 |
+
$dir = dirname( $this->basefile );
|
141 |
+
$this->slug = basename( $dir );
|
142 |
+
$exts = explode( '.', $this->basefile );
|
143 |
+
$ext = $exts[ count( $exts ) - 1 ];
|
144 |
+
if ( 'css' === $ext ) {
|
145 |
+
$this->type = 'theme';
|
146 |
+
}
|
147 |
+
if ( 'php' === $ext ) {
|
148 |
+
$this->type = 'plugin';
|
149 |
+
}
|
150 |
+
$this->key = self::key_ready_name( $this->slug );
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Normalize string.
|
155 |
+
*
|
156 |
+
* @param string $string the String to be normalized for cron handler.
|
157 |
+
*
|
158 |
+
* @return string $name The normalized string.
|
159 |
+
*/
|
160 |
+
public static function key_ready_name( $string ) {
|
161 |
+
return str_replace( '-', '_', strtolower( trim( $string ) ) );
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Setup props from fileheaders.
|
166 |
+
*/
|
167 |
+
public function setup_from_fileheaders() {
|
168 |
+
$file_headers = array(
|
169 |
+
'Requires License' => 'Requires License',
|
170 |
+
'WordPress Available' => 'WordPress Available',
|
171 |
+
'Pro Slug' => 'Pro Slug',
|
172 |
+
'Version' => 'Version',
|
173 |
+
);
|
174 |
+
if ( 'plugin' === $this->type ) {
|
175 |
+
$file_headers['Name'] = 'Plugin Name';
|
176 |
+
$file_headers['AuthorName'] = 'Author';
|
177 |
+
$file_headers['AuthorURI'] = 'Author URI';
|
178 |
+
}
|
179 |
+
if ( 'theme' === $this->type ) {
|
180 |
+
$file_headers['Name'] = 'Theme Name';
|
181 |
+
$file_headers['AuthorName'] = 'Author';
|
182 |
+
$file_headers['AuthorURI'] = 'Author URI';
|
183 |
+
}
|
184 |
+
$file_headers = get_file_data( $this->basefile, $file_headers );
|
185 |
+
|
186 |
+
$this->name = $file_headers['Name'];
|
187 |
+
$this->store_name = $file_headers['AuthorName'];
|
188 |
+
$this->author_url = $file_headers['AuthorURI'];
|
189 |
+
$this->store_url = $file_headers['AuthorURI'];
|
190 |
+
|
191 |
+
$this->requires_license = ( 'yes' === $file_headers['Requires License'] ) ? true : false;
|
192 |
+
$this->wordpress_available = ( 'yes' === $file_headers['WordPress Available'] ) ? true : false;
|
193 |
+
$this->pro_slug = ! empty( $file_headers['Pro Slug'] ) ? $file_headers['Pro Slug'] : '';
|
194 |
+
$this->version = $file_headers['Version'];
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Return the product key.
|
200 |
+
*
|
201 |
+
* @return string The product key.
|
202 |
+
*/
|
203 |
+
public function get_key() {
|
204 |
+
return $this->key;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Check if the product is either theme or plugin.
|
209 |
+
*
|
210 |
+
* @return string Product type.
|
211 |
+
*/
|
212 |
+
public function get_type() {
|
213 |
+
return $this->type;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Return if the product is used as a plugin.
|
218 |
+
*
|
219 |
+
* @return bool Is plugin?
|
220 |
+
*/
|
221 |
+
public function is_plugin() {
|
222 |
+
return self::PLUGIN_TYPE === $this->type;
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Return if the product is used as a theme.
|
227 |
+
*
|
228 |
+
* @return bool Is theme ?
|
229 |
+
*/
|
230 |
+
public function is_theme() {
|
231 |
+
return self::THEME_TYPE === $this->type;
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Returns the product slug.
|
236 |
+
*
|
237 |
+
* @return string The product slug.
|
238 |
+
*/
|
239 |
+
public function get_slug() {
|
240 |
+
return $this->slug;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* The magic var_dump info method.
|
245 |
+
*
|
246 |
+
* @return array Debug info.
|
247 |
+
*/
|
248 |
+
public function __debugInfo() {
|
249 |
+
return array(
|
250 |
+
'name' => $this->name,
|
251 |
+
'slug' => $this->slug,
|
252 |
+
'version' => $this->version,
|
253 |
+
'basefile' => $this->basefile,
|
254 |
+
'key' => $this->key,
|
255 |
+
'type' => $this->type,
|
256 |
+
'store_name' => $this->store_name,
|
257 |
+
'store_url' => $this->store_url,
|
258 |
+
'wordpress_available' => $this->wordpress_available,
|
259 |
+
'requires_license' => $this->requires_license,
|
260 |
+
);
|
261 |
+
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Getter for product version.
|
266 |
+
*
|
267 |
+
* @return string The product version.
|
268 |
+
*/
|
269 |
+
public function get_version() {
|
270 |
+
return $this->version;
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Returns current product license, if available.
|
275 |
+
*
|
276 |
+
* @return string Return license key, if available.
|
277 |
+
*/
|
278 |
+
public function get_license() {
|
279 |
+
|
280 |
+
if ( ! $this->requires_license() && ! $this->is_wordpress_available() ) {
|
281 |
+
return 'free';
|
282 |
+
}
|
283 |
+
$license_data = get_option( $this->get_key() . '_license_data', '' );
|
284 |
+
|
285 |
+
if ( empty( $license_data ) ) {
|
286 |
+
return get_option( $this->get_key() . '_license', '' );
|
287 |
+
}
|
288 |
+
if ( ! isset( $license_data->key ) ) {
|
289 |
+
return get_option( $this->get_key() . '_license', '' );
|
290 |
+
}
|
291 |
+
|
292 |
+
return $license_data->key;
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Either the product requires license or not.
|
297 |
+
*
|
298 |
+
* @return bool Either requires license or not.
|
299 |
+
*/
|
300 |
+
public function requires_license() {
|
301 |
+
return $this->requires_license;
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* If product is available on wordpress.org or not.
|
306 |
+
*
|
307 |
+
* @return bool Either is wp available or not.
|
308 |
+
*/
|
309 |
+
public function is_wordpress_available() {
|
310 |
+
return $this->wordpress_available;
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Return friendly name.
|
315 |
+
*
|
316 |
+
* @return string Friendly name.
|
317 |
+
*/
|
318 |
+
public function get_friendly_name() {
|
319 |
+
$name = apply_filters( $this->get_key() . '_friendly_name', trim( str_replace( 'Lite', '', $this->get_name() ) ) );
|
320 |
+
$name = rtrim( $name, '- ()' );
|
321 |
+
|
322 |
+
return $name;
|
323 |
+
}
|
324 |
+
|
325 |
+
/**
|
326 |
+
* Getter for product name.
|
327 |
+
*
|
328 |
+
* @return string The product name.
|
329 |
+
*/
|
330 |
+
public function get_name() {
|
331 |
+
return $this->name;
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Returns the Store name.
|
336 |
+
*
|
337 |
+
* @return string Store name.
|
338 |
+
*/
|
339 |
+
public function get_store_name() {
|
340 |
+
return $this->store_name;
|
341 |
+
}
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Returns the store url.
|
345 |
+
*
|
346 |
+
* @return string The store url.
|
347 |
+
*/
|
348 |
+
public function get_store_url() {
|
349 |
+
|
350 |
+
if ( strpos( $this->store_url, '/themeisle.com' ) !== false ) {
|
351 |
+
return 'https://store.themeisle.com/';
|
352 |
+
}
|
353 |
+
|
354 |
+
return $this->store_url;
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Returns product basefile, which holds the metaheaders.
|
359 |
+
*
|
360 |
+
* @return string The product basefile.
|
361 |
+
*/
|
362 |
+
public function get_basefile() {
|
363 |
+
return $this->basefile;
|
364 |
+
}
|
365 |
+
|
366 |
+
/**
|
367 |
+
* Get changelog url.
|
368 |
+
*
|
369 |
+
* @return string Changelog url.
|
370 |
+
*/
|
371 |
+
public function get_changelog() {
|
372 |
+
return add_query_arg(
|
373 |
+
[
|
374 |
+
'name' => rawurlencode( $this->get_name() ),
|
375 |
+
'edd_action' => 'view_changelog',
|
376 |
+
],
|
377 |
+
$this->get_store_url()
|
378 |
+
);
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Returns product filename.
|
383 |
+
*
|
384 |
+
* @return string The product filename.
|
385 |
+
*/
|
386 |
+
public function get_file() {
|
387 |
+
return $this->file;
|
388 |
+
}
|
389 |
+
|
390 |
+
/**
|
391 |
+
* Returns the pro slug, if available.
|
392 |
+
*
|
393 |
+
* @return string The pro slug.
|
394 |
+
*/
|
395 |
+
public function get_pro_slug() {
|
396 |
+
return $this->pro_slug;
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Return the install timestamp.
|
401 |
+
*
|
402 |
+
* @return int The install timestamp.
|
403 |
+
*/
|
404 |
+
public function get_install_time() {
|
405 |
+
return $this->install;
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Returns the URL of the product base file.
|
410 |
+
*
|
411 |
+
* @param string $path The path to the file.
|
412 |
+
*
|
413 |
+
* @return string The URL of the product base file.
|
414 |
+
*/
|
415 |
+
public function get_base_url( $path = '/' ) {
|
416 |
+
if ( $this->type ) {
|
417 |
+
return plugins_url( $path, $this->basefile );
|
418 |
+
}
|
419 |
+
}
|
420 |
+
|
421 |
+
}
|
vendor/codeinwp/themeisle-sdk/start.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
11 |
+
namespace ThemeisleSDK;
|
12 |
+
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
14 |
+
exit;
|
15 |
+
}
|
16 |
+
$products = apply_filters( 'themeisle_sdk_products', array() );
|
17 |
+
$themeisle_library_path = dirname( __FILE__ );
|
18 |
+
$files_to_load = [
|
19 |
+
$themeisle_library_path . '/src/Loader.php',
|
20 |
+
$themeisle_library_path . '/src/Product.php',
|
21 |
+
|
22 |
+
$themeisle_library_path . '/src/Common/Abstract_module.php',
|
23 |
+
$themeisle_library_path . '/src/Common/Module_factory.php',
|
24 |
+
|
25 |
+
$themeisle_library_path . '/src/Modules/Dashboard_widget.php',
|
26 |
+
$themeisle_library_path . '/src/Modules/Rollback.php',
|
27 |
+
$themeisle_library_path . '/src/Modules/Uninstall_feedback.php',
|
28 |
+
$themeisle_library_path . '/src/Modules/Licenser.php',
|
29 |
+
$themeisle_library_path . '/src/Modules/Endpoint.php',
|
30 |
+
$themeisle_library_path . '/src/Modules/Notification.php',
|
31 |
+
$themeisle_library_path . '/src/Modules/Logger.php',
|
32 |
+
$themeisle_library_path . '/src/Modules/Translate.php',
|
33 |
+
$themeisle_library_path . '/src/Modules/Review.php',
|
34 |
+
$themeisle_library_path . '/src/Modules/Recommendation.php',
|
35 |
+
];
|
36 |
+
|
37 |
+
$files_to_load = array_merge( $files_to_load, apply_filters( 'themeisle_sdk_required_files', [] ) );
|
38 |
+
|
39 |
+
foreach ( $files_to_load as $file ) {
|
40 |
+
if ( is_file( $file ) ) {
|
41 |
+
require_once $file;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
Loader::init();
|
46 |
+
|
47 |
+
foreach ( $products as $product ) {
|
48 |
+
Loader::add_product( $product );
|
49 |
+
}
|
vendor/composer/ClassLoader.php
ADDED
@@ -0,0 +1,572 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 https://www.php-fig.org/psr/psr-0/
|
41 |
+
* @see https://www.php-fig.org/psr/psr-4/
|
42 |
+
*/
|
43 |
+
class ClassLoader
|
44 |
+
{
|
45 |
+
/** @var ?string */
|
46 |
+
private $vendorDir;
|
47 |
+
|
48 |
+
// PSR-4
|
49 |
+
/**
|
50 |
+
* @var array[]
|
51 |
+
* @psalm-var array<string, array<string, int>>
|
52 |
+
*/
|
53 |
+
private $prefixLengthsPsr4 = array();
|
54 |
+
/**
|
55 |
+
* @var array[]
|
56 |
+
* @psalm-var array<string, array<int, string>>
|
57 |
+
*/
|
58 |
+
private $prefixDirsPsr4 = array();
|
59 |
+
/**
|
60 |
+
* @var array[]
|
61 |
+
* @psalm-var array<string, string>
|
62 |
+
*/
|
63 |
+
private $fallbackDirsPsr4 = array();
|
64 |
+
|
65 |
+
// PSR-0
|
66 |
+
/**
|
67 |
+
* @var array[]
|
68 |
+
* @psalm-var array<string, array<string, string[]>>
|
69 |
+
*/
|
70 |
+
private $prefixesPsr0 = array();
|
71 |
+
/**
|
72 |
+
* @var array[]
|
73 |
+
* @psalm-var array<string, string>
|
74 |
+
*/
|
75 |
+
private $fallbackDirsPsr0 = array();
|
76 |
+
|
77 |
+
/** @var bool */
|
78 |
+
private $useIncludePath = false;
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @var string[]
|
82 |
+
* @psalm-var array<string, string>
|
83 |
+
*/
|
84 |
+
private $classMap = array();
|
85 |
+
|
86 |
+
/** @var bool */
|
87 |
+
private $classMapAuthoritative = false;
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @var bool[]
|
91 |
+
* @psalm-var array<string, bool>
|
92 |
+
*/
|
93 |
+
private $missingClasses = array();
|
94 |
+
|
95 |
+
/** @var ?string */
|
96 |
+
private $apcuPrefix;
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @var self[]
|
100 |
+
*/
|
101 |
+
private static $registeredLoaders = array();
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @param ?string $vendorDir
|
105 |
+
*/
|
106 |
+
public function __construct($vendorDir = null)
|
107 |
+
{
|
108 |
+
$this->vendorDir = $vendorDir;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @return string[]
|
113 |
+
*/
|
114 |
+
public function getPrefixes()
|
115 |
+
{
|
116 |
+
if (!empty($this->prefixesPsr0)) {
|
117 |
+
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
118 |
+
}
|
119 |
+
|
120 |
+
return array();
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* @return array[]
|
125 |
+
* @psalm-return array<string, array<int, string>>
|
126 |
+
*/
|
127 |
+
public function getPrefixesPsr4()
|
128 |
+
{
|
129 |
+
return $this->prefixDirsPsr4;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* @return array[]
|
134 |
+
* @psalm-return array<string, string>
|
135 |
+
*/
|
136 |
+
public function getFallbackDirs()
|
137 |
+
{
|
138 |
+
return $this->fallbackDirsPsr0;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @return array[]
|
143 |
+
* @psalm-return array<string, string>
|
144 |
+
*/
|
145 |
+
public function getFallbackDirsPsr4()
|
146 |
+
{
|
147 |
+
return $this->fallbackDirsPsr4;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* @return string[] Array of classname => path
|
152 |
+
* @psalm-return array<string, string>
|
153 |
+
*/
|
154 |
+
public function getClassMap()
|
155 |
+
{
|
156 |
+
return $this->classMap;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* @param string[] $classMap Class to filename map
|
161 |
+
* @psalm-param array<string, string> $classMap
|
162 |
+
*
|
163 |
+
* @return void
|
164 |
+
*/
|
165 |
+
public function addClassMap(array $classMap)
|
166 |
+
{
|
167 |
+
if ($this->classMap) {
|
168 |
+
$this->classMap = array_merge($this->classMap, $classMap);
|
169 |
+
} else {
|
170 |
+
$this->classMap = $classMap;
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Registers a set of PSR-0 directories for a given prefix, either
|
176 |
+
* appending or prepending to the ones previously set for this prefix.
|
177 |
+
*
|
178 |
+
* @param string $prefix The prefix
|
179 |
+
* @param string[]|string $paths The PSR-0 root directories
|
180 |
+
* @param bool $prepend Whether to prepend the directories
|
181 |
+
*
|
182 |
+
* @return void
|
183 |
+
*/
|
184 |
+
public function add($prefix, $paths, $prepend = false)
|
185 |
+
{
|
186 |
+
if (!$prefix) {
|
187 |
+
if ($prepend) {
|
188 |
+
$this->fallbackDirsPsr0 = array_merge(
|
189 |
+
(array) $paths,
|
190 |
+
$this->fallbackDirsPsr0
|
191 |
+
);
|
192 |
+
} else {
|
193 |
+
$this->fallbackDirsPsr0 = array_merge(
|
194 |
+
$this->fallbackDirsPsr0,
|
195 |
+
(array) $paths
|
196 |
+
);
|
197 |
+
}
|
198 |
+
|
199 |
+
return;
|
200 |
+
}
|
201 |
+
|
202 |
+
$first = $prefix[0];
|
203 |
+
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
204 |
+
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
205 |
+
|
206 |
+
return;
|
207 |
+
}
|
208 |
+
if ($prepend) {
|
209 |
+
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
210 |
+
(array) $paths,
|
211 |
+
$this->prefixesPsr0[$first][$prefix]
|
212 |
+
);
|
213 |
+
} else {
|
214 |
+
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
215 |
+
$this->prefixesPsr0[$first][$prefix],
|
216 |
+
(array) $paths
|
217 |
+
);
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Registers a set of PSR-4 directories for a given namespace, either
|
223 |
+
* appending or prepending to the ones previously set for this namespace.
|
224 |
+
*
|
225 |
+
* @param string $prefix The prefix/namespace, with trailing '\\'
|
226 |
+
* @param string[]|string $paths The PSR-4 base directories
|
227 |
+
* @param bool $prepend Whether to prepend the directories
|
228 |
+
*
|
229 |
+
* @throws \InvalidArgumentException
|
230 |
+
*
|
231 |
+
* @return void
|
232 |
+
*/
|
233 |
+
public function addPsr4($prefix, $paths, $prepend = false)
|
234 |
+
{
|
235 |
+
if (!$prefix) {
|
236 |
+
// Register directories for the root namespace.
|
237 |
+
if ($prepend) {
|
238 |
+
$this->fallbackDirsPsr4 = array_merge(
|
239 |
+
(array) $paths,
|
240 |
+
$this->fallbackDirsPsr4
|
241 |
+
);
|
242 |
+
} else {
|
243 |
+
$this->fallbackDirsPsr4 = array_merge(
|
244 |
+
$this->fallbackDirsPsr4,
|
245 |
+
(array) $paths
|
246 |
+
);
|
247 |
+
}
|
248 |
+
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
249 |
+
// Register directories for a new namespace.
|
250 |
+
$length = strlen($prefix);
|
251 |
+
if ('\\' !== $prefix[$length - 1]) {
|
252 |
+
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
253 |
+
}
|
254 |
+
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
255 |
+
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
256 |
+
} elseif ($prepend) {
|
257 |
+
// Prepend directories for an already registered namespace.
|
258 |
+
$this->prefixDirsPsr4[$prefix] = array_merge(
|
259 |
+
(array) $paths,
|
260 |
+
$this->prefixDirsPsr4[$prefix]
|
261 |
+
);
|
262 |
+
} else {
|
263 |
+
// Append directories for an already registered namespace.
|
264 |
+
$this->prefixDirsPsr4[$prefix] = array_merge(
|
265 |
+
$this->prefixDirsPsr4[$prefix],
|
266 |
+
(array) $paths
|
267 |
+
);
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Registers a set of PSR-0 directories for a given prefix,
|
273 |
+
* replacing any others previously set for this prefix.
|
274 |
+
*
|
275 |
+
* @param string $prefix The prefix
|
276 |
+
* @param string[]|string $paths The PSR-0 base directories
|
277 |
+
*
|
278 |
+
* @return void
|
279 |
+
*/
|
280 |
+
public function set($prefix, $paths)
|
281 |
+
{
|
282 |
+
if (!$prefix) {
|
283 |
+
$this->fallbackDirsPsr0 = (array) $paths;
|
284 |
+
} else {
|
285 |
+
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Registers a set of PSR-4 directories for a given namespace,
|
291 |
+
* replacing any others previously set for this namespace.
|
292 |
+
*
|
293 |
+
* @param string $prefix The prefix/namespace, with trailing '\\'
|
294 |
+
* @param string[]|string $paths The PSR-4 base directories
|
295 |
+
*
|
296 |
+
* @throws \InvalidArgumentException
|
297 |
+
*
|
298 |
+
* @return void
|
299 |
+
*/
|
300 |
+
public function setPsr4($prefix, $paths)
|
301 |
+
{
|
302 |
+
if (!$prefix) {
|
303 |
+
$this->fallbackDirsPsr4 = (array) $paths;
|
304 |
+
} else {
|
305 |
+
$length = strlen($prefix);
|
306 |
+
if ('\\' !== $prefix[$length - 1]) {
|
307 |
+
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
308 |
+
}
|
309 |
+
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
310 |
+
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
311 |
+
}
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Turns on searching the include path for class files.
|
316 |
+
*
|
317 |
+
* @param bool $useIncludePath
|
318 |
+
*
|
319 |
+
* @return void
|
320 |
+
*/
|
321 |
+
public function setUseIncludePath($useIncludePath)
|
322 |
+
{
|
323 |
+
$this->useIncludePath = $useIncludePath;
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Can be used to check if the autoloader uses the include path to check
|
328 |
+
* for classes.
|
329 |
+
*
|
330 |
+
* @return bool
|
331 |
+
*/
|
332 |
+
public function getUseIncludePath()
|
333 |
+
{
|
334 |
+
return $this->useIncludePath;
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Turns off searching the prefix and fallback directories for classes
|
339 |
+
* that have not been registered with the class map.
|
340 |
+
*
|
341 |
+
* @param bool $classMapAuthoritative
|
342 |
+
*
|
343 |
+
* @return void
|
344 |
+
*/
|
345 |
+
public function setClassMapAuthoritative($classMapAuthoritative)
|
346 |
+
{
|
347 |
+
$this->classMapAuthoritative = $classMapAuthoritative;
|
348 |
+
}
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Should class lookup fail if not found in the current class map?
|
352 |
+
*
|
353 |
+
* @return bool
|
354 |
+
*/
|
355 |
+
public function isClassMapAuthoritative()
|
356 |
+
{
|
357 |
+
return $this->classMapAuthoritative;
|
358 |
+
}
|
359 |
+
|
360 |
+
/**
|
361 |
+
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
362 |
+
*
|
363 |
+
* @param string|null $apcuPrefix
|
364 |
+
*
|
365 |
+
* @return void
|
366 |
+
*/
|
367 |
+
public function setApcuPrefix($apcuPrefix)
|
368 |
+
{
|
369 |
+
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
* The APCu prefix in use, or null if APCu caching is not enabled.
|
374 |
+
*
|
375 |
+
* @return string|null
|
376 |
+
*/
|
377 |
+
public function getApcuPrefix()
|
378 |
+
{
|
379 |
+
return $this->apcuPrefix;
|
380 |
+
}
|
381 |
+
|
382 |
+
/**
|
383 |
+
* Registers this instance as an autoloader.
|
384 |
+
*
|
385 |
+
* @param bool $prepend Whether to prepend the autoloader or not
|
386 |
+
*
|
387 |
+
* @return void
|
388 |
+
*/
|
389 |
+
public function register($prepend = false)
|
390 |
+
{
|
391 |
+
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
392 |
+
|
393 |
+
if (null === $this->vendorDir) {
|
394 |
+
return;
|
395 |
+
}
|
396 |
+
|
397 |
+
if ($prepend) {
|
398 |
+
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
399 |
+
} else {
|
400 |
+
unset(self::$registeredLoaders[$this->vendorDir]);
|
401 |
+
self::$registeredLoaders[$this->vendorDir] = $this;
|
402 |
+
}
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Unregisters this instance as an autoloader.
|
407 |
+
*
|
408 |
+
* @return void
|
409 |
+
*/
|
410 |
+
public function unregister()
|
411 |
+
{
|
412 |
+
spl_autoload_unregister(array($this, 'loadClass'));
|
413 |
+
|
414 |
+
if (null !== $this->vendorDir) {
|
415 |
+
unset(self::$registeredLoaders[$this->vendorDir]);
|
416 |
+
}
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Loads the given class or interface.
|
421 |
+
*
|
422 |
+
* @param string $class The name of the class
|
423 |
+
* @return true|null True if loaded, null otherwise
|
424 |
+
*/
|
425 |
+
public function loadClass($class)
|
426 |
+
{
|
427 |
+
if ($file = $this->findFile($class)) {
|
428 |
+
includeFile($file);
|
429 |
+
|
430 |
+
return true;
|
431 |
+
}
|
432 |
+
|
433 |
+
return null;
|
434 |
+
}
|
435 |
+
|
436 |
+
/**
|
437 |
+
* Finds the path to the file where the class is defined.
|
438 |
+
*
|
439 |
+
* @param string $class The name of the class
|
440 |
+
*
|
441 |
+
* @return string|false The path if found, false otherwise
|
442 |
+
*/
|
443 |
+
public function findFile($class)
|
444 |
+
{
|
445 |
+
// class map lookup
|
446 |
+
if (isset($this->classMap[$class])) {
|
447 |
+
return $this->classMap[$class];
|
448 |
+
}
|
449 |
+
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
450 |
+
return false;
|
451 |
+
}
|
452 |
+
if (null !== $this->apcuPrefix) {
|
453 |
+
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
454 |
+
if ($hit) {
|
455 |
+
return $file;
|
456 |
+
}
|
457 |
+
}
|
458 |
+
|
459 |
+
$file = $this->findFileWithExtension($class, '.php');
|
460 |
+
|
461 |
+
// Search for Hack files if we are running on HHVM
|
462 |
+
if (false === $file && defined('HHVM_VERSION')) {
|
463 |
+
$file = $this->findFileWithExtension($class, '.hh');
|
464 |
+
}
|
465 |
+
|
466 |
+
if (null !== $this->apcuPrefix) {
|
467 |
+
apcu_add($this->apcuPrefix.$class, $file);
|
468 |
+
}
|
469 |
+
|
470 |
+
if (false === $file) {
|
471 |
+
// Remember that this class does not exist.
|
472 |
+
$this->missingClasses[$class] = true;
|
473 |
+
}
|
474 |
+
|
475 |
+
return $file;
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
480 |
+
*
|
481 |
+
* @return self[]
|
482 |
+
*/
|
483 |
+
public static function getRegisteredLoaders()
|
484 |
+
{
|
485 |
+
return self::$registeredLoaders;
|
486 |
+
}
|
487 |
+
|
488 |
+
/**
|
489 |
+
* @param string $class
|
490 |
+
* @param string $ext
|
491 |
+
* @return string|false
|
492 |
+
*/
|
493 |
+
private function findFileWithExtension($class, $ext)
|
494 |
+
{
|
495 |
+
// PSR-4 lookup
|
496 |
+
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
497 |
+
|
498 |
+
$first = $class[0];
|
499 |
+
if (isset($this->prefixLengthsPsr4[$first])) {
|
500 |
+
$subPath = $class;
|
501 |
+
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
502 |
+
$subPath = substr($subPath, 0, $lastPos);
|
503 |
+
$search = $subPath . '\\';
|
504 |
+
if (isset($this->prefixDirsPsr4[$search])) {
|
505 |
+
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
506 |
+
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
507 |
+
if (file_exists($file = $dir . $pathEnd)) {
|
508 |
+
return $file;
|
509 |
+
}
|
510 |
+
}
|
511 |
+
}
|
512 |
+
}
|
513 |
+
}
|
514 |
+
|
515 |
+
// PSR-4 fallback dirs
|
516 |
+
foreach ($this->fallbackDirsPsr4 as $dir) {
|
517 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
518 |
+
return $file;
|
519 |
+
}
|
520 |
+
}
|
521 |
+
|
522 |
+
// PSR-0 lookup
|
523 |
+
if (false !== $pos = strrpos($class, '\\')) {
|
524 |
+
// namespaced class name
|
525 |
+
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
526 |
+
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
527 |
+
} else {
|
528 |
+
// PEAR-like class name
|
529 |
+
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
530 |
+
}
|
531 |
+
|
532 |
+
if (isset($this->prefixesPsr0[$first])) {
|
533 |
+
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
534 |
+
if (0 === strpos($class, $prefix)) {
|
535 |
+
foreach ($dirs as $dir) {
|
536 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
537 |
+
return $file;
|
538 |
+
}
|
539 |
+
}
|
540 |
+
}
|
541 |
+
}
|
542 |
+
}
|
543 |
+
|
544 |
+
// PSR-0 fallback dirs
|
545 |
+
foreach ($this->fallbackDirsPsr0 as $dir) {
|
546 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
547 |
+
return $file;
|
548 |
+
}
|
549 |
+
}
|
550 |
+
|
551 |
+
// PSR-0 include paths.
|
552 |
+
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
553 |
+
return $file;
|
554 |
+
}
|
555 |
+
|
556 |
+
return false;
|
557 |
+
}
|
558 |
+
}
|
559 |
+
|
560 |
+
/**
|
561 |
+
* Scope isolated include.
|
562 |
+
*
|
563 |
+
* Prevents access to $this/self from included files.
|
564 |
+
*
|
565 |
+
* @param string $file
|
566 |
+
* @return void
|
567 |
+
* @private
|
568 |
+
*/
|
569 |
+
function includeFile($file)
|
570 |
+
{
|
571 |
+
include $file;
|
572 |
+
}
|
vendor/composer/InstalledVersions.php
ADDED
@@ -0,0 +1,350 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
14 |
+
|
15 |
+
use Composer\Autoload\ClassLoader;
|
16 |
+
use Composer\Semver\VersionParser;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* This class is copied in every Composer installed project and available to all
|
20 |
+
*
|
21 |
+
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
22 |
+
*
|
23 |
+
* To require its presence, you can require `composer-runtime-api ^2.0`
|
24 |
+
*/
|
25 |
+
class InstalledVersions
|
26 |
+
{
|
27 |
+
/**
|
28 |
+
* @var mixed[]|null
|
29 |
+
* @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
|
30 |
+
*/
|
31 |
+
private static $installed;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @var bool|null
|
35 |
+
*/
|
36 |
+
private static $canGetVendors;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @var array[]
|
40 |
+
* @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
41 |
+
*/
|
42 |
+
private static $installedByVendor = array();
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
46 |
+
*
|
47 |
+
* @return string[]
|
48 |
+
* @psalm-return list<string>
|
49 |
+
*/
|
50 |
+
public static function getInstalledPackages()
|
51 |
+
{
|
52 |
+
$packages = array();
|
53 |
+
foreach (self::getInstalled() as $installed) {
|
54 |
+
$packages[] = array_keys($installed['versions']);
|
55 |
+
}
|
56 |
+
|
57 |
+
if (1 === \count($packages)) {
|
58 |
+
return $packages[0];
|
59 |
+
}
|
60 |
+
|
61 |
+
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Returns a list of all package names with a specific type e.g. 'library'
|
66 |
+
*
|
67 |
+
* @param string $type
|
68 |
+
* @return string[]
|
69 |
+
* @psalm-return list<string>
|
70 |
+
*/
|
71 |
+
public static function getInstalledPackagesByType($type)
|
72 |
+
{
|
73 |
+
$packagesByType = array();
|
74 |
+
|
75 |
+
foreach (self::getInstalled() as $installed) {
|
76 |
+
foreach ($installed['versions'] as $name => $package) {
|
77 |
+
if (isset($package['type']) && $package['type'] === $type) {
|
78 |
+
$packagesByType[] = $name;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
return $packagesByType;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Checks whether the given package is installed
|
88 |
+
*
|
89 |
+
* This also returns true if the package name is provided or replaced by another package
|
90 |
+
*
|
91 |
+
* @param string $packageName
|
92 |
+
* @param bool $includeDevRequirements
|
93 |
+
* @return bool
|
94 |
+
*/
|
95 |
+
public static function isInstalled($packageName, $includeDevRequirements = true)
|
96 |
+
{
|
97 |
+
foreach (self::getInstalled() as $installed) {
|
98 |
+
if (isset($installed['versions'][$packageName])) {
|
99 |
+
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
return false;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Checks whether the given package satisfies a version constraint
|
108 |
+
*
|
109 |
+
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
110 |
+
*
|
111 |
+
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
112 |
+
*
|
113 |
+
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
114 |
+
* @param string $packageName
|
115 |
+
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
116 |
+
* @return bool
|
117 |
+
*/
|
118 |
+
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
119 |
+
{
|
120 |
+
$constraint = $parser->parseConstraints($constraint);
|
121 |
+
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
122 |
+
|
123 |
+
return $provided->matches($constraint);
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Returns a version constraint representing all the range(s) which are installed for a given package
|
128 |
+
*
|
129 |
+
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
130 |
+
* whether a given version of a package is installed, and not just whether it exists
|
131 |
+
*
|
132 |
+
* @param string $packageName
|
133 |
+
* @return string Version constraint usable with composer/semver
|
134 |
+
*/
|
135 |
+
public static function getVersionRanges($packageName)
|
136 |
+
{
|
137 |
+
foreach (self::getInstalled() as $installed) {
|
138 |
+
if (!isset($installed['versions'][$packageName])) {
|
139 |
+
continue;
|
140 |
+
}
|
141 |
+
|
142 |
+
$ranges = array();
|
143 |
+
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
144 |
+
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
145 |
+
}
|
146 |
+
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
147 |
+
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
148 |
+
}
|
149 |
+
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
150 |
+
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
151 |
+
}
|
152 |
+
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
153 |
+
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
154 |
+
}
|
155 |
+
|
156 |
+
return implode(' || ', $ranges);
|
157 |
+
}
|
158 |
+
|
159 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @param string $packageName
|
164 |
+
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
165 |
+
*/
|
166 |
+
public static function getVersion($packageName)
|
167 |
+
{
|
168 |
+
foreach (self::getInstalled() as $installed) {
|
169 |
+
if (!isset($installed['versions'][$packageName])) {
|
170 |
+
continue;
|
171 |
+
}
|
172 |
+
|
173 |
+
if (!isset($installed['versions'][$packageName]['version'])) {
|
174 |
+
return null;
|
175 |
+
}
|
176 |
+
|
177 |
+
return $installed['versions'][$packageName]['version'];
|
178 |
+
}
|
179 |
+
|
180 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* @param string $packageName
|
185 |
+
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
186 |
+
*/
|
187 |
+
public static function getPrettyVersion($packageName)
|
188 |
+
{
|
189 |
+
foreach (self::getInstalled() as $installed) {
|
190 |
+
if (!isset($installed['versions'][$packageName])) {
|
191 |
+
continue;
|
192 |
+
}
|
193 |
+
|
194 |
+
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
195 |
+
return null;
|
196 |
+
}
|
197 |
+
|
198 |
+
return $installed['versions'][$packageName]['pretty_version'];
|
199 |
+
}
|
200 |
+
|
201 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* @param string $packageName
|
206 |
+
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
207 |
+
*/
|
208 |
+
public static function getReference($packageName)
|
209 |
+
{
|
210 |
+
foreach (self::getInstalled() as $installed) {
|
211 |
+
if (!isset($installed['versions'][$packageName])) {
|
212 |
+
continue;
|
213 |
+
}
|
214 |
+
|
215 |
+
if (!isset($installed['versions'][$packageName]['reference'])) {
|
216 |
+
return null;
|
217 |
+
}
|
218 |
+
|
219 |
+
return $installed['versions'][$packageName]['reference'];
|
220 |
+
}
|
221 |
+
|
222 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* @param string $packageName
|
227 |
+
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
228 |
+
*/
|
229 |
+
public static function getInstallPath($packageName)
|
230 |
+
{
|
231 |
+
foreach (self::getInstalled() as $installed) {
|
232 |
+
if (!isset($installed['versions'][$packageName])) {
|
233 |
+
continue;
|
234 |
+
}
|
235 |
+
|
236 |
+
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
237 |
+
}
|
238 |
+
|
239 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* @return array
|
244 |
+
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
|
245 |
+
*/
|
246 |
+
public static function getRootPackage()
|
247 |
+
{
|
248 |
+
$installed = self::getInstalled();
|
249 |
+
|
250 |
+
return $installed[0]['root'];
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Returns the raw installed.php data for custom implementations
|
255 |
+
*
|
256 |
+
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
257 |
+
* @return array[]
|
258 |
+
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
|
259 |
+
*/
|
260 |
+
public static function getRawData()
|
261 |
+
{
|
262 |
+
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
263 |
+
|
264 |
+
if (null === self::$installed) {
|
265 |
+
// only require the installed.php file if this file is loaded from its dumped location,
|
266 |
+
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
267 |
+
if (substr(__DIR__, -8, 1) !== 'C') {
|
268 |
+
self::$installed = include __DIR__ . '/installed.php';
|
269 |
+
} else {
|
270 |
+
self::$installed = array();
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
return self::$installed;
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
279 |
+
*
|
280 |
+
* @return array[]
|
281 |
+
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
282 |
+
*/
|
283 |
+
public static function getAllRawData()
|
284 |
+
{
|
285 |
+
return self::getInstalled();
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Lets you reload the static array from another file
|
290 |
+
*
|
291 |
+
* This is only useful for complex integrations in which a project needs to use
|
292 |
+
* this class but then also needs to execute another project's autoloader in process,
|
293 |
+
* and wants to ensure both projects have access to their version of installed.php.
|
294 |
+
*
|
295 |
+
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
296 |
+
* the data it needs from this class, then call reload() with
|
297 |
+
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
298 |
+
* the project in which it runs can then also use this class safely, without
|
299 |
+
* interference between PHPUnit's dependencies and the project's dependencies.
|
300 |
+
*
|
301 |
+
* @param array[] $data A vendor/composer/installed.php data set
|
302 |
+
* @return void
|
303 |
+
*
|
304 |
+
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
|
305 |
+
*/
|
306 |
+
public static function reload($data)
|
307 |
+
{
|
308 |
+
self::$installed = $data;
|
309 |
+
self::$installedByVendor = array();
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* @return array[]
|
314 |
+
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
315 |
+
*/
|
316 |
+
private static function getInstalled()
|
317 |
+
{
|
318 |
+
if (null === self::$canGetVendors) {
|
319 |
+
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
320 |
+
}
|
321 |
+
|
322 |
+
$installed = array();
|
323 |
+
|
324 |
+
if (self::$canGetVendors) {
|
325 |
+
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
326 |
+
if (isset(self::$installedByVendor[$vendorDir])) {
|
327 |
+
$installed[] = self::$installedByVendor[$vendorDir];
|
328 |
+
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
329 |
+
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
330 |
+
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
331 |
+
self::$installed = $installed[count($installed) - 1];
|
332 |
+
}
|
333 |
+
}
|
334 |
+
}
|
335 |
+
}
|
336 |
+
|
337 |
+
if (null === self::$installed) {
|
338 |
+
// only require the installed.php file if this file is loaded from its dumped location,
|
339 |
+
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
340 |
+
if (substr(__DIR__, -8, 1) !== 'C') {
|
341 |
+
self::$installed = require __DIR__ . '/installed.php';
|
342 |
+
} else {
|
343 |
+
self::$installed = array();
|
344 |
+
}
|
345 |
+
}
|
346 |
+
$installed[] = self::$installed;
|
347 |
+
|
348 |
+
return $installed;
|
349 |
+
}
|
350 |
+
}
|
vendor/composer/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
Copyright (c) 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,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
10 |
+
);
|
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 |
+
'7c3f92ec501ce72fe4f09265dc506991' => $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,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_real.php @generated by Composer
|
4 |
+
|
5 |
+
class ComposerAutoloaderInitd450da3bedcb4518199c80b96d40a4f1
|
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 |
+
/**
|
17 |
+
* @return \Composer\Autoload\ClassLoader
|
18 |
+
*/
|
19 |
+
public static function getLoader()
|
20 |
+
{
|
21 |
+
if (null !== self::$loader) {
|
22 |
+
return self::$loader;
|
23 |
+
}
|
24 |
+
|
25 |
+
spl_autoload_register(array('ComposerAutoloaderInitd450da3bedcb4518199c80b96d40a4f1', 'loadClassLoader'), true, true);
|
26 |
+
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
27 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitd450da3bedcb4518199c80b96d40a4f1', 'loadClassLoader'));
|
28 |
+
|
29 |
+
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
30 |
+
if ($useStaticLoader) {
|
31 |
+
require __DIR__ . '/autoload_static.php';
|
32 |
+
|
33 |
+
call_user_func(\Composer\Autoload\ComposerStaticInitd450da3bedcb4518199c80b96d40a4f1::getInitializer($loader));
|
34 |
+
} else {
|
35 |
+
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
+
foreach ($map as $namespace => $path) {
|
37 |
+
$loader->set($namespace, $path);
|
38 |
+
}
|
39 |
+
|
40 |
+
$map = require __DIR__ . '/autoload_psr4.php';
|
41 |
+
foreach ($map as $namespace => $path) {
|
42 |
+
$loader->setPsr4($namespace, $path);
|
43 |
+
}
|
44 |
+
|
45 |
+
$classMap = require __DIR__ . '/autoload_classmap.php';
|
46 |
+
if ($classMap) {
|
47 |
+
$loader->addClassMap($classMap);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
$loader->register(true);
|
52 |
+
|
53 |
+
if ($useStaticLoader) {
|
54 |
+
$includeFiles = Composer\Autoload\ComposerStaticInitd450da3bedcb4518199c80b96d40a4f1::$files;
|
55 |
+
} else {
|
56 |
+
$includeFiles = require __DIR__ . '/autoload_files.php';
|
57 |
+
}
|
58 |
+
foreach ($includeFiles as $fileIdentifier => $file) {
|
59 |
+
composerRequired450da3bedcb4518199c80b96d40a4f1($fileIdentifier, $file);
|
60 |
+
}
|
61 |
+
|
62 |
+
return $loader;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @param string $fileIdentifier
|
68 |
+
* @param string $file
|
69 |
+
* @return void
|
70 |
+
*/
|
71 |
+
function composerRequired450da3bedcb4518199c80b96d40a4f1($fileIdentifier, $file)
|
72 |
+
{
|
73 |
+
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
74 |
+
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
75 |
+
|
76 |
+
require $file;
|
77 |
+
}
|
78 |
+
}
|
vendor/composer/autoload_static.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_static.php @generated by Composer
|
4 |
+
|
5 |
+
namespace Composer\Autoload;
|
6 |
+
|
7 |
+
class ComposerStaticInitd450da3bedcb4518199c80b96d40a4f1
|
8 |
+
{
|
9 |
+
public static $files = array (
|
10 |
+
'7c3f92ec501ce72fe4f09265dc506991' => __DIR__ . '/..' . '/codeinwp/themeisle-sdk/load.php',
|
11 |
+
);
|
12 |
+
|
13 |
+
public static $classMap = array (
|
14 |
+
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
15 |
+
);
|
16 |
+
|
17 |
+
public static function getInitializer(ClassLoader $loader)
|
18 |
+
{
|
19 |
+
return \Closure::bind(function () use ($loader) {
|
20 |
+
$loader->classMap = ComposerStaticInitd450da3bedcb4518199c80b96d40a4f1::$classMap;
|
21 |
+
|
22 |
+
}, null, ClassLoader::class);
|
23 |
+
}
|
24 |
+
}
|
vendor/composer/installed.json
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"packages": [
|
3 |
+
{
|
4 |
+
"name": "codeinwp/themeisle-sdk",
|
5 |
+
"version": "3.2.22",
|
6 |
+
"version_normalized": "3.2.22.0",
|
7 |
+
"source": {
|
8 |
+
"type": "git",
|
9 |
+
"url": "https://github.com/Codeinwp/themeisle-sdk.git",
|
10 |
+
"reference": "394d0f27e17dab350efa7e91bffff31f4b451fec"
|
11 |
+
},
|
12 |
+
"dist": {
|
13 |
+
"type": "zip",
|
14 |
+
"url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/394d0f27e17dab350efa7e91bffff31f4b451fec",
|
15 |
+
"reference": "394d0f27e17dab350efa7e91bffff31f4b451fec",
|
16 |
+
"shasum": ""
|
17 |
+
},
|
18 |
+
"require-dev": {
|
19 |
+
"codeinwp/phpcs-ruleset": "dev-main"
|
20 |
+
},
|
21 |
+
"time": "2021-10-27T10:27:45+00:00",
|
22 |
+
"type": "library",
|
23 |
+
"installation-source": "dist",
|
24 |
+
"notification-url": "https://packagist.org/downloads/",
|
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/v3.2.22"
|
43 |
+
},
|
44 |
+
"install-path": "../codeinwp/themeisle-sdk"
|
45 |
+
}
|
46 |
+
],
|
47 |
+
"dev": false,
|
48 |
+
"dev-package-names": []
|
49 |
+
}
|
vendor/composer/installed.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php return array(
|
2 |
+
'root' => array(
|
3 |
+
'pretty_version' => '2.4.3',
|
4 |
+
'version' => '2.4.3.0',
|
5 |
+
'type' => 'wordpress-plugin',
|
6 |
+
'install_path' => __DIR__ . '/../../',
|
7 |
+
'aliases' => array(),
|
8 |
+
'reference' => NULL,
|
9 |
+
'name' => 'codeinwp/wp-maintenance-mode',
|
10 |
+
'dev' => false,
|
11 |
+
),
|
12 |
+
'versions' => array(
|
13 |
+
'codeinwp/themeisle-sdk' => array(
|
14 |
+
'pretty_version' => '3.2.22',
|
15 |
+
'version' => '3.2.22.0',
|
16 |
+
'type' => 'library',
|
17 |
+
'install_path' => __DIR__ . '/../codeinwp/themeisle-sdk',
|
18 |
+
'aliases' => array(),
|
19 |
+
'reference' => '394d0f27e17dab350efa7e91bffff31f4b451fec',
|
20 |
+
'dev_requirement' => false,
|
21 |
+
),
|
22 |
+
'codeinwp/wp-maintenance-mode' => array(
|
23 |
+
'pretty_version' => '2.4.3',
|
24 |
+
'version' => '2.4.3.0',
|
25 |
+
'type' => 'wordpress-plugin',
|
26 |
+
'install_path' => __DIR__ . '/../../',
|
27 |
+
'aliases' => array(),
|
28 |
+
'reference' => NULL,
|
29 |
+
'dev_requirement' => false,
|
30 |
+
),
|
31 |
+
),
|
32 |
+
);
|
views/promo-blocksy.php
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Promo Blocksy
|
4 |
-
*
|
5 |
-
* @version 2.4.0
|
6 |
-
*/
|
7 |
-
|
8 |
-
defined( 'ABSPATH' ) || exit;
|
9 |
-
?>
|
10 |
-
<strong><?php esc_html_e( 'Blocksy - The Most Innovative & Lightning Fast WordPress Theme', 'wp-maintenance-mode' ); ?></strong>
|
11 |
-
|
12 |
-
<br /><br />
|
13 |
-
<?php esc_html_e( 'A blazing fast and lightweight WordPress theme built with the latest web technologies. It was built with the Gutenberg editor in mind and has a lot of options that makes it extendable and customizable.', 'wp-maintenance-mode' ); ?>
|
14 |
-
<br /><br />
|
15 |
-
|
16 |
-
<a class="button button-primary" href="<?php echo esc_url( wpmm_get_utmized_url( 'https://creativethemes.com/blocksy/', array( 'source' => 'notice' ) ) ); ?>" target="_blank">
|
17 |
-
<?php esc_html_e( 'Download for Free Now', 'wp-maintenance-mode' ); ?>
|
18 |
-
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/promo-pulsetic.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Promo Pulsetic
|
4 |
-
*
|
5 |
-
* @version 2.4.0
|
6 |
-
*/
|
7 |
-
|
8 |
-
defined( 'ABSPATH' ) || exit;
|
9 |
-
?>
|
10 |
-
<strong><?php esc_html_e( 'Is Your Website Down? We\'ll Alert You!
|
11 |
-
', 'wp-maintenance-mode' ); ?></strong>
|
12 |
-
|
13 |
-
<br /><br />
|
14 |
-
<?php esc_html_e( 'Get website downtime alerts by phone call, SMS, email or Slack if your website is down. Create beautiful status pages & incident management reports and keep your visitors updated.', 'wp-maintenance-mode' ); ?>
|
15 |
-
<br /><br />
|
16 |
-
|
17 |
-
<a class="button button-primary" href="<?php echo esc_url( wpmm_get_utmized_url( 'https://pulsetic.com/', array( 'source' => 'noticewpmm' ) ) ); ?>" target="_blank">
|
18 |
-
<?php esc_html_e( 'Monitor Your Website and Create Status Pages', 'wp-maintenance-mode' ); ?>
|
19 |
-
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/settings.php
CHANGED
@@ -215,7 +215,7 @@ defined( 'ABSPATH' ) || exit;
|
|
215 |
$hide_shortcodes_text = __( 'Hide available shortcodes', 'wp-maintenance-mode' );
|
216 |
$show_shortcodes_text = __( 'See available shortcodes', 'wp-maintenance-mode' );
|
217 |
?>
|
218 |
-
<a href="javascript:void(0);" class="button button-small toggle-shortcodes-list" data-hide="<?php echo esc_attr( $hide_shortcodes_text ); ?>" data-show="<?php echo esc_attr( $show_shortcodes_text ); ?>" ><?php echo esc_html( $show_shortcodes_text ); ?></a>
|
219 |
|
220 |
<ul class="shortcodes-list">
|
221 |
<li>
|
@@ -280,11 +280,11 @@ defined( 'ABSPATH' ) || exit;
|
|
280 |
<td>
|
281 |
<input type="text" value="<?php echo esc_url( $this->plugin_settings['design']['bg_custom'] ); ?>" name="options[design][bg_custom]" class="background_url" />
|
282 |
<input
|
283 |
-
type="button"
|
284 |
-
value="<?php echo esc_attr_x( 'Upload', 'upload background button', 'wp-maintenance-mode' ); ?>"
|
285 |
-
class="button image_uploader_trigger"
|
286 |
-
data-name="background"
|
287 |
-
data-title="<?php esc_attr_e( 'Upload Background', 'wp-maintenance-mode' ); ?>"
|
288 |
data-button-text="<?php esc_attr_e( 'Choose Background', 'wp-maintenance-mode' ); ?>"
|
289 |
data-to-selector=".background_url"
|
290 |
/>
|
@@ -295,7 +295,7 @@ defined( 'ABSPATH' ) || exit;
|
|
295 |
<th scope="row">
|
296 |
<label for="options[design][bg_predefined]"><?php esc_html_e( 'Choose background', 'wp-maintenance-mode' ); ?></label>
|
297 |
|
298 |
-
<p class="description">
|
299 |
<?php
|
300 |
printf(
|
301 |
wp_kses(
|
@@ -303,7 +303,7 @@ defined( 'ABSPATH' ) || exit;
|
|
303 |
__( '* source <a href="%s" target="_blank">Free Photos</a>', 'wp-maintenance-mode' ),
|
304 |
wpmm_translated_string_allowed_html()
|
305 |
),
|
306 |
-
esc_url( wpmm_get_utmized_url( '
|
307 |
);
|
308 |
?>
|
309 |
</p>
|
@@ -512,7 +512,7 @@ defined( 'ABSPATH' ) || exit;
|
|
512 |
<th scope="row">
|
513 |
<label for="options[modules][social_instagram]">Instagram</label>
|
514 |
</th>
|
515 |
-
<td>
|
516 |
<input type="text" value="<?php echo esc_attr( $this->plugin_settings['modules']['social_instagram'] ); ?>" name="options[modules][social_instagram]" />
|
517 |
</td>
|
518 |
</tr>
|
@@ -673,11 +673,11 @@ defined( 'ABSPATH' ) || exit;
|
|
673 |
<td>
|
674 |
<input type="text" value="<?php echo esc_url( $this->plugin_settings['bot']['avatar'] ); ?>" name="options[bot][avatar]" id="options[bot][avatar]" class="avatar_url" />
|
675 |
<input
|
676 |
-
type="button"
|
677 |
-
value="<?php echo esc_attr_x( 'Upload', 'upload avatar button', 'wp-maintenance-mode' ); ?>"
|
678 |
-
class="button image_uploader_trigger"
|
679 |
-
data-name="avatar"
|
680 |
-
data-title="<?php esc_attr_e( 'Upload Avatar', 'wp-maintenance-mode' ); ?>"
|
681 |
data-button-text="<?php esc_attr_e( 'Choose picture', 'wp-maintenance-mode' ); ?>"
|
682 |
data-to-selector=".avatar_url"
|
683 |
/>
|
215 |
$hide_shortcodes_text = __( 'Hide available shortcodes', 'wp-maintenance-mode' );
|
216 |
$show_shortcodes_text = __( 'See available shortcodes', 'wp-maintenance-mode' );
|
217 |
?>
|
218 |
+
<a href="javascript:void(0);" class="button button-small toggle-shortcodes-list" data-hide="<?php echo esc_attr( $hide_shortcodes_text ); ?>" data-show="<?php echo esc_attr( $show_shortcodes_text ); ?>" ><?php echo esc_html( $show_shortcodes_text ); ?></a>
|
219 |
|
220 |
<ul class="shortcodes-list">
|
221 |
<li>
|
280 |
<td>
|
281 |
<input type="text" value="<?php echo esc_url( $this->plugin_settings['design']['bg_custom'] ); ?>" name="options[design][bg_custom]" class="background_url" />
|
282 |
<input
|
283 |
+
type="button"
|
284 |
+
value="<?php echo esc_attr_x( 'Upload', 'upload background button', 'wp-maintenance-mode' ); ?>"
|
285 |
+
class="button image_uploader_trigger"
|
286 |
+
data-name="background"
|
287 |
+
data-title="<?php esc_attr_e( 'Upload Background', 'wp-maintenance-mode' ); ?>"
|
288 |
data-button-text="<?php esc_attr_e( 'Choose Background', 'wp-maintenance-mode' ); ?>"
|
289 |
data-to-selector=".background_url"
|
290 |
/>
|
295 |
<th scope="row">
|
296 |
<label for="options[design][bg_predefined]"><?php esc_html_e( 'Choose background', 'wp-maintenance-mode' ); ?></label>
|
297 |
|
298 |
+
<p class="description">
|
299 |
<?php
|
300 |
printf(
|
301 |
wp_kses(
|
303 |
__( '* source <a href="%s" target="_blank">Free Photos</a>', 'wp-maintenance-mode' ),
|
304 |
wpmm_translated_string_allowed_html()
|
305 |
),
|
306 |
+
esc_url( wpmm_get_utmized_url( 'https://themeisle.com/blog/wordpress-stock-photos/', array( 'source' => 'settings' ) ) )
|
307 |
);
|
308 |
?>
|
309 |
</p>
|
512 |
<th scope="row">
|
513 |
<label for="options[modules][social_instagram]">Instagram</label>
|
514 |
</th>
|
515 |
+
<td>
|
516 |
<input type="text" value="<?php echo esc_attr( $this->plugin_settings['modules']['social_instagram'] ); ?>" name="options[modules][social_instagram]" />
|
517 |
</td>
|
518 |
</tr>
|
673 |
<td>
|
674 |
<input type="text" value="<?php echo esc_url( $this->plugin_settings['bot']['avatar'] ); ?>" name="options[bot][avatar]" id="options[bot][avatar]" class="avatar_url" />
|
675 |
<input
|
676 |
+
type="button"
|
677 |
+
value="<?php echo esc_attr_x( 'Upload', 'upload avatar button', 'wp-maintenance-mode' ); ?>"
|
678 |
+
class="button image_uploader_trigger"
|
679 |
+
data-name="avatar"
|
680 |
+
data-title="<?php esc_attr_e( 'Upload Avatar', 'wp-maintenance-mode' ); ?>"
|
681 |
data-button-text="<?php esc_attr_e( 'Choose picture', 'wp-maintenance-mode' ); ?>"
|
682 |
data-to-selector=".avatar_url"
|
683 |
/>
|
wp-maintenance-mode.php
CHANGED
@@ -2,19 +2,19 @@
|
|
2 |
/**
|
3 |
* WP Maintenance Mode
|
4 |
*
|
5 |
-
* Plugin Name: WP Maintenance Mode
|
6 |
-
* Plugin URI: https://designmodo.com/
|
7 |
* Description: Adds a splash page to your site that lets visitors know your site is down for maintenance. It's perfect for a coming soon page.
|
8 |
-
* Version: 2.4.
|
9 |
-
* Author:
|
10 |
-
* Author URI: https://
|
11 |
-
* Twitter:
|
12 |
-
* GitHub Plugin URI: https://github.com/
|
13 |
-
* GitHub Branch: master
|
14 |
-
* Text Domain: wp-maintenance-mode
|
15 |
* License: GPL-2.0+
|
16 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
17 |
* Domain Path: /languages
|
|
|
|
|
18 |
*/
|
19 |
|
20 |
defined( 'ABSPATH' ) || exit;
|
@@ -68,3 +68,23 @@ if ( is_admin() ) {
|
|
68 |
require_once WPMM_CLASSES_PATH . 'wp-maintenance-mode-admin.php';
|
69 |
add_action( 'plugins_loaded', array( 'WP_Maintenance_Mode_Admin', 'get_instance' ) );
|
70 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* WP Maintenance Mode
|
4 |
*
|
5 |
+
* Plugin Name: WP Maintenance Mode & Coming Soon
|
|
|
6 |
* Description: Adds a splash page to your site that lets visitors know your site is down for maintenance. It's perfect for a coming soon page.
|
7 |
+
* Version: 2.4.3
|
8 |
+
* Author: Themeisle
|
9 |
+
* Author URI: https://themeisle.com/
|
10 |
+
* Twitter: themeisle
|
11 |
+
* GitHub Plugin URI: https://github.com/codeinwp/wp-maintenance-mode
|
|
|
|
|
12 |
* License: GPL-2.0+
|
13 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
14 |
+
* Text Domain: wp-maintenance-mode
|
15 |
* Domain Path: /languages
|
16 |
+
* WordPress Available: yes
|
17 |
+
* Requires License: no
|
18 |
*/
|
19 |
|
20 |
defined( 'ABSPATH' ) || exit;
|
68 |
require_once WPMM_CLASSES_PATH . 'wp-maintenance-mode-admin.php';
|
69 |
add_action( 'plugins_loaded', array( 'WP_Maintenance_Mode_Admin', 'get_instance' ) );
|
70 |
}
|
71 |
+
|
72 |
+
add_filter( 'themeisle_sdk_products', 'wpmm_load_sdk' );
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Filter products array.
|
77 |
+
*
|
78 |
+
* @param array $products products array.
|
79 |
+
*
|
80 |
+
* @return array
|
81 |
+
*/
|
82 |
+
function wpmm_load_sdk( $products ) {
|
83 |
+
$products[] = __FILE__;
|
84 |
+
return $products;
|
85 |
+
}
|
86 |
+
|
87 |
+
$autoload_path = __DIR__ . '/vendor/autoload.php';
|
88 |
+
if ( is_file( $autoload_path ) ) {
|
89 |
+
require_once $autoload_path;
|
90 |
+
}
|