Version Description
- 15th November 2019 =
- Added - Feedback form on plugin deactivation
Download this release
Release Info
Developer | cyberchimps |
Plugin | Responsive Add Ons |
Version | 2.0.9 |
Comparing to | |
See all releases |
Code changes from version 2.0.8 to 2.0.9
- analytics/assets/css/admin/dialog-boxes.css +2 -0
- analytics/config.php +61 -0
- analytics/includes/analytics-core-functions.php +246 -0
- analytics/includes/analytics-essential-functions.php +28 -0
- analytics/includes/class-analytics.php +782 -0
- analytics/includes/sdk/Exceptions/Exception.php +73 -0
- analytics/require.php +14 -0
- analytics/start.php +63 -0
- analytics/templates/forms/deactivation/form.php +439 -0
- includes/importers/class-responsive-ready-sites-importer.php +7 -1
- readme.txt +7 -2
- responsive-add-ons.php +29 -1
analytics/assets/css/admin/dialog-boxes.css
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
.as-modal{position:fixed;overflow:auto;height:100%;width:100%;top:0;z-index:100000;display:none;background:rgba(0,0,0,0.6)}.as-modal .as-modal-dialog{background:transparent;position:absolute;left:50%;margin-left:-298px;padding-bottom:30px;top:-100%;z-index:100001;width:596px}@media (max-width: 650px){.as-modal .as-modal-dialog{margin-left:-50%;box-sizing:border-box;padding-left:10px;padding-right:10px;width:100%}.as-modal .as-modal-dialog .as-modal-panel>h3>strong{font-size:1.3em}}.as-modal.active{display:block}.as-modal.active:before{display:block}.as-modal.active .as-modal-dialog{top:10%}.as-modal.as-success .as-modal-header{border-bottom-color:#46b450}.as-modal.as-success .as-modal-body{background-color:#f7fff7}.as-modal.as-warn .as-modal-header{border-bottom-color:#ffb900}.as-modal.as-warn .as-modal-body{background-color:#fff8e5}.as-modal.as-error .as-modal-header{border-bottom-color:#dc3232}.as-modal.as-error .as-modal-body{background-color:#ffeaea}.as-modal .as-modal-body,.as-modal .as-modal-footer{border:0;background:#fefefe;padding:20px}.as-modal .as-modal-header{border-bottom:#eeeeee solid 1px;background:#fbfbfb;padding:15px 20px;position:relative;margin-bottom:-10px}.as-modal .as-modal-header h4{margin:0;padding:0;text-transform:uppercase;font-size:1.2em;font-weight:bold;color:#cacaca;text-shadow:1px 1px 1px #fff;letter-spacing:0.6px;-webkit-font-smoothing:antialiased}.as-modal .as-modal-header .as-close{position:absolute;right:10px;top:12px;cursor:pointer;color:#bbb;-moz-border-radius:20px;-webkit-border-radius:20px;border-radius:20px;padding:3px;-moz-transition:all 0.2s ease-in-out;-o-transition:all 0.2s ease-in-out;-ms-transition:all 0.2s ease-in-out;-webkit-transition:all 0.2s ease-in-out;transition:all 0.2s ease-in-out}.as-modal .as-modal-header .as-close:hover{color:#fff;background:#aaa}.as-modal .as-modal-header .as-close .dashicons,.as-modal .as-modal-header .as-close:hover .dashicons{text-decoration:none}.as-modal .as-modal-body{border-bottom:0}.as-modal .as-modal-body p{font-size:14px}.as-modal .as-modal-body h2{font-size:20px;line-height:1.5em}.as-modal .as-modal-body>div{margin-top:10px}.as-modal .as-modal-body>div h2{font-weight:bold;font-size:20px;margin-top:0}.as-modal .as-modal-footer{border-top:#eeeeee solid 1px;text-align:right}.as-modal .as-modal-footer>.button{margin:0 7px}.as-modal .as-modal-footer>.button:first-child{margin:0}.as-modal .as-modal-panel>.notice.inline{margin:0;display:none}.as-modal .as-modal-panel:not(.active){display:none}.rtl .as-modal .as-modal-header .as-close{right:auto;left:20px}body.has-as-modal{overflow:hidden}.as-modal.as-modal-deactivation-feedback .reason-input,.as-modal.as-modal-deactivation-feedback .internal-message{margin:3px 0 3px 22px}.as-modal.as-modal-deactivation-feedback .reason-input input,.as-modal.as-modal-deactivation-feedback .reason-input textarea,.as-modal.as-modal-deactivation-feedback .internal-message input,.as-modal.as-modal-deactivation-feedback .internal-message textarea{width:100%}.as-modal.as-modal-deactivation-feedback li.reason.has-internal-message .internal-message{border:1px solid #ccc;padding:7px;display:none}@media (max-width: 650px){.as-modal.as-modal-deactivation-feedback li.reason li.reason{margin-bottom:10px}.as-modal.as-modal-deactivation-feedback li.reason li.reason .reason-input,.as-modal.as-modal-deactivation-feedback li.reason li.reason .internal-message{margin-left:29px}.as-modal.as-modal-deactivation-feedback li.reason li.reason label{display:table}.as-modal.as-modal-deactivation-feedback li.reason li.reason label>span{display:table-cell;font-size:1.3em}}.as-modal.as-modal-deactivation-feedback .anonymous-feedback-label{float:left}.as-modal.as-modal-deactivation-feedback .as-modal-panel{margin-top:0 !important}.as-modal.as-modal-deactivation-feedback .as-modal-panel h3{margin-top:0;line-height:1.5em}#the-list .deactivate>.as-slug{display:none}.as-modal.as-modal-subscription-cancellation .as-price-increase-warning{color:red;font-weight:bold;padding:0 25px;margin-bottom:0}.as-modal.as-modal-subscription-cancellation ul.subscription-actions label input{float:left;top:5px;position:relative}.rtl .as-modal.as-modal-subscription-cancellation ul.subscription-actions label input{float:right}.as-modal.as-modal-subscription-cancellation ul.subscription-actions label span{display:block;margin-left:24px}.rtl .as-modal.as-modal-subscription-cancellation ul.subscription-actions label span{margin-left:0;margin-right:24px}.as-modal.as-modal-license-activation .as-modal-body input.as-license-key{width:100%}.as-license-options-container table,.as-license-options-container table select,.as-license-options-container table .as-available-license-key{width:100%}.as-license-options-container table td:first-child{width:1%}.as-license-options-container table .as-other-license-key-container label{position:relative;top:6px;float:left;margin-right:5px}.as-license-options-container table .as-other-license-key-container div{overflow:hidden;width:auto;height:30px;display:block;top:2px;position:relative}.as-license-options-container table .as-other-license-key-container div input{margin:0}.as-sites-list-container td{cursor:pointer}.as-modal.as-modal-developer-license-debug-mode .as-modal-body input.as-license-or-user-key{width:100%}.as-multisite-options-container{margin-top:10px;border:1px solid #ccc;padding:5px}.as-multisite-options-container a{text-decoration:none}.as-multisite-options-container a:focus{box-shadow:none}.as-multisite-options-container a.selected{font-weight:bold}.as-multisite-options-container.as-apply-on-all-sites{border:0 none;padding:0}.as-multisite-options-container.as-apply-on-all-sites .as-all-sites-options{border-spacing:0}.as-multisite-options-container.as-apply-on-all-sites .as-all-sites-options td:not(:first-child){display:none}.as-multisite-options-container .as-sites-list-container{display:none;overflow:auto}.as-multisite-options-container .as-sites-list-container table td{border-top:1px solid #ccc;padding:4px 2px}.as-modal.as-modal-license-key-resend .email-address-container{overflow:hidden;padding-right:2px}.as-modal.as-modal-license-key-resend.as-analytics input.email-address{width:300px}.as-modal.as-modal-license-key-resend.as-analytics label{display:block;margin-bottom:10px}.as-modal.as-modal-license-key-resend.as-premium input.email-address{width:100%}.as-modal.as-modal-license-key-resend.as-premium .button-container{float:right;margin-left:7px}@media (max-width: 650px){.as-modal.as-modal-license-key-resend.as-premium .button-container{margin-top:2px}}
|
2 |
+
.rtl .as-modal.as-modal-license-key-resend .as-modal-body .input-container>.email-address-container{padding-left:2px;padding-right:0}.rtl .as-modal.as-modal-license-key-resend .as-modal-body .button-container{float:left;margin-right:7px;margin-left:0}a.show-license-resend-modal{margin-top:4px;display:inline-block}.as-ajax-loader{position:relative;width:170px;height:20px;margin:auto}.as-ajax-loader .as-ajax-loader-bar{position:absolute;top:0;background-color:#0074a3;width:20px;height:20px;-webkit-animation-name:bounce_ajaxLoader;-moz-animation-name:bounce_ajaxLoader;-ms-animation-name:bounce_ajaxLoader;-o-animation-name:bounce_ajaxLoader;animation-name:bounce_ajaxLoader;-webkit-animation-duration:1.5s;-moz-animation-duration:1.5s;-ms-animation-duration:1.5s;-o-animation-duration:1.5s;animation-duration:1.5s;animation-iteration-count:infinite;-o-animation-iteration-count:infinite;-ms-animation-iteration-count:infinite;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;-webkit-animation-direction:normal;-moz-animation-direction:normal;-ms-animation-direction:normal;-o-animation-direction:normal;animation-direction:normal;-moz-transform:0.3;-o-transform:0.3;-ms-transform:0.3;-webkit-transform:0.3;transform:0.3}.as-ajax-loader .as-ajax-loader-bar-1{left:0px;animation-delay:0.6s;-o-animation-delay:0.6s;-ms-animation-delay:0.6s;-webkit-animation-delay:0.6s;-moz-animation-delay:0.6s}.as-ajax-loader .as-ajax-loader-bar-2{left:19px;animation-delay:0.75s;-o-animation-delay:0.75s;-ms-animation-delay:0.75s;-webkit-animation-delay:0.75s;-moz-animation-delay:0.75s}.as-ajax-loader .as-ajax-loader-bar-3{left:38px;animation-delay:0.9s;-o-animation-delay:0.9s;-ms-animation-delay:0.9s;-webkit-animation-delay:0.9s;-moz-animation-delay:0.9s}.as-ajax-loader .as-ajax-loader-bar-4{left:57px;animation-delay:1.05s;-o-animation-delay:1.05s;-ms-animation-delay:1.05s;-webkit-animation-delay:1.05s;-moz-animation-delay:1.05s}.as-ajax-loader .as-ajax-loader-bar-5{left:76px;animation-delay:1.2s;-o-animation-delay:1.2s;-ms-animation-delay:1.2s;-webkit-animation-delay:1.2s;-moz-animation-delay:1.2s}.as-ajax-loader .as-ajax-loader-bar-6{left:95px;animation-delay:1.35s;-o-animation-delay:1.35s;-ms-animation-delay:1.35s;-webkit-animation-delay:1.35s;-moz-animation-delay:1.35s}.as-ajax-loader .as-ajax-loader-bar-7{left:114px;animation-delay:1.5s;-o-animation-delay:1.5s;-ms-animation-delay:1.5s;-webkit-animation-delay:1.5s;-moz-animation-delay:1.5s}.as-ajax-loader .as-ajax-loader-bar-8{left:133px;animation-delay:1.65s;-o-animation-delay:1.65s;-ms-animation-delay:1.65s;-webkit-animation-delay:1.65s;-moz-animation-delay:1.65s}@-moz-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-ms-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-o-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-webkit-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}.as-modal-auto-install #request-filesystem-credentials-form h2,.as-modal-auto-install #request-filesystem-credentials-form .request-filesystem-credentials-action-buttons{display:none}.as-modal-auto-install #request-filesystem-credentials-form input[type=password],.as-modal-auto-install #request-filesystem-credentials-form input[type=email],.as-modal-auto-install #request-filesystem-credentials-form input[type=text]{-webkit-appearance:none;padding:10px 10px 5px 10px;width:300px;max-width:100%}.as-modal-auto-install #request-filesystem-credentials-form>div,.as-modal-auto-install #request-filesystem-credentials-form label,.as-modal-auto-install #request-filesystem-credentials-form fieldset{width:300px;max-width:100%;margin:0 auto;display:block}.button-primary.warn{box-shadow:0 1px 0 #d2593c;text-shadow:0 -1px 1px #d2593c,1px 0 1px #d2593c,0 1px 1px #d2593c,-1px 0 1px #d2593c;background:#f56a48;border-color:#ec6544 #d2593c #d2593c}.button-primary.warn:hover{background:#fd6d4a;border-color:#d2593c}.button-primary.warn:focus{box-shadow:0 1px 0 #dd6041,0 0 2px 1px #e4a796}.button-primary.warn:active{background:#dd6041;border-color:#d2593c;box-shadow:inset 0 2px 0 #d2593c}.button-primary.warn.disabled{color:#f5b3a1 !important;background:#e76444 !important;border-color:#d85e40 !important;text-shadow:0 -1px 0 rgba(0,0,0,0.1) !important}
|
analytics/config.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Analytics Configurations.
|
4 |
+
*
|
5 |
+
* @package Analytics
|
6 |
+
* @copyright Copyright (c) 2019, CyberChimps, Inc.
|
7 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
8 |
+
* @since 1.0.0
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
|
15 |
+
define( 'WP_STAT__DOMAIN_PRODUCTION', 'feedback.cyberchimps.com' );
|
16 |
+
define( 'WP_STAT__ADDRESS_PRODUCTION', 'https://' . WP_STAT__DOMAIN_PRODUCTION );
|
17 |
+
|
18 |
+
if ( ! defined( 'WP_STAT__ADDRESS' ) ) {
|
19 |
+
define( 'WP_STAT__ADDRESS', ( WP_STAT__ADDRESS_PRODUCTION ) );
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Module types
|
24 |
+
*
|
25 |
+
* @since 1.0.0
|
26 |
+
*/
|
27 |
+
define( 'WP_STAT__MODULE_TYPE_PLUGIN', 'plugin' );
|
28 |
+
define( 'WP_STAT__MODULE_TYPE_THEME', 'theme' );
|
29 |
+
|
30 |
+
if ( ! defined( 'WP_CYB__DEFAULT_PRIORITY' ) ) {
|
31 |
+
define( 'WP_CYB__DEFAULT_PRIORITY', 10 );
|
32 |
+
}
|
33 |
+
|
34 |
+
// Directories.
|
35 |
+
if ( ! defined( 'WP_STAT__DIR' ) ) {
|
36 |
+
define( 'WP_STAT__DIR', dirname( __FILE__ ) );
|
37 |
+
}
|
38 |
+
if ( ! defined( 'WP_STAT__DIR_INCLUDES' ) ) {
|
39 |
+
define( 'WP_STAT__DIR_INCLUDES', WP_STAT__DIR . '/includes' );
|
40 |
+
}
|
41 |
+
if ( ! defined( 'WP_STAT__DIR_TEMPLATES' ) ) {
|
42 |
+
define( 'WP_STAT__DIR_TEMPLATES', WP_STAT__DIR . '/templates' );
|
43 |
+
}
|
44 |
+
if ( ! defined( 'WP_STAT__DIR_TEMPLATES' ) ) {
|
45 |
+
define( 'WP_STAT__DIR_TEMPLATES', WP_STAT__DIR . '/templates' );
|
46 |
+
}
|
47 |
+
if ( ! defined( 'WP_STAT__DIR_ASSETS' ) ) {
|
48 |
+
define( 'WP_STAT__DIR_ASSETS', WP_STAT__DIR . '/assets' );
|
49 |
+
}
|
50 |
+
if ( ! defined( 'WP_STAT__DIR_CSS' ) ) {
|
51 |
+
define( 'WP_STAT__DIR_CSS', WP_STAT__DIR_ASSETS . '/css' );
|
52 |
+
}
|
53 |
+
if ( ! defined( 'WP_STAT__DIR_JS' ) ) {
|
54 |
+
define( 'WP_STAT__DIR_JS', WP_STAT__DIR_ASSETS . '/js' );
|
55 |
+
}
|
56 |
+
if ( ! defined( 'WP_STAT__DIR_IMG' ) ) {
|
57 |
+
define( 'WP_STAT__DIR_IMG', WP_STAT__DIR_ASSETS . '/img' );
|
58 |
+
}
|
59 |
+
if ( ! defined( 'WP_STAT__DIR_SDK' ) ) {
|
60 |
+
define( 'WP_STAT__DIR_SDK', WP_STAT__DIR_INCLUDES . '/sdk' );
|
61 |
+
}
|
analytics/includes/analytics-core-functions.php
ADDED
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Analytics Core functions.
|
4 |
+
*
|
5 |
+
* @package Analytics
|
6 |
+
* @copyright Copyright (c) 2019, CyberChimps, Inc.
|
7 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
8 |
+
* @since 1.0.0
|
9 |
+
*/
|
10 |
+
|
11 |
+
/*
|
12 |
+
Templates / Views.
|
13 |
+
--------------------------------------------------------------------------------------------
|
14 |
+
*/
|
15 |
+
if ( ! function_exists( 'as_get_template_path' ) ) {
|
16 |
+
/**
|
17 |
+
* Get analytics template path
|
18 |
+
*
|
19 |
+
* @param string $path template path.
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
function as_get_template_path( $path ) {
|
23 |
+
return WP_STAT__DIR_TEMPLATES . '/' . trim( $path, '/' );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Include template.
|
28 |
+
*
|
29 |
+
* @param string $path Path.
|
30 |
+
* @param null $params Parameters.
|
31 |
+
*/
|
32 |
+
function as_include_template( $path, &$params = null ) {
|
33 |
+
$VARS = &$params;
|
34 |
+
include as_get_template_path( $path );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Include once.
|
39 |
+
*
|
40 |
+
* @param string $path Path.
|
41 |
+
* @param null $params Parameters.
|
42 |
+
*/
|
43 |
+
function as_include_once_template( $path, &$params = null ) {
|
44 |
+
$VARS = &$params;
|
45 |
+
include_once as_get_template_path( $path );
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Require template.
|
50 |
+
*
|
51 |
+
* @param string $path Path.
|
52 |
+
* @param array $params Parameters.
|
53 |
+
*/
|
54 |
+
function as_require_template( $path, &$params = null ) {
|
55 |
+
$VARS = &$params;
|
56 |
+
require as_get_template_path( $path );
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Require once.
|
61 |
+
*
|
62 |
+
* @param string $path Path.
|
63 |
+
* @param array $params Parameters.
|
64 |
+
*/
|
65 |
+
function as_require_once_template( $path, &$params = null ) {
|
66 |
+
$VARS = &$params;
|
67 |
+
require_once as_get_template_path( $path );
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Get Template.
|
72 |
+
*
|
73 |
+
* @param string $path Path.
|
74 |
+
* @param array $params Parameters.
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
function as_get_template( $path, &$params = null ) {
|
78 |
+
ob_start();
|
79 |
+
|
80 |
+
$VARS = &$params;
|
81 |
+
require as_get_template_path( $path );
|
82 |
+
|
83 |
+
return ob_get_clean();
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
if ( ! function_exists( 'as_request_get' ) ) {
|
88 |
+
/**
|
89 |
+
* A helper method to fetch GET/POST user input.
|
90 |
+
*
|
91 |
+
* @author CyberChimps
|
92 |
+
*
|
93 |
+
* @param string $key Key.
|
94 |
+
* @param mixed $def Defined.
|
95 |
+
* @param string|bool $type Type.
|
96 |
+
*
|
97 |
+
* @return mixed
|
98 |
+
*/
|
99 |
+
function as_request_get( $key, $def = false, $type = false ) {
|
100 |
+
if ( is_string( $type ) ) {
|
101 |
+
$type = strtolower( $type );
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Helper method to fetch GET/POST user input.
|
106 |
+
*/
|
107 |
+
switch ( $type ) {
|
108 |
+
case 'post':
|
109 |
+
$value = isset( $_POST[ $key ] ) ? $_POST[ $key ] : $def;
|
110 |
+
break;
|
111 |
+
case 'get':
|
112 |
+
$value = isset( $_GET[ $key ] ) ? $_GET[ $key ] : $def;
|
113 |
+
break;
|
114 |
+
default:
|
115 |
+
$value = isset( $_REQUEST[ $key ] ) ? $_REQUEST[ $key ] : $def;
|
116 |
+
break;
|
117 |
+
}
|
118 |
+
|
119 |
+
return $value;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
if ( ! function_exists( 'as_request_get_bool' ) ) {
|
124 |
+
/**
|
125 |
+
* Fetch GET/POST user boolean input
|
126 |
+
*
|
127 |
+
* @author CyberChimps
|
128 |
+
*
|
129 |
+
* @param string $key Key.
|
130 |
+
* @param bool $def Defined.
|
131 |
+
*
|
132 |
+
* @return bool|mixed
|
133 |
+
*/
|
134 |
+
function as_request_get_bool( $key, $def = false ) {
|
135 |
+
$val = as_request_get( $key, null );
|
136 |
+
|
137 |
+
if ( is_null( $val ) ) {
|
138 |
+
return $def;
|
139 |
+
}
|
140 |
+
|
141 |
+
if ( is_bool( $val ) ) {
|
142 |
+
return $val;
|
143 |
+
} elseif ( is_numeric( $val ) ) {
|
144 |
+
if ( 1 === $val ) {
|
145 |
+
return true;
|
146 |
+
} elseif ( 0 === $val ) {
|
147 |
+
return false;
|
148 |
+
}
|
149 |
+
} elseif ( is_string( $val ) ) {
|
150 |
+
$val = strtolower( $val );
|
151 |
+
|
152 |
+
if ( 'true' === $val ) {
|
153 |
+
return true;
|
154 |
+
} elseif ( 'false' === $val ) {
|
155 |
+
return false;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
return $def;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
if ( ! function_exists( 'as_get_raw_referer' ) ) {
|
164 |
+
/**
|
165 |
+
* Retrieves unvalidated referer from '_wp_http_referer'
|
166 |
+
*
|
167 |
+
* @since 1.0.0
|
168 |
+
*
|
169 |
+
* @return string|false Referer URL on success, false on failure.
|
170 |
+
*/
|
171 |
+
function as_get_raw_referer() {
|
172 |
+
if ( function_exists( 'wp_get_raw_referer' ) ) {
|
173 |
+
return wp_get_raw_referer();
|
174 |
+
}
|
175 |
+
if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
176 |
+
return wp_unslash( $_REQUEST['_wp_http_referer'] );
|
177 |
+
} elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
|
178 |
+
return wp_unslash( $_SERVER['HTTP_REFERER'] );
|
179 |
+
}
|
180 |
+
|
181 |
+
return false;
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
if ( ! function_exists( 'as_asset_url' ) ) {
|
186 |
+
/**
|
187 |
+
* Generates an absolute URL to the given path. This function ensures that the URL will be correct whether the asset
|
188 |
+
* is inside a plugin's folder or a theme's folder.
|
189 |
+
*
|
190 |
+
* Examples:
|
191 |
+
* 1. "themes" folder
|
192 |
+
* Path: C:/xampp/htdocs/fswp/wp-content/themes/twentytwelve/analytics/assets/css/admin/common.css
|
193 |
+
* URL: http://awp:8080/wp-content/themes/twentytwelve/analytics/assets/css/admin/common.css
|
194 |
+
*
|
195 |
+
* 2. "plugins" folder
|
196 |
+
* Path: C:/xampp/htdocs/fswp/wp-content/plugins/rating-widget-premium/analytics/assets/css/admin/common.css
|
197 |
+
* URL: http://awp:8080/wp-content/plugins/rating-widget-premium/analytics/assets/css/admin/common.css
|
198 |
+
*
|
199 |
+
* @author CyberChimps
|
200 |
+
* @since 1.0.0
|
201 |
+
*
|
202 |
+
* @param string $asset_abs_path Asset's absolute path.
|
203 |
+
*
|
204 |
+
* @return string Asset's URL.
|
205 |
+
*/
|
206 |
+
function as_asset_url( $asset_abs_path ) {
|
207 |
+
$wp_content_dir = as_normalize_path( WP_CONTENT_DIR );
|
208 |
+
$asset_abs_path = as_normalize_path( $asset_abs_path );
|
209 |
+
|
210 |
+
if ( 0 === strpos( $asset_abs_path, $wp_content_dir ) ) {
|
211 |
+
// Handle both theme and plugin assets located in the standard directories.
|
212 |
+
$asset_rel_path = str_replace( $wp_content_dir, '', $asset_abs_path );
|
213 |
+
$asset_url = content_url( as_normalize_path( $asset_rel_path ) );
|
214 |
+
} else {
|
215 |
+
$wp_plugins_dir = as_normalize_path( WP_PLUGIN_DIR );
|
216 |
+
if ( 0 === strpos( $asset_abs_path, $wp_plugins_dir ) ) {
|
217 |
+
// Try to handle plugin assets that may be located in a non-standard plugins directory.
|
218 |
+
$asset_rel_path = str_replace( $wp_plugins_dir, '', $asset_abs_path );
|
219 |
+
$asset_url = plugins_url( as_normalize_path( $asset_rel_path ) );
|
220 |
+
} else {
|
221 |
+
// Try to handle theme assets that may be located in a non-standard themes directory.
|
222 |
+
$active_theme_stylesheet = get_stylesheet();
|
223 |
+
$wp_themes_dir = as_normalize_path( trailingslashit( get_theme_root( $active_theme_stylesheet ) ) );
|
224 |
+
$asset_rel_path = str_replace( $wp_themes_dir, '', as_normalize_path( $asset_abs_path ) );
|
225 |
+
$asset_url = trailingslashit( get_theme_root_uri( $active_theme_stylesheet ) ) . as_normalize_path( $asset_rel_path );
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
return $asset_url;
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
if ( ! function_exists( 'as_enqueue_local_style' ) ) {
|
234 |
+
/**
|
235 |
+
* Enqueue Local style.
|
236 |
+
*
|
237 |
+
* @param string $handle Handle.
|
238 |
+
* @param string $path Path.
|
239 |
+
* @param array $deps Dependencies.
|
240 |
+
* @param bool $ver Version.
|
241 |
+
* @param string $media Media.
|
242 |
+
*/
|
243 |
+
function as_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) {
|
244 |
+
wp_enqueue_style( $handle, as_asset_url( WP_STAT__DIR_CSS . '/' . trim( $path, '/' ) ), $deps, $ver, $media );
|
245 |
+
}
|
246 |
+
}
|
analytics/includes/analytics-essential-functions.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Analytics Essentials functions.
|
4 |
+
*
|
5 |
+
* @package Analytics
|
6 |
+
* @copyright Copyright (c) 2019, CyberChimps, Inc.
|
7 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
8 |
+
* @since 1.0.0
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! function_exists( 'as_normalize_path' ) ) {
|
12 |
+
/**
|
13 |
+
* Normalize path.
|
14 |
+
*
|
15 |
+
* @param string $path Path.
|
16 |
+
* @return mixed|string|string[]|null
|
17 |
+
*/
|
18 |
+
function as_normalize_path( $path ) {
|
19 |
+
if ( function_exists( 'wp_normalize_path' ) ) {
|
20 |
+
return wp_normalize_path( $path );
|
21 |
+
} else {
|
22 |
+
$path = str_replace( '\\', '/', $path );
|
23 |
+
$path = preg_replace( '|/+|', '/', $path );
|
24 |
+
|
25 |
+
return $path;
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|
analytics/includes/class-analytics.php
ADDED
@@ -0,0 +1,782 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Analytics Class.
|
4 |
+
*
|
5 |
+
* @package Analytics
|
6 |
+
* @copyright Copyright (c) 2019, CyberChimps, Inc.
|
7 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
8 |
+
* @since 1.0.0
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Class Analytics.
|
17 |
+
*/
|
18 |
+
class Analytics {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Analytics Instance
|
22 |
+
*
|
23 |
+
* @var Analytics[]
|
24 |
+
*/
|
25 |
+
private static $_instances = array();
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Statics Loaded.
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
*
|
32 |
+
* @var bool
|
33 |
+
*/
|
34 |
+
private static $_statics_loaded = false;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Module Type.
|
38 |
+
*
|
39 |
+
* @since 1.0.0
|
40 |
+
*
|
41 |
+
* @var string
|
42 |
+
*/
|
43 |
+
private $_module_type;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Module Id.
|
47 |
+
*
|
48 |
+
* @since 1.0.0
|
49 |
+
*
|
50 |
+
* @var number
|
51 |
+
*/
|
52 |
+
private $_module_id;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Plugin BaseName.
|
56 |
+
*
|
57 |
+
* @since 1.0.0
|
58 |
+
*
|
59 |
+
* @var string
|
60 |
+
*/
|
61 |
+
private $_plugin_basename;
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Current page.
|
65 |
+
*
|
66 |
+
* @author CyberChimps
|
67 |
+
* @since 1.0.0
|
68 |
+
*
|
69 |
+
* @var string
|
70 |
+
*/
|
71 |
+
private static $_pagenow;
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Product Version.
|
75 |
+
*
|
76 |
+
* @since 1.0.0
|
77 |
+
*
|
78 |
+
* @var string
|
79 |
+
*/
|
80 |
+
private $_version = false;
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Product Name.
|
84 |
+
*
|
85 |
+
* @since 1.0.0
|
86 |
+
*
|
87 |
+
* @var string
|
88 |
+
*/
|
89 |
+
private $_product_name;
|
90 |
+
|
91 |
+
const REASON_OTHER = 8;
|
92 |
+
const REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION = 9;
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Main singleton instance.
|
96 |
+
*
|
97 |
+
* @author CyberChimps
|
98 |
+
* @since 1.0.0
|
99 |
+
*
|
100 |
+
* @param number $module_id Module Id.
|
101 |
+
* @param string|bool $slug Slug.
|
102 |
+
* @param string $product_name Product Name.
|
103 |
+
* @param string $version Product Version.
|
104 |
+
* @param string $module_type Module Type.
|
105 |
+
*/
|
106 |
+
private function __construct( $module_id, $slug = false, $product_name, $version, $module_type, $plugin_basename = '' ) {
|
107 |
+
$this->_module_id = $module_id;
|
108 |
+
$this->_slug = $slug;
|
109 |
+
$this->_module_type = $module_type;
|
110 |
+
$this->_product_name = $product_name;
|
111 |
+
$this->_version = $version;
|
112 |
+
if ( '' !== $plugin_basename ) {
|
113 |
+
$this->_plugin_basename = $plugin_basename;
|
114 |
+
}
|
115 |
+
|
116 |
+
$this->_blog_id = is_multisite() ? get_current_blog_id() : null;
|
117 |
+
|
118 |
+
$this->register_constructor_hooks();
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Main singleton instance.
|
123 |
+
*
|
124 |
+
* @author CyberChimps
|
125 |
+
* @since 1.0.0
|
126 |
+
*
|
127 |
+
* @param number $module_id Module Id.
|
128 |
+
* @param string|bool $slug Slug.
|
129 |
+
* @param string $product_name Product Name.
|
130 |
+
* @param string $version Product Version.
|
131 |
+
* @param string $module_type Module Type.
|
132 |
+
*
|
133 |
+
* @return Analytics|false
|
134 |
+
*/
|
135 |
+
static function instance( $module_id, $slug = false, $product_name, $version, $module_type, $plugin_basename = '' ) {
|
136 |
+
if ( empty( $module_id ) ) {
|
137 |
+
return false;
|
138 |
+
}
|
139 |
+
|
140 |
+
$key = 'm_' . $slug;
|
141 |
+
|
142 |
+
self::$_instances[ $key ] = new Analytics( $module_id, $slug, $product_name, $version, $module_type, $plugin_basename );
|
143 |
+
|
144 |
+
return self::$_instances[ $key ];
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Load resources.
|
149 |
+
*
|
150 |
+
* @author CyberChimps
|
151 |
+
* @since 1.0.0
|
152 |
+
*/
|
153 |
+
private static function _load_required_static() {
|
154 |
+
if ( self::$_statics_loaded ) {
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
|
158 |
+
if ( 0 === did_action( 'plugins_loaded' ) ) {
|
159 |
+
add_action( 'plugins_loaded', array( 'Analytics', '_load_textdomain' ), 1 );
|
160 |
+
}
|
161 |
+
|
162 |
+
self::$_statics_loaded = true;
|
163 |
+
}
|
164 |
+
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Dynamic initiator
|
168 |
+
*
|
169 |
+
* @author CyberChimps
|
170 |
+
* @since 1.0.0
|
171 |
+
*
|
172 |
+
* @param array $plugin_info Plugin Info.
|
173 |
+
*
|
174 |
+
* @throws Analytics_Exception Analytics Exception.
|
175 |
+
*/
|
176 |
+
public function dynamic_init( array $plugin_info ) {
|
177 |
+
|
178 |
+
if ( $this->should_stop_execution() ) {
|
179 |
+
return;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Register Constructor Hooks.
|
185 |
+
*
|
186 |
+
* @author CyberChimps
|
187 |
+
* @since 1.0.0
|
188 |
+
*/
|
189 |
+
private function register_constructor_hooks() {
|
190 |
+
|
191 |
+
if ( is_admin() ) {
|
192 |
+
add_action( 'admin_init', array( &$this, '_hook_action_links_and_register_account_hooks' ) );
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Checks if the current user can activate plugins or switch themes.
|
198 |
+
*
|
199 |
+
* @author CyberChimps
|
200 |
+
* @since 1.0.0
|
201 |
+
*
|
202 |
+
* @return bool
|
203 |
+
*/
|
204 |
+
function is_user_admin() {
|
205 |
+
|
206 |
+
return ( $this->is_plugin() && current_user_can( is_multisite() ? 'manage_options' : 'activate_plugins' ) )
|
207 |
+
|| ( $this->is_theme() && current_user_can( 'switch_themes' ) );
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Checks if the module type is "theme". The other type is "plugin".
|
212 |
+
*
|
213 |
+
* @author CyberChimps
|
214 |
+
* @since 1.0.0
|
215 |
+
*
|
216 |
+
* @return bool
|
217 |
+
*/
|
218 |
+
public function is_theme() {
|
219 |
+
return ( ! $this->is_plugin() );
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Get Slug.
|
224 |
+
*
|
225 |
+
* @author CyberChimps
|
226 |
+
* @since 1.0.0
|
227 |
+
*
|
228 |
+
* @return string Plugin slug.
|
229 |
+
*/
|
230 |
+
public function get_slug() {
|
231 |
+
|
232 |
+
return $this->_slug;
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Keep Watch.
|
237 |
+
*
|
238 |
+
* @author CyberChimps
|
239 |
+
* @since 1.0.0
|
240 |
+
*
|
241 |
+
* @return bool
|
242 |
+
*/
|
243 |
+
private function should_stop_execution() {
|
244 |
+
|
245 |
+
if ( $this->is_activation_mode() ) {
|
246 |
+
if ( ! is_admin() ) {
|
247 |
+
/**
|
248 |
+
* If in activation mode, don't execute Analytics outside of the
|
249 |
+
* admin dashboard.
|
250 |
+
*
|
251 |
+
* @author CyberChimps
|
252 |
+
* @since 1.0.0
|
253 |
+
*/
|
254 |
+
return true;
|
255 |
+
}
|
256 |
+
|
257 |
+
if ( self::is_ajax()
|
258 |
+
) {
|
259 |
+
/**
|
260 |
+
* During activation, if running in AJAX mode, unless there's a sticky
|
261 |
+
* connectivity issue notice, don't run Analytics.
|
262 |
+
*
|
263 |
+
* @author CyberChimps
|
264 |
+
* @since 1.0.0
|
265 |
+
*/
|
266 |
+
return true;
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
return false;
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Is plugin in activation mode.
|
275 |
+
*
|
276 |
+
* @author CyberChimps
|
277 |
+
* @since 1.0.0
|
278 |
+
*
|
279 |
+
* @param bool $and_on And ON.
|
280 |
+
*
|
281 |
+
* @return bool
|
282 |
+
*/
|
283 |
+
public function is_activation_mode( $and_on = true ) {
|
284 |
+
return true;
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Check if a real user is visiting the admin dashboard.
|
289 |
+
*
|
290 |
+
* @author CyberChimps
|
291 |
+
* @since 1.0.0
|
292 |
+
*
|
293 |
+
* @return bool
|
294 |
+
*/
|
295 |
+
public function is_user_in_admin() {
|
296 |
+
return is_admin();
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Get Option
|
301 |
+
*
|
302 |
+
* @param string[] $options Options.
|
303 |
+
* @param string $key Key.
|
304 |
+
* @param mixed $default Default.
|
305 |
+
*
|
306 |
+
* @return bool
|
307 |
+
*/
|
308 |
+
private function get_option( &$options, $key, $default = false ) {
|
309 |
+
return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Get Boolean Option.
|
314 |
+
*
|
315 |
+
* @param array $options Options.
|
316 |
+
* @param string $key Key.
|
317 |
+
* @param bool $default Default.
|
318 |
+
* @return bool|mixed
|
319 |
+
*/
|
320 |
+
private function get_bool_option( &$options, $key, $default = false ) {
|
321 |
+
return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
|
322 |
+
}
|
323 |
+
/**
|
324 |
+
* Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
|
325 |
+
* page.
|
326 |
+
*
|
327 |
+
* @author CyberChimps
|
328 |
+
*
|
329 |
+
* @since 1.0.0
|
330 |
+
*/
|
331 |
+
public function _add_deactivation_feedback_dialog_box() {
|
332 |
+
|
333 |
+
$show_deactivation_feedback_form = true;
|
334 |
+
|
335 |
+
$vars = array(
|
336 |
+
'id' => $this->_module_id,
|
337 |
+
'slug' => $this->_slug,
|
338 |
+
'product_name' => $this->_product_name,
|
339 |
+
'version' => $this->_version,
|
340 |
+
'module_type' => $this->_module_type,
|
341 |
+
);
|
342 |
+
|
343 |
+
if ( $show_deactivation_feedback_form ) {
|
344 |
+
/*
|
345 |
+
Check the type of user:
|
346 |
+
* 1. Long-term (long-term)
|
347 |
+
* 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).
|
348 |
+
* 3. Short-term (short-term)
|
349 |
+
*/
|
350 |
+
|
351 |
+
$is_long_term_user = true;
|
352 |
+
|
353 |
+
if ( $is_long_term_user ) {
|
354 |
+
$user_type = 'long-term';
|
355 |
+
} else {
|
356 |
+
if ( ! $this->is_registered() && ! $this->is_anonymous() ) {
|
357 |
+
$user_type = 'non-registered-and-non-anonymous-short-term';
|
358 |
+
} else {
|
359 |
+
$user_type = 'short-term';
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
$uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
|
364 |
+
|
365 |
+
$vars['reasons'] = $uninstall_reasons;
|
366 |
+
}
|
367 |
+
$uninstall_confirmation_message = apply_filters( 'uninstall_confirmation_message', '' );
|
368 |
+
|
369 |
+
$vars['show_deactivation_feedback_form'] = $show_deactivation_feedback_form;
|
370 |
+
$vars['uninstall_confirmation_message'] = $uninstall_confirmation_message;
|
371 |
+
|
372 |
+
/**
|
373 |
+
* Load the HTML template for the deactivation feedback dialog box.
|
374 |
+
*/
|
375 |
+
as_require_template( 'forms/deactivation/form.php', $vars );
|
376 |
+
}
|
377 |
+
|
378 |
+
/**
|
379 |
+
* Get Uninstall Reasons.
|
380 |
+
*
|
381 |
+
* @author CyberChimps
|
382 |
+
* @since 1.0.0
|
383 |
+
*
|
384 |
+
* @param string $user_type User Type.
|
385 |
+
*
|
386 |
+
* @return array The uninstall reasons for the specified user type.
|
387 |
+
*/
|
388 |
+
public function _get_uninstall_reasons( $user_type = 'long-term' ) {
|
389 |
+
|
390 |
+
$params = array();
|
391 |
+
$params['module_type'] = $this->_module_type;
|
392 |
+
|
393 |
+
if ( false === get_transient( $this->_module_type . '_uninstall_reasons' ) ) {
|
394 |
+
$request = array(
|
395 |
+
'method' => 'GET',
|
396 |
+
'body' => $params,
|
397 |
+
'timeout' => 30,
|
398 |
+
);
|
399 |
+
|
400 |
+
$url = esc_url( WP_STAT__ADDRESS . '/wp-json/uninstall/reason/theme/' );
|
401 |
+
$response = wp_remote_get( $url, $request );
|
402 |
+
|
403 |
+
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
404 |
+
$uninstall_reasons = $this->get_default_uninstall_reasons( $params );
|
405 |
+
} else {
|
406 |
+
$uninstall_reasons = json_decode( $response['body'], true );
|
407 |
+
}
|
408 |
+
|
409 |
+
set_transient( $this->_module_type . '_uninstall_reasons', $uninstall_reasons, 60 * 60 * 24 );
|
410 |
+
} else {
|
411 |
+
|
412 |
+
$uninstall_reasons = get_transient( $this->_module_type . '_uninstall_reasons' );
|
413 |
+
}
|
414 |
+
return $uninstall_reasons;
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Get Default uninstall reasons
|
419 |
+
*
|
420 |
+
* @param array $params Parameters
|
421 |
+
* @return array
|
422 |
+
*/
|
423 |
+
public function get_default_uninstall_reasons( $params = array() ) {
|
424 |
+
$module_type = $params['module_type'];
|
425 |
+
|
426 |
+
$deactivation_reasons = array(
|
427 |
+
array(
|
428 |
+
'id' => 1,
|
429 |
+
'text' => "I couldn't understand how to make it workkkkkkkkkk",
|
430 |
+
'input_type' => '',
|
431 |
+
'input_placeholder' => '',
|
432 |
+
),
|
433 |
+
array(
|
434 |
+
'id' => 2,
|
435 |
+
'text' => sprintf( "The %s is great, but I need specific feature that you don't support", $module_type ),
|
436 |
+
'input_type' => 'textarea',
|
437 |
+
'input_placeholder' => 'What feature?',
|
438 |
+
),
|
439 |
+
array(
|
440 |
+
'id' => 3,
|
441 |
+
'text' => sprintf( 'The %s is not working', $module_type ),
|
442 |
+
'input_type' => 'textarea',
|
443 |
+
'input_placeholder' => "Kindly share what didn't work so we can fix it for future users...",
|
444 |
+
),
|
445 |
+
array(
|
446 |
+
'id' => 4,
|
447 |
+
'text' => "It's not what I was looking for",
|
448 |
+
'input_type' => 'textarea',
|
449 |
+
'input_placeholder' => "What you've been looking for?",
|
450 |
+
),
|
451 |
+
array(
|
452 |
+
'id' => 5,
|
453 |
+
'text' => sprintf( "The %s didn't work as expected", $module_type ),
|
454 |
+
'input_type' => 'textarea',
|
455 |
+
'input_placeholder' => 'What did you expect?',
|
456 |
+
),
|
457 |
+
array(
|
458 |
+
'id' => 6,
|
459 |
+
'text' => sprintf( 'I found a better %s', $module_type ),
|
460 |
+
'input_type' => 'textfield',
|
461 |
+
'input_placeholder' => sprintf( "What's the %s's name?", $module_type ),
|
462 |
+
),
|
463 |
+
array(
|
464 |
+
'id' => 7,
|
465 |
+
'text' => sprintf( "It's a temporary %s switch. I'm just debugging an issue.", $module_type ),
|
466 |
+
'input_type' => '',
|
467 |
+
'input_placeholder' => '',
|
468 |
+
),
|
469 |
+
array(
|
470 |
+
'id' => 8,
|
471 |
+
'text' => 'Other',
|
472 |
+
'input_type' => 'textfield',
|
473 |
+
'input_placeholder' => '',
|
474 |
+
),
|
475 |
+
);
|
476 |
+
return $deactivation_reasons;
|
477 |
+
}
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Checks if the plugin's type is "plugin". The other type is "theme".
|
481 |
+
*
|
482 |
+
* @author CyberChimps
|
483 |
+
* @since 1.0.0
|
484 |
+
*
|
485 |
+
* @return bool
|
486 |
+
*/
|
487 |
+
public function is_plugin() {
|
488 |
+
return ( WP_STAT__MODULE_TYPE_PLUGIN === $this->_module_type );
|
489 |
+
}
|
490 |
+
|
491 |
+
/**
|
492 |
+
* Hook Action links.
|
493 |
+
*
|
494 |
+
* @author CyberChimps
|
495 |
+
* @since 1.0.0
|
496 |
+
*/
|
497 |
+
public function _hook_action_links_and_register_account_hooks() {
|
498 |
+
if ( self::is_plugins_page() && $this->is_plugin() ) {
|
499 |
+
$this->hook_plugin_action_links();
|
500 |
+
}
|
501 |
+
|
502 |
+
$this->_register_account_hooks();
|
503 |
+
}
|
504 |
+
|
505 |
+
/**
|
506 |
+
* Hook to plugin action links filter.
|
507 |
+
*
|
508 |
+
* @author CyberChimps
|
509 |
+
* @since 1.0.0
|
510 |
+
*/
|
511 |
+
private function hook_plugin_action_links() {
|
512 |
+
|
513 |
+
// Add action link to settings page.
|
514 |
+
add_filter(
|
515 |
+
'plugin_action_links_' . $this->_plugin_basename,
|
516 |
+
array(
|
517 |
+
&$this,
|
518 |
+
'_modify_plugin_action_links_hook',
|
519 |
+
),
|
520 |
+
WP_CYB__DEFAULT_PRIORITY,
|
521 |
+
2
|
522 |
+
);
|
523 |
+
add_filter(
|
524 |
+
'network_admin_plugin_action_links_' . $this->_plugin_basename,
|
525 |
+
array(
|
526 |
+
&$this,
|
527 |
+
'_modify_plugin_action_links_hook',
|
528 |
+
),
|
529 |
+
WP_CYB__DEFAULT_PRIORITY,
|
530 |
+
2
|
531 |
+
);
|
532 |
+
}
|
533 |
+
|
534 |
+
/**
|
535 |
+
* Modify plugin's deactivate action links collection.
|
536 |
+
*
|
537 |
+
* @author CyberChimps
|
538 |
+
* @since 1.0.0
|
539 |
+
*
|
540 |
+
* @param array $links
|
541 |
+
* @param $file
|
542 |
+
*
|
543 |
+
* @return array
|
544 |
+
*/
|
545 |
+
function _modify_plugin_action_links_hook( $links, $file ) {
|
546 |
+
|
547 |
+
$passed_deactivate = false;
|
548 |
+
$deactivate_link = '';
|
549 |
+
$before_deactivate = array();
|
550 |
+
$after_deactivate = array();
|
551 |
+
foreach ( $links as $key => $link ) {
|
552 |
+
if ( 'deactivate' === $key ) {
|
553 |
+
$deactivate_link = $link;
|
554 |
+
$passed_deactivate = true;
|
555 |
+
continue;
|
556 |
+
}
|
557 |
+
|
558 |
+
if ( ! $passed_deactivate ) {
|
559 |
+
$before_deactivate[ $key ] = $link;
|
560 |
+
} else {
|
561 |
+
$after_deactivate[ $key ] = $link;
|
562 |
+
}
|
563 |
+
}
|
564 |
+
|
565 |
+
if ( ! empty( $deactivate_link ) ) {
|
566 |
+
/**
|
567 |
+
* HTML to identify the correct plugin
|
568 |
+
*
|
569 |
+
* @since 1.0.0
|
570 |
+
*/
|
571 |
+
$deactivate_link .= '<i class="as-module-slug" data-module-slug="' . $this->_slug . '"></i>';
|
572 |
+
|
573 |
+
// Append deactivation link.
|
574 |
+
$before_deactivate['deactivate'] = $deactivate_link;
|
575 |
+
}
|
576 |
+
|
577 |
+
return array_merge( $before_deactivate, $after_deactivate );
|
578 |
+
}
|
579 |
+
|
580 |
+
/**
|
581 |
+
* Register Account Hooks.
|
582 |
+
*
|
583 |
+
* @author CyberChimps
|
584 |
+
* @since 1.0.0
|
585 |
+
*/
|
586 |
+
private function _register_account_hooks() {
|
587 |
+
if ( ! is_admin() ) {
|
588 |
+
return;
|
589 |
+
}
|
590 |
+
|
591 |
+
/**
|
592 |
+
* Show deactivation form on themes.php page.
|
593 |
+
*
|
594 |
+
* @since 1.0.0
|
595 |
+
*/
|
596 |
+
add_action( 'wp_ajax_submit_uninstall_reason', array( &$this, '_submit_uninstall_reason_action' ) );
|
597 |
+
|
598 |
+
if ( ( $this->is_theme() && self::is_themes_page() ||
|
599 |
+
( $this->is_plugin() && self::is_plugins_page() ) )
|
600 |
+
) {
|
601 |
+
add_action( 'admin_footer', array( &$this, '_add_deactivation_feedback_dialog_box' ) );
|
602 |
+
}
|
603 |
+
}
|
604 |
+
|
605 |
+
/**
|
606 |
+
* Called after the user has submitted his reason for deactivating the plugin.
|
607 |
+
*
|
608 |
+
* @author CyberChimps
|
609 |
+
* @since 1.0.0
|
610 |
+
*/
|
611 |
+
public function _submit_uninstall_reason_action() {
|
612 |
+
|
613 |
+
$deactivation_reason = as_request_get( 'deactivation_reason' );
|
614 |
+
|
615 |
+
$reason_info = trim( as_request_get( 'reason_info', '' ) );
|
616 |
+
if ( ! empty( $reason_info ) ) {
|
617 |
+
$reason_info = substr( $reason_info, 0, 128 );
|
618 |
+
}
|
619 |
+
|
620 |
+
$reason = array(
|
621 |
+
'deactivation_reason' => $deactivation_reason,
|
622 |
+
'info' => $reason_info,
|
623 |
+
'is_anonymous' => as_request_get_bool( 'is_anonymous' ),
|
624 |
+
);
|
625 |
+
|
626 |
+
$this->_uninstall_plugin_event( false, $reason );
|
627 |
+
|
628 |
+
// Print '1' for successful operation.
|
629 |
+
echo 1;
|
630 |
+
exit;
|
631 |
+
}
|
632 |
+
|
633 |
+
/**
|
634 |
+
* Plugin uninstall hook.
|
635 |
+
*
|
636 |
+
* @author CyberChimps
|
637 |
+
* @since 1.0..
|
638 |
+
*
|
639 |
+
* @param bool $check_user User have plugins activation privileges.
|
640 |
+
* @param arrat $reason Reasons.
|
641 |
+
*/
|
642 |
+
public function _uninstall_plugin_event( $check_user = true, $reason = array() ) {
|
643 |
+
|
644 |
+
if ( $check_user && ! current_user_can( 'activate_plugins' ) ) {
|
645 |
+
return;
|
646 |
+
}
|
647 |
+
|
648 |
+
$params = array();
|
649 |
+
|
650 |
+
$current_user = wp_get_current_user();
|
651 |
+
|
652 |
+
if ( isset( $reason ) ) {
|
653 |
+
$params['deactivation_reason'] = $reason['deactivation_reason'];
|
654 |
+
$params['reason_info'] = $reason['info'];
|
655 |
+
$params['platform_version'] = get_bloginfo( 'version' );
|
656 |
+
if ( $reason['is_anonymous'] ) {
|
657 |
+
$params['user_nickname'] = '';
|
658 |
+
$params['user_email'] = '';
|
659 |
+
$params['site_url'] = '';
|
660 |
+
} else {
|
661 |
+
$params['user_nickname'] = $current_user->user_nicename;
|
662 |
+
$params['user_email'] = $current_user->user_email;
|
663 |
+
$params['site_url'] = get_site_url();
|
664 |
+
}
|
665 |
+
$params['slug'] = $this->_slug;
|
666 |
+
$params['product_name'] = $this->_product_name;
|
667 |
+
$params['version'] = $this->_version;
|
668 |
+
$params['module_type'] = $this->_module_type;
|
669 |
+
}
|
670 |
+
|
671 |
+
$request = array(
|
672 |
+
'method' => 'POST',
|
673 |
+
'body' => $params,
|
674 |
+
'timeout' => 30,
|
675 |
+
);
|
676 |
+
|
677 |
+
// Send anonymous uninstall event only if user submitted a feedback.
|
678 |
+
if ( isset( $reason ) ) {
|
679 |
+
$url = esc_url( WP_STAT__ADDRESS . '/wp-json/action/submit/uninstall/reason/' );
|
680 |
+
$response = wp_remote_post( $url, $request );
|
681 |
+
}
|
682 |
+
|
683 |
+
}
|
684 |
+
|
685 |
+
/**
|
686 |
+
* Get current page or the referer if executing a WP AJAX request.
|
687 |
+
*
|
688 |
+
* @author CyberChimps
|
689 |
+
* @since 1.0.0
|
690 |
+
*
|
691 |
+
* @return string
|
692 |
+
*/
|
693 |
+
public static function get_current_page() {
|
694 |
+
if ( ! isset( self::$_pagenow ) ) {
|
695 |
+
global $pagenow;
|
696 |
+
if ( empty( $pagenow ) && is_admin() && is_multisite() ) {
|
697 |
+
/**
|
698 |
+
* It appears that `$pagenow` is not yet initialized in some network admin pages when this method
|
699 |
+
* is called, so initialize it here using some pieces of code from `wp-includes/vars.php`.
|
700 |
+
*
|
701 |
+
* @author CyberChimps
|
702 |
+
* @since 1.0.0
|
703 |
+
*/
|
704 |
+
if ( is_network_admin() ) {
|
705 |
+
preg_match( '#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches );
|
706 |
+
} elseif ( is_user_admin() ) {
|
707 |
+
preg_match( '#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches );
|
708 |
+
} else {
|
709 |
+
preg_match( '#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches );
|
710 |
+
}
|
711 |
+
|
712 |
+
$pagenow = $self_matches[1];
|
713 |
+
$pagenow = trim( $pagenow, '/' );
|
714 |
+
$pagenow = preg_replace( '#\?.*?$#', '', $pagenow );
|
715 |
+
if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) {
|
716 |
+
$pagenow = 'index.php';
|
717 |
+
} else {
|
718 |
+
preg_match( '#(.*?)(/|$)#', $pagenow, $self_matches );
|
719 |
+
$pagenow = strtolower( $self_matches[1] );
|
720 |
+
if ( '.php' !== substr( $pagenow, -4, 4 ) ) {
|
721 |
+
$pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried).
|
722 |
+
}
|
723 |
+
}
|
724 |
+
}
|
725 |
+
|
726 |
+
self::$_pagenow = $pagenow;
|
727 |
+
|
728 |
+
if ( self::is_ajax() &&
|
729 |
+
'admin-ajax.php' === $pagenow
|
730 |
+
) {
|
731 |
+
$referer = as_get_raw_referer();
|
732 |
+
|
733 |
+
if ( is_string( $referer ) ) {
|
734 |
+
$parts = explode( '?', $referer );
|
735 |
+
|
736 |
+
self::$_pagenow = basename( $parts[0] );
|
737 |
+
}
|
738 |
+
}
|
739 |
+
}
|
740 |
+
|
741 |
+
return self::$_pagenow;
|
742 |
+
}
|
743 |
+
|
744 |
+
/**
|
745 |
+
* Check is ajax request
|
746 |
+
*
|
747 |
+
* @author CyberChimps
|
748 |
+
* @since 1.0.0
|
749 |
+
*
|
750 |
+
* @return bool Is running in AJAX call.
|
751 |
+
*
|
752 |
+
* @link http://wordpress.stackexchange.com/questions/70676/how-to-check-if-i-am-in-admin-ajax
|
753 |
+
*/
|
754 |
+
public static function is_ajax() {
|
755 |
+
return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
|
756 |
+
}
|
757 |
+
|
758 |
+
/**
|
759 |
+
* Helper method to check if user in the themes page.
|
760 |
+
*
|
761 |
+
* @author CyberChimps
|
762 |
+
* @since 1.0.0
|
763 |
+
*
|
764 |
+
* @return bool
|
765 |
+
*/
|
766 |
+
public static function is_themes_page() {
|
767 |
+
return ( 'themes.php' === self::get_current_page() );
|
768 |
+
}
|
769 |
+
|
770 |
+
/**
|
771 |
+
* Helper method to check if user in the plugins page.
|
772 |
+
*
|
773 |
+
* @author CyberChimps
|
774 |
+
* @since 1.0.0
|
775 |
+
*
|
776 |
+
* @return bool
|
777 |
+
*/
|
778 |
+
static function is_plugins_page() {
|
779 |
+
return ( 'plugins.php' === self::get_current_page() );
|
780 |
+
}
|
781 |
+
|
782 |
+
}
|
analytics/includes/sdk/Exceptions/Exception.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! class_exists( 'Analytics_Exception' ) ) {
|
3 |
+
/**
|
4 |
+
* Thrown when an API call returns an exception.
|
5 |
+
*/
|
6 |
+
class Analytics_Exception extends Exception {
|
7 |
+
protected $_result;
|
8 |
+
protected $_type;
|
9 |
+
protected $_code;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Make a new API Exception with the given result.
|
13 |
+
*
|
14 |
+
* @param array $result The result from the API server.
|
15 |
+
*/
|
16 |
+
public function __construct( $result ) {
|
17 |
+
$this->_result = $result;
|
18 |
+
|
19 |
+
$code = 0;
|
20 |
+
$message = 'Unknown error, please check GetResult().';
|
21 |
+
$type = '';
|
22 |
+
|
23 |
+
if ( isset( $result['error'] ) && is_array( $result['error'] ) ) {
|
24 |
+
if ( isset( $result['error']['code'] ) ) {
|
25 |
+
$code = $result['error']['code'];
|
26 |
+
}
|
27 |
+
if ( isset( $result['error']['message'] ) ) {
|
28 |
+
$message = $result['error']['message'];
|
29 |
+
}
|
30 |
+
if ( isset( $result['error']['type'] ) ) {
|
31 |
+
$type = $result['error']['type'];
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
$this->_type = $type;
|
36 |
+
$this->_code = $code;
|
37 |
+
|
38 |
+
parent::__construct( $message, is_numeric( $code ) ? $code : 0 );
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Return the associated result object returned by the API server.
|
43 |
+
*
|
44 |
+
* @return array The result from the API server
|
45 |
+
*/
|
46 |
+
public function getResult() {
|
47 |
+
return $this->_result;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getStringCode() {
|
51 |
+
return $this->_code;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getType() {
|
55 |
+
return $this->_type;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* To make debugging easier.
|
60 |
+
*
|
61 |
+
* @return string The string representation of the error
|
62 |
+
*/
|
63 |
+
public function __toString() {
|
64 |
+
$str = $this->getType() . ': ';
|
65 |
+
|
66 |
+
if ( $this->code != 0 ) {
|
67 |
+
$str .= $this->getStringCode() . ': ';
|
68 |
+
}
|
69 |
+
|
70 |
+
return $str . $this->getMessage();
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
analytics/require.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Analytics
|
4 |
+
* @copyright Copyright (c) 2019, CyberChimps, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
+
* @since 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Configuration should be loaded first.
|
10 |
+
require_once dirname( __FILE__ ) . '/config.php';
|
11 |
+
require_once WP_STAT__DIR_INCLUDES . '/analytics-core-functions.php';
|
12 |
+
|
13 |
+
require_once WP_STAT__DIR_INCLUDES . '/sdk/Exceptions/Exception.php';
|
14 |
+
require_once WP_STAT__DIR_INCLUDES . '/class-analytics.php';
|
analytics/start.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Invoke the SDK.
|
4 |
+
*
|
5 |
+
* @package Analytics
|
6 |
+
* @copyright Copyright (c) 2019, CyberChimps, Inc.
|
7 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
8 |
+
* @since 1.0.0
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Analytics SDK Version.
|
17 |
+
*
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
$this_sdk_version = '1.0.0';
|
21 |
+
|
22 |
+
require_once dirname( __FILE__ ) . '/includes/analytics-essential-functions.php';
|
23 |
+
|
24 |
+
if ( ! class_exists( 'Analytics' ) ) {
|
25 |
+
if ( ! defined( 'WP_STAT__SDK_VERSION' ) ) {
|
26 |
+
define( 'WP_STAT__SDK_VERSION', $this_sdk_version );
|
27 |
+
}
|
28 |
+
}
|
29 |
+
// Load SDK files.
|
30 |
+
require_once dirname( __FILE__ ) . '/require.php';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Dynamic Init.
|
34 |
+
*
|
35 |
+
* @param array <string,string> $module Plugin or Theme details.
|
36 |
+
*
|
37 |
+
* @return Analytics
|
38 |
+
*/
|
39 |
+
function ras_dynamic_init( $module ) {
|
40 |
+
if ( ! isset( $module['plugin_basename'] ) ) {
|
41 |
+
$plugin_basename = '';
|
42 |
+
} else {
|
43 |
+
$plugin_basename = $module['plugin_basename'];
|
44 |
+
}
|
45 |
+
$ra = Analytics::instance( $module['id'], $module['slug'], $module['product_name'], $module['version'], $module['module_type'], $plugin_basename );
|
46 |
+
$ra->dynamic_init( $module );
|
47 |
+
|
48 |
+
return $ra;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Quick shortcut to get Analytics for specified plugin.
|
53 |
+
* Used by various templates.
|
54 |
+
*
|
55 |
+
* @param number $module_id Module Id.
|
56 |
+
* @param string $slug Slug.
|
57 |
+
* @param string $product_name Product Name.
|
58 |
+
* @param string $version Product Version.
|
59 |
+
* @param string $module_type Module type.
|
60 |
+
*/
|
61 |
+
function analytics( $module_id, $slug, $product_name, $version, $module_type ) {
|
62 |
+
return Analytics::instance( $module_id, $slug, $product_name, $version, $module_type );
|
63 |
+
}
|
analytics/templates/forms/deactivation/form.php
ADDED
@@ -0,0 +1,439 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Analytics
|
4 |
+
* @copyright Copyright (c) 2019, CyberChimps, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
+
* @since 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
+
exit;
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var array $VARS
|
15 |
+
*/
|
16 |
+
$as = analytics( $VARS['id'], $VARS['slug'], $VARS['product_name'], $VARS['version'], $VARS['module_type'] );
|
17 |
+
$slug = $as->get_slug();
|
18 |
+
|
19 |
+
$show_deactivation_feedback_form = $VARS['show_deactivation_feedback_form'];
|
20 |
+
$confirmation_message = $VARS['uninstall_confirmation_message'];
|
21 |
+
|
22 |
+
$is_anonymous = ( true );
|
23 |
+
$anonymous_feedback_checkbox_html = '';
|
24 |
+
|
25 |
+
$reasons_list_items_html = '';
|
26 |
+
|
27 |
+
if ( $show_deactivation_feedback_form ) {
|
28 |
+
$reasons = $VARS['reasons'];
|
29 |
+
|
30 |
+
foreach ( $reasons as $reason ) {
|
31 |
+
$list_item_classes = 'reason' . ( ! empty( $reason['input_type'] ) ? ' has-input' : '' );
|
32 |
+
|
33 |
+
if ( isset( $reason['internal_message'] ) && ! empty( $reason['internal_message'] ) ) {
|
34 |
+
$list_item_classes .= ' has-internal-message';
|
35 |
+
$reason_internal_message = $reason['internal_message'];
|
36 |
+
} else {
|
37 |
+
$reason_internal_message = '';
|
38 |
+
}
|
39 |
+
|
40 |
+
$reason_input_type = ( ! empty( $reason['input_type'] ) ? $reason['input_type'] : '' );
|
41 |
+
$reason_input_placeholder = ( ! empty( $reason['input_placeholder'] ) ? $reason['input_placeholder'] : '' );
|
42 |
+
|
43 |
+
$reason_list_item_html = <<< HTML
|
44 |
+
<li class="{$list_item_classes}"
|
45 |
+
data-input-type="{$reason_input_type}"
|
46 |
+
data-input-placeholder="{$reason_input_placeholder}">
|
47 |
+
<label>
|
48 |
+
<span>
|
49 |
+
<input type="radio" name="selected-reason" value="{$reason['id']}"/>
|
50 |
+
</span>
|
51 |
+
<span class="deactivation_reason">{$reason['text']}</span>
|
52 |
+
</label>
|
53 |
+
<div class="internal-message">{$reason_internal_message}</div>
|
54 |
+
</li>
|
55 |
+
HTML;
|
56 |
+
|
57 |
+
$reasons_list_items_html .= $reason_list_item_html;
|
58 |
+
}
|
59 |
+
|
60 |
+
if ( $is_anonymous ) {
|
61 |
+
$anonymous_feedback_checkbox_html = sprintf(
|
62 |
+
'<label class="anonymous-feedback-label"><input type="checkbox" class="anonymous-feedback-checkbox"> %s</label>',
|
63 |
+
__( 'Anonymous feedback', 'analytics' )
|
64 |
+
);
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
// Aliases.
|
69 |
+
$deactivate_text = __( 'Deactivate', 'analytics' );
|
70 |
+
$theme_text = __( 'Theme', 'analytics' );
|
71 |
+
$activate_x_text = __( 'Activate %s', 'analytics' );
|
72 |
+
|
73 |
+
as_enqueue_local_style( 'as_dialog_boxes', '/admin/dialog-boxes.css' );
|
74 |
+
?>
|
75 |
+
<script type="text/javascript">
|
76 |
+
(function ($) {
|
77 |
+
var reasonsHtml = <?php echo json_encode( $reasons_list_items_html ); ?>,
|
78 |
+
modalHtml =
|
79 |
+
'<div class="as-modal as-modal-deactivation-feedback<?php echo empty( $confirmation_message ) ? ' no-confirmation-message' : ''; ?>">'
|
80 |
+
+ ' <div class="as-modal-dialog">'
|
81 |
+
+ ' <div class="as-modal-header">'
|
82 |
+
+ ' <h4><?php echo __( 'Quick Feedback', 'analytics' ); ?></h4>'
|
83 |
+
+ ' </div>'
|
84 |
+
+ ' <div class="as-modal-body">'
|
85 |
+
+ ' <div class="as-modal-panel" data-panel-id="confirm"><p><?php echo $confirmation_message; ?></p></div>'
|
86 |
+
+ ' <div class="as-modal-panel active" data-panel-id="reasons"><h3><strong><?php echo esc_js( sprintf( __( 'If you have a moment, please let us know why you are %s', 'analytics' ), ( $as->is_plugin() ? __( 'deactivating', 'analytics' ) : __( 'switching', 'analytics' ) ) ) ); ?>:</strong></h3><ul id="reasons-list">' + reasonsHtml + '</ul></div>'
|
87 |
+
+ ' </div>'
|
88 |
+
+ ' <div class="as-modal-footer">'
|
89 |
+
+ ' <?php echo $anonymous_feedback_checkbox_html; ?>'
|
90 |
+
+ ' <a href="#" class="button button-secondary button-deactivate"></a>'
|
91 |
+
+ ' <a href="#" class="button button-primary button-close"><?php echo __( 'Cancel', 'analytics' ); ?></a>'
|
92 |
+
+ ' </div>'
|
93 |
+
+ ' </div>'
|
94 |
+
+ '</div>',
|
95 |
+
$modal = $(modalHtml),
|
96 |
+
$deactivateLink = $('#the-list .deactivate > [data-module-slug=<?php echo $as->get_slug() ?>].as-module-slug').prev(),
|
97 |
+
selectedReasonID = false,
|
98 |
+
redirectLink = '',
|
99 |
+
$anonymousFeedback = $modal.find( '.anonymous-feedback-label' ),
|
100 |
+
isAnonymous = <?php echo ( $is_anonymous ? 'true' : 'false' ); ?>,
|
101 |
+
otherReasonID = <?php echo Analytics::REASON_OTHER; ?>,
|
102 |
+
dontShareDataReasonID = <?php echo Analytics::REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION; ?>,
|
103 |
+
deleteThemeUpdateData = <?php echo $as->is_theme() ? 'true' : 'false'; ?>,
|
104 |
+
showDeactivationFeedbackForm = <?php echo ( $show_deactivation_feedback_form ? 'true' : 'false' ); ?>;
|
105 |
+
|
106 |
+
$modal.appendTo($('body'));
|
107 |
+
|
108 |
+
registerEventHandlers();
|
109 |
+
|
110 |
+
function registerEventHandlers() {
|
111 |
+
$deactivateLink.click(function (evt) {
|
112 |
+
evt.preventDefault();
|
113 |
+
redirectLink = $(this).attr('href');
|
114 |
+
showModal();
|
115 |
+
});
|
116 |
+
<?php
|
117 |
+
if ( ! $as->is_plugin() ) {
|
118 |
+
/**
|
119 |
+
* For "theme" module type, the modal is shown when the current user clicks on
|
120 |
+
*/
|
121 |
+
?>
|
122 |
+
$('body').on('click', '.theme-browser .theme .theme-actions .button.activate', function (evt) {
|
123 |
+
evt.preventDefault();
|
124 |
+
|
125 |
+
redirectLink = $(this).attr('href');
|
126 |
+
|
127 |
+
if ( $modal.hasClass( 'no-confirmation-message' ) && ! showDeactivationFeedbackForm ) {
|
128 |
+
deactivateModule();
|
129 |
+
} else {
|
130 |
+
showModal();
|
131 |
+
}
|
132 |
+
});
|
133 |
+
<?php
|
134 |
+
}
|
135 |
+
?>
|
136 |
+
|
137 |
+
$modal.on('input propertychange', '.reason-input input', function () {
|
138 |
+
if (!isOtherReasonSelected()) {
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
var reason = $(this).val().trim();
|
143 |
+
|
144 |
+
/**
|
145 |
+
* If reason is not empty, remove the error-message class of the message container
|
146 |
+
* to change the message color back to default.
|
147 |
+
*/
|
148 |
+
if (reason.length > 0) {
|
149 |
+
$('.message').removeClass('error-message');
|
150 |
+
enableDeactivateButton();
|
151 |
+
}
|
152 |
+
});
|
153 |
+
|
154 |
+
$modal.on('blur', '.reason-input input', function () {
|
155 |
+
var $userReason = $(this);
|
156 |
+
|
157 |
+
setTimeout(function () {
|
158 |
+
if (!isOtherReasonSelected()) {
|
159 |
+
return;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* If reason is empty, add the error-message class to the message container
|
164 |
+
* to change the message color to red.
|
165 |
+
*/
|
166 |
+
if (0 === $userReason.val().trim().length) {
|
167 |
+
$('.message').addClass('error-message');
|
168 |
+
disableDeactivateButton();
|
169 |
+
}
|
170 |
+
}, 150);
|
171 |
+
});
|
172 |
+
|
173 |
+
$modal.on('click', '.as-modal-footer .button', function (evt) {
|
174 |
+
evt.preventDefault();
|
175 |
+
|
176 |
+
if ($(this).hasClass('disabled')) {
|
177 |
+
return;
|
178 |
+
}
|
179 |
+
|
180 |
+
var _parent = $(this).parents('.as-modal:first');
|
181 |
+
var _this = $(this);
|
182 |
+
|
183 |
+
if (_this.hasClass('allow-deactivate')) {
|
184 |
+
var $radio = $modal.find('input[type="radio"]:checked');
|
185 |
+
|
186 |
+
if (0 === $radio.length) {
|
187 |
+
window.location.href = redirectLink;
|
188 |
+
return;
|
189 |
+
}
|
190 |
+
|
191 |
+
var $selected_reason = $radio.parents('li:first'),
|
192 |
+
$input = $selected_reason.find('textarea, input[type="text"]'),
|
193 |
+
userReason = ( 0 !== $input.length ) ? $input.val().trim() : '';
|
194 |
+
|
195 |
+
var $deactivation_reason = $selected_reason.find('.deactivation_reason').text();
|
196 |
+
|
197 |
+
if (isOtherReasonSelected() && ( '' === userReason )) {
|
198 |
+
return;
|
199 |
+
}
|
200 |
+
|
201 |
+
$.ajax({
|
202 |
+
url : ajaxurl,
|
203 |
+
method : 'POST',
|
204 |
+
data : {
|
205 |
+
action : 'submit_uninstall_reason',
|
206 |
+
deactivation_reason : $deactivation_reason,
|
207 |
+
reason_info : userReason,
|
208 |
+
is_anonymous : isAnonymousFeedback()
|
209 |
+
},
|
210 |
+
beforeSend: function () {
|
211 |
+
_parent.find('.as-modal-footer .button').addClass('disabled');
|
212 |
+
_parent.find('.as-modal-footer .button-secondary').text('Processing...');
|
213 |
+
},
|
214 |
+
complete : function () {
|
215 |
+
// Do not show the dialog box, deactivate the plugin.
|
216 |
+
window.location.href = redirectLink;
|
217 |
+
}
|
218 |
+
});
|
219 |
+
} else if (_this.hasClass('button-deactivate')) {
|
220 |
+
// Change the Deactivate button's text and show the reasons panel.
|
221 |
+
_parent.find('.button-deactivate').addClass('allow-deactivate');
|
222 |
+
|
223 |
+
if ( showDeactivationFeedbackForm ) {
|
224 |
+
showPanel('reasons');
|
225 |
+
} else {
|
226 |
+
deactivateModule();
|
227 |
+
}
|
228 |
+
}
|
229 |
+
});
|
230 |
+
|
231 |
+
$modal.on('click', 'input[type="radio"]', function () {
|
232 |
+
var $selectedReasonOption = $( this );
|
233 |
+
|
234 |
+
// If the selection has not changed, do not proceed.
|
235 |
+
if (selectedReasonID === $selectedReasonOption.val())
|
236 |
+
return;
|
237 |
+
|
238 |
+
selectedReasonID = $selectedReasonOption.val();
|
239 |
+
|
240 |
+
if ( isAnonymous ) {
|
241 |
+
if ( isReasonSelected( dontShareDataReasonID ) ) {
|
242 |
+
$anonymousFeedback.hide();
|
243 |
+
} else {
|
244 |
+
$anonymousFeedback.show();
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
var _parent = $(this).parents('li:first');
|
249 |
+
|
250 |
+
$modal.find('.reason-input').remove();
|
251 |
+
$modal.find( '.internal-message' ).hide();
|
252 |
+
$modal.find('.button-deactivate').html('<?php echo esc_js( sprintf(
|
253 |
+
__( 'Submit & %s', 'analytics' , $slug ),
|
254 |
+
$as->is_plugin() ?
|
255 |
+
$deactivate_text :
|
256 |
+
sprintf( $activate_x_text, $theme_text )
|
257 |
+
) ) ?>');
|
258 |
+
|
259 |
+
enableDeactivateButton();
|
260 |
+
|
261 |
+
if ( _parent.hasClass( 'has-internal-message' ) ) {
|
262 |
+
_parent.find( '.internal-message' ).show();
|
263 |
+
}
|
264 |
+
|
265 |
+
if (_parent.hasClass('has-input')) {
|
266 |
+
var inputType = _parent.data('input-type'),
|
267 |
+
inputPlaceholder = _parent.data('input-placeholder'),
|
268 |
+
reasonInputHtml = '<div class="reason-input"><span class="message"></span>' + ( ( 'textfield' === inputType ) ? '<input type="text" maxlength="128" />' : '<textarea rows="5" maxlength="128"></textarea>' ) + '</div>';
|
269 |
+
|
270 |
+
_parent.append($(reasonInputHtml));
|
271 |
+
_parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
|
272 |
+
|
273 |
+
if (isOtherReasonSelected()) {
|
274 |
+
showMessage('<?php echo esc_js( __( 'Kindly tell us the reason so we can improve.', 'analytics' ) ); ?>');
|
275 |
+
disableDeactivateButton();
|
276 |
+
}
|
277 |
+
}
|
278 |
+
});
|
279 |
+
|
280 |
+
// If the user has clicked outside the window, cancel it.
|
281 |
+
$modal.on('click', function (evt) {
|
282 |
+
var $target = $(evt.target);
|
283 |
+
|
284 |
+
// If the user has clicked anywhere in the modal dialog, just return.
|
285 |
+
if ($target.hasClass('as-modal-body') || $target.hasClass('as-modal-footer')) {
|
286 |
+
return;
|
287 |
+
}
|
288 |
+
|
289 |
+
// If the user has not clicked the close button and the clicked element is inside the modal dialog, just return.
|
290 |
+
if (
|
291 |
+
! $target.hasClass( 'button-close' ) &&
|
292 |
+
( $target.parents( '.as-modal-body' ).length > 0 || $target.parents( '.as-modal-footer' ).length > 0 )
|
293 |
+
) {
|
294 |
+
return;
|
295 |
+
}
|
296 |
+
|
297 |
+
closeModal();
|
298 |
+
|
299 |
+
return false;
|
300 |
+
});
|
301 |
+
}
|
302 |
+
|
303 |
+
function isAnonymousFeedback() {
|
304 |
+
if ( ! isAnonymous ) {
|
305 |
+
return false;
|
306 |
+
}
|
307 |
+
|
308 |
+
return ( isReasonSelected( dontShareDataReasonID ) || $anonymousFeedback.find( 'input' ).prop( 'checked' ) );
|
309 |
+
}
|
310 |
+
|
311 |
+
function isReasonSelected( reasonID ) {
|
312 |
+
// Get the selected radio input element.
|
313 |
+
var $selectedReasonOption = $modal.find('input[type="radio"]:checked');
|
314 |
+
|
315 |
+
return ( reasonID == $selectedReasonOption.val() );
|
316 |
+
}
|
317 |
+
|
318 |
+
function isOtherReasonSelected() {
|
319 |
+
return isReasonSelected( otherReasonID );
|
320 |
+
}
|
321 |
+
|
322 |
+
function showModal() {
|
323 |
+
resetModal();
|
324 |
+
|
325 |
+
// Display the dialog box.
|
326 |
+
$modal.addClass('active');
|
327 |
+
|
328 |
+
$('body').addClass('has-as-modal');
|
329 |
+
}
|
330 |
+
|
331 |
+
function closeModal() {
|
332 |
+
$modal.removeClass('active');
|
333 |
+
|
334 |
+
$('body').removeClass('has-as-modal');
|
335 |
+
}
|
336 |
+
|
337 |
+
function resetModal() {
|
338 |
+
selectedReasonID = false;
|
339 |
+
|
340 |
+
enableDeactivateButton();
|
341 |
+
|
342 |
+
// Uncheck all radio buttons.
|
343 |
+
$modal.find('input[type="radio"]').prop('checked', false);
|
344 |
+
|
345 |
+
// Remove all input fields ( textfield, textarea ).
|
346 |
+
$modal.find('.reason-input').remove();
|
347 |
+
|
348 |
+
$modal.find('.message').hide();
|
349 |
+
|
350 |
+
if ( isAnonymous ) {
|
351 |
+
$anonymousFeedback.find( 'input' ).prop( 'checked', false );
|
352 |
+
|
353 |
+
// Hide, since by default there is no selected reason.
|
354 |
+
$anonymousFeedback.hide();
|
355 |
+
}
|
356 |
+
|
357 |
+
var $deactivateButton = $modal.find('.button-deactivate');
|
358 |
+
|
359 |
+
/*
|
360 |
+
* If the modal dialog has no confirmation message, that is, it has only one panel, then ensure
|
361 |
+
* that clicking the deactivate button will actually deactivate the plugin.
|
362 |
+
*/
|
363 |
+
if ( $modal.hasClass( 'no-confirmation-message' ) ) {
|
364 |
+
$deactivateButton.addClass( 'allow-deactivate' );
|
365 |
+
|
366 |
+
showPanel( 'reasons' );
|
367 |
+
} else {
|
368 |
+
$deactivateButton.removeClass( 'allow-deactivate' );
|
369 |
+
|
370 |
+
showPanel( 'confirm' );
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
+
function showMessage(message) {
|
375 |
+
$modal.find('.message').text(message).show();
|
376 |
+
}
|
377 |
+
|
378 |
+
function enableDeactivateButton() {
|
379 |
+
$modal.find('.button-deactivate').removeClass('disabled');
|
380 |
+
}
|
381 |
+
|
382 |
+
function disableDeactivateButton() {
|
383 |
+
$modal.find('.button-deactivate').addClass('disabled');
|
384 |
+
}
|
385 |
+
|
386 |
+
function showPanel(panelType) {
|
387 |
+
$modal.find( '.as-modal-panel' ).removeClass( 'active' );
|
388 |
+
$modal.find( '[data-panel-id="' + panelType + '"]' ).addClass( 'active' );
|
389 |
+
|
390 |
+
updateButtonLabels();
|
391 |
+
}
|
392 |
+
|
393 |
+
function updateButtonLabels() {
|
394 |
+
var $deactivateButton = $modal.find( '.button-deactivate' );
|
395 |
+
|
396 |
+
// Reset the deactivate button's text.
|
397 |
+
if ( 'confirm' === getCurrentPanel() ) {
|
398 |
+
$deactivateButton.text(
|
399 |
+
<?php
|
400 |
+
echo json_encode(
|
401 |
+
sprintf(
|
402 |
+
__( 'Yes - %s', 'analytics' ),
|
403 |
+
$as->is_plugin() ?
|
404 |
+
$deactivate_text :
|
405 |
+
sprintf( $activate_x_text, $theme_text )
|
406 |
+
)
|
407 |
+
)
|
408 |
+
?>
|
409 |
+
);
|
410 |
+
} else {
|
411 |
+
$deactivateButton.html(
|
412 |
+
<?php
|
413 |
+
echo json_encode(
|
414 |
+
sprintf(
|
415 |
+
__( 'Skip & %s', 'analytics' ),
|
416 |
+
$as->is_plugin() ?
|
417 |
+
$deactivate_text :
|
418 |
+
sprintf( $activate_x_text, $theme_text )
|
419 |
+
)
|
420 |
+
)
|
421 |
+
?>
|
422 |
+
);
|
423 |
+
}
|
424 |
+
}
|
425 |
+
|
426 |
+
function getCurrentPanel() {
|
427 |
+
return $modal.find('.as-modal-panel.active').attr('data-panel-id');
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* @author CyberChimps
|
432 |
+
*
|
433 |
+
* @since 1.0.0
|
434 |
+
*/
|
435 |
+
function deactivateModule() {
|
436 |
+
window.location.href = redirectLink;
|
437 |
+
}
|
438 |
+
})(jQuery);
|
439 |
+
</script>
|
includes/importers/class-responsive-ready-sites-importer.php
CHANGED
@@ -305,7 +305,13 @@ if ( ! class_exists( 'Responsive_Ready_Sites_Importer' ) ) :
|
|
305 |
}
|
306 |
|
307 |
if ( isset( $customizer_data['theme_mods_responsive'] ) ) {
|
308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
}
|
310 |
|
311 |
// Add Custom CSS.
|
305 |
}
|
306 |
|
307 |
if ( isset( $customizer_data['theme_mods_responsive'] ) ) {
|
308 |
+
$current_theme = wp_get_theme();
|
309 |
+
if ( is_child_theme() && 'Responsive' === $current_theme->parent()->get( 'Name' ) ) {
|
310 |
+
$current_theme = str_replace( ' ', '-', strtolower( $current_theme ) );
|
311 |
+
update_option( 'theme_mods_' . $current_theme, $customizer_data['theme_mods_responsive'] );
|
312 |
+
} else {
|
313 |
+
update_option( 'theme_mods_responsive', $customizer_data['theme_mods_responsive'] );
|
314 |
+
}
|
315 |
}
|
316 |
|
317 |
// Add Custom CSS.
|
readme.txt
CHANGED
@@ -3,12 +3,14 @@ Contributors: cyberchimps
|
|
3 |
Donate Link: http://cyberchimps.com
|
4 |
Tags: Elementor, Demo Importer, Templates, Starter Sites, Ready Websites
|
5 |
Requires at least: 5.0
|
6 |
-
Tested up to: 5.
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 2.0.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
|
|
|
|
12 |
== Description ==
|
13 |
|
14 |
[youtube https://www.youtube.com/watch?v=JNeQKg1QJhk&t=2s]
|
@@ -59,6 +61,9 @@ Absolutely not! Once you install the plugin, it will take care of all other depe
|
|
59 |
4. Your website is ready
|
60 |
|
61 |
== Changelog ==
|
|
|
|
|
|
|
62 |
= 2.0.8 - 24th September 2019 =
|
63 |
* Changed plugin name, updated readme
|
64 |
|
3 |
Donate Link: http://cyberchimps.com
|
4 |
Tags: Elementor, Demo Importer, Templates, Starter Sites, Ready Websites
|
5 |
Requires at least: 5.0
|
6 |
+
Tested up to: 5.3
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 2.0.9
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
12 |
+
Build your website with 30+ ready-to-use website templates (more coming soon). Simply edit templates with the drag-n-drop Elementor page builder and hit launch!
|
13 |
+
|
14 |
== Description ==
|
15 |
|
16 |
[youtube https://www.youtube.com/watch?v=JNeQKg1QJhk&t=2s]
|
61 |
4. Your website is ready
|
62 |
|
63 |
== Changelog ==
|
64 |
+
= 2.0.9 - 15th November 2019 =
|
65 |
+
* Added - Feedback form on plugin deactivation
|
66 |
+
|
67 |
= 2.0.8 - 24th September 2019 =
|
68 |
* Changed plugin name, updated readme
|
69 |
|
responsive-add-ons.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Responsive Ready Sites Importer
|
4 |
Plugin URI: http://wordpress.org/plugins/responsive-add-ons/
|
5 |
Description: Import Responsive Ready Sites that help you launch your website quickly. Just import, update & hit the launch button.
|
6 |
-
Version: 2.0.
|
7 |
Author: CyberChimps
|
8 |
Author URI: http://www.cyberchimps.com
|
9 |
License: GPL2
|
@@ -38,6 +38,34 @@ if ( ! defined( 'RESPONSIVE_ADDONS_URI' ) ) {
|
|
38 |
define( 'RESPONSIVE_ADDONS_URI', plugins_url( '/', RESPONSIVE_ADDONS_FILE ) );
|
39 |
}
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
if( !class_exists( 'Responsive_Addons' ) ) {
|
42 |
|
43 |
class Responsive_Addons {
|
3 |
Plugin Name: Responsive Ready Sites Importer
|
4 |
Plugin URI: http://wordpress.org/plugins/responsive-add-ons/
|
5 |
Description: Import Responsive Ready Sites that help you launch your website quickly. Just import, update & hit the launch button.
|
6 |
+
Version: 2.0.9
|
7 |
Author: CyberChimps
|
8 |
Author URI: http://www.cyberchimps.com
|
9 |
License: GPL2
|
38 |
define( 'RESPONSIVE_ADDONS_URI', plugins_url( '/', RESPONSIVE_ADDONS_FILE ) );
|
39 |
}
|
40 |
|
41 |
+
if ( ! function_exists( 'ra_fs' ) ) {
|
42 |
+
// Helper function to access SDK
|
43 |
+
function ra_fs() {
|
44 |
+
global $rao_fs;
|
45 |
+
|
46 |
+
if ( ! isset( $rao_fs ) ) {
|
47 |
+
// Include Analytics SDK.
|
48 |
+
require_once dirname(__FILE__) . '/analytics/start.php';
|
49 |
+
|
50 |
+
$rao_fs = ras_dynamic_init( array(
|
51 |
+
'id' => '1',
|
52 |
+
'slug' => 'responsive-add-ons',
|
53 |
+
'product_name' => 'Responsive Ready Sites Importer',
|
54 |
+
'module_type' => 'plugin',
|
55 |
+
'version' => '2.0.9',
|
56 |
+
'plugin_basename' => 'responsive-add-ons/responsive-add-ons.php',
|
57 |
+
) );
|
58 |
+
}
|
59 |
+
|
60 |
+
return $rao_fs;
|
61 |
+
}
|
62 |
+
|
63 |
+
// Init Analytics.
|
64 |
+
ra_fs();
|
65 |
+
// SDK initiated.
|
66 |
+
do_action( 'ra_fs_loaded' );
|
67 |
+
}
|
68 |
+
|
69 |
if( !class_exists( 'Responsive_Addons' ) ) {
|
70 |
|
71 |
class Responsive_Addons {
|