PluginProbe ʕ •ᴥ•ʔ
Brevo – Email, SMS, Web Push, Chat, and more. / 1.0
Brevo – Email, SMS, Web Push, Chat, and more. v1.0
2.9.13 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.2 3.1.20 3.1.21 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.1.29 3.1.3 3.1.30 3.1.31 3.1.32 3.1.33 3.1.34 3.1.35 3.1.36 3.1.37 3.1.38 3.1.39 3.1.4 3.1.40 3.1.41 3.1.42 3.1.43 3.1.44 3.1.45 3.1.46 3.1.47 3.1.48 3.1.49 3.1.5 3.1.50 3.1.51 3.1.52 3.1.53 3.1.54 3.1.55 3.1.56 3.1.57 3.1.58 3.1.59 3.1.6 3.1.60 3.1.61 3.1.62 3.1.63 3.1.64 3.1.65 3.1.66 3.1.67 3.1.68 3.1.69 3.1.7 3.1.70 3.1.71 3.1.72 3.1.73 3.1.74 3.1.75 3.1.76 3.1.77 3.1.78 3.1.79 3.1.8 3.1.80 3.1.81 3.1.82 3.1.83 3.1.84 3.1.85 3.1.86 3.1.87 3.1.88 3.1.89 3.1.9 3.1.90 3.1.91 3.1.92 3.1.93 3.1.94 3.1.95 3.1.96 3.1.97 3.1.98 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 trunk 1.0 1.5 2.0.8 2.9.10 2.9.11 2.9.12
mailin / mailin.php
mailin Last commit date
css 13 years ago js 13 years ago lang 13 years ago api_form.php 13 years ago compatibility.php 13 years ago cron.php 13 years ago listings.php 13 years ago mailin.php 13 years ago mailin_widget.php 13 years ago mailinapi.class.php 13 years ago readme.txt 13 years ago
mailin.php
441 lines
1 <?php
2
3 /**
4 Plugin Name: Mailin
5 Plugin URI: http://mailin.fr
6 Description: The Mailin plugin provides quick and easy way to synchronize subscribers from wordpress site to Mailin website account and vice versa.
7 Version: 1.0.0
8 Author: Mailin.fr
9 Author URI: http://www.mailin.fr
10 License: GPLv2 or later
11 */
12
13 /*
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License
16 as published by the Free Software Foundation; either version 2
17 of the License, or (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 */
28
29 //Mailin version
30 define('MAILIN_VER', '1.0.0');
31
32 //Initiallize mailin constants
33 Initiallize_mailin_constants();
34
35
36 // Get Mailin API class in application domain
37 if (!class_exists('mailin_API'))
38 {
39 require_once('mailinapi.class.php');
40 }
41
42 // Include Compatibility functions
43 require_once('compatibility.php');
44
45
46 /**
47 * Initillize mailin plugin
48 * @return void
49 */
50 function mailin_init()
51 {
52
53 mailin_load_resources();
54
55 //Internationalize the plugin
56 $i18n_file_name = 'mailin_lang';
57 $locale = apply_filters( 'plugin_locale', get_locale(), $i18n_file_name);
58
59 $filename = MAILIN_LANG_DIR.$i18n_file_name.'-'.$locale.'.mo';
60 load_textdomain('mailin_i18n', $filename);
61
62 }
63
64 add_action( 'init', 'mailin_init');
65
66
67 //Initilize Widget
68 include_once('mailin_widget.php');
69
70 /**
71 * Loads JS and CSS
72 * @return void
73 */
74 function mailin_load_resources()
75 {
76 wp_enqueue_style('mailin_wp_css', MAILIN_URL.'css/mailin_plugin.css');
77 }
78
79
80
81 /**
82 * Loads Mailin Admin page css
83 * @return void
84 */
85 function mailin_load_resources_admin()
86 {
87 wp_enqueue_style('mailin_admin_css', MAILIN_URL.'css/admin.css');
88 }
89
90 add_action('load-settings_page_mailin_options', 'mailin_load_resources_admin');
91
92
93
94 /**
95 * Update lists and campaigns on refreshing a page
96 *
97 */
98
99 $mObj = new mailin_API();
100 $api_key = get_option('mailin_apikey');
101
102
103 if(is_admin() && isset($_GET['page']) && $_GET['page'] == 'mailin_options' && $api_key != '' && $_SERVER['REQUEST_METHOD'] == 'GET'){
104
105 $mObj->updateUserLists($api_key);
106 $mObj->updateUserCampaigns($api_key);
107
108 }
109
110 /**
111 * Gets or sets error/success message
112 * @return string/bool depending on get/set
113 **/
114 function mailin_messages($msg = null)
115 {
116
117 global $mailin_msg;
118
119 if (!is_array($mailin_msg))
120 {
121 $mailin_msg = array();
122 }
123
124 if (is_null($msg))
125 {
126 return implode('', $mailin_msg);
127 }
128
129 $mailin_msg[] = $msg;
130 return true;
131 }
132
133
134 /**
135 * Handles forms submit
136 * @return void , sets error/success message
137 **/
138 function mailin_form_submit()
139 {
140
141 $action = '';
142
143 if(isset($_POST['mailin_form_action']))
144 {
145 $action = trim($_POST['mailin_form_action']);
146 if($action == '')
147 {
148 return;
149
150 }elseif($action == 'sync_users') {
151
152 $mObj = new mailin_API();
153 $mObj->syncUsers();
154
155 $message = '<p class="mailin_success" >'.__('Users synchronized successfully', 'mailin_i18n').'</p>';
156 mailin_messages($message);
157
158 }elseif($action == 'list_details') {
159
160 $mObj = new mailin_API();
161 $listDetails = $mObj->getListDetails($_POST['list_id']);
162
163 }elseif($action == 'apikey_update') {
164
165 $mObj = new mailin_API();
166 $mObj->handle_apikey_form_submit(strip_tags(stripslashes($_POST['mailin_apikey'])));
167
168 if(empty($mObj->_mailin_error))
169 {
170
171 $message = implode('<br/>', $mObj->_mailin_success);
172 $message = '<p class="mailin_success" >'.$message.'</p>';
173 mailin_messages($message);
174
175 }else{
176
177 $message = implode('<br/>', $mObj->_mailin_error);
178 $message = '<p class="mailin_error" >'.$message.'</p>';
179 mailin_messages($message);
180
181 }
182 }elseif($action == 'logout') {
183
184 $mObj = new mailin_API();
185 $mObj->handle_logout_form_submit();
186
187
188 }elseif($action == 'update_list'){
189
190 $mailin_list = isset($_POST['mailin_list']) ? $_POST['mailin_list'] : '' ;
191
192 $mObj = new mailin_API();
193 $mObj->handle_updatelist_form_submit($mailin_list);
194
195 if(!empty($mObj->_mailin_error))
196 {
197 $message = implode('<br/>', $mObj->_mailin_error);
198 $message = '<p class="mailin_error" >'.$message.'</p>';
199 mailin_messages($message);
200 }
201
202 if(!empty($mObj->_mailin_success))
203 {
204 $message = implode('<br/>', $mObj->_mailin_success);
205 $message = '<p class="mailin_success" >'.$message.'</p>';
206 mailin_messages($message);
207 }
208
209 }elseif($action == 'update_campaigns') {
210
211 $mailin_list = isset($_POST['mailin_list']) ? $_POST['mailin_list'] : '' ;
212
213 $mObj = new mailin_API();
214 $mObj->updateUserCampaigns();
215
216 $message = '<p class="mailin_success" >'.__('Campaigns updated successfully', 'mailin_i18n').'</p>';
217 mailin_messages($message);
218
219
220 }elseif($action == 'subscribe_form_submit'){
221
222 $mObj = new mailin_API();
223 $mObj->handle_newsletter_subscribe_submit();
224
225 if(!empty($mObj->_mailin_error))
226 {
227 $message = implode('<br/>', $mObj->_mailin_error);
228 $message = '<p class="mailin_error" >'.$message.'</p>';
229 mailin_messages($message);
230 }
231
232 if(!empty($mObj->_mailin_success))
233 {
234 $message = implode('<br/>', $mObj->_mailin_success);
235 $message = '<p class="mailin_success" >'.$message.'</p>';
236 mailin_messages($message);
237 }
238 }
239 }
240 }
241
242
243 add_action('init', 'mailin_form_submit');
244
245 /**
246 * Loads the view of Mailin admin page
247 * @return void
248 **/
249 function mailin_settings_admin_page()
250 {
251
252 // CHECK IF API KEY EXISTS
253 $api_key = get_option('mailin_apikey');
254
255 ?>
256 <div class="wrap">
257 <div style="float:left;margin-bottom:10px;width:670px;">
258 <div class="icon32" id="icon-options-general"><br></div>
259 <h2><?php esc_html_e('Mailin Setup', 'mailin_i18n');?> </h2>
260 </div>
261
262 <?php
263 if (mailin_messages() != '')
264 {
265 ?>
266 <div id="mc_message" class="mailin_row"><?php echo mailin_messages(); ?></div>
267 <?php
268 }
269
270 if($api_key != '')
271 {
272 require "listings.php";
273 }else{
274 require "api_form.php";
275 }
276 ?>
277
278 </div>
279 <?php
280 }
281
282 add_action('admin_menu', 'admin_menu');
283
284
285 /**
286 * Adds setup navigation link under settings
287 * @return void
288 **/
289 function admin_menu()
290 {
291 add_options_page('Mailin Setup', 'Mailin setup', 'administrator', 'mailin_options', 'mailin_settings_admin_page');
292 }
293
294
295
296 /**
297 * Links Mailin setup page to URL
298 * @return setup page link
299 **/
300 function mailin_action_links($links)
301 {
302 $settings_page = add_query_arg(array('page' => 'mailin_options'), admin_url('options-general.php'));
303 $settings_link = '<a href="'.esc_url($settings_page).'">'.__('Settings', 'Mailin setup' ).'</a>';
304 array_unshift($links, $settings_link);
305 return $links;
306 }
307
308 add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'mailin_action_links', 10, 1);
309
310
311 /**
312 * Sets up Plugin URL , Plugin directory , Plugin Language Directory
313 * SETUP subscriber table name
314 * @return setup page link
315 **/
316 function Initiallize_mailin_constants()
317 {
318
319 $locations = array(
320 'plugins' => array(
321 'dir' => WP_PLUGIN_DIR,
322 'url' => plugins_url()
323 ),
324 'template' => array(
325 'dir' => trailingslashit(get_template_directory()).'plugins/',
326 'url' => trailingslashit(get_template_directory_uri()).'plugins/',
327 )
328 );
329
330 $mailin_dirbase = trailingslashit(basename(dirname(__FILE__)));
331 $mailin_dir = trailingslashit(WP_PLUGIN_DIR).$mailin_dirbase;
332 $mailin_url = trailingslashit(WP_PLUGIN_URL).$mailin_dirbase;
333
334 foreach ($locations as $key => $loc)
335 {
336 $dir = trailingslashit($loc['dir']).$mailin_dirbase;
337 $url = trailingslashit($loc['url']).$mailin_dirbase;
338 if (is_file($dir.basename(__FILE__)))
339 {
340 $mailin_dir = $dir;
341 $mailin_url = $url;
342 break;
343 }
344 }
345
346 //MAILIN DIRECTORY PATH
347 define('MAILIN_DIR', $mailin_dir);
348
349 //MAILIN LANGUAGE DIRECTORY PATH
350 define('MAILIN_LANG_DIR', trailingslashit(MAILIN_DIR).'lang/');
351
352 //MAILIN PLUGIN DIRECTORY PATH
353 define('MAILIN_URL', $mailin_url);
354
355 global $wpdb;
356
357 //Subscribers table name
358 define('MAILIN_SUBSCRIBERS', $wpdb->prefix.'mailin_subscribers');
359
360 }
361
362 /*
363 * Create subscribers table upon installation
364 */
365 function mailin_install()
366 {
367
368 global $wpdb;
369 $sql = "CREATE TABLE ".MAILIN_SUBSCRIBERS." (
370 id int(11) NOT NULL AUTO_INCREMENT,
371 email VARCHAR(255) DEFAULT '' NOT NULL,
372 fname VARCHAR(55) DEFAULT '' NOT NULL,
373 lname VARCHAR(55) DEFAULT '' NOT NULL,
374 list VARCHAR(255) DEFAULT '' NOT NULL,
375 subscribed TINYINT(1) DEFAULT '1' NOT NULL,
376 create_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
377 UNIQUE KEY id (id)
378 );";
379
380 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
381 dbDelta($sql);
382 }
383
384
385 /*
386 * Called plugin is removed
387 * We do not remove previous data
388 */
389 function mailin_remove()
390 {
391
392
393 }
394
395 /* Runs when plugin is activated */
396 register_activation_hook(__FILE__,'mailin_install');
397
398 /* Runs on plugin deactivation*/
399 register_deactivation_hook( __FILE__, 'mailin_remove' );
400
401
402 class siteUsers
403 {
404
405 static function init()
406 {
407 add_action( 'user_register', array( __CLASS__, 'register_newly_added_user' ) );
408 }
409
410 /*
411 * This function is called when a new user is created
412 * User is added in mailinlist
413 */
414 static function register_newly_added_user( $user_id = null )
415 {
416
417 if($user_id != null)
418 {
419 $info = get_userdata( $user_id );
420
421 if(is_object($info))
422 {
423 if(isset($info->data->user_email) && $info->data->user_email != '')
424 {
425 $user_nicename = isset($info->data->user_nicename) ? $info->data->user_nicename : '';
426 $selected_list = get_option('mailin_list_selected');
427 $mObj = new mailin_API();
428 $mObj->updateSubscribers($info->data->user_email , $selected_list, $user_nicename , '' );
429 }
430 }
431 }
432 wp_update_user( $args );
433 }
434
435 }
436
437 siteUsers::init();
438
439
440 ?>
441