PluginProbe
Ultimate WP Mail / 1.3.9
Ultimate WP Mail v1.3.9
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 1.3.9, at ultimate-wp-mail.php

424 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.9
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.9' );
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/InstallationWalkthrough.class.php' );
90 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Logging.class.php' );
91 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Notifications.class.php' );
92 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Permissions.class.php' );
93 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/ReviewAsk.class.php' );
94 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Settings.class.php' );
95 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/SMSQueue.class.php' );
96 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/template-functions.php' );
97 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/UserManager.class.php' );
98 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/Widgets.class.php' );
99 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/WooCommerce.class.php' );
100 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/WPForms.class.php' );
101 }
102
103 /**
104 * Spin up instances of our plugin classes.
105 *
106 * @since 1.0.0
107 * @access protected
108 * @return void
109 */
110 protected function instantiate() {
111
112 new ewduwpmDashboard();
113 new ewduwpmDeactivationSurvey();
114 new ewduwpmInstallationWalkthrough();
115 new ewduwpmReviewAsk();
116
117 $this->admin_email_lists = new ewduwpmAdminEmailLists();
118 $this->admin_user_stats = new ewduwpmAdminUserStats();
119 $this->cpts = new ewduwpmCustomPostTypes();
120 $this->custom_element_manager = new ewduwpmCustomElementManager();
121 $this->database_manager = new ewduwpmDatabaseManager();
122 $this->logging = new ewduwpmLogging();
123 $this->notifications = new ewduwpmNotifications();
124 $this->permissions = new ewduwpmPermissions();
125 $this->settings = new ewduwpmSettings();
126 $this->woocommerce = new ewduwpmWooCommerce();
127 $this->wp_forms = new ewduwpmWPForms();
128
129 new ewduwpmAJAX();
130 new ewduwpmBlocks();
131 new ewduwpmUserManager();
132 new ewduwpmWidgetManager();
133 new ewduwpmAboutUs();
134 }
135
136 /**
137 * Run walk-through, load assets, add links to plugin listing, etc.
138 *
139 * @since 1.0.0
140 * @access protected
141 * @return void
142 */
143 protected function wp_hooks() {
144
145 register_activation_hook( __FILE__, array( $this, 'run_walkthrough' ) );
146 register_activation_hook( __FILE__, array( $this, 'convert_options' ) );
147 register_activation_hook( __FILE__, array( $this, 'create_tables' ) );
148
149 add_action( 'init', array( $this, 'load_view_files' ) );
150
151 add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
152 add_action( 'plugins_loaded', array( $this, 'init_queues' ) );
153
154 add_action( 'admin_notices', array( $this, 'display_header_area' ) );
155
156 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 10, 1 );
157 add_action( 'admin_head', array( $this, 'output_tinymce_vars' ) );
158 add_action( 'admin_enqueue_scripts', array( $this, 'register_assets' ) );
159 add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ) );
160 add_action( 'wp_head', 'ewd_add_frontend_ajax_url' );
161
162 add_filter( 'enter_title_here', array( $this, 'change_add_title_placeholder' ) );
163
164 add_filter( 'mce_external_plugins', array( $this, 'register_tinymce_javascript' ) );
165 add_filter( 'mce_buttons', array( $this, 'register_tinymce_buttons' ) );
166
167 add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2);
168 }
169
170 /**
171 * Run the options conversion function on update if necessary
172 *
173 * @since 1.0.0
174 * @access protected
175 * @return void
176 */
177 public function convert_options() {
178
179 require_once( EWD_UWPM_PLUGIN_DIR . '/includes/BackwardsCompatibility.class.php' );
180 new ewduwpmBackwardsCompatibility();
181 }
182
183 /**
184 * Creates the tables where statistics and user information are stored
185 *
186 * @since 1.0.0
187 * @access protected
188 * @return void
189 */
190 public function create_tables() {
191
192 $this->database_manager->create_tables();
193 }
194
195 /**
196 * Load files needed for views
197 * @since 1.0.0
198 * @note Can be filtered to add new classes as needed
199 */
200 public function load_view_files() {
201
202 $files = array(
203 EWD_UWPM_PLUGIN_DIR . '/views/Base.class.php' // This will load all default classes
204 );
205
206 $files = apply_filters( 'ewd_uwpm_load_view_files', $files );
207
208 foreach( $files as $file ) {
209 require_once( $file );
210 }
211
212 }
213
214 /**
215 * Load the plugin textdomain for localisation
216 * @since 1.0.0
217 */
218 public function load_textdomain() {
219
220 load_plugin_textdomain( 'ultimate-wp-mail', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
221 }
222
223 /**
224 * Create the email queue
225 * */
226 public function init_queues() {
227 $this->email_queue = new ewduwpmEmailQueue();
228 $this->sms_queue = new ewduwpmSMSQueue();
229 }
230
231 /**
232 * Set a transient so that the walk-through gets run
233 * @since 1.0.0
234 */
235 public function run_walkthrough() {
236
237 set_transient( 'ewd-uwpm-getting-started', true, 30 );
238 }
239
240 /**
241 * Enqueue the admin-only CSS and Javascript
242 * @since 1.0.0
243 */
244 public function enqueue_admin_assets( $hook ) {
245 global $post;
246
247 $screen = get_current_screen();
248
249 $candidates = array(
250 EWD_UWPM_EMAIL_POST_TYPE,
251 EWD_UWPM_EMAIL_LOG_POST_TYPE,
252 EWD_UWPM_SMS_POST_TYPE,
253
254 'admin_page_ewd-uwpm-settings',
255
256 'uwpm_mail_template_page_ewd-uwpm-user-stats',
257 'uwpm_mail_template_page_ewd-uwpm-email-lists',
258 'uwpm_mail_template_page_ewd-uwpm-settings',
259
260 'edit-uwpm-category',
261 );
262
263 // Return if not UWPM post_type, we're not on a post-type page, or we're not on the settings or widget pages
264 if ( ! in_array( $hook, $candidates )
265 and ( empty( $screen->post_type ) or ! in_array ( $screen->post_type, $candidates ) )
266 and ! in_array( $screen->id, $candidates )
267 ) {
268 return;
269 }
270
271 wp_enqueue_style( 'ewd-uwpm-spectrum-css', EWD_UWPM_PLUGIN_URL . '/assets/css/spectrum.css', array(), EWD_UWPM_VERSION );
272 wp_enqueue_script( 'ewd-uwpm-spectrum-js', EWD_UWPM_PLUGIN_URL . '/assets/js/spectrum.js', array( 'jquery' ), EWD_UWPM_VERSION, true );
273 wp_enqueue_style( 'ewd-uwpm-admin-css', EWD_UWPM_PLUGIN_URL . '/assets/css/ewd-uwpm-admin.css', array(), EWD_UWPM_VERSION );
274 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 );
275
276 $settings = array(
277 'nonce' => wp_create_nonce( 'ewd-uwpm-admin-js' ),
278 );
279
280 wp_localize_script( 'ewd-uwpm-admin-js', 'ewd_uwpm_admin_php_data', $settings );
281 }
282
283 /**
284 * Register the front-end CSS and Javascript for the FAQs
285 * @since 1.0.0
286 */
287 function register_assets() {
288 global $ewd_uwpm_controller;
289
290 wp_register_style( 'ewd-uwpm-css', EWD_UWPM_PLUGIN_URL . '/assets/css/ewd-uwpm.css', EWD_UWPM_VERSION );
291
292 wp_register_script( 'ewd-uwpm-js', EWD_UWPM_PLUGIN_URL . '/assets/js/ewd-uwpm.js', array( 'jquery' ), EWD_UWPM_VERSION, true );
293 }
294
295 /**
296 * Add links to the plugin listing on the installed plugins page
297 * @since 1.0.0
298 */
299 public function plugin_action_links( $links, $plugin ) {
300
301 if ( $plugin == EWD_UWPM_PLUGIN_FNAME ) {
302
303 $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>';
304 }
305
306 return $links;
307 }
308
309 /**
310 * Change the title placeholder for this CPT from 'Add Title' to 'Subject'
311 * @since 1.0.9
312 */
313 public function change_add_title_placeholder( $placeholder ) {
314
315 if ( get_post_type() != EWD_UWPM_EMAIL_POST_TYPE ) { return $placeholder; }
316
317 $placeholder = __( 'Subject', 'ultimate-wp-mail' );
318
319 return $placeholder;
320 }
321
322 /**
323 * Add the plugin's tiny MCE plugin, so that tags can be easily used in emails
324 * @since 1.0.0
325 */
326 public function register_tinymce_javascript( $plugin_array ) {
327
328 $plugin_array['UWPM_Tags'] = EWD_UWPM_PLUGIN_URL . '/assets/js/tinymce-plugin.js';
329
330 return $plugin_array;
331 }
332
333 /**
334 * Output the usable email tags on the admin email builder page
335 * @since 1.0.0
336 */
337 public function output_tinymce_vars() {
338 global $post;
339 global $ewd_uwpm_controller;
340
341 if ( ! isset($post) or $post->post_type != EWD_UWPM_EMAIL_POST_TYPE ) { return; }
342
343 $fields_data = array(
344 'uwpm_user_tags' => $ewd_uwpm_controller->custom_element_manager->get_user_fields(),
345 'uwpm_custom_elements' => $ewd_uwpm_controller->custom_element_manager->get_custom_elements(),
346 'uwpm_custom_element_sections' => $ewd_uwpm_controller->custom_element_manager->get_custom_element_sections(),
347 'uwpm_post_tags' => $post_fields = array(
348 array( 'slug' => 'post_title', 'name' => 'Post Title' ),
349 array( 'slug' => 'post_content', 'name' => 'Post Content' ),
350 array( 'slug' => 'post_date', 'name' => 'Post Date' ),
351 array( 'slug' => 'post_status', 'name' => 'Post Status' ),
352 array( 'slug' => 'post_type', 'name' => 'Post Type' ),
353 )
354 );
355
356 if ( empty( $fields_data['custom_elements'] ) ) { $fields_data['custom_elements'] = array( array( 'slug' => -1, 'name' => 'No Elements Registered', 'attributes' => array() ) ); }
357
358 wp_localize_script( 'ewd-uwpm-admin-js', 'ewd_uwpm_php_data', $fields_data );
359 }
360
361 /**
362 * Adds in the tinyMCE that lets the email tags be accessed
363 * @since 1.0.0
364 */
365 public function register_tinymce_buttons( $buttons ) {
366
367 array_push( $buttons, 'separator', 'UWPM_Tags' );
368
369 return $buttons;
370 }
371
372 /**
373 * Adds in a menu bar for the plugin
374 * @since 1.0.0
375 */
376 public function display_header_area() {
377 global $ewd_uwpm_controller;
378
379 $screen = get_current_screen();
380
381 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; }
382
383 if ( ! $this->permissions->check_permission( 'ultimate' ) or get_option( 'EWD_UWPM_Trial_Happening' ) == 'Yes' ) {
384 ?>
385 <div class="ewd-uwpm-dashboard-new-upgrade-banner">
386 <div class="ewd-uwpm-dashboard-banner-icon"></div>
387 <div class="ewd-uwpm-dashboard-banner-buttons">
388 <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>
389 </div>
390 <div class="ewd-uwpm-dashboard-banner-text">
391 <div class="ewd-uwpm-dashboard-banner-title">
392 GET FULL ACCESS WITH OUR ULTIMATE VERSION
393 </div>
394 <div class="ewd-uwpm-dashboard-banner-brief">
395 SMS notifications, premium support and more!
396 </div>
397 </div>
398 </div>
399 <?php
400 }
401 ?>
402 <div class="ewd-uwpm-admin-header-menu">
403 <h2 class="nav-tab-wrapper">
404 <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>
405 <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>
406 <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>
407 <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>
408 <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>
409 <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>
410 <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>
411 <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>
412 </h2>
413 </div>
414
415 <?php
416 }
417
418 }
419 } // endif;
420
421 global $ewd_uwpm_controller;
422 $ewd_uwpm_controller = new ewduwpmInit();
423
424 do_action( 'ewd_uwpm_initialized' );