-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspeakout-email-petitions.php
256 lines (206 loc) · 8.37 KB
/
speakout-email-petitions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
/*
Plugin Name: SpeakOut! Email Petitions Pro
Plugin URI: https://speakoutpetitions.com/
Description: This is the fully featured Pro version of SpeakOut! Create custom email petition forms and include them on your site via shortcode or a widget. When signed, the petition is emailed to your target and signatures are saved in the database. There are many customisable options to make this plugin very flexible.
Author: Steve D
Author URI: https://SpeakOutPetitions.com
Text Domain: speakout
Domain Path: /languages
Requires at least: 5.0
Tested up to: 6.0
Requires PHP: 7.4
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Version: 105.3.7
{Plugin Name} is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
any later version.
{Plugin Name} is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
For the full text of the GNU General Public License see {License URI}.
*/
global $wpdb, $db_petitions, $db_signatures, $dk_speakout_version, $options;
$dk_speakout_version = '105.3.7';
$db_petitions = $wpdb->prefix . 'dk_speakout_petitions';
$db_signatures = $wpdb->prefix . 'dk_speakout_signatures';
$options = get_option( 'dk_speakout_options' );
// enable localizations
add_action( 'init', 'dk_speakout_translate' );
function dk_speakout_translate() {
load_plugin_textdomain( 'speakout', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
// load admin functions only on admin pages
if ( is_admin() ) {
include_once( dirname( __FILE__ ) . '/includes/install.php' );
include_once( dirname( __FILE__ ) . '/includes/admin.php' );
include_once( dirname( __FILE__ ) . '/includes/petitions.php' );
include_once( dirname( __FILE__ ) . '/includes/addnew.php' );
include_once( dirname( __FILE__ ) . '/includes/signatures.php' );
include_once( dirname( __FILE__ ) . '/includes/settings.php' );
include_once( dirname( __FILE__ ) . '/includes/csv.php' );
include_once( dirname( __FILE__ ) . '/includes/ajax.php' );
include_once( dirname( __FILE__ ) . '/includes/verify.php' );
include_once( dirname( __FILE__ ) . '/includes/license.php' );
if ( version_compare( get_bloginfo( 'version' ), '3.3', '>' ) == 1 ) {
include_once( dirname( __FILE__ ) . '/includes/help.php' );
}
// enable plugin activation
register_activation_hook( __FILE__, 'dk_speakout_install' );
}
// public pages
else {
include_once( dirname( __FILE__ ) . '/includes/emailpetition.php' );
include_once( dirname( __FILE__ ) . '/includes/signaturelist.php' );
include_once( dirname( __FILE__ ) . '/includes/confirmations.php' );
}
add_filter( 'plugin_row_meta', 'speakout_support_and_faq_links', 10, 4 );
function speakout_support_and_faq_links( $links_array, $plugin_file_name, $plugin_data, $status ){
if ( strpos( $plugin_file_name, basename(__FILE__) ) ) {
if($plugin_data['slug'] == 'speakout') { unset($links_array[2]); }
$links_array[] = '<a href="https://speakoutpetitions.com/faq/" target="_blank">FAQ</a>';
$links_array[] = '<a href="https://speakoutpetitions.com/contact" target="_blank">Support</a>';
$links_array[] = '<a href="https://speakoutpetitions.com/changelog" target="_blank">Changelog</a>';
$links_array[] = 'Thanks for upgrading!';
}
return $links_array;
}
// updater code
if( !class_exists( 'SpeakOutUpdateChecker' ) ) {
class SpeakOutUpdateChecker{
public $plugin_slug;
public $version;
public $cache_key;
public $cache_allowed;
public function __construct( $dk_speakout_version ) {
$this->plugin_slug = plugin_basename( __DIR__ );
$this->version = $dk_speakout_version;
$this->cache_key = 'speakout_custom_upd';
$this->cache_allowed = false;
add_filter( 'plugins_api', array( $this, 'info' ), 20, 3 );
add_filter( 'site_transient_update_plugins', array( $this, 'update' ) );
add_action( 'upgrader_process_complete', array( $this, 'purge' ), 10, 2 );
}
public function request(){
$remote = get_transient( $this->cache_key );
if( false === $remote || ! $this->cache_allowed ) {
$remote = wp_remote_get(
'https://speakoutpetitions.com/updater/info.json',
array(
'timeout' => 10,
'headers' => array(
'Accept' => 'application/json'
)
)
);
if(
is_wp_error( $remote )
|| 200 !== wp_remote_retrieve_response_code( $remote )
|| empty( wp_remote_retrieve_body( $remote ) )
) {
return false;
}
set_transient( $this->cache_key, $remote, DAY_IN_SECONDS );
}
$remote = json_decode( wp_remote_retrieve_body( $remote ) );
return $remote;
}
function info( $res, $action, $args ) {
// do nothing if you're not getting plugin information right now
if( 'plugin_information' !== $action ) {
return $res;
}
// do nothing if it is not our plugin
if( $this->plugin_slug !== $args->slug ) {
return $res;
}
// get updates
$remote = $this->request();
if( ! $remote ) {
return $res;
}
$res = new stdClass();
$res->name = $remote->name;
$res->slug = $remote->slug;
$res->version = $remote->version;
$res->tested = $remote->tested;
$res->requires = $remote->requires;
$res->author = $remote->author;
$res->author_profile = $remote->author_profile;
$res->download_link = $remote->download_url;
$res->trunk = $remote->download_url;
$res->requires_php = $remote->requires_php;
$res->last_updated = $remote->last_updated;
$res->sections = array(
'description' => $remote->sections->description,
'installation' => $remote->sections->installation,
'changelog' => $remote->sections->changelog
);
if( ! empty( $remote->banners ) ) {
$res->banners = array(
'low' => $remote->banners->low,
'high' => $remote->banners->high
);
}
return $res;
}
public function update( $transient ) {
if ( empty($transient->checked ) ) {
return $transient;
}
$remote = $this->request();
if(
$remote
&& version_compare( $this->version, $remote->version, '<' )
&& version_compare( $remote->requires, get_bloginfo( 'version' ), '<=' )
&& version_compare( $remote->requires_php, PHP_VERSION, '<' )
) {
$res = new stdClass();
$res->slug = $this->plugin_slug;
$res->plugin = plugin_basename( __FILE__ );
$res->new_version = $remote->version;
$res->tested = $remote->tested;
$res->package = $remote->download_url;
$transient->response[ $res->plugin ] = $res;
}
return $transient;
}
public function purge( $upgrader, $options ){
if (
$this->cache_allowed
&& 'update' === $options['action']
&& 'plugin' === $options[ 'type' ]
) {
// just clean the cache when new plugin version is installed
delete_transient( $this->cache_key );
}
}
}
// if updater enabled in settings check for latest version
if($options['updater'] == "on"){
new SpeakOutUpdateChecker($dk_speakout_version);
}
}
// eliminate warning - ob_end_flush(): failed to send buffer of zlib output compression
remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
//currently disabled until I have time to fix
/* $current_user = get_current_user_id();
function SpeakOut_plugin_notice() {
$user_id = $current_user->ID;
if (!get_user_meta($user_id, 'SpeakOut_plugin_notice_ignore')) {
echo '<div class="updated notice"><p>The SpeakOut! petition plugin is now also integrated with Mailerlite. Please help keep SpeakOut! 100% free - <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4PPYZ8K2KLXUJ" target=_blank">Donate</a> :: <a href="?' . $_SERVER['QUERY_STRING'] . '&SpeakOut-ignore-notice">Dismiss</a></p></div>';
}
}
add_action('admin_notices', 'SpeakOut_plugin_notice');
function SpeakOut_plugin_notice_ignore() {
$user_id = $current_user->ID;
if (isset($_GET['SpeakOut-ignore-notice'])) {
add_user_meta($user_id, 'SpeakOut_plugin_notice_ignore', 'true', true);
}
}
add_action('admin_init', 'SpeakOut_plugin_notice_ignore');
*/
?>