PluginProbe
WANotifier for Forms and Actions / 2.4.5
WANotifier for Forms and Actions v2.4.5
3.1.1 3.1.0 3.0.4 2.7.10 2.7.11 2.7.12 2.7.13 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 3.0.0 3.0.1 3.0.2 3.0.3 trunk 0.1.0 0.1.1 1.0.0 1.0.1 1.0.2 All 67 releases
← All changes | includes/class-notifier.php +104 -21 1.0.32.4.5 View file →
@@ -22,13 +22,13 @@
22 22 /**
23 23 * Define Constants.
24 24 */
25 25 private function define_constants() {
26 - $this->define( 'NOTIFIER_VERSION', '1.0.3' );
26 + $this->define( 'NOTIFIER_VERSION', '2.4.5' );
27 27 $this->define( 'NOTIFIER_NAME', 'notifier' );
28 28 $this->define( 'NOTIFIER_PREFIX', 'notifier_' );
29 29 $this->define( 'NOTIFIER_URL', trailingslashit( plugins_url( '', dirname(__FILE__) ) ) );
30 - $this->define( 'NOTIFIER_APP_API_URL', 'https://app.wanotifier.com/api/' );
30 + $this->define( 'NOTIFIER_APP_API_URL', 'https://app.wanotifier.com/api/v1/' );
31 31 }
32 32
33 33 /**
34 34 * Define constant if not already set.
@@ -57,14 +57,12 @@
57 57 /**
58 58 * Include required core files used in admin and on the frontend.
59 59 */
60 60 private function includes() {
61 - // Libraries
62 - require_once NOTIFIER_PATH . 'libraries/action-scheduler/action-scheduler.php';
63 -
64 61 // Functions
65 62 require_once NOTIFIER_PATH . 'includes/functions/functions-notifier-helpers.php';
66 63 require_once NOTIFIER_PATH . 'includes/functions/functions-notifier-meta-box-fields.php';
64 + require_once NOTIFIER_PATH . 'libraries/action-scheduler/action-scheduler.php';
67 65
68 66 // Classes
69 67 require_once NOTIFIER_PATH . 'includes/classes/class-notifier-admin-notices.php';
70 68 require_once NOTIFIER_PATH . 'includes/classes/class-notifier-dashboard.php';
@@ -70,8 +68,9 @@
70 68 require_once NOTIFIER_PATH . 'includes/classes/class-notifier-dashboard.php';
71 69 require_once NOTIFIER_PATH . 'includes/classes/class-notifier-notification-merge-tags.php';
72 70 require_once NOTIFIER_PATH . 'includes/classes/class-notifier-notification-triggers.php';
73 71 require_once NOTIFIER_PATH . 'includes/classes/class-notifier-settings.php';
72 + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-frontend.php';
74 73 }
75 74
76 75 /**
77 76 * Hook into actions and filters.
@@ -78,18 +77,19 @@
78 77 */
79 78 private function init_hooks() {
80 79 register_activation_hook ( NOTIFIER_FILE, array( $this, 'install') );
81 80
82 - add_action( 'plugins_loaded', array( 'Notifier_Admin_Notices', 'init' ) );
83 - add_action( 'plugins_loaded', array( 'Notifier_Dashboard', 'init' ) );
84 - add_action( 'plugins_loaded', array( 'Notifier_Notification_Merge_Tags', 'init' ) );
85 - add_action( 'plugins_loaded', array( 'Notifier_Notification_Triggers', 'init' ) );
86 - add_action( 'plugins_loaded', array( 'Notifier_Settings', 'init' ) );
87 -
88 - add_action( 'plugins_loaded', array( $this, 'maybe_include_woocoomerce_class' ) );
89 -
81 + add_action( 'after_setup_theme', array( 'Notifier_Admin_Notices', 'init' ) );
82 + add_action( 'after_setup_theme', array( 'Notifier_Dashboard', 'init' ) );
83 + add_action( 'after_setup_theme', array( 'Notifier_Notification_Merge_Tags', 'init' ) );
84 + add_action( 'after_setup_theme', array( 'Notifier_Notification_Triggers', 'init' ) );
85 + add_action( 'after_setup_theme', array( 'Notifier_Settings', 'init' ) );
86 + add_action( 'after_setup_theme', array( 'Notifier_Frontend', 'init' ) );
90 87 add_action( 'admin_enqueue_scripts', array( $this , 'admin_scripts') );
88 + add_action( 'wp_enqueue_scripts', array( $this , 'frontend_scripts') );
91 89 add_action( 'in_admin_header', array( $this , 'embed_page_header' ) );
90 +
91 + add_action( 'after_setup_theme', array( $this, 'maybe_include_integrations' ) );
92 92 }
93 93
94 94 /**
95 95 * Setup during plugin activation
@@ -136,9 +136,9 @@
136 136 true
137 137 );
138 138 wp_localize_script(
139 139 NOTIFIER_NAME . '-admin-js',
140 - 'waNotifier',
140 + 'notifierObj',
141 141 apply_filters( 'notifier_js_variables', array('ajaxurl' => admin_url( 'admin-ajax.php' ) ) )
142 142 );
143 143
144 144 // Styles
@@ -150,8 +150,23 @@
150 150 );
151 151 }
152 152
153 153 /**
154 + * Add frontend scripts and styles
155 + */
156 + public function frontend_scripts () {
157 + if('yes' === get_option('notifier_ctc_enable')){
158 + // Styles
159 + wp_enqueue_style(
160 + NOTIFIER_NAME . '-frontend-css',
161 + NOTIFIER_URL . 'assets/css/frontend.css',
162 + null,
163 + NOTIFIER_VERSION
164 + );
165 + }
166 + }
167 +
168 + /**
154 169 * Set up a div for the header embed to render into.
155 170 * The initial contents here are meant as a place loader for when the PHP page initialy loads.
156 171 */
157 172 public static function embed_page_header() {
@@ -163,9 +178,10 @@
163 178 $tax = ( '' !== $current_screen->taxonomy) ? $current_screen->taxonomy : '';
164 179 ?>
165 180 <div id="notifier-admin-header" data-post-type="<?php echo esc_attr($cpt); ?>">
166 181 <div class="notifier-admin-header-content">
167 - <div class="header-page-title w-30">
182 + <div class="header-page-title w-30 d-flex align-content-center">
183 + <a class="header-logo" href="admin.php?page=notifier"><img src="<?php echo NOTIFIER_URL; ?>assets/images/favicon.svg"></a>
168 184 <h2><?php echo esc_attr(get_admin_page_title()); ?></h2>
169 185 </div>
170 186 <div class="header-action-links w-30 d-flex justify-content-end">
171 187 <span class="header-version">Version: <?php echo esc_html(NOTIFIER_VERSION); ?></span>
@@ -178,9 +194,9 @@
178 194
179 195 /**
180 196 * For sending API requests
181 197 */
182 - public static function send_api_request ( $args, $method, $headers = array() ) {
198 + public static function send_api_request ( $endpoint, $args, $method = 'POST', $headers = array() ) {
183 199 $api_key = get_option('notifier_api_key');
184 200 $api_key = trim($api_key);
185 201 if('' == $api_key) {
186 202 return false;
@@ -185,19 +201,27 @@
185 201 if('' == $api_key) {
186 202 return false;
187 203 }
188 204
189 - $request_url = NOTIFIER_APP_API_URL . $api_key . '/';
205 + if(empty($headers)){
206 + $headers = array(
207 + 'Content-Type' => 'application/json; charset=utf-8'
208 + );
209 + }
210 +
211 + $request_url = NOTIFIER_APP_API_URL . $endpoint . '?key=' . $api_key;
190 212 $request_args = array(
191 213 'method' => $method,
192 214 'headers' => $headers,
193 215 'timeout' => 120,
194 - 'body' => $args,
216 + 'body' => json_encode($args),
195 217 'sslverify' => false
196 218 );
197 219
198 - $response = wp_remote_request( $request_url, $request_args);
220 + $response = wp_remote_request( $request_url, $request_args );
199 221
222 + $response_body = wp_remote_retrieve_body( $response );
223 +
200 224 if ( is_wp_error( $response ) ) {
201 225 error_log( $response->get_error_message() );
202 226 return false;
203 227 } else {
@@ -208,12 +232,71 @@
208 232
209 233 /**
210 234 * Load Woocommerce class if it's present is activated
211 235 */
212 - public static function maybe_include_woocoomerce_class () {
236 + public static function maybe_include_integrations () {
237 + // Woocommerce
213 238 if ( class_exists( 'WooCommerce' ) ) {
214 - require_once NOTIFIER_PATH . 'includes/classes/class-notifier-woocommerce.php';
239 + require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-woocommerce.php';
215 240 Notifier_Woocommerce::init();
241 + }
242 + if ( ! class_exists( 'WC_Session' ) ) {
243 + include_once( WP_PLUGIN_DIR . '/woocommerce/includes/abstracts/abstract-wc-session.php' );
244 + }
245 +
246 + // WooCommerce Cart Abandonment Recovery by CartFlows
247 + if ( class_exists( 'CARTFLOWS_CA_Loader' ) && defined('CARTFLOWS_CA_VER') && version_compare(CARTFLOWS_CA_VER, '1.2.25', '>=')) {
248 + require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-wcar.php';
249 + Notifier_WCAR::init();
250 + }
251 +
252 + // Gravity Forms
253 + if ( class_exists( 'GFCommon' ) ) {
254 + require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-gravityforms.php';
255 + Notifier_GravityForms::init();
256 + }
257 +
258 + // Contact Form 7
259 + if ( class_exists( 'WPCF7' ) ) {
260 + require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-cf7.php';
261 + Notifier_ContactForm7::init();
262 + }
263 +
264 + // WPForms
265 + if ( class_exists( 'WPForms' ) ) {
266 + require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-wpforms.php';
267 + Notifier_WPForms::init();
268 + }
269 +
270 + // Ninja Forms
271 + if ( class_exists( 'Ninja_Forms' ) ) {
272 + require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-ninjaforms.php';
273 + Notifier_NinjaForms::init();
274 + }
275 +
276 + //FrmForm
277 + if ( class_exists( 'FrmForm' ) ) {
278 + require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-formidable.php';
279 + Notifier_Formidable::init();
280 + }
281 +
282 + //WPFluentForm
283 + if ( function_exists( 'fluentFormApi' ) ) {
284 + require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-fluentforms.php';
285 + Notifier_FluentForms::init();
286 + }
287 + }
288 +
289 + /**
290 + * Is connection to WANotifier.com active?
291 + */
292 + public static function is_api_active () {
293 + $activated = get_option(NOTIFIER_PREFIX . 'api_activated');
294 + if('yes' == $activated) {
295 + return true;
296 + }
297 + else{
298 + return false;
216 299 }
217 300 }
218 301
219 302 }