| @@ -22,14 +22,13 @@ | ||
| 22 | 22 | /** |
| 23 | 23 | * Define Constants. |
| 24 | 24 | */ |
| 25 | 25 | private function define_constants() { |
| 26 | - $this->define( 'NOTIFIER_VERSION', '0.1.1' ); | |
| 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_WA_API_VERSION', 'v14.0' ); | |
| 31 | - $this->define( 'NOTIFIER_WA_API_URL', 'https://graph.facebook.com/' . NOTIFIER_WA_API_VERSION . '/' ); | |
| 30 | + $this->define( 'NOTIFIER_APP_API_URL', 'https://app.wanotifier.com/api/v1/' ); | |
| 32 | 31 | } |
| 33 | 32 | |
| 34 | 33 | /** |
| 35 | 34 | * Define constant if not already set. |
| @@ -58,23 +57,20 @@ | ||
| 58 | 57 | /** |
| 59 | 58 | * Include required core files used in admin and on the frontend. |
| 60 | 59 | */ |
| 61 | 60 | private function includes() { |
| 62 | - // Libraries | |
| 63 | - require_once NOTIFIER_PATH . 'libraries/action-scheduler/action-scheduler.php'; | |
| 64 | - | |
| 65 | 61 | // Functions |
| 66 | 62 | require_once NOTIFIER_PATH . 'includes/functions/functions-notifier-helpers.php'; |
| 67 | 63 | require_once NOTIFIER_PATH . 'includes/functions/functions-notifier-meta-box-fields.php'; |
| 64 | + require_once NOTIFIER_PATH . 'libraries/action-scheduler/action-scheduler.php'; | |
| 68 | 65 | |
| 69 | 66 | // Classes |
| 70 | 67 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-admin-notices.php'; |
| 71 | 68 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-dashboard.php'; |
| 72 | - require_once NOTIFIER_PATH . 'includes/classes/class-notifier-message-templates.php'; | |
| 73 | - require_once NOTIFIER_PATH . 'includes/classes/class-notifier-contacts.php'; | |
| 74 | - require_once NOTIFIER_PATH . 'includes/classes/class-notifier-notifications.php'; | |
| 69 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-notification-merge-tags.php'; | |
| 75 | 70 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-notification-triggers.php'; |
| 76 | 71 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-settings.php'; |
| 72 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-frontend.php'; | |
| 77 | 73 | } |
| 78 | 74 | |
| 79 | 75 | /** |
| 80 | 76 | * Hook into actions and filters. |
| @@ -81,24 +77,19 @@ | ||
| 81 | 77 | */ |
| 82 | 78 | private function init_hooks() { |
| 83 | 79 | register_activation_hook ( NOTIFIER_FILE, array( $this, 'install') ); |
| 84 | 80 | |
| 85 | - add_action( 'plugins_loaded', array( 'Notifier_Dashboard', 'init' ) ); | |
| 86 | - add_action( 'plugins_loaded', array( 'Notifier_Message_Templates', 'init' ) ); | |
| 87 | - add_action( 'plugins_loaded', array( 'Notifier_Contacts', 'init' ) ); | |
| 88 | - add_action( 'plugins_loaded', array( 'Notifier_Notifications', 'init' ) ); | |
| 89 | - add_action( 'plugins_loaded', array( 'Notifier_Notification_Triggers', 'init' ) ); | |
| 90 | - add_action( 'plugins_loaded', array( 'Notifier_Settings', 'init' ) ); | |
| 91 | - add_action( 'plugins_loaded', array( $this, 'maybe_include_woocoomerce_class' ) ); | |
| 92 | - | |
| 93 | - add_filter( 'init', array( $this , 'handle_webhook_requests') ); | |
| 94 | - | |
| 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' ) ); | |
| 95 | 87 | add_action( 'admin_enqueue_scripts', array( $this , 'admin_scripts') ); |
| 88 | + add_action( 'wp_enqueue_scripts', array( $this , 'frontend_scripts') ); | |
| 96 | 89 | add_action( 'in_admin_header', array( $this , 'embed_page_header' ) ); |
| 97 | 90 | |
| 98 | - add_action( 'removable_query_args', array( $this , 'remove_admin_query_args') ); | |
| 99 | - | |
| 100 | - add_action( 'admin_footer', array($this, 'add_admin_html_templates') ); | |
| 91 | + add_action( 'after_setup_theme', array( $this, 'maybe_include_integrations' ) ); | |
| 101 | 92 | } |
| 102 | 93 | |
| 103 | 94 | /** |
| 104 | 95 | * Setup during plugin activation |
| @@ -103,14 +94,9 @@ | ||
| 103 | 94 | /** |
| 104 | 95 | * Setup during plugin activation |
| 105 | 96 | */ |
| 106 | 97 | public function install() { |
| 107 | - $verify_token = get_option(NOTIFIER_PREFIX . 'verify_token'); | |
| 108 | - if (!$verify_token) { | |
| 109 | - $bytes = random_bytes(20); | |
| 110 | - $verify_token = NOTIFIER_NAME . '-' . substr(bin2hex($bytes), 0, 10); | |
| 111 | - update_option(NOTIFIER_PREFIX . 'verify_token', $verify_token); | |
| 112 | - } | |
| 98 | + | |
| 113 | 99 | } |
| 114 | 100 | |
| 115 | 101 | /** |
| 116 | 102 | * Check if plugin's page |
| @@ -120,13 +106,8 @@ | ||
| 120 | 106 | if ( strpos($current_screen->id, NOTIFIER_NAME) !== false) { |
| 121 | 107 | return true; |
| 122 | 108 | } |
| 123 | 109 | |
| 124 | - $plugin_ctps = array( 'wa_message_template', 'wa_contact', 'wa_notification' ); | |
| 125 | - if ( '' !== $current_screen->post_type && in_array( $current_screen->post_type, $plugin_ctps ) ) { | |
| 126 | - return true; | |
| 127 | - } | |
| 128 | - | |
| 129 | 110 | return false; |
| 130 | 111 | } |
| 131 | 112 | |
| 132 | 113 | /** |
| @@ -145,18 +126,8 @@ | ||
| 145 | 126 | NOTIFIER_VERSION, |
| 146 | 127 | true |
| 147 | 128 | ); |
| 148 | 129 | |
| 149 | - // Date / time picker | |
| 150 | - wp_enqueue_script( 'jquery-ui-datepicker' ); | |
| 151 | - wp_enqueue_script( | |
| 152 | - NOTIFIER_NAME . '-timepicker-addon', | |
| 153 | - NOTIFIER_URL . 'assets/js/jquery-ui-timepicker-addon.min.js', | |
| 154 | - array( 'jquery-ui-datepicker' ), | |
| 155 | - NOTIFIER_VERSION, | |
| 156 | - true | |
| 157 | - ); | |
| 158 | - | |
| 159 | 130 | // Admin JS file |
| 160 | 131 | wp_enqueue_script( |
| 161 | 132 | NOTIFIER_NAME . '-admin-js', |
| 162 | 133 | NOTIFIER_URL . 'assets/js/admin.js', |
| @@ -165,15 +136,12 @@ | ||
| 165 | 136 | true |
| 166 | 137 | ); |
| 167 | 138 | wp_localize_script( |
| 168 | 139 | NOTIFIER_NAME . '-admin-js', |
| 169 | - 'waNotifier', | |
| 140 | + 'notifierObj', | |
| 170 | 141 | apply_filters( 'notifier_js_variables', array('ajaxurl' => admin_url( 'admin-ajax.php' ) ) ) |
| 171 | 142 | ); |
| 172 | 143 | |
| 173 | - // Media upload library | |
| 174 | - wp_enqueue_media(); | |
| 175 | - | |
| 176 | 144 | // Styles |
| 177 | 145 | wp_enqueue_style( |
| 178 | 146 | NOTIFIER_NAME . '-admin-css', |
| 179 | 147 | NOTIFIER_URL . 'assets/css/admin.css', |
| @@ -182,8 +150,23 @@ | ||
| 182 | 150 | ); |
| 183 | 151 | } |
| 184 | 152 | |
| 185 | 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 | + /** | |
| 186 | 169 | * Set up a div for the header embed to render into. |
| 187 | 170 | * The initial contents here are meant as a place loader for when the PHP page initialy loads. |
| 188 | 171 | */ |
| 189 | 172 | public static function embed_page_header() { |
| @@ -195,34 +178,15 @@ | ||
| 195 | 178 | $tax = ( '' !== $current_screen->taxonomy) ? $current_screen->taxonomy : ''; |
| 196 | 179 | ?> |
| 197 | 180 | <div id="notifier-admin-header" data-post-type="<?php echo esc_attr($cpt); ?>"> |
| 198 | 181 | <div class="notifier-admin-header-content"> |
| 199 | - <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> | |
| 200 | 184 | <h2><?php echo esc_attr(get_admin_page_title()); ?></h2> |
| 201 | 185 | </div> |
| 202 | - <div class="header-menu-items w-40 d-flex justify-content-center"> | |
| 203 | - <?php | |
| 204 | - if ( 'wa_contact' == $cpt ) { | |
| 205 | - ?> | |
| 206 | - <ul> | |
| 207 | - <li> | |
| 208 | - <a class="<?php echo ('wa_contact_list' !== $tax && 'wa_contact_tag' !== $tax) ? 'active' : ''; ?>" href="<?php echo esc_url( admin_url('edit.php?post_type=wa_contact') ); ?>" class="">Contacts</a> | |
| 209 | - </li> | |
| 210 | - <li> | |
| 211 | - <a class="<?php echo ('wa_contact_list' == $tax) ? 'active' : ''; ?>" href="<?php echo esc_url( admin_url('edit-tags.php?taxonomy=wa_contact_list&post_type=wa_contact') ); ?>">Lists</a> | |
| 212 | - </li> | |
| 213 | - <li> | |
| 214 | - <a class="<?php echo ('wa_contact_tag' == $tax) ? 'active' : ''; ?>" href="<?php echo esc_url( admin_url('edit-tags.php?taxonomy=wa_contact_tag&post_type=wa_contact') ); ?>">Tags</a> | |
| 215 | - </li> | |
| 216 | - </ul> | |
| 217 | - <?php | |
| 218 | - } | |
| 219 | - ?> | |
| 220 | - </div> | |
| 221 | 186 | <div class="header-action-links w-30 d-flex justify-content-end"> |
| 222 | - <span class="header-version">Version: <?php echo esc_html(NOTIFIER_VERSION); ?> (beta)</span> | |
| 223 | - <a href="mailto:[email protected]?subject=%5BWA%20Notifier%5D%20Help%20Needed%20on<?php echo esc_url(get_site_url()); ?>">Help</a> | |
| 224 | - <a href="admin.php?page=notifier&show=disclaimer">Disclaimer</a> | |
| 187 | + <span class="header-version">Version: <?php echo esc_html(NOTIFIER_VERSION); ?></span> | |
| 188 | + <a href="https://wanotifier.com/support/" target="_blank">Help</a> | |
| 225 | 189 | </div> |
| 226 | 190 | </div> |
| 227 | 191 | </div> |
| 228 | 192 | <?php |
| @@ -228,81 +192,39 @@ | ||
| 228 | 192 | <?php |
| 229 | 193 | } |
| 230 | 194 | |
| 231 | 195 | /** |
| 232 | - * Handle response from Whatsapp | |
| 196 | + * For sending API requests | |
| 233 | 197 | */ |
| 234 | - public static function handle_webhook_requests () { | |
| 235 | - if ( ! isset($_GET['notifier']) ) { | |
| 236 | - return; | |
| 198 | + public static function send_api_request ( $endpoint, $args, $method = 'POST', $headers = array() ) { | |
| 199 | + $api_key = get_option('notifier_api_key'); | |
| 200 | + $api_key = trim($api_key); | |
| 201 | + if('' == $api_key) { | |
| 202 | + return false; | |
| 237 | 203 | } |
| 238 | 204 | |
| 239 | - if ( ! isset($_POST) ) { | |
| 240 | - return; | |
| 205 | + if(empty($headers)){ | |
| 206 | + $headers = array( | |
| 207 | + 'Content-Type' => 'application/json; charset=utf-8' | |
| 208 | + ); | |
| 241 | 209 | } |
| 242 | 210 | |
| 243 | - $hub_mode = isset($_GET['hub_mode']) ? sanitize_text_field( wp_unslash( $_GET['hub_mode'] ) ) : ''; | |
| 244 | - $hub_verify_token = isset($_GET['hub_verify_token']) ? sanitize_text_field( wp_unslash( $_GET['hub_verify_token'] ) ) : ''; | |
| 245 | - $hub_challenge = isset($_GET['hub_challenge']) ? sanitize_text_field( wp_unslash( $_GET['hub_challenge'] ) ) : ''; | |
| 246 | - | |
| 247 | - /* Validate WhastApp API webbook */ | |
| 248 | - if ( 'subscribe' === $hub_mode ) { | |
| 249 | - $verify_token = get_option(NOTIFIER_PREFIX . 'verify_token'); | |
| 250 | - if ($hub_verify_token == $verify_token) { | |
| 251 | - echo esc_html($hub_challenge); | |
| 252 | - } | |
| 253 | - } | |
| 254 | - | |
| 255 | - exit; | |
| 256 | - } | |
| 257 | - | |
| 258 | - /** | |
| 259 | - * For sending requests to Cloud API | |
| 260 | - */ | |
| 261 | - public static function wa_cloud_api_request ( $endpoint, $args = array(), $method = 'POST', $headers = array() ) { | |
| 262 | - $phone_number_id = get_option('notifier_phone_number_id'); | |
| 263 | - $request_url = NOTIFIER_WA_API_URL . $phone_number_id . '/' . untrailingslashit($endpoint); | |
| 264 | - return self::send_api_request($request_url, $args, $method, $headers); | |
| 265 | - } | |
| 266 | - | |
| 267 | - /** | |
| 268 | - * For sending requests to WA Business API | |
| 269 | - */ | |
| 270 | - public static function wa_business_api_request ( $endpoint, $args = array(), $method = 'POST', $headers = array() ) { | |
| 271 | - $business_account_id = get_option('notifier_business_account_id'); | |
| 272 | - $request_url = NOTIFIER_WA_API_URL . $business_account_id . '/' . untrailingslashit($endpoint); | |
| 273 | - return self::send_api_request($request_url, $args, $method, $headers); | |
| 274 | - } | |
| 275 | - | |
| 276 | - /** | |
| 277 | - * For sending graph api requests | |
| 278 | - */ | |
| 279 | - public static function wa_graph_api_request ( $endpoint, $args = array(), $method = 'POST', $headers = array() ) { | |
| 280 | - $request_url = NOTIFIER_WA_API_URL . untrailingslashit($endpoint); | |
| 281 | - return self::send_api_request($request_url, $args, $method, $headers); | |
| 282 | - } | |
| 283 | - | |
| 284 | - /** | |
| 285 | - * For sending API requests | |
| 286 | - */ | |
| 287 | - private static function send_api_request ( $request_url, $args, $method, $headers ) { | |
| 288 | - $permanent_access_token = get_option('notifier_permanent_access_token'); | |
| 289 | - $headers = wp_parse_args($headers, array( | |
| 290 | - 'Authorization' => 'Bearer ' . $permanent_access_token | |
| 291 | - )); | |
| 211 | + $request_url = NOTIFIER_APP_API_URL . $endpoint . '?key=' . $api_key; | |
| 292 | 212 | $request_args = array( |
| 293 | 213 | 'method' => $method, |
| 294 | 214 | 'headers' => $headers, |
| 295 | 215 | 'timeout' => 120, |
| 296 | - 'body' => $args | |
| 216 | + 'body' => json_encode($args), | |
| 217 | + 'sslverify' => false | |
| 297 | 218 | ); |
| 298 | - $response = wp_remote_request( $request_url, $request_args); | |
| 219 | + | |
| 220 | + $response = wp_remote_request( $request_url, $request_args ); | |
| 221 | + | |
| 222 | + $response_body = wp_remote_retrieve_body( $response ); | |
| 223 | + | |
| 299 | 224 | if ( is_wp_error( $response ) ) { |
| 300 | 225 | error_log( $response->get_error_message() ); |
| 301 | 226 | return false; |
| 302 | - } elseif (isset($response->error)) { | |
| 303 | - error_log($response->error_user_title . ' - ' . $response->eerror_user_msg); | |
| 304 | - return json_decode($response_body); | |
| 305 | 227 | } else { |
| 306 | 228 | $response_body = wp_remote_retrieve_body( $response ); |
| 307 | 229 | return json_decode($response_body); |
| 308 | 230 | } |
| @@ -308,95 +230,73 @@ | ||
| 308 | 230 | } |
| 309 | 231 | } |
| 310 | 232 | |
| 311 | 233 | /** |
| 312 | - * For uploading media to WhatsApp | |
| 234 | + * Load Woocommerce class if it's present is activated | |
| 313 | 235 | */ |
| 314 | - public static function wa_cloud_api_upload_media($attachment_id) { | |
| 315 | - $file_path = get_attached_file($attachment_id); | |
| 316 | - $file_size = filesize($file_path); | |
| 236 | + public static function maybe_include_integrations () { | |
| 237 | + // Woocommerce | |
| 238 | + if ( class_exists( 'WooCommerce' ) ) { | |
| 239 | + require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-woocommerce.php'; | |
| 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 | + } | |
| 317 | 245 | |
| 318 | - if (!$file_path) { | |
| 319 | - return; | |
| 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(); | |
| 320 | 250 | } |
| 321 | 251 | |
| 322 | - $file_args = array ( | |
| 323 | - 'file_length' => $file_size, | |
| 324 | - 'file_type' => get_post_mime_type($attachment_id) | |
| 325 | - ); | |
| 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 | + } | |
| 326 | 257 | |
| 327 | - $permanent_access_token = get_option('notifier_permanent_access_token'); | |
| 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 | + } | |
| 328 | 263 | |
| 329 | - // Create session ID for upload | |
| 330 | - $upload_session = self::wa_graph_api_request('app/uploads', $file_args); | |
| 331 | - if (!isset($upload_session->id)) { | |
| 332 | - error_log('Error creating WhatsApp image upload session: ' . $upload_session); | |
| 333 | - return false; | |
| 264 | + // WPForms | |
| 265 | + if ( class_exists( 'WPForms' ) ) { | |
| 266 | + require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-wpforms.php'; | |
| 267 | + Notifier_WPForms::init(); | |
| 334 | 268 | } |
| 335 | 269 | |
| 336 | - // Upload the file | |
| 337 | - $file = @fopen( $file_path, 'r' ); | |
| 338 | - $file_data = fread( $file, $file_size ); | |
| 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 | + } | |
| 339 | 275 | |
| 340 | - $upload_headers = array( | |
| 341 | - 'Authorization' => 'OAuth ' . $permanent_access_token, | |
| 342 | - 'file_offset' => 0, | |
| 343 | - 'Connection' => 'Close', | |
| 344 | - 'Host' => 'graph.facebook.com', | |
| 345 | - 'Content-Type' => 'multipart/form-data' | |
| 346 | - ); | |
| 347 | - | |
| 348 | - $upload_handle = self::wa_graph_api_request( $upload_session->id, $file_data, null, $upload_headers ); | |
| 349 | - if (!isset($upload_handle->h)) { | |
| 350 | - error_log('Error while uploading profile image: ' . $upload_handle); | |
| 351 | - return false; | |
| 276 | + //FrmForm | |
| 277 | + if ( class_exists( 'FrmForm' ) ) { | |
| 278 | + require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-formidable.php'; | |
| 279 | + Notifier_Formidable::init(); | |
| 352 | 280 | } |
| 353 | 281 | |
| 354 | - return $upload_handle->h; | |
| 355 | - } | |
| 356 | - | |
| 357 | - /** | |
| 358 | - * Remove query args from WP backend | |
| 359 | - */ | |
| 360 | - public static function remove_admin_query_args ($args) { | |
| 361 | - $remove_args = array('wa_import_count', 'wa_import_skipped', 'wa_contacts_import', 'import_contacts_from_users', 'refresh_status'); | |
| 362 | - return array_merge($args, $remove_args); | |
| 363 | - } | |
| 364 | - | |
| 365 | - /** | |
| 366 | - * Load Woocommerce class if it's present is activated | |
| 367 | - */ | |
| 368 | - public static function maybe_include_woocoomerce_class () { | |
| 369 | - if ( class_exists( 'WooCommerce' ) ) { | |
| 370 | - require_once NOTIFIER_PATH . 'includes/classes/class-notifier-woocommerce.php'; | |
| 371 | - Notifier_Woocommerce::init(); | |
| 282 | + //WPFluentForm | |
| 283 | + if ( function_exists( 'fluentFormApi' ) ) { | |
| 284 | + require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-fluentforms.php'; | |
| 285 | + Notifier_FluentForms::init(); | |
| 372 | 286 | } |
| 373 | 287 | } |
| 374 | 288 | |
| 375 | 289 | /** |
| 376 | - * Add admin html templates to footer | |
| 290 | + * Is connection to WANotifier.com active? | |
| 377 | 291 | */ |
| 378 | - public static function add_admin_html_templates () { | |
| 379 | - if (!self::is_notifier_page()) { | |
| 380 | - return; | |
| 292 | + public static function is_api_active () { | |
| 293 | + $activated = get_option(NOTIFIER_PREFIX . 'api_activated'); | |
| 294 | + if('yes' == $activated) { | |
| 295 | + return true; | |
| 381 | 296 | } |
| 382 | - | |
| 383 | - $templates = apply_filters('notifier_admin_html_templates', array()); | |
| 384 | - | |
| 385 | - if (count($templates) == 0) { | |
| 386 | - return; | |
| 297 | + else{ | |
| 298 | + return false; | |
| 387 | 299 | } |
| 388 | - | |
| 389 | - echo '<div class="notifier-templates">'; | |
| 390 | - foreach ($templates as $template) { | |
| 391 | - $file_path = NOTIFIER_PATH . '/views/templates/admin-' . $template . '.php'; | |
| 392 | - if ( ! file_exists($file_path) ) { | |
| 393 | - continue; | |
| 394 | - } | |
| 395 | - echo '<template id="notifier-template-' . esc_attr($template) . '">'; | |
| 396 | - require_once $file_path; | |
| 397 | - echo '</template>'; | |
| 398 | - } | |
| 399 | - echo '</div>'; | |
| 400 | 300 | } |
| 401 | 301 | |
| 402 | 302 | } |