Version Description
- Added a note on dashbaord about what to look for to disable our plugins. People have started leaving negative feedback cause can't remember what they installed. Hopefully, this clears it up
- Removed donation Requests
- Few other small bugs fixed
Download this release
Release Info
Developer | pigeonhut |
Plugin | Reduce HTTP Requests, Disable Emojis & Disable Embeds, Speedup WooCommerce |
Version | 1.5.20 |
Comparing to | |
See all releases |
Code changes from version 1.5.18 to 1.5.20
- lib/class-wpperformance-admin.php +6 -9
- readme.txt +12 -1
- tracking/class-example-settings.php +0 -169
- tracking/class-plugin-usage-tracker.php +0 -1072
- views/optimisationio-dashboard.php +8 -13
- wpperformance.php +1 -41
lib/class-wpperformance-admin.php
CHANGED
@@ -24,7 +24,7 @@ class WpPerformance_Admin {
|
|
24 |
{
|
25 |
wp_enqueue_style($single_external_font_to_load["unique_name"], $single_external_font_to_load["src"], array());
|
26 |
}
|
27 |
-
}
|
28 |
|
29 |
public function wp_performance_load_external_scripts($tag, $handle) {
|
30 |
//var_dump($handle);
|
@@ -315,7 +315,7 @@ class WpPerformance_Admin {
|
|
315 |
"unique_name" => "angular-route1.6.5",
|
316 |
"src" => "https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-route.js",
|
317 |
"priority" => 2
|
318 |
-
)
|
319 |
);
|
320 |
}
|
321 |
|
@@ -329,7 +329,7 @@ class WpPerformance_Admin {
|
|
329 |
array(
|
330 |
"unique_name" => "angular-route1.6.5",
|
331 |
"src" => "https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-route.js"
|
332 |
-
)
|
333 |
);
|
334 |
}
|
335 |
|
@@ -701,8 +701,7 @@ class WpPerformance_Admin {
|
|
701 |
<?php } ?>
|
702 |
<li data-tab-setting="tags"><?php esc_html_e('Tags', 'optimisationio'); ?></li>
|
703 |
<li data-tab-setting="admin"><?php esc_html_e('Admin', 'optimisationio'); ?></li>
|
704 |
-
<li data-tab-setting="
|
705 |
-
<li data-tab-setting="others"><?php esc_html_e('Others', 'optimisationio'); ?></li>
|
706 |
<li data-tab-setting="rest-api"><?php esc_html_e('REST API', 'optimisationio'); ?></li>
|
707 |
</ul>
|
708 |
</div>
|
@@ -995,7 +994,8 @@ class WpPerformance_Admin {
|
|
995 |
</div>
|
996 |
</div>
|
997 |
|
998 |
-
|
|
|
999 |
<div class="field">
|
1000 |
<div class="field-left"><?php esc_attr_e('Remove Yoast SEO comment from head section', 'optimisationio'); ?></div>
|
1001 |
<div class="field-right"><?php Optimisationio_Dashboard::checkbox_component('remove_yoast_comment', isset( $sett['remove_yoast_comment'] ) && 1 === (int) $sett['remove_yoast_comment']); ?></div>
|
@@ -1004,9 +1004,6 @@ class WpPerformance_Admin {
|
|
1004 |
<div class="field-left"><?php esc_attr_e('Remove duplicate names in breadcrumbs WP SEO by Yoast', 'optimisationio'); ?></div>
|
1005 |
<div class="field-right"><?php Optimisationio_Dashboard::checkbox_component('remove_yoast_breadcrumbs_duplicates', isset( $sett['remove_yoast_breadcrumbs_duplicates'] ) && 1 === (int) $sett['remove_yoast_breadcrumbs_duplicates']); ?></div>
|
1006 |
</div>
|
1007 |
-
</div>
|
1008 |
-
|
1009 |
-
<div data-tab-setting="others" class="addon-settings-content auto-table-layout">
|
1010 |
<div class="field">
|
1011 |
<div class="field-left"><?php esc_attr_e('Disable pingbacks and trackbacks', 'optimisationio'); ?></div>
|
1012 |
<div class="field-right"><?php Optimisationio_Dashboard::checkbox_component('default_ping_status', isset( $sett['default_ping_status'] ) && 1 === (int) $sett['default_ping_status']); ?></div>
|
24 |
{
|
25 |
wp_enqueue_style($single_external_font_to_load["unique_name"], $single_external_font_to_load["src"], array());
|
26 |
}
|
27 |
+
}
|
28 |
|
29 |
public function wp_performance_load_external_scripts($tag, $handle) {
|
30 |
//var_dump($handle);
|
315 |
"unique_name" => "angular-route1.6.5",
|
316 |
"src" => "https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-route.js",
|
317 |
"priority" => 2
|
318 |
+
)
|
319 |
);
|
320 |
}
|
321 |
|
329 |
array(
|
330 |
"unique_name" => "angular-route1.6.5",
|
331 |
"src" => "https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-route.js"
|
332 |
+
)
|
333 |
);
|
334 |
}
|
335 |
|
701 |
<?php } ?>
|
702 |
<li data-tab-setting="tags"><?php esc_html_e('Tags', 'optimisationio'); ?></li>
|
703 |
<li data-tab-setting="admin"><?php esc_html_e('Admin', 'optimisationio'); ?></li>
|
704 |
+
<li data-tab-setting="others"><?php esc_html_e('SEO', 'optimisationio'); ?></li>
|
|
|
705 |
<li data-tab-setting="rest-api"><?php esc_html_e('REST API', 'optimisationio'); ?></li>
|
706 |
</ul>
|
707 |
</div>
|
994 |
</div>
|
995 |
</div>
|
996 |
|
997 |
+
|
998 |
+
<div data-tab-setting="others" class="addon-settings-content auto-table-layout">
|
999 |
<div class="field">
|
1000 |
<div class="field-left"><?php esc_attr_e('Remove Yoast SEO comment from head section', 'optimisationio'); ?></div>
|
1001 |
<div class="field-right"><?php Optimisationio_Dashboard::checkbox_component('remove_yoast_comment', isset( $sett['remove_yoast_comment'] ) && 1 === (int) $sett['remove_yoast_comment']); ?></div>
|
1004 |
<div class="field-left"><?php esc_attr_e('Remove duplicate names in breadcrumbs WP SEO by Yoast', 'optimisationio'); ?></div>
|
1005 |
<div class="field-right"><?php Optimisationio_Dashboard::checkbox_component('remove_yoast_breadcrumbs_duplicates', isset( $sett['remove_yoast_breadcrumbs_duplicates'] ) && 1 === (int) $sett['remove_yoast_breadcrumbs_duplicates']); ?></div>
|
1006 |
</div>
|
|
|
|
|
|
|
1007 |
<div class="field">
|
1008 |
<div class="field-left"><?php esc_attr_e('Disable pingbacks and trackbacks', 'optimisationio'); ?></div>
|
1009 |
<div class="field-right"><?php Optimisationio_Dashboard::checkbox_component('default_ping_status', isset( $sett['default_ping_status'] ) && 1 === (int) $sett['default_ping_status']); ?></div>
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: optimisation.io, hosting.io
|
|
3 |
Tags: Disable Emoji, Disable Embeds, Disable Gravatars, Remove Querystrings, Reduce HTTP Requests, speedup WooCommerce, Close comments, Optimization
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 4.9
|
6 |
-
Stable tag: 1.5.
|
7 |
License: GPLv2 or later
|
8 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -81,6 +81,15 @@ You can try our <a href="https://wordpress.org/plugins/wp-image-compression/">Fr
|
|
81 |
|
82 |
|
83 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
= 1.5.18 =
|
85 |
* Fix Auto Update - IMPORTANT -- please disable and re-enable the plugin to enable the auto update to work.
|
86 |
|
@@ -173,6 +182,8 @@ No new features, but this is a stepping stone.
|
|
173 |
* General code improvements
|
174 |
|
175 |
== Upgrade Notice ==
|
|
|
|
|
176 |
|
177 |
= 1.5.17 =
|
178 |
Minor Update, Removed Freemius tracking
|
3 |
Tags: Disable Emoji, Disable Embeds, Disable Gravatars, Remove Querystrings, Reduce HTTP Requests, speedup WooCommerce, Close comments, Optimization
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 4.9
|
6 |
+
Stable tag: 1.5.20
|
7 |
License: GPLv2 or later
|
8 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
81 |
|
82 |
|
83 |
== Changelog ==
|
84 |
+
= 1.5.20 =
|
85 |
+
* Added a note on dashbaord about what to look for to disable our plugins. People have started leaving negative feedback cause can't remember what they installed. Hopefully, this clears it up
|
86 |
+
* Removed donation Requests
|
87 |
+
* Few other small bugs fixed
|
88 |
+
|
89 |
+
= 1.5.19 =
|
90 |
+
* IMPORTANT -- please disable and then update the plugin to enable the auto update to work. Something went wrong with the last update and it seems to be fo
|
91 |
+
* Freemius Removed
|
92 |
+
|
93 |
= 1.5.18 =
|
94 |
* Fix Auto Update - IMPORTANT -- please disable and re-enable the plugin to enable the auto update to work.
|
95 |
|
182 |
* General code improvements
|
183 |
|
184 |
== Upgrade Notice ==
|
185 |
+
= 1.5.19 =
|
186 |
+
Please disable plugin, and then update, or update from the "WP Updates" area
|
187 |
|
188 |
= 1.5.17 =
|
189 |
Minor Update, Removed Freemius tracking
|
tracking/class-example-settings.php
DELETED
@@ -1,169 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Discussion Board admin class
|
4 |
-
*/
|
5 |
-
|
6 |
-
// Exit if accessed directly
|
7 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
-
exit;
|
9 |
-
}
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Plugin admin class
|
13 |
-
**/
|
14 |
-
if ( ! class_exists ( 'PUT_Example_Settings' ) ) { // Don't initialise if there's already a Discussion Board activated
|
15 |
-
|
16 |
-
class PUT_Example_Settings {
|
17 |
-
|
18 |
-
public function __construct() {
|
19 |
-
//
|
20 |
-
}
|
21 |
-
|
22 |
-
/*
|
23 |
-
* Initialize the class and start calling our hooks and filters
|
24 |
-
* @since 1.0.0
|
25 |
-
*/
|
26 |
-
public function init() {
|
27 |
-
add_action ( 'admin_menu', array ( $this, 'add_settings_submenu' ) );
|
28 |
-
add_action ( 'admin_init', array ( $this, 'register_options_init' ) );
|
29 |
-
add_action ( 'admin_init', array ( $this, 'save_registered_setting' ) );
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* We save this artificially to let the tracker know that we're allowed to export this option's data
|
34 |
-
*/
|
35 |
-
public function save_registered_setting() {
|
36 |
-
$options = get_option( 'wisdom_example_options_settings' );
|
37 |
-
$options['wisdom_registered_setting'] = 1;
|
38 |
-
update_option( 'wisdom_example_options_settings', $options );
|
39 |
-
}
|
40 |
-
|
41 |
-
// Add the menu item
|
42 |
-
public function add_settings_submenu() {
|
43 |
-
add_submenu_page( 'options-general.php', __( 'Example Settings', 'plugin-usage-tracker' ), __( 'Example Settings', 'plugin-usage-tracker' ), 'manage_options', 'example-settings-page', array ( $this, 'options_page' ) );
|
44 |
-
}
|
45 |
-
|
46 |
-
public function register_options_init() {
|
47 |
-
|
48 |
-
register_setting ( 'wisdom_example_options', 'wisdom_example_options_settings' );
|
49 |
-
|
50 |
-
add_settings_section (
|
51 |
-
'wisdom_example_options_section',
|
52 |
-
__( 'Example Settings', 'plugin-usage-tracker' ),
|
53 |
-
array ( $this, 'example_settings_section_callback' ),
|
54 |
-
'wisdom_example_options'
|
55 |
-
);
|
56 |
-
add_settings_field (
|
57 |
-
'text_field_example',
|
58 |
-
__( 'Text field:', 'plugin-usage-tracker' ),
|
59 |
-
array ( $this, 'text_field_example_render' ),
|
60 |
-
'wisdom_example_options',
|
61 |
-
'wisdom_example_options_section'
|
62 |
-
);
|
63 |
-
add_settings_field (
|
64 |
-
'checkbox_example',
|
65 |
-
__( 'Checkbox', 'plugin-usage-tracker' ),
|
66 |
-
array ( $this, 'checkbox_example_render' ),
|
67 |
-
'wisdom_example_options',
|
68 |
-
'wisdom_example_options_section'
|
69 |
-
);
|
70 |
-
add_settings_field (
|
71 |
-
'select_example',
|
72 |
-
__( 'Select', 'plugin-usage-tracker' ),
|
73 |
-
array ( $this, 'select_example_render' ),
|
74 |
-
'wisdom_example_options',
|
75 |
-
'wisdom_example_options_section'
|
76 |
-
);
|
77 |
-
add_settings_field (
|
78 |
-
'wisdom_opt_out',
|
79 |
-
__( 'Opt out', 'plugin-usage-tracker' ),
|
80 |
-
array ( $this, 'opt_out_example_render' ),
|
81 |
-
'wisdom_example_options',
|
82 |
-
'wisdom_example_options_section'
|
83 |
-
);
|
84 |
-
|
85 |
-
// Set default options
|
86 |
-
$options = get_option( 'wisdom_example_options_settings' );
|
87 |
-
if ( false === $options ) {
|
88 |
-
// Get defaults
|
89 |
-
$defaults = $this->get_default_options_settings();
|
90 |
-
update_option( 'wisdom_example_options_settings', $defaults );
|
91 |
-
}
|
92 |
-
|
93 |
-
}
|
94 |
-
|
95 |
-
public function get_default_options_settings() {
|
96 |
-
$defaults = array(
|
97 |
-
'text_field_example' => __( 'Default setting', 'plugin-usage-tracker' ),
|
98 |
-
'checkbox_example' => 1,
|
99 |
-
'select_example' => 'option-1',
|
100 |
-
'wisdom_opt_out' => '',
|
101 |
-
'wisdom_registered_setting' => 1 // For plugin-usage-tracker
|
102 |
-
);
|
103 |
-
return $defaults;
|
104 |
-
}
|
105 |
-
|
106 |
-
public function text_field_example_render() {
|
107 |
-
$options = get_option( 'wisdom_example_options_settings' );
|
108 |
-
$value = '';
|
109 |
-
if( isset( $options['text_field_example'] ) ) {
|
110 |
-
$value = $options['text_field_example'];
|
111 |
-
}
|
112 |
-
?>
|
113 |
-
<input type='text' name='wisdom_example_options_settings[text_field_example]' value="<?php echo $value; ?>" />
|
114 |
-
<?php
|
115 |
-
}
|
116 |
-
|
117 |
-
public function checkbox_example_render() {
|
118 |
-
$options = get_option( 'wisdom_example_options_settings' );
|
119 |
-
?>
|
120 |
-
<input type='checkbox' name='wisdom_example_options_settings[checkbox_example]' <?php checked ( ! empty ( $options['checkbox_example'] ), 1 ); ?> value='1'>
|
121 |
-
<?php
|
122 |
-
}
|
123 |
-
|
124 |
-
public function opt_out_example_render() {
|
125 |
-
$options = get_option( 'wisdom_example_options_settings' );
|
126 |
-
?>
|
127 |
-
<input type='checkbox' name='wisdom_example_options_settings[wisdom_opt_out]' <?php checked ( ! empty ( $options['wisdom_opt_out'] ), 1 ); ?> value='1'>
|
128 |
-
<p class="description"><?php _e( 'You previously opted in to sending tracking details. You can change that setting here.', 'plugin-usage-tracker' ); ?></p>
|
129 |
-
<?php
|
130 |
-
}
|
131 |
-
|
132 |
-
public function select_example_render() {
|
133 |
-
$options = get_option( 'wisdom_example_options_settings' );
|
134 |
-
$value = '';
|
135 |
-
if( isset( $options['select_example'] ) ) {
|
136 |
-
$value = $options['select_example'];
|
137 |
-
}
|
138 |
-
?>
|
139 |
-
<select name='wisdom_example_options_settings[select_example]'>
|
140 |
-
<option value="option-1" <?php selected( esc_attr( $value ), 'option-1' ); ?>><?php _e( 'Option 1', 'plugin-usage-tracker' ); ?></option>
|
141 |
-
<option value="option-2" <?php selected( esc_attr( $value ), 'option-2' ); ?>><?php _e( 'Option 2', 'plugin-usage-tracker' ); ?></option>
|
142 |
-
<option value="option-3" <?php selected( esc_attr( $value ), 'option-3' ); ?>><?php _e( 'Option 3', 'plugin-usage-tracker' ); ?></option>
|
143 |
-
</select>
|
144 |
-
<?php
|
145 |
-
}
|
146 |
-
|
147 |
-
public function example_settings_section_callback() {
|
148 |
-
echo '<p>' . __( 'These settings are for example only.', 'plugin-usage-tracker' ) . '</p>';
|
149 |
-
}
|
150 |
-
|
151 |
-
public function options_page() { ?>
|
152 |
-
<div class="wrap">
|
153 |
-
<form action='options.php' method='post'>
|
154 |
-
<?php
|
155 |
-
settings_fields( 'wisdom_example_options' );
|
156 |
-
do_settings_sections( 'wisdom_example_options' );
|
157 |
-
submit_button();
|
158 |
-
?>
|
159 |
-
</form>
|
160 |
-
</div><!-- .wrap -->
|
161 |
-
<?php
|
162 |
-
}
|
163 |
-
|
164 |
-
}
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
$PUT_Example_Settings = new PUT_Example_Settings();
|
169 |
-
$PUT_Example_Settings -> init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tracking/class-plugin-usage-tracker.php
DELETED
@@ -1,1072 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This is the class that sends all the data back to the home site
|
4 |
-
* It also handles opting in and deactivation
|
5 |
-
* @version 1.2.4
|
6 |
-
*/
|
7 |
-
|
8 |
-
// Exit if accessed directly
|
9 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
-
exit;
|
11 |
-
}
|
12 |
-
|
13 |
-
if( ! class_exists( 'Plugin_Usage_Tracker') ) {
|
14 |
-
|
15 |
-
class Plugin_Usage_Tracker {
|
16 |
-
|
17 |
-
private $wisdom_version = '1.2.4';
|
18 |
-
private $home_url = '';
|
19 |
-
private $plugin_file = '';
|
20 |
-
private $plugin_name = '';
|
21 |
-
private $options = array();
|
22 |
-
private $require_optin = true;
|
23 |
-
private $include_goodbye_form = true;
|
24 |
-
private $marketing = false;
|
25 |
-
private $collect_email = false;
|
26 |
-
private $what_am_i = 'plugin';
|
27 |
-
private $theme_allows_tracking = 0;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Class constructor
|
31 |
-
*
|
32 |
-
* @param $_home_url The URL to the site we're sending data to
|
33 |
-
* @param $_plugin_file The file path for this plugin
|
34 |
-
* @param $_options Plugin options to track
|
35 |
-
* @param $_require_optin Whether user opt-in is required (always required on WordPress.org)
|
36 |
-
* @param $_include_goodbye_form Whether to include a form when the user deactivates
|
37 |
-
* @param $_marketing Marketing method:
|
38 |
-
* 0: Don't collect email addresses
|
39 |
-
* 1: Request permission same time as tracking opt-in
|
40 |
-
* 2: Request permission after opt-in
|
41 |
-
*/
|
42 |
-
public function __construct(
|
43 |
-
$_plugin_file,
|
44 |
-
$_home_url,
|
45 |
-
$_options,
|
46 |
-
$_require_optin=true,
|
47 |
-
$_include_goodbye_form=true,
|
48 |
-
$_marketing=false ) {
|
49 |
-
|
50 |
-
$this->plugin_file = $_plugin_file;
|
51 |
-
$this->home_url = trailingslashit( $_home_url );
|
52 |
-
|
53 |
-
// If the filename is 'functions' then we're tracking a theme
|
54 |
-
if( basename( $this->plugin_file, '.php' ) != 'functions' ) {
|
55 |
-
$this->plugin_name = basename( $this->plugin_file, '.php' );
|
56 |
-
} else {
|
57 |
-
$this->what_am_i = 'theme';
|
58 |
-
$theme = wp_get_theme();
|
59 |
-
if( $theme->Name ) {
|
60 |
-
$this->plugin_name = sanitize_text_field( $theme->Name );
|
61 |
-
}
|
62 |
-
}
|
63 |
-
|
64 |
-
$this->options = $_options;
|
65 |
-
$this->require_optin = $_require_optin;
|
66 |
-
$this->include_goodbye_form = $_include_goodbye_form;
|
67 |
-
$this->marketing = $_marketing;
|
68 |
-
|
69 |
-
// Only use this on switching theme
|
70 |
-
$this->theme_allows_tracking = get_theme_mod( 'wisdom-allow-tracking', 0 );
|
71 |
-
|
72 |
-
// Schedule / deschedule tracking when activated / deactivated
|
73 |
-
if( $this->what_am_i == 'theme' ) {
|
74 |
-
// Need to think about scheduling for sites that have already activated the theme
|
75 |
-
add_action( 'after_switch_theme', array( $this, 'schedule_tracking' ) );
|
76 |
-
add_action( 'switch_theme', array( $this, 'deactivate_this_plugin' ) );
|
77 |
-
} else {
|
78 |
-
register_activation_hook( $this->plugin_file, array( $this, 'schedule_tracking' ) );
|
79 |
-
register_deactivation_hook( $this->plugin_file, array( $this, 'deactivate_this_plugin' ) );
|
80 |
-
}
|
81 |
-
|
82 |
-
// Get it going
|
83 |
-
$this->init();
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
public function init() {
|
88 |
-
// Check marketing
|
89 |
-
if( $this->marketing == 3 ) {
|
90 |
-
$this->set_can_collect_email( true, $this->plugin_name );
|
91 |
-
}
|
92 |
-
|
93 |
-
// Check whether opt-in is required
|
94 |
-
// If not, then tracking is allowed
|
95 |
-
if( ! $this->require_optin ) {
|
96 |
-
$this->set_can_collect_email( true, $this->plugin_name );
|
97 |
-
$this->set_is_tracking_allowed( true );
|
98 |
-
$this->update_block_notice();
|
99 |
-
$this->do_tracking();
|
100 |
-
}
|
101 |
-
|
102 |
-
// Hook our do_tracking function to the weekly action
|
103 |
-
add_filter( 'cron_schedules', array( $this, 'schedule_weekly_event' ) );
|
104 |
-
// It's called weekly, but in fact it could be daily, weekly or monthly
|
105 |
-
add_action( 'put_do_weekly_action', array( $this, 'do_tracking' ) );
|
106 |
-
|
107 |
-
// Use this action for local testing
|
108 |
-
// add_action( 'admin_init', array( $this, 'do_tracking' ) );
|
109 |
-
|
110 |
-
// Display the admin notice on activation
|
111 |
-
add_action( 'admin_init', array( $this, 'set_notification_time' ) );
|
112 |
-
add_action( 'admin_notices', array( $this, 'optin_notice' ) );
|
113 |
-
add_action( 'admin_notices', array( $this, 'marketing_notice' ) );
|
114 |
-
|
115 |
-
// Deactivation
|
116 |
-
add_filter( 'plugin_action_links_' . plugin_basename( $this->plugin_file ), array( $this, 'filter_action_links' ) );
|
117 |
-
add_action( 'admin_footer-plugins.php', array( $this, 'goodbye_ajax' ) );
|
118 |
-
add_action( 'wp_ajax_goodbye_form', array( $this, 'goodbye_form_callback' ) );
|
119 |
-
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* When the plugin is activated
|
124 |
-
* Create scheduled event
|
125 |
-
* And check if tracking is enabled - perhaps the plugin has been reactivated
|
126 |
-
*
|
127 |
-
* @since 1.0.0
|
128 |
-
*/
|
129 |
-
public function schedule_tracking() {
|
130 |
-
if ( ! wp_next_scheduled( 'put_do_weekly_action' ) ) {
|
131 |
-
$schedule = $this->get_schedule();
|
132 |
-
wp_schedule_event( time(), $schedule, 'put_do_weekly_action' );
|
133 |
-
}
|
134 |
-
$this->do_tracking( true );
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Create weekly schedule
|
139 |
-
*
|
140 |
-
* @since 1.2.3
|
141 |
-
*/
|
142 |
-
public function schedule_weekly_event( $schedules ) {
|
143 |
-
$schedules['weekly'] = array(
|
144 |
-
'interval' => 604800,
|
145 |
-
'display' => __( 'Once Weekly' )
|
146 |
-
);
|
147 |
-
$schedules['monthly'] = array(
|
148 |
-
'interval' => 2635200,
|
149 |
-
'display' => __( 'Once Monthly' )
|
150 |
-
);
|
151 |
-
return $schedules;
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Get how frequently data is tracked back
|
156 |
-
*
|
157 |
-
* @since 1.2.3
|
158 |
-
*/
|
159 |
-
public function get_schedule() {
|
160 |
-
// Could be daily, weekly or monthly
|
161 |
-
$schedule = apply_filters( 'wisdom_filter_schedule_' . $this->plugin_name, 'monthly' );
|
162 |
-
return $schedule;
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* This is our function to get everything going
|
167 |
-
* Check that user has opted in
|
168 |
-
* Collect data
|
169 |
-
* Then send it back
|
170 |
-
*
|
171 |
-
* @since 1.0.0
|
172 |
-
* @param $force Force tracking if it's not time
|
173 |
-
*/
|
174 |
-
public function do_tracking( $force=false ) {
|
175 |
-
|
176 |
-
// If the home site hasn't been defined, we just drop out. Nothing much we can do.
|
177 |
-
if ( ! $this->home_url ) {
|
178 |
-
return;
|
179 |
-
}
|
180 |
-
|
181 |
-
// Check to see if the user has opted in to tracking
|
182 |
-
$allow_tracking = $this->get_is_tracking_allowed();
|
183 |
-
if( ! $allow_tracking ) {
|
184 |
-
return;
|
185 |
-
}
|
186 |
-
|
187 |
-
// Check to see if it's time to track
|
188 |
-
$track_time = $this->get_is_time_to_track();
|
189 |
-
if( ! $track_time && ! $force ) {
|
190 |
-
return;
|
191 |
-
}
|
192 |
-
|
193 |
-
$this->set_admin_email();
|
194 |
-
|
195 |
-
// Get our data
|
196 |
-
$body = $this->get_data();
|
197 |
-
|
198 |
-
// Send the data
|
199 |
-
$this->send_data( $body );
|
200 |
-
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* We hook this to admin_init when the user accepts tracking
|
205 |
-
* Ensures the email address is available
|
206 |
-
*
|
207 |
-
* @since 1.2.1
|
208 |
-
*/
|
209 |
-
public function force_tracking() {
|
210 |
-
$this->do_tracking( true ); // Run this straightaway
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* Send the data to the home site
|
215 |
-
*
|
216 |
-
* @since 1.0.0
|
217 |
-
*/
|
218 |
-
public function send_data( $body ) {
|
219 |
-
|
220 |
-
$request = wp_remote_post(
|
221 |
-
esc_url( $this->home_url . '?usage_tracker=hello' ),
|
222 |
-
array(
|
223 |
-
'method' => 'POST',
|
224 |
-
'timeout' => 20,
|
225 |
-
'redirection' => 5,
|
226 |
-
'httpversion' => '1.1',
|
227 |
-
'blocking' => true,
|
228 |
-
'body' => $body,
|
229 |
-
'user-agent' => 'PUT/1.0.0; ' . home_url()
|
230 |
-
)
|
231 |
-
);
|
232 |
-
|
233 |
-
$this->set_track_time();
|
234 |
-
|
235 |
-
if( is_wp_error( $request ) ) {
|
236 |
-
return $request;
|
237 |
-
}
|
238 |
-
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Here we collect most of the data
|
243 |
-
*
|
244 |
-
* @since 1.0.0
|
245 |
-
*/
|
246 |
-
public function get_data() {
|
247 |
-
|
248 |
-
// Use this to pass error messages back if necessary
|
249 |
-
$body['message'] = '';
|
250 |
-
|
251 |
-
// Use this array to send data back
|
252 |
-
$body = array(
|
253 |
-
'plugin_slug' => sanitize_text_field( $this->plugin_name ),
|
254 |
-
'url' => home_url(),
|
255 |
-
'site_name' => get_bloginfo( 'name' ),
|
256 |
-
'site_version' => get_bloginfo( 'version' ),
|
257 |
-
'site_language' => get_bloginfo( 'language' ),
|
258 |
-
'charset' => get_bloginfo( 'charset' ),
|
259 |
-
'wisdom_version' => $this->wisdom_version,
|
260 |
-
'php_version' => phpversion(),
|
261 |
-
'multisite' => is_multisite(),
|
262 |
-
'file_location' => __FILE__,
|
263 |
-
'product_type' => esc_html( $this->what_am_i )
|
264 |
-
);
|
265 |
-
|
266 |
-
// Collect the email if the correct option has been set
|
267 |
-
if( $this->get_can_collect_email() ) {
|
268 |
-
$body['email'] = $this->get_admin_email();
|
269 |
-
}
|
270 |
-
$body['marketing_method'] = $this->marketing;
|
271 |
-
|
272 |
-
$body['server'] = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '';
|
273 |
-
|
274 |
-
// Retrieve current plugin information
|
275 |
-
if( ! function_exists( 'get_plugins' ) ) {
|
276 |
-
include ABSPATH . '/wp-admin/includes/plugin.php';
|
277 |
-
}
|
278 |
-
|
279 |
-
$plugins = array_keys( get_plugins() );
|
280 |
-
$active_plugins = get_option( 'active_plugins', array() );
|
281 |
-
|
282 |
-
foreach ( $plugins as $key => $plugin ) {
|
283 |
-
if ( in_array( $plugin, $active_plugins ) ) {
|
284 |
-
// Remove active plugins from list so we can show active and inactive separately
|
285 |
-
unset( $plugins[$key] );
|
286 |
-
}
|
287 |
-
}
|
288 |
-
|
289 |
-
$body['active_plugins'] = $active_plugins;
|
290 |
-
$body['inactive_plugins'] = $plugins;
|
291 |
-
|
292 |
-
// Check text direction
|
293 |
-
$body['text_direction'] = 'LTR';
|
294 |
-
if( function_exists( 'is_rtl' ) ) {
|
295 |
-
if( is_rtl() ) {
|
296 |
-
$body['text_direction'] = 'RTL';
|
297 |
-
}
|
298 |
-
} else {
|
299 |
-
$body['text_direction'] = 'not set';
|
300 |
-
}
|
301 |
-
|
302 |
-
/**
|
303 |
-
* Get our plugin data
|
304 |
-
* Currently we grab plugin name and version
|
305 |
-
* Or, return a message if the plugin data is not available
|
306 |
-
* @since 1.0.0
|
307 |
-
*/
|
308 |
-
$plugin = $this->plugin_data();
|
309 |
-
$body['status'] = 'Active'; // Never translated
|
310 |
-
if( empty( $plugin ) ) {
|
311 |
-
// We can't find the plugin data
|
312 |
-
// Send a message back to our home site
|
313 |
-
$body['message'] .= __( 'We can\'t detect any product information. This is most probably because you have not included the code snippet.', 'singularity' );
|
314 |
-
$body['status'] = 'Data not found'; // Never translated
|
315 |
-
} else {
|
316 |
-
if( isset( $plugin['Name'] ) ) {
|
317 |
-
$body['plugin'] = sanitize_text_field( $plugin['Name'] );
|
318 |
-
}
|
319 |
-
if( isset( $plugin['Version'] ) ) {
|
320 |
-
$body['version'] = sanitize_text_field( $plugin['Version'] );
|
321 |
-
}
|
322 |
-
|
323 |
-
}
|
324 |
-
|
325 |
-
/**
|
326 |
-
* Get our plugin options
|
327 |
-
* @since 1.0.0
|
328 |
-
*/
|
329 |
-
$options = $this->options;
|
330 |
-
$plugin_options = array();
|
331 |
-
if( ! empty( $options ) && is_array( $options ) ) {
|
332 |
-
foreach( $options as $option ) {
|
333 |
-
$fields = get_option( $option );
|
334 |
-
// Check for permission to send this option
|
335 |
-
if( isset( $fields['wisdom_registered_setting'] ) ) {
|
336 |
-
foreach( $fields as $key=>$value ) {
|
337 |
-
$plugin_options[$key] = $value;
|
338 |
-
}
|
339 |
-
}
|
340 |
-
}
|
341 |
-
}
|
342 |
-
$body['plugin_options'] = $this->options; // Returns array
|
343 |
-
$body['plugin_options_fields'] = $plugin_options; // Returns object
|
344 |
-
|
345 |
-
/**
|
346 |
-
* Get our theme data
|
347 |
-
* Currently we grab theme name and version
|
348 |
-
* @since 1.0.0
|
349 |
-
*/
|
350 |
-
$theme = wp_get_theme();
|
351 |
-
if( $theme->Name ) {
|
352 |
-
$body['theme'] = sanitize_text_field( $theme->Name );
|
353 |
-
}
|
354 |
-
if( $theme->Version ) {
|
355 |
-
$body['theme_version'] = sanitize_text_field( $theme->Version );
|
356 |
-
}
|
357 |
-
if( $theme->Template ) {
|
358 |
-
$body['theme_parent'] = sanitize_text_field( $theme->Template );
|
359 |
-
}
|
360 |
-
|
361 |
-
// Return the data
|
362 |
-
return $body;
|
363 |
-
|
364 |
-
}
|
365 |
-
|
366 |
-
/**
|
367 |
-
* Return plugin data
|
368 |
-
* @since 1.0.0
|
369 |
-
*/
|
370 |
-
public function plugin_data() {
|
371 |
-
// Being cautious here
|
372 |
-
if( ! function_exists( 'get_plugin_data' ) ) {
|
373 |
-
include ABSPATH . '/wp-admin/includes/plugin.php';
|
374 |
-
}
|
375 |
-
// Retrieve current plugin information
|
376 |
-
$plugin = get_plugin_data( $this->plugin_file );
|
377 |
-
return $plugin;
|
378 |
-
}
|
379 |
-
|
380 |
-
/**
|
381 |
-
* Deactivating plugin
|
382 |
-
* @since 1.0.0
|
383 |
-
*/
|
384 |
-
public function deactivate_this_plugin() {
|
385 |
-
// Check to see if the user has opted in to tracking
|
386 |
-
if( $this->what_am_i == 'theme' ) {
|
387 |
-
$allow_tracking = $this->theme_allows_tracking;
|
388 |
-
} else {
|
389 |
-
$allow_tracking = $this->get_is_tracking_allowed();
|
390 |
-
}
|
391 |
-
|
392 |
-
if( ! $allow_tracking ) {
|
393 |
-
return;
|
394 |
-
}
|
395 |
-
|
396 |
-
$body = $this->get_data();
|
397 |
-
$body['status'] = 'Deactivated'; // Never translated
|
398 |
-
$body['deactivated_date'] = time();
|
399 |
-
|
400 |
-
// Add deactivation form data
|
401 |
-
if( false !== get_option( 'wisdom_deactivation_reason_' . $this->plugin_name ) ) {
|
402 |
-
$body['deactivation_reason'] = get_option( 'wisdom_deactivation_reason_' . $this->plugin_name );
|
403 |
-
}
|
404 |
-
if( false !== get_option( 'wisdom_deactivation_details_' . $this->plugin_name ) ) {
|
405 |
-
$body['deactivation_details'] = get_option( 'wisdom_deactivation_details_' . $this->plugin_name );
|
406 |
-
}
|
407 |
-
|
408 |
-
$this->send_data( $body );
|
409 |
-
// Clear scheduled update
|
410 |
-
wp_clear_scheduled_hook( 'put_do_weekly_action' );
|
411 |
-
|
412 |
-
// Clear the wisdom_last_track_time value for this plugin
|
413 |
-
// @since 1.2.2
|
414 |
-
$track_time = get_option( 'wisdom_last_track_time' );
|
415 |
-
if( isset( $track_time[$this->plugin_name]) ) {
|
416 |
-
unset( $track_time[$this->plugin_name] );
|
417 |
-
}
|
418 |
-
update_option( 'wisdom_last_track_time', $track_time );
|
419 |
-
|
420 |
-
}
|
421 |
-
|
422 |
-
/**
|
423 |
-
* Is tracking allowed?
|
424 |
-
* @since 1.0.0
|
425 |
-
*/
|
426 |
-
public function get_is_tracking_allowed() {
|
427 |
-
|
428 |
-
// First, check if the user has changed their mind and opted out of tracking
|
429 |
-
if( $this->has_user_opted_out() ) {
|
430 |
-
$this->set_is_tracking_allowed( false, $this->plugin_name );
|
431 |
-
return false;
|
432 |
-
}
|
433 |
-
|
434 |
-
if( $this->what_am_i == 'theme' ) {
|
435 |
-
|
436 |
-
$mod = get_theme_mod( 'wisdom-allow-tracking', 0 );
|
437 |
-
if( $mod ) {
|
438 |
-
return true;
|
439 |
-
}
|
440 |
-
|
441 |
-
} else {
|
442 |
-
|
443 |
-
// The wisdom_allow_tracking option is an array of plugins that are being tracked
|
444 |
-
$allow_tracking = get_option( 'wisdom_allow_tracking' );
|
445 |
-
// If this plugin is in the array, then tracking is allowed
|
446 |
-
if( isset( $allow_tracking[$this->plugin_name] ) ) {
|
447 |
-
return true;
|
448 |
-
}
|
449 |
-
|
450 |
-
}
|
451 |
-
|
452 |
-
return false;
|
453 |
-
}
|
454 |
-
|
455 |
-
/**
|
456 |
-
* Set if tracking is allowed
|
457 |
-
* Option is an array of all plugins with tracking permitted
|
458 |
-
* More than one plugin may be using the tracker
|
459 |
-
* @since 1.0.0
|
460 |
-
* @param $is_allowed Boolean true if tracking is allowed, false if not
|
461 |
-
*/
|
462 |
-
public function set_is_tracking_allowed( $is_allowed, $plugin=null ) {
|
463 |
-
|
464 |
-
if( empty( $plugin ) ) {
|
465 |
-
$plugin = $this->plugin_name;
|
466 |
-
}
|
467 |
-
|
468 |
-
// The wisdom_allow_tracking option is an array of plugins that are being tracked
|
469 |
-
$allow_tracking = get_option( 'wisdom_allow_tracking' );
|
470 |
-
|
471 |
-
// If the user has decided to opt out
|
472 |
-
if( $this->has_user_opted_out() ) {
|
473 |
-
if( $this->what_am_i == 'theme' ) {
|
474 |
-
set_theme_mod( 'wisdom-allow-tracking', 0 );
|
475 |
-
} else {
|
476 |
-
if( isset( $allow_tracking[$plugin] ) ) {
|
477 |
-
unset( $allow_tracking[$plugin] );
|
478 |
-
}
|
479 |
-
}
|
480 |
-
|
481 |
-
} else if( $is_allowed || ! $this->require_optin ) {
|
482 |
-
// If the user has agreed to allow tracking or if opt-in is not required
|
483 |
-
|
484 |
-
if( $this->what_am_i == 'theme' ) {
|
485 |
-
set_theme_mod( 'wisdom-allow-tracking', 1 );
|
486 |
-
} else {
|
487 |
-
if( empty( $allow_tracking ) || ! is_array( $allow_tracking ) ) {
|
488 |
-
// If nothing exists in the option yet, start a new array with the plugin name
|
489 |
-
$allow_tracking = array( $plugin => $plugin );
|
490 |
-
} else {
|
491 |
-
// Else add the plugin name to the array
|
492 |
-
$allow_tracking[$plugin] = $plugin;
|
493 |
-
}
|
494 |
-
}
|
495 |
-
|
496 |
-
} else {
|
497 |
-
|
498 |
-
if( $this->what_am_i == 'theme' ) {
|
499 |
-
set_theme_mod( 'wisdom-allow-tracking', 0 );
|
500 |
-
} else {
|
501 |
-
if( isset( $allow_tracking[$plugin] ) ) {
|
502 |
-
unset( $allow_tracking[$plugin] );
|
503 |
-
}
|
504 |
-
}
|
505 |
-
|
506 |
-
}
|
507 |
-
|
508 |
-
update_option( 'wisdom_allow_tracking', $allow_tracking );
|
509 |
-
|
510 |
-
}
|
511 |
-
|
512 |
-
/**
|
513 |
-
* Has the user opted out of allowing tracking?
|
514 |
-
* Note that themes are opt in / plugins are opt out
|
515 |
-
* @since 1.1.0
|
516 |
-
* @return Boolean
|
517 |
-
*/
|
518 |
-
public function has_user_opted_out() {
|
519 |
-
// Different opt-out methods for plugins and themes
|
520 |
-
if( $this->what_am_i == 'theme' ) {
|
521 |
-
// Look for the theme mod
|
522 |
-
$mod = get_theme_mod( 'wisdom-allow-tracking', 0 );
|
523 |
-
if( false === $mod ) {
|
524 |
-
// If the theme mod is not set, then return true - the user has opted out
|
525 |
-
return true;
|
526 |
-
}
|
527 |
-
} else {
|
528 |
-
// Iterate through the options that are being tracked looking for wisdom_opt_out setting
|
529 |
-
if( ! empty( $this->options ) ) {
|
530 |
-
foreach( $this->options as $option_name ) {
|
531 |
-
// Check each option
|
532 |
-
$options = get_option( $option_name );
|
533 |
-
// If we find the setting, return true
|
534 |
-
if( ! empty( $options['wisdom_opt_out'] ) ) {
|
535 |
-
return true;
|
536 |
-
}
|
537 |
-
}
|
538 |
-
}
|
539 |
-
}
|
540 |
-
return false;
|
541 |
-
}
|
542 |
-
|
543 |
-
/**
|
544 |
-
* Check if it's time to track
|
545 |
-
* @since 1.1.1
|
546 |
-
*/
|
547 |
-
public function get_is_time_to_track() {
|
548 |
-
// Let's see if we're due to track this plugin yet
|
549 |
-
$track_times = get_option( 'wisdom_last_track_time', array() );
|
550 |
-
if( ! isset( $track_times[$this->plugin_name] ) ) {
|
551 |
-
// If we haven't set a time for this plugin yet, then we must track it
|
552 |
-
return true;
|
553 |
-
} else {
|
554 |
-
// If the time is set, let's get our schedule and check if it's time to track
|
555 |
-
$schedule = $this->get_schedule();
|
556 |
-
if( $schedule == 'daily' ) {
|
557 |
-
$period = 'day';
|
558 |
-
} else if( $schedule == 'weekly' ) {
|
559 |
-
$period = 'week';
|
560 |
-
} else {
|
561 |
-
$period = 'month';
|
562 |
-
}
|
563 |
-
if( $track_times[$this->plugin_name] < strtotime( '-1 ' . $period ) ) {
|
564 |
-
return true;
|
565 |
-
}
|
566 |
-
}
|
567 |
-
return false;
|
568 |
-
}
|
569 |
-
|
570 |
-
/**
|
571 |
-
* Record the time we send tracking data
|
572 |
-
* @since 1.1.1
|
573 |
-
*/
|
574 |
-
public function set_track_time() {
|
575 |
-
// We've tracked, so record the time
|
576 |
-
$track_times = get_option( 'wisdom_last_track_time', array() );
|
577 |
-
// Set different times according to plugin, in case we are tracking multiple plugins
|
578 |
-
$track_times[$this->plugin_name] = time();
|
579 |
-
update_option( 'wisdom_last_track_time', $track_times );
|
580 |
-
}
|
581 |
-
|
582 |
-
/**
|
583 |
-
* Set the time when we can display the opt-in notification
|
584 |
-
* Will display now unless filtered
|
585 |
-
* @since 1.2.4
|
586 |
-
*/
|
587 |
-
public function set_notification_time() {
|
588 |
-
$notification_times = get_option( 'wisdom_notification_times', array() );
|
589 |
-
// Set different times according to plugin, in case we are tracking multiple plugins
|
590 |
-
if( ! isset( $notification_times[$this->plugin_name] ) ) {
|
591 |
-
$delay_notification = apply_filters( 'wisdom_delay_notification_' . $this->plugin_name, 0 );
|
592 |
-
// We can delay the notification time
|
593 |
-
$notification_time = time() + absint( $delay_notification );
|
594 |
-
$notification_times[$this->plugin_name] = $notification_time;
|
595 |
-
update_option( 'wisdom_notification_times', $notification_times );
|
596 |
-
}
|
597 |
-
}
|
598 |
-
|
599 |
-
/**
|
600 |
-
* Get whether it's time to display the notification
|
601 |
-
* @since 1.2.4
|
602 |
-
* @return Boolean
|
603 |
-
*/
|
604 |
-
public function get_is_notification_time() {
|
605 |
-
$notification_times = get_option( 'wisdom_notification_times', array() );
|
606 |
-
$time = time();
|
607 |
-
// Set different times according to plugin, in case we are tracking multiple plugins
|
608 |
-
if( isset( $notification_times[$this->plugin_name] ) ) {
|
609 |
-
$notification_time = $notification_times[$this->plugin_name];
|
610 |
-
if( $time >= $notification_time ) {
|
611 |
-
return true;
|
612 |
-
}
|
613 |
-
}
|
614 |
-
return false;
|
615 |
-
}
|
616 |
-
|
617 |
-
/**
|
618 |
-
* Set if we should block the opt-in notice for this plugin
|
619 |
-
* Option is an array of all plugins that have received a response from the user
|
620 |
-
* @since 1.0.0
|
621 |
-
*/
|
622 |
-
public function update_block_notice( $plugin=null ) {
|
623 |
-
if( empty( $plugin ) ) {
|
624 |
-
$plugin = $this->plugin_name;
|
625 |
-
}
|
626 |
-
$block_notice = get_option( 'wisdom_block_notice' );
|
627 |
-
if( empty( $block_notice ) || ! is_array( $block_notice ) ) {
|
628 |
-
// If nothing exists in the option yet, start a new array with the plugin name
|
629 |
-
$block_notice = array( $plugin => $plugin );
|
630 |
-
} else {
|
631 |
-
// Else add the plugin name to the array
|
632 |
-
$block_notice[$plugin] = $plugin;
|
633 |
-
}
|
634 |
-
update_option( 'wisdom_block_notice', $block_notice );
|
635 |
-
}
|
636 |
-
|
637 |
-
/**
|
638 |
-
* Can we collect the email address?
|
639 |
-
* @since 1.0.0
|
640 |
-
*/
|
641 |
-
public function get_can_collect_email() {
|
642 |
-
// The wisdom_collect_email option is an array of plugins that are being tracked
|
643 |
-
$collect_email = get_option( 'wisdom_collect_email' );
|
644 |
-
// If this plugin is in the array, then we can collect the email address
|
645 |
-
if( isset( $collect_email[$this->plugin_name] ) ) {
|
646 |
-
return true;
|
647 |
-
}
|
648 |
-
return false;
|
649 |
-
}
|
650 |
-
|
651 |
-
/**
|
652 |
-
* Set if user has allowed us to collect their email address
|
653 |
-
* Option is an array of all plugins with email collection permitted
|
654 |
-
* More than one plugin may be using the tracker
|
655 |
-
* @since 1.0.0
|
656 |
-
* @param $can_collect Boolean true if collection is allowed, false if not
|
657 |
-
*/
|
658 |
-
public function set_can_collect_email( $can_collect, $plugin=null ) {
|
659 |
-
if( empty( $plugin ) ) {
|
660 |
-
$plugin = $this->plugin_name;
|
661 |
-
}
|
662 |
-
// The wisdom_collect_email option is an array of plugins that are being tracked
|
663 |
-
$collect_email = get_option( 'wisdom_collect_email' );
|
664 |
-
// If the user has agreed to allow tracking or if opt-in is not required
|
665 |
-
if( $can_collect ) {
|
666 |
-
if( empty( $collect_email ) || ! is_array( $collect_email ) ) {
|
667 |
-
// If nothing exists in the option yet, start a new array with the plugin name
|
668 |
-
$collect_email = array( $plugin => $plugin );
|
669 |
-
} else {
|
670 |
-
// Else add the plugin name to the array
|
671 |
-
$collect_email[$plugin] = $plugin;
|
672 |
-
}
|
673 |
-
} else {
|
674 |
-
if( isset( $collect_email[$plugin] ) ) {
|
675 |
-
unset( $collect_email[$plugin] );
|
676 |
-
}
|
677 |
-
}
|
678 |
-
update_option( 'wisdom_collect_email', $collect_email );
|
679 |
-
}
|
680 |
-
|
681 |
-
/**
|
682 |
-
* Get the correct email address to use
|
683 |
-
* @since 1.1.2
|
684 |
-
* @return Email address
|
685 |
-
*/
|
686 |
-
public function get_admin_email() {
|
687 |
-
// The wisdom_collect_email option is an array of plugins that are being tracked
|
688 |
-
$email = get_option( 'wisdom_admin_emails' );
|
689 |
-
// If this plugin is in the array, then we can collect the email address
|
690 |
-
if( isset( $email[$this->plugin_name] ) ) {
|
691 |
-
return $email[$this->plugin_name];
|
692 |
-
}
|
693 |
-
return false;
|
694 |
-
}
|
695 |
-
|
696 |
-
/**
|
697 |
-
* Set the correct email address to use
|
698 |
-
* There might be more than one admin on the site
|
699 |
-
* So we only use the first admin's email address
|
700 |
-
* @param $email Email address to set
|
701 |
-
* @param $plugin Plugin name to set email address for
|
702 |
-
* @since 1.1.2
|
703 |
-
*/
|
704 |
-
public function set_admin_email( $email=null, $plugin=null ) {
|
705 |
-
if( empty( $plugin ) ) {
|
706 |
-
$plugin = $this->plugin_name;
|
707 |
-
}
|
708 |
-
// If no email address passed, try to get the current user's email
|
709 |
-
if( empty( $email ) ) {
|
710 |
-
// Have to check that current user object is available
|
711 |
-
if( function_exists( 'wp_get_current_user' ) ) {
|
712 |
-
$current_user = wp_get_current_user();
|
713 |
-
$email = $current_user->user_email;
|
714 |
-
}
|
715 |
-
}
|
716 |
-
// The wisdom_admin_emails option is an array of admin email addresses
|
717 |
-
$admin_emails = get_option( 'wisdom_admin_emails' );
|
718 |
-
if( empty( $admin_emails ) || ! is_array( $admin_emails ) ) {
|
719 |
-
// If nothing exists in the option yet, start a new array with the plugin name
|
720 |
-
$admin_emails = array( $plugin => sanitize_email( $email ) );
|
721 |
-
} else if( empty( $admin_emails[$plugin] ) ) {
|
722 |
-
// Else add the email address to the array, if not already set
|
723 |
-
$admin_emails[$plugin] = sanitize_email( $email );
|
724 |
-
}
|
725 |
-
update_option( 'wisdom_admin_emails', $admin_emails );
|
726 |
-
}
|
727 |
-
|
728 |
-
/**
|
729 |
-
* Display the admin notice to users to allow them to opt in
|
730 |
-
*
|
731 |
-
* @since 1.0.0
|
732 |
-
*/
|
733 |
-
public function optin_notice() {
|
734 |
-
// Check for plugin args
|
735 |
-
if( isset( $_GET['plugin'] ) && isset( $_GET['plugin_action'] ) ) {
|
736 |
-
$plugin = sanitize_text_field( $_GET['plugin'] );
|
737 |
-
$action = sanitize_text_field( $_GET['plugin_action'] );
|
738 |
-
if( $action == 'yes' ) {
|
739 |
-
$this->set_is_tracking_allowed( true, $plugin );
|
740 |
-
// Run this straightaway
|
741 |
-
add_action( 'admin_init', array( $this, 'force_tracking' ) );
|
742 |
-
} else {
|
743 |
-
$this->set_is_tracking_allowed( false, $plugin );
|
744 |
-
}
|
745 |
-
$this->update_block_notice( $plugin );
|
746 |
-
}
|
747 |
-
|
748 |
-
// Is it time to display the notification?
|
749 |
-
$is_time = $this->get_is_notification_time();
|
750 |
-
if( ! $is_time ) {
|
751 |
-
return false;
|
752 |
-
}
|
753 |
-
|
754 |
-
// Check whether to block the notice, e.g. because we're in a local environment
|
755 |
-
// wisdom_block_notice works the same as wisdom_allow_tracking, an array of plugin names
|
756 |
-
$block_notice = get_option( 'wisdom_block_notice' );
|
757 |
-
|
758 |
-
if( isset( $block_notice[$this->plugin_name] ) ) {
|
759 |
-
return;
|
760 |
-
}
|
761 |
-
|
762 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
763 |
-
return;
|
764 |
-
}
|
765 |
-
|
766 |
-
// @credit EDD
|
767 |
-
// Don't bother asking user to opt in if they're in local dev
|
768 |
-
$is_local = false;
|
769 |
-
if( stristr( network_site_url( '/' ), '.dev' ) !== false || stristr( network_site_url( '/' ), 'localhost' ) !== false || stristr( network_site_url( '/' ), ':8888' ) !== false ) {
|
770 |
-
$is_local = true;
|
771 |
-
}
|
772 |
-
$is_local = apply_filters( 'wisdom_is_local_' . $this->plugin_name, $is_local );
|
773 |
-
if ( $is_local ) {
|
774 |
-
$this->update_block_notice();
|
775 |
-
} else {
|
776 |
-
|
777 |
-
// Display the notice requesting permission to track
|
778 |
-
// Retrieve current plugin information
|
779 |
-
$plugin = $this->plugin_data();
|
780 |
-
$plugin_name = $plugin['Name'];
|
781 |
-
|
782 |
-
// Args to add to query if user opts in to tracking
|
783 |
-
$yes_args = array(
|
784 |
-
'plugin' => $this->plugin_name,
|
785 |
-
'plugin_action' => 'yes'
|
786 |
-
);
|
787 |
-
|
788 |
-
// Decide how to request permission to collect email addresses
|
789 |
-
if( $this->marketing == 1 ) {
|
790 |
-
// Option 1 combines permissions to track and collect email
|
791 |
-
$yes_args['marketing_optin'] = 'yes';
|
792 |
-
} else if( $this->marketing == 2 ) {
|
793 |
-
// Option 2 enables a second notice that fires after the user opts in to tracking
|
794 |
-
$yes_args['marketing'] = 'yes';
|
795 |
-
}
|
796 |
-
$url_yes = add_query_arg( $yes_args );
|
797 |
-
$url_no = add_query_arg( array(
|
798 |
-
'plugin' => $this->plugin_name,
|
799 |
-
'plugin_action' => 'no'
|
800 |
-
) );
|
801 |
-
|
802 |
-
// Decide on notice text
|
803 |
-
if( $this->marketing != 1 ) {
|
804 |
-
// Standard notice text
|
805 |
-
$notice_text = sprintf(
|
806 |
-
__( 'Thank you for installing our %1$s. We would like to track its usage on your site. We don\'t record any sensitive data, only information regarding the WordPress environment and %1$s settings, which we will use to help us make improvements to the %1$s. Tracking is completely optional.', 'singularity' ),
|
807 |
-
$this->what_am_i
|
808 |
-
);
|
809 |
-
} else {
|
810 |
-
// If we have option 1 for marketing, we include reference to sending product information here
|
811 |
-
$notice_text = sprintf(
|
812 |
-
__( 'Thank you for installing our %1$s. We\'d like your permission to track its usage on your site and subscribe you to our newsletter. We won\'t record any sensitive data, only information regarding the WordPress environment and %1$s settings, which we will use to help us make improvements to the %1$s. Tracking is completely optional.', 'singularity' ),
|
813 |
-
$this->what_am_i
|
814 |
-
);
|
815 |
-
}
|
816 |
-
// And we allow you to filter the text anyway
|
817 |
-
$notice_text = apply_filters( 'wisdom_notice_text_' . esc_attr( $this->plugin_name ), $notice_text ); ?>
|
818 |
-
|
819 |
-
<div class="notice notice-info updated put-dismiss-notice">
|
820 |
-
<p><?php echo '<strong>' . esc_html( $plugin_name ) . '</strong>'; ?></p>
|
821 |
-
<p><?php echo esc_html( $notice_text ); ?></p>
|
822 |
-
<p>
|
823 |
-
<a href="<?php echo esc_url( $url_yes ); ?>" class="button-secondary"><?php _e( 'Allow', 'singularity' ); ?></a>
|
824 |
-
<a href="<?php echo esc_url( $url_no ); ?>" class="button-secondary"><?php _e( 'Do Not Allow', 'singularity' ); ?></a>
|
825 |
-
</p>
|
826 |
-
</div>
|
827 |
-
<?php
|
828 |
-
}
|
829 |
-
|
830 |
-
}
|
831 |
-
|
832 |
-
/**
|
833 |
-
* Display the marketing notice to users if enabled
|
834 |
-
* Only displays after the user has opted in to tracking
|
835 |
-
*
|
836 |
-
* @since 1.0.0
|
837 |
-
*/
|
838 |
-
public function marketing_notice() {
|
839 |
-
// Check if user has opted in to marketing
|
840 |
-
if( isset( $_GET['marketing_optin'] ) ) {
|
841 |
-
// Set marketing optin
|
842 |
-
$this->set_can_collect_email( sanitize_text_field( $_GET['marketing_optin'] ), $this->plugin_name );
|
843 |
-
// Do tracking
|
844 |
-
$this->do_tracking( true );
|
845 |
-
} else if( isset( $_GET['marketing'] ) && $_GET['marketing']=='yes' ) {
|
846 |
-
// Display the notice requesting permission to collect email address
|
847 |
-
// Retrieve current plugin information
|
848 |
-
$plugin = $this->plugin_data();
|
849 |
-
$plugin_name = $plugin['Name'];
|
850 |
-
|
851 |
-
$url_yes = add_query_arg( array(
|
852 |
-
'plugin' => $this->plugin_name,
|
853 |
-
'marketing_optin' => 'yes'
|
854 |
-
) );
|
855 |
-
$url_no = add_query_arg( array(
|
856 |
-
'plugin' => $this->plugin_name,
|
857 |
-
'marketing_optin' => 'no'
|
858 |
-
) );
|
859 |
-
|
860 |
-
$marketing_text = sprintf(
|
861 |
-
__( 'Thank you for opting in to tracking. Would you like to receive occasional news about this %s, including details of new features and special offers?', 'singularity' ),
|
862 |
-
$this->what_am_i
|
863 |
-
);
|
864 |
-
$marketing_text = apply_filters( 'wisdom_marketing_text_' . esc_attr( $this->plugin_name ), $marketing_text ); ?>
|
865 |
-
|
866 |
-
<div class="notice notice-info updated put-dismiss-notice">
|
867 |
-
<p><?php echo '<strong>' . esc_html( $plugin_name ) . '</strong>'; ?></p>
|
868 |
-
<p><?php echo esc_html( $marketing_text ); ?></p>
|
869 |
-
<p>
|
870 |
-
<a href="<?php echo esc_url( $url_yes ); ?>" data-putnotice="yes" class="button-secondary"><?php _e( 'Yes Please', 'singularity' ); ?></a>
|
871 |
-
<a href="<?php echo esc_url( $url_no ); ?>" data-putnotice="no" class="button-secondary"><?php _e( 'No Thank You', 'singularity' ); ?></a>
|
872 |
-
</p>
|
873 |
-
</div>
|
874 |
-
<?php }
|
875 |
-
}
|
876 |
-
|
877 |
-
/**
|
878 |
-
* Filter the deactivation link to allow us to present a form when the user deactivates the plugin
|
879 |
-
* @since 1.0.0
|
880 |
-
*/
|
881 |
-
public function filter_action_links( $links ) {
|
882 |
-
// Check to see if the user has opted in to tracking
|
883 |
-
if( ! $this->get_is_tracking_allowed() ) {
|
884 |
-
return $links;
|
885 |
-
}
|
886 |
-
if( isset( $links['deactivate'] ) && $this->include_goodbye_form ) {
|
887 |
-
$deactivation_link = $links['deactivate'];
|
888 |
-
// Insert an onClick action to allow form before deactivating
|
889 |
-
$deactivation_link = str_replace( '<a ', '<div class="put-goodbye-form-wrapper"><span class="put-goodbye-form" id="put-goodbye-form-' . esc_attr( $this->plugin_name ) . '"></span></div><a onclick="javascript:event.preventDefault();" id="put-goodbye-link-' . esc_attr( $this->plugin_name ) . '" ', $deactivation_link );
|
890 |
-
$links['deactivate'] = $deactivation_link;
|
891 |
-
}
|
892 |
-
return $links;
|
893 |
-
}
|
894 |
-
|
895 |
-
/*
|
896 |
-
* Form text strings
|
897 |
-
* These are non-filterable and used as fallback in case filtered strings aren't set correctly
|
898 |
-
* @since 1.0.0
|
899 |
-
*/
|
900 |
-
public function form_default_text() {
|
901 |
-
$form = array();
|
902 |
-
$form['heading'] = __( 'Sorry to see you go', 'singularity' );
|
903 |
-
$form['body'] = __( 'Before you deactivate the plugin, would you quickly give us your reason for doing so?', 'singularity' );
|
904 |
-
$form['options'] = array(
|
905 |
-
__( 'Set up is too difficult', 'singularity' ),
|
906 |
-
__( 'Lack of documentation', 'singularity' ),
|
907 |
-
__( 'Not the features I wanted', 'singularity' ),
|
908 |
-
__( 'Found a better plugin', 'singularity' ),
|
909 |
-
__( 'Installed by mistake', 'singularity' ),
|
910 |
-
__( 'Only required temporarily', 'singularity' ),
|
911 |
-
__( 'Didn\'t work', 'singularity' )
|
912 |
-
);
|
913 |
-
$form['details'] = __( 'Details (optional)', 'singularity' );
|
914 |
-
return $form;
|
915 |
-
}
|
916 |
-
|
917 |
-
/**
|
918 |
-
* Form text strings
|
919 |
-
* These can be filtered
|
920 |
-
* The filter hook must be unique to the plugin
|
921 |
-
* @since 1.0.0
|
922 |
-
*/
|
923 |
-
public function form_filterable_text() {
|
924 |
-
$form = $this->form_default_text();
|
925 |
-
return apply_filters( 'wisdom_form_text_' . esc_attr( $this->plugin_name ), $form );
|
926 |
-
}
|
927 |
-
|
928 |
-
/**
|
929 |
-
* Form text strings
|
930 |
-
* These can be filtered
|
931 |
-
* @since 1.0.0
|
932 |
-
*/
|
933 |
-
public function goodbye_ajax() {
|
934 |
-
// Get our strings for the form
|
935 |
-
$form = $this->form_filterable_text();
|
936 |
-
if( ! isset( $form['heading'] ) || ! isset( $form['body'] ) || ! isset( $form['options'] ) || ! is_array( $form['options'] ) || ! isset( $form['details'] ) ) {
|
937 |
-
// If the form hasn't been filtered correctly, we revert to the default form
|
938 |
-
$form = $this->form_default_text();
|
939 |
-
}
|
940 |
-
// Build the HTML to go in the form
|
941 |
-
$html = '<div class="put-goodbye-form-head"><strong>' . esc_html( $form['heading'] ) . '</strong></div>';
|
942 |
-
$html .= '<div class="put-goodbye-form-body"><p>' . esc_html( $form['body'] ) . '</p>';
|
943 |
-
if( is_array( $form['options'] ) ) {
|
944 |
-
$html .= '<div class="put-goodbye-options"><p>';
|
945 |
-
foreach( $form['options'] as $option ) {
|
946 |
-
$html .= '<input type="checkbox" name="put-goodbye-options[]" id="' . str_replace( " ", "", esc_attr( $option ) ) . '" value="' . esc_attr( $option ) . '"> <label for="' . str_replace( " ", "", esc_attr( $option ) ) . '">' . esc_attr( $option ) . '</label><br>';
|
947 |
-
}
|
948 |
-
$html .= '</p><label for="put-goodbye-reasons">' . esc_html( $form['details'] ) .'</label><textarea name="put-goodbye-reasons" id="put-goodbye-reasons" rows="2" style="width:100%"></textarea>';
|
949 |
-
$html .= '</div><!-- .put-goodbye-options -->';
|
950 |
-
}
|
951 |
-
$html .= '</div><!-- .put-goodbye-form-body -->';
|
952 |
-
$html .= '<p class="deactivating-spinner"><span class="spinner"></span> ' . __( 'Submitting form', 'singularity' ) . '</p>';
|
953 |
-
?>
|
954 |
-
<div class="put-goodbye-form-bg"></div>
|
955 |
-
<style type="text/css">
|
956 |
-
.put-form-active .put-goodbye-form-bg {
|
957 |
-
background: rgba( 0, 0, 0, .5 );
|
958 |
-
position: fixed;
|
959 |
-
top: 0;
|
960 |
-
left: 0;
|
961 |
-
width: 100%;
|
962 |
-
height: 100%;
|
963 |
-
}
|
964 |
-
.put-goodbye-form-wrapper {
|
965 |
-
position: relative;
|
966 |
-
z-index: 999;
|
967 |
-
display: none;
|
968 |
-
}
|
969 |
-
.put-form-active .put-goodbye-form-wrapper {
|
970 |
-
display: block;
|
971 |
-
}
|
972 |
-
.put-goodbye-form {
|
973 |
-
display: none;
|
974 |
-
}
|
975 |
-
.put-form-active .put-goodbye-form {
|
976 |
-
position: absolute;
|
977 |
-
bottom: 30px;
|
978 |
-
left: 0;
|
979 |
-
max-width: 400px;
|
980 |
-
background: #fff;
|
981 |
-
white-space: normal;
|
982 |
-
}
|
983 |
-
.put-goodbye-form-head {
|
984 |
-
background: #0073aa;
|
985 |
-
color: #fff;
|
986 |
-
padding: 8px 18px;
|
987 |
-
}
|
988 |
-
.put-goodbye-form-body {
|
989 |
-
padding: 8px 18px;
|
990 |
-
color: #444;
|
991 |
-
}
|
992 |
-
.deactivating-spinner {
|
993 |
-
display: none;
|
994 |
-
}
|
995 |
-
.deactivating-spinner .spinner {
|
996 |
-
float: none;
|
997 |
-
margin: 4px 4px 0 18px;
|
998 |
-
vertical-align: bottom;
|
999 |
-
visibility: visible;
|
1000 |
-
}
|
1001 |
-
.put-goodbye-form-footer {
|
1002 |
-
padding: 8px 18px;
|
1003 |
-
}
|
1004 |
-
</style>
|
1005 |
-
<script>
|
1006 |
-
jQuery(document).ready(function($){
|
1007 |
-
$("#put-goodbye-link-<?php echo esc_attr( $this->plugin_name ); ?>").on("click",function(){
|
1008 |
-
// We'll send the user to this deactivation link when they've completed or dismissed the form
|
1009 |
-
var url = document.getElementById("put-goodbye-link-<?php echo esc_attr( $this->plugin_name ); ?>");
|
1010 |
-
$('body').toggleClass('put-form-active');
|
1011 |
-
$("#put-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?>").fadeIn();
|
1012 |
-
$("#put-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?>").html( '<?php echo $html; ?>' + '<div class="put-goodbye-form-footer"><p><a id="put-submit-form" class="button primary" href="#"><?php _e( 'Submit and Deactivate', 'singularity' ); ?></a> <a class="secondary button" href="'+url+'"><?php _e( 'Just Deactivate', 'singularity' ); ?></a></p></div>');
|
1013 |
-
$('#put-submit-form').on('click', function(e){
|
1014 |
-
// As soon as we click, the body of the form should disappear
|
1015 |
-
$("#put-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?> .put-goodbye-form-body").fadeOut();
|
1016 |
-
$("#put-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?> .put-goodbye-form-footer").fadeOut();
|
1017 |
-
// Fade in spinner
|
1018 |
-
$("#put-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?> .deactivating-spinner").fadeIn();
|
1019 |
-
e.preventDefault();
|
1020 |
-
var values = new Array();
|
1021 |
-
$.each($("input[name='put-goodbye-options[]']:checked"), function(){
|
1022 |
-
values.push($(this).val());
|
1023 |
-
});
|
1024 |
-
var details = $('#put-goodbye-reasons').val();
|
1025 |
-
var data = {
|
1026 |
-
'action': 'goodbye_form',
|
1027 |
-
'values': values,
|
1028 |
-
'details': details,
|
1029 |
-
'security': "<?php echo wp_create_nonce ( 'wisdom_goodbye_form' ); ?>",
|
1030 |
-
'dataType': "json"
|
1031 |
-
}
|
1032 |
-
$.post(
|
1033 |
-
ajaxurl,
|
1034 |
-
data,
|
1035 |
-
function(response){
|
1036 |
-
// Redirect to original deactivation URL
|
1037 |
-
window.location.href = url;
|
1038 |
-
}
|
1039 |
-
);
|
1040 |
-
});
|
1041 |
-
// If we click outside the form, the form will close
|
1042 |
-
$('.put-goodbye-form-bg').on('click',function(){
|
1043 |
-
$("#put-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?>").fadeOut();
|
1044 |
-
$('body').removeClass('put-form-active');
|
1045 |
-
});
|
1046 |
-
});
|
1047 |
-
});
|
1048 |
-
</script>
|
1049 |
-
<?php }
|
1050 |
-
|
1051 |
-
/**
|
1052 |
-
* AJAX callback when the form is submitted
|
1053 |
-
* @since 1.0.0
|
1054 |
-
*/
|
1055 |
-
public function goodbye_form_callback() {
|
1056 |
-
check_ajax_referer( 'wisdom_goodbye_form', 'security' );
|
1057 |
-
if( isset( $_POST['values'] ) ) {
|
1058 |
-
$values = json_encode( wp_unslash( $_POST['values'] ) );
|
1059 |
-
update_option( 'wisdom_deactivation_reason_' . $this->plugin_name, $values );
|
1060 |
-
}
|
1061 |
-
if( isset( $_POST['details'] ) ) {
|
1062 |
-
$details = sanitize_text_field( $_POST['details'] );
|
1063 |
-
update_option( 'wisdom_deactivation_details_' . $this->plugin_name, $details );
|
1064 |
-
}
|
1065 |
-
$this->do_tracking(); // Run this straightaway
|
1066 |
-
echo 'success';
|
1067 |
-
wp_die();
|
1068 |
-
}
|
1069 |
-
|
1070 |
-
}
|
1071 |
-
|
1072 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/optimisationio-dashboard.php
CHANGED
@@ -17,7 +17,7 @@ $addons = Optimisationio_Dashboard::$addons;
|
|
17 |
<a href="https://optimisation.io/faq/" title="" target="_blank"><img src="<?php echo esc_url( plugin_dir_url( dirname( __FILE__ ) ) . 'images/logo-optimisation-line.png' ); ?>" alt="" /><?php _e( 'Help and Support' , 'optimisationio' ); ?></a>
|
18 |
</div>
|
19 |
<div class="statistics-top-cell support">
|
20 |
-
<a href="https://www.paypal.me/web9/10" class="donate-link" title="" target="_blank"><img src="<?php echo esc_url( plugin_dir_url( dirname( __FILE__ ) ) . 'images/icon-support.png' ); ?>" alt="" /><span><?php _e( '
|
21 |
</div>
|
22 |
</div>
|
23 |
|
@@ -95,25 +95,20 @@ $addons = Optimisationio_Dashboard::$addons;
|
|
95 |
<div class="donation-overlay-inner">
|
96 |
<div class="donation-overlay-top">
|
97 |
<img src="<?php echo esc_url( plugin_dir_url( dirname( __FILE__ ) ) . 'images/logo-optimisation.png' ); ?>" alt="" />
|
98 |
-
<span><?php _e( '
|
99 |
</div>
|
100 |
<div class="donation-overlay-bottom">
|
101 |
-
|
102 |
-
<
|
103 |
-
<
|
104 |
-
<
|
105 |
-
|
106 |
-
<option value="50">$50 - I really love this plugin</option>
|
107 |
-
<option value="60">$60 - A beer a month</option>
|
108 |
-
<option value="100">$100 - Money well spent</option>
|
109 |
-
</select>
|
110 |
<br/>
|
111 |
-
<button class="button button-primary button-large">DONATE</button>
|
112 |
</div>
|
113 |
<button class="close"><span>x</span></button>
|
114 |
</div>
|
115 |
</div>
|
116 |
-
</div>
|
117 |
</div><!-- // .donation-overlay-wrap -->
|
118 |
|
119 |
</div>
|
17 |
<a href="https://optimisation.io/faq/" title="" target="_blank"><img src="<?php echo esc_url( plugin_dir_url( dirname( __FILE__ ) ) . 'images/logo-optimisation-line.png' ); ?>" alt="" /><?php _e( 'Help and Support' , 'optimisationio' ); ?></a>
|
18 |
</div>
|
19 |
<div class="statistics-top-cell support">
|
20 |
+
<a href="https://www.paypal.me/web9/10" class="donate-link" title="" target="_blank"><img src="<?php echo esc_url( plugin_dir_url( dirname( __FILE__ ) ) . 'images/icon-support.png' ); ?>" alt="" /><span><?php _e( 'Need to disable one of our plugins?' , 'optimisationio' ); ?></span></a>
|
21 |
</div>
|
22 |
</div>
|
23 |
|
95 |
<div class="donation-overlay-inner">
|
96 |
<div class="donation-overlay-top">
|
97 |
<img src="<?php echo esc_url( plugin_dir_url( dirname( __FILE__ ) ) . 'images/logo-optimisation.png' ); ?>" alt="" />
|
98 |
+
<span><?php _e( 'Need to disable something?' , 'optimisationio' ); ?></span>
|
99 |
</div>
|
100 |
<div class="donation-overlay-bottom">
|
101 |
+
|
102 |
+
The primary plugin <b>WP Disable is called "WP Disable" </b>and can be disabled via the plugins page</p>
|
103 |
+
Our Image Optimisation Plugin is called <b>"JPG, PNG Compression and Optimization"</b> and can be disabled via the Plugins page</p>
|
104 |
+
Our Cache plugin is called <b>"Cache for WordPress Performance"</b> and can be disabled via the Plugins page
|
105 |
+
|
|
|
|
|
|
|
|
|
106 |
<br/>
|
|
|
107 |
</div>
|
108 |
<button class="close"><span>x</span></button>
|
109 |
</div>
|
110 |
</div>
|
111 |
+
</div>
|
112 |
</div><!-- // .donation-overlay-wrap -->
|
113 |
|
114 |
</div>
|
wpperformance.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: Improve WordPress performance by disabling unused items. <a href="admin.php?page=optimisationio-dashboard">Open Settings</a>
|
6 |
* Author: optimisation.io - jody nesbitt
|
7 |
* Author URI:https://optimisation.io
|
8 |
-
* Version: 1.5.
|
9 |
*
|
10 |
* Copyright (C) 2017-2018 Optimisation.io
|
11 |
*/
|
@@ -152,46 +152,6 @@ add_filter( 'cron_schedules', 'wpperformance_cron_additions' );
|
|
152 |
|
153 |
add_action( 'plugins_loaded', array( 'WpPerformance', 'get_instance' ) );
|
154 |
|
155 |
-
/**
|
156 |
-
* This function allows you to track usage of your plugin
|
157 |
-
* Place in your main plugin file
|
158 |
-
* Refer to https://wisdomplugin.com/support for help
|
159 |
-
*/
|
160 |
-
if( ! class_exists( 'Plugin_Usage_Tracker') ) {
|
161 |
-
require_once dirname( __FILE__ ) . '/tracking/class-plugin-usage-tracker.php';
|
162 |
-
}
|
163 |
-
if( ! function_exists( 'wpperformance_start_plugin_tracking' ) ) {
|
164 |
-
function wpperformance_start_plugin_tracking() {
|
165 |
-
$wisdom = new Plugin_Usage_Tracker(
|
166 |
-
__FILE__,
|
167 |
-
'https://hosting.io',
|
168 |
-
array(),
|
169 |
-
true,
|
170 |
-
true,
|
171 |
-
0
|
172 |
-
);
|
173 |
-
}
|
174 |
-
wpperformance_start_plugin_tracking();
|
175 |
-
}
|
176 |
-
|
177 |
-
// reasons
|
178 |
-
function your_prefix_filter_deactivation_form( $form ) {
|
179 |
-
$form[‘heading’] = __('Sorry to see you go', 'your-text-domain' );
|
180 |
-
$form['body'] = __('Before you deactivate the plugin, would you quickly give us your reason for doing so?', 'your-text-domain' );
|
181 |
-
$form['options'] = array(
|
182 |
-
__('Set up too difficult', 'your-text-domain' ),
|
183 |
-
__('The plugin broke my site', 'your-text-domain' ),
|
184 |
-
__('Not the features I wanted', 'your-text-domain' ),
|
185 |
-
__('Found a better plugin', 'your-text-domain' ),
|
186 |
-
__('Did not make any difference to performance', 'your-text-domain' ),
|
187 |
-
__('To difficult to use', 'your-text-domain' ),
|
188 |
-
__('I was just testing/comparing', 'your-text-domain' ),
|
189 |
-
);
|
190 |
-
return $form;
|
191 |
-
}
|
192 |
-
add_filter( ‘wisdom_form_text_’ .basename( __FILE__, '.php' ), ‘your_prefix_filter_deactivation_form’ );
|
193 |
-
// Must be added to your main plugin file
|
194 |
-
|
195 |
//Better update notifications
|
196 |
function prefix_plugin_update_message( $data, $response ) {
|
197 |
if( isset( $data['upgrade_notice'] ) ) {
|
5 |
* Description: Improve WordPress performance by disabling unused items. <a href="admin.php?page=optimisationio-dashboard">Open Settings</a>
|
6 |
* Author: optimisation.io - jody nesbitt
|
7 |
* Author URI:https://optimisation.io
|
8 |
+
* Version: 1.5.20
|
9 |
*
|
10 |
* Copyright (C) 2017-2018 Optimisation.io
|
11 |
*/
|
152 |
|
153 |
add_action( 'plugins_loaded', array( 'WpPerformance', 'get_instance' ) );
|
154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
//Better update notifications
|
156 |
function prefix_plugin_update_message( $data, $response ) {
|
157 |
if( isset( $data['upgrade_notice'] ) ) {
|