PluginProbe
Ultimate WP Mail / trunk
Ultimate WP Mail vtrunk
1.3.13 1.3.12 trunk 0.11 0.25 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 All 46 releases
ultimate-wp-mail / ultimate-wp-mail.php

ultimate-wp-mail.php in Ultimate WP Mail trunk, at ultimate-wp-mail.php

425 lines 15.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Ultimate WP Mail
4 Plugin URI: http://www.etoilewebdesign.com/plugins/ultimate-wp-mail/
5 Description: Custom email and SMS notifications. Automatic send actions. WPForms SMS integration. WooCommerce notifications for purchases, abandoned cart and more!
6 Author: Etoile Web Design
7 Author URI: https://www.etoilewebdesign.com/
8 Terms and Conditions: https://www.etoilewebdesign.com/plugin-terms-and-conditions/
9 Text Domain: ultimate-wp-mail
10 Version: 1.3.13
11 */
12
13
14 if ( ! defined( 'ABSPATH' ) )
15 exit;
16
17 if ( ! class_exists( 'ewduwpmInit' ) ) {
18 class ewduwpmInit {
19
20 // pointers to classes used by the plugin, where needed
21 public $admin_email_lists;
22 public $admin_user_stats;
23 public $cpts;
24 public $custom_element_manager;
25 public $database_manager;
26 public $email_queue;
27 public $logging;
28 public $notifications;
29 public $permissions;
30 public $settings;
31 public $sms_queue;
32 public $woocommerce;
33 public $wp_forms;
34
35 /**
36 * Initialize the plugin and register hooks
37 */
38 public function __construct() {
39
40 self::constants();
41 self::includes();
42 self::instantiate();
43 self::wp_hooks();
44 }
45
46 /**
47 * Define plugin constants.
48 *
49 * @since 1.0.0
50 * @access protected
51 * @return void
52 */
53 protected function constants() {
54
55 define( 'EWD_UWPM_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
56 define( 'EWD_UWPM_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
57 define( 'EWD_UWPM_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
58 define( 'EWD_UWPM_TEMPLATE_DIR', 'ewd-uwpm-templates' );
59 define( 'EWD_UWPM_VERSION', '1.3.13' );
60
61 define( 'EWD_UWPM_EMAIL_POST_TYPE', 'uwpm_mail_template' );
62 define( 'EWD_UWPM_SMS_POST_TYPE', 'uwpm_sms_template' );
63 define( 'EWD_UWPM_EMAIL_LOG_POST_TYPE', 'uwpm_email_log' );
64 define( 'EWD_UWPM_EMAIL_CATEGORY_TAXONOMY', 'uwpm-category' );
65 }
66
67 /**
68 * Include necessary classes.
69 *
70 * @since 1.0.0
71 * @access protected
72 * @return void
73 */
74 protected function includes() {
75
76 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/AboutUs.class.php' );
77 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/AdminEmailLists.class.php' );
78 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/AdminUserStats.class.php' );
79 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Ajax.class.php' );
80 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Blocks.class.php' );
81 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/CustomElement.class.php' );
82 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/CustomElementManager.class.php' );
83 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/CustomElementSection.class.php' );
84 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/CustomPostTypes.class.php' );
85 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Dashboard.class.php' );
86 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/DatabaseManager.class.php' );
87 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/DeactivationSurvey.class.php' );
88 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/EmailQueue.class.php' );
89 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Helper.class.php' );
90 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/InstallationWalkthrough.class.php' );
91 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Logging.class.php' );
92 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Notifications.class.php' );
93 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Permissions.class.php' );
94 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/ReviewAsk.class.php' );
95 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Settings.class.php' );
96 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/SMSQueue.class.php' );
97 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/template-functions.php' );
98 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/UserManager.class.php' );
99 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Widgets.class.php' );
100 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/WooCommerce.class.php' );
101 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/WPForms.class.php' );
102 }
103
104 /**
105 * Spin up instances of our plugin classes.
106 *
107 * @since 1.0.0
108 * @access protected
109 * @return void
110 */
111 protected function instantiate() {
112
113 new ewduwpmDashboard();
114 new ewduwpmDeactivationSurvey();
115 new ewduwpmInstallationWalkthrough();
116 new ewduwpmReviewAsk();
117
118 $this->admin_email_lists = new ewduwpmAdminEmailLists();
119 $this->admin_user_stats = new ewduwpmAdminUserStats();
120 $this->cpts = new ewduwpmCustomPostTypes();
121 $this->custom_element_manager = new ewduwpmCustomElementManager();
122 $this->database_manager = new ewduwpmDatabaseManager();
123 $this->logging = new ewduwpmLogging();
124 $this->notifications = new ewduwpmNotifications();
125 $this->permissions = new ewduwpmPermissions();
126 $this->settings = new ewduwpmSettings();
127 $this->woocommerce = new ewduwpmWooCommerce();
128 $this->wp_forms = new ewduwpmWPForms();
129
130 new ewduwpmAJAX();
131 new ewduwpmBlocks();
132 new ewduwpmUserManager();
133 new ewduwpmWidgetManager();
134 new ewduwpmAboutUs();
135 }
136
137 /**
138 * Run walk-through, load assets, add links to plugin listing, etc.
139 *
140 * @since 1.0.0
141 * @access protected
142 * @return void
143 */
144 protected function wp_hooks() {
145
146 register_activation_hook( __FILE__, array( $this, 'run_walkthrough' ) );
147 register_activation_hook( __FILE__, array( $this, 'convert_options' ) );
148 register_activation_hook( __FILE__, array( $this, 'create_tables' ) );
149
150 add_action( 'init', array( $this, 'load_view_files' ) );
151
152 add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
153 add_action( 'plugins_loaded', array( $this, 'init_queues' ) );
154
155 add_action( 'admin_notices', array( $this, 'display_header_area' ) );
156
157 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 10, 1 );
158 add_action( 'admin_head', array( $this, 'output_tinymce_vars' ) );
159 add_action( 'admin_enqueue_scripts', array( $this, 'register_assets' ) );
160 add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ) );
161 add_action( 'wp_head', 'ewd_add_frontend_ajax_url' );
162
163 add_filter( 'enter_title_here', array( $this, 'change_add_title_placeholder' ) );
164
165 add_filter( 'mce_external_plugins', array( $this, 'register_tinymce_javascript' ) );
166 add_filter( 'mce_buttons', array( $this, 'register_tinymce_buttons' ) );
167
168 add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2);
169 }
170
171 /**
172 * Run the options conversion function on update if necessary
173 *
174 * @since 1.0.0
175 * @access protected
176 * @return void
177 */
178 public function convert_options() {
179
180 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/BackwardsCompatibility.class.php' );
181 new ewduwpmBackwardsCompatibility();
182 }
183
184 /**
185 * Creates the tables where statistics and user information are stored
186 *
187 * @since 1.0.0
188 * @access protected
189 * @return void
190 */
191 public function create_tables() {
192
193 $this->database_manager->create_tables();
194 }
195
196 /**
197 * Load files needed for views
198 * @since 1.0.0
199 * @note Can be filtered to add new classes as needed
200 */
201 public function load_view_files() {
202
203 $files = array(
204 EWD_UWPM_PLUGIN_DIR . '/views/Base.class.php' // This will load all default classes
205 );
206
207 $files = apply_filters( 'ewd_uwpm_load_view_files', $files );
208
209 foreach( $files as $file ) {
210 require_once( $file );
211 }
212
213 }
214
215 /**
216 * Load the plugin textdomain for localisation
217 * @since 1.0.0
218 */
219 public function load_textdomain() {
220
221 load_plugin_textdomain( 'ultimate-wp-mail', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
222 }
223
224 /**
225 * Create the email queue
226 * */
227 public function init_queues() {
228 $this->email_queue = new ewduwpmEmailQueue();
229 $this->sms_queue = new ewduwpmSMSQueue();
230 }
231
232 /**
233 * Set a transient so that the walk-through gets run
234 * @since 1.0.0
235 */
236 public function run_walkthrough() {
237
238 set_transient( 'ewd-uwpm-getting-started', true, 30 );
239 }
240
241 /**
242 * Enqueue the admin-only CSS and Javascript
243 * @since 1.0.0
244 */
245 public function enqueue_admin_assets( $hook ) {
246 global $post;
247
248 $screen = get_current_screen();
249
250 $candidates = array(
251 EWD_UWPM_EMAIL_POST_TYPE,
252 EWD_UWPM_EMAIL_LOG_POST_TYPE,
253 EWD_UWPM_SMS_POST_TYPE,
254
255 'admin_page_ewd-uwpm-settings',
256
257 'uwpm_mail_template_page_ewd-uwpm-user-stats',
258 'uwpm_mail_template_page_ewd-uwpm-email-lists',
259 'uwpm_mail_template_page_ewd-uwpm-settings',
260
261 'edit-uwpm-category',
262 );
263
264 // Return if not UWPM post_type, we're not on a post-type page, or we're not on the settings or widget pages
265 if ( ! in_array( $hook, $candidates )
266 and ( empty( $screen->post_type ) or ! in_array ( $screen->post_type, $candidates ) )
267 and ! in_array( $screen->id, $candidates )
268 ) {
269 return;
270 }
271
272 wp_enqueue_style( 'ewd-uwpm-spectrum-css', EWD_UWPM_PLUGIN_URL . '/assets/css/spectrum.css', array(), EWD_UWPM_VERSION );
273 wp_enqueue_script( 'ewd-uwpm-spectrum-js', EWD_UWPM_PLUGIN_URL . '/assets/js/spectrum.js', array( 'jquery' ), EWD_UWPM_VERSION, true );
274 wp_enqueue_style( 'ewd-uwpm-admin-css', EWD_UWPM_PLUGIN_URL . '/assets/css/ewd-uwpm-admin.css', array(), EWD_UWPM_VERSION );
275 wp_enqueue_script( 'ewd-uwpm-admin-js', EWD_UWPM_PLUGIN_URL . '/assets/js/ewd-uwpm-admin.js', array( 'jquery', 'jquery-ui-sortable' ), EWD_UWPM_VERSION, true );
276
277 $settings = array(
278 'nonce' => wp_create_nonce( 'ewd-uwpm-admin-js' ),
279 );
280
281 wp_localize_script( 'ewd-uwpm-admin-js', 'ewd_uwpm_admin_php_data', $settings );
282 }
283
284 /**
285 * Register the front-end CSS and Javascript for the FAQs
286 * @since 1.0.0
287 */
288 function register_assets() {
289 global $ewd_uwpm_controller;
290
291 wp_register_style( 'ewd-uwpm-css', EWD_UWPM_PLUGIN_URL . '/assets/css/ewd-uwpm.css', EWD_UWPM_VERSION );
292
293 wp_register_script( 'ewd-uwpm-js', EWD_UWPM_PLUGIN_URL . '/assets/js/ewd-uwpm.js', array( 'jquery' ), EWD_UWPM_VERSION, true );
294 }
295
296 /**
297 * Add links to the plugin listing on the installed plugins page
298 * @since 1.0.0
299 */
300 public function plugin_action_links( $links, $plugin ) {
301
302 if ( $plugin == EWD_UWPM_PLUGIN_FNAME ) {
303
304 $links['settings'] = '<a href="admin.php?page=ewd-uwpm-settings" title="' . __( 'Head to the settings page for Ultimate WP Mail', 'ultimate-wp-mail' ) . '">' . __( 'Settings', 'ultimate-wp-mail' ) . '</a>';
305 }
306
307 return $links;
308 }
309
310 /**
311 * Change the title placeholder for this CPT from 'Add Title' to 'Subject'
312 * @since 1.0.9
313 */
314 public function change_add_title_placeholder( $placeholder ) {
315
316 if ( get_post_type() != EWD_UWPM_EMAIL_POST_TYPE ) { return $placeholder; }
317
318 $placeholder = __( 'Subject', 'ultimate-wp-mail' );
319
320 return $placeholder;
321 }
322
323 /**
324 * Add the plugin's tiny MCE plugin, so that tags can be easily used in emails
325 * @since 1.0.0
326 */
327 public function register_tinymce_javascript( $plugin_array ) {
328
329 $plugin_array['UWPM_Tags'] = EWD_UWPM_PLUGIN_URL . '/assets/js/tinymce-plugin.js';
330
331 return $plugin_array;
332 }
333
334 /**
335 * Output the usable email tags on the admin email builder page
336 * @since 1.0.0
337 */
338 public function output_tinymce_vars() {
339 global $post;
340 global $ewd_uwpm_controller;
341
342 if ( ! isset($post) or $post->post_type != EWD_UWPM_EMAIL_POST_TYPE ) { return; }
343
344 $fields_data = array(
345 'uwpm_user_tags' => $ewd_uwpm_controller->custom_element_manager->get_user_fields(),
346 'uwpm_custom_elements' => $ewd_uwpm_controller->custom_element_manager->get_custom_elements(),
347 'uwpm_custom_element_sections' => $ewd_uwpm_controller->custom_element_manager->get_custom_element_sections(),
348 'uwpm_post_tags' => $post_fields = array(
349 array( 'slug' => 'post_title', 'name' => 'Post Title' ),
350 array( 'slug' => 'post_content', 'name' => 'Post Content' ),
351 array( 'slug' => 'post_date', 'name' => 'Post Date' ),
352 array( 'slug' => 'post_status', 'name' => 'Post Status' ),
353 array( 'slug' => 'post_type', 'name' => 'Post Type' ),
354 )
355 );
356
357 if ( empty( $fields_data['custom_elements'] ) ) { $fields_data['custom_elements'] = array( array( 'slug' => -1, 'name' => 'No Elements Registered', 'attributes' => array() ) ); }
358
359 wp_localize_script( 'ewd-uwpm-admin-js', 'ewd_uwpm_php_data', $fields_data );
360 }
361
362 /**
363 * Adds in the tinyMCE that lets the email tags be accessed
364 * @since 1.0.0
365 */
366 public function register_tinymce_buttons( $buttons ) {
367
368 array_push( $buttons, 'separator', 'UWPM_Tags' );
369
370 return $buttons;
371 }
372
373 /**
374 * Adds in a menu bar for the plugin
375 * @since 1.0.0
376 */
377 public function display_header_area() {
378 global $ewd_uwpm_controller;
379
380 $screen = get_current_screen();
381
382 if ( ( empty( $screen->parent_file ) or $screen->parent_file != 'edit.php?post_type=uwpm_mail_template' ) and $screen->id != 'admin_page_ewd-uwpm-settings' ) { return; }
383
384 if ( ! $this->permissions->check_permission( 'ultimate' ) or get_option( 'EWD_UWPM_Trial_Happening' ) == 'Yes' ) {
385 ?>
386 <div class="ewd-uwpm-dashboard-new-upgrade-banner">
387 <div class="ewd-uwpm-dashboard-banner-icon"></div>
388 <div class="ewd-uwpm-dashboard-banner-buttons">
389 <a class="ewd-uwpm-dashboard-new-upgrade-button" href="https://www.etoilewebdesign.com/license-payment/?Selected=UWPMU&Quantity=12&utm_source=uwpm_admin&utm_content=banner" target="_blank">UPGRADE NOW</a>
390 </div>
391 <div class="ewd-uwpm-dashboard-banner-text">
392 <div class="ewd-uwpm-dashboard-banner-title">
393 GET FULL ACCESS WITH OUR ULTIMATE VERSION
394 </div>
395 <div class="ewd-uwpm-dashboard-banner-brief">
396 SMS notifications, premium support and more!
397 </div>
398 </div>
399 </div>
400 <?php
401 }
402 ?>
403 <div class="ewd-uwpm-admin-header-menu">
404 <h2 class="nav-tab-wrapper">
405 <a id="ewd-uwpm-dash-mobile-menu-open" href="#" class="menu-tab nav-tab"><?php _e("MENU", 'ultimate-wp-mail'); ?><span id="ewd-uwpm-dash-mobile-menu-down-caret">&nbsp;&nbsp;&#9660;</span><span id="ewd-uwpm-dash-mobile-menu-up-caret">&nbsp;&nbsp;&#9650;</span></a>
406 <a id="dashboard-menu" href='admin.php?page=ewd-uwpm-dashboard' class="menu-tab nav-tab <?php if ( $screen->id == 'uwpm_mail_template_ewd-ufaq-dashboard' ) {echo 'nav-tab-active';}?>"><?php _e("Dashboard", 'ultimate-wp-mail'); ?></a>
407 <a id="emails-menu" href='edit.php?post_type=uwpm_mail_template' class="menu-tab nav-tab <?php if ( $screen->id == 'edit-uwpm_mail_template' ) {echo 'nav-tab-active';}?>"><?php _e("Emails", 'ultimate-wp-mail'); ?></a>
408 <a id="add-email-menu" href='post-new.php?post_type=uwpm_mail_template' class="menu-tab nav-tab"><?php _e("Add New", 'ultimate-wp-mail'); ?></a>
409 <a id="categories-menu" href='edit-tags.php?taxonomy=uwpm-category&post_type=uwpm_mail_template' class="menu-tab nav-tab <?php if ( $screen->id == 'toplevel_page_uwpm-category' ) {echo 'nav-tab-active';}?>"><?php _e("Categories", 'ultimate-wp-mail'); ?></a>
410 <a id="lists-menu" href='admin.php?page=ewd-uwpm-email-lists' class="menu-tab nav-tab <?php if ( $screen->id == 'toplevel_page_ewd-uwpm-lists' ) {echo 'nav-tab-active';}?>"><?php _e("Lists", 'ultimate-wp-mail'); ?></a>
411 <a id="stats-menu" href='admin.php?page=ewd-uwpm-user-stats' class="menu-tab nav-tab <?php if ( $screen->id == 'toplevel_page_ewd-uwpm-stats' ) {echo 'nav-tab-active';}?>"><?php _e("Stats", 'ultimate-wp-mail'); ?></a>
412 <a id="options-menu" href='admin.php?page=ewd-uwpm-settings' class="menu-tab nav-tab <?php if ( $screen->id == 'ewd_uwpm_page_ewd-uwpm-settings' ) {echo 'nav-tab-active';}?>"><?php _e("Settings", 'ultimate-wp-mail'); ?></a>
413 </h2>
414 </div>
415
416 <?php
417 }
418
419 }
420 } // endif;
421
422 global $ewd_uwpm_controller;
423 $ewd_uwpm_controller = new ewduwpmInit();
424
425 do_action( 'ewd_uwpm_initialized' );