| @@ -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.0' ); | |
| 26 | + $this->define( 'NOTIFIER_VERSION', '2.1.3' ); | |
| 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,11 +57,8 @@ | ||
| 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'; |
| 68 | 64 | |
| @@ -68,13 +64,12 @@ | ||
| 68 | 64 | |
| 69 | 65 | // Classes |
| 70 | 66 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-admin-notices.php'; |
| 71 | 67 | 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'; | |
| 68 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-notification-merge-tags.php'; | |
| 75 | 69 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-notification-triggers.php'; |
| 76 | 70 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-settings.php'; |
| 71 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-frontend.php'; | |
| 77 | 72 | } |
| 78 | 73 | |
| 79 | 74 | /** |
| 80 | 75 | * Hook into actions and filters. |
| @@ -81,24 +76,19 @@ | ||
| 81 | 76 | */ |
| 82 | 77 | private function init_hooks() { |
| 83 | 78 | register_activation_hook ( NOTIFIER_FILE, array( $this, 'install') ); |
| 84 | 79 | |
| 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 | - | |
| 80 | + add_action( 'after_setup_theme', array( 'Notifier_Admin_Notices', 'init' ) ); | |
| 81 | + add_action( 'after_setup_theme', array( 'Notifier_Dashboard', 'init' ) ); | |
| 82 | + add_action( 'after_setup_theme', array( 'Notifier_Notification_Merge_Tags', 'init' ) ); | |
| 83 | + add_action( 'after_setup_theme', array( 'Notifier_Notification_Triggers', 'init' ) ); | |
| 84 | + add_action( 'after_setup_theme', array( 'Notifier_Settings', 'init' ) ); | |
| 85 | + add_action( 'after_setup_theme', array( 'Notifier_Frontend', 'init' ) ); | |
| 95 | 86 | add_action( 'admin_enqueue_scripts', array( $this , 'admin_scripts') ); |
| 87 | + add_action( 'wp_enqueue_scripts', array( $this , 'frontend_scripts') ); | |
| 96 | 88 | add_action( 'in_admin_header', array( $this , 'embed_page_header' ) ); |
| 97 | 89 | |
| 98 | - add_action( 'removable_query_args', array( $this , 'remove_admin_query_args') ); | |
| 99 | - | |
| 100 | - add_action( 'admin_footer', array($this, 'add_admin_html_templates') ); | |
| 90 | + add_action( 'after_setup_theme', array( $this, 'maybe_include_integrations' ) ); | |
| 101 | 91 | } |
| 102 | 92 | |
| 103 | 93 | /** |
| 104 | 94 | * Setup during plugin activation |
| @@ -103,14 +93,9 @@ | ||
| 103 | 93 | /** |
| 104 | 94 | * Setup during plugin activation |
| 105 | 95 | */ |
| 106 | 96 | 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 | - } | |
| 97 | + | |
| 113 | 98 | } |
| 114 | 99 | |
| 115 | 100 | /** |
| 116 | 101 | * Check if plugin's page |
| @@ -120,13 +105,8 @@ | ||
| 120 | 105 | if ( strpos($current_screen->id, NOTIFIER_NAME) !== false) { |
| 121 | 106 | return true; |
| 122 | 107 | } |
| 123 | 108 | |
| 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 | 109 | return false; |
| 130 | 110 | } |
| 131 | 111 | |
| 132 | 112 | /** |
| @@ -145,18 +125,8 @@ | ||
| 145 | 125 | NOTIFIER_VERSION, |
| 146 | 126 | true |
| 147 | 127 | ); |
| 148 | 128 | |
| 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 | 129 | // Admin JS file |
| 160 | 130 | wp_enqueue_script( |
| 161 | 131 | NOTIFIER_NAME . '-admin-js', |
| 162 | 132 | NOTIFIER_URL . 'assets/js/admin.js', |
| @@ -165,15 +135,12 @@ | ||
| 165 | 135 | true |
| 166 | 136 | ); |
| 167 | 137 | wp_localize_script( |
| 168 | 138 | NOTIFIER_NAME . '-admin-js', |
| 169 | - 'waNotifier', | |
| 139 | + 'notifierObj', | |
| 170 | 140 | apply_filters( 'notifier_js_variables', array('ajaxurl' => admin_url( 'admin-ajax.php' ) ) ) |
| 171 | 141 | ); |
| 172 | 142 | |
| 173 | - // Media upload library | |
| 174 | - wp_enqueue_media(); | |
| 175 | - | |
| 176 | 143 | // Styles |
| 177 | 144 | wp_enqueue_style( |
| 178 | 145 | NOTIFIER_NAME . '-admin-css', |
| 179 | 146 | NOTIFIER_URL . 'assets/css/admin.css', |
| @@ -182,8 +149,23 @@ | ||
| 182 | 149 | ); |
| 183 | 150 | } |
| 184 | 151 | |
| 185 | 152 | /** |
| 153 | + * Add frontend scripts and styles | |
| 154 | + */ | |
| 155 | + public function frontend_scripts () { | |
| 156 | + if('yes' === get_option('notifier_ctc_enable')){ | |
| 157 | + // Styles | |
| 158 | + wp_enqueue_style( | |
| 159 | + NOTIFIER_NAME . '-frontend-css', | |
| 160 | + NOTIFIER_URL . 'assets/css/frontend.css', | |
| 161 | + null, | |
| 162 | + NOTIFIER_VERSION | |
| 163 | + ); | |
| 164 | + } | |
| 165 | + } | |
| 166 | + | |
| 167 | + /** | |
| 186 | 168 | * Set up a div for the header embed to render into. |
| 187 | 169 | * The initial contents here are meant as a place loader for when the PHP page initialy loads. |
| 188 | 170 | */ |
| 189 | 171 | public static function embed_page_header() { |
| @@ -198,31 +180,11 @@ | ||
| 198 | 180 | <div class="notifier-admin-header-content"> |
| 199 | 181 | <div class="header-page-title w-30"> |
| 200 | 182 | <h2><?php echo esc_attr(get_admin_page_title()); ?></h2> |
| 201 | 183 | </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 | 184 | <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> | |
| 185 | + <span class="header-version">Version: <?php echo esc_html(NOTIFIER_VERSION); ?></span> | |
| 186 | + <a href="https://wanotifier.com/support/" target="_blank">Help</a> | |
| 225 | 187 | </div> |
| 226 | 188 | </div> |
| 227 | 189 | </div> |
| 228 | 190 | <?php |
| @@ -228,80 +190,39 @@ | ||
| 228 | 190 | <?php |
| 229 | 191 | } |
| 230 | 192 | |
| 231 | 193 | /** |
| 232 | - * Handle response from Whatsapp | |
| 194 | + * For sending API requests | |
| 233 | 195 | */ |
| 234 | - public static function handle_webhook_requests () { | |
| 235 | - if ( ! isset($_GET['notifier']) ) { | |
| 236 | - return; | |
| 196 | + public static function send_api_request ( $endpoint, $args, $method = 'POST', $headers = array() ) { | |
| 197 | + $api_key = get_option('notifier_api_key'); | |
| 198 | + $api_key = trim($api_key); | |
| 199 | + if('' == $api_key) { | |
| 200 | + return false; | |
| 237 | 201 | } |
| 238 | 202 | |
| 239 | - if ( ! isset($_POST) ) { | |
| 240 | - return; | |
| 203 | + if(empty($headers)){ | |
| 204 | + $headers = array( | |
| 205 | + 'Content-Type' => 'application/json; charset=utf-8' | |
| 206 | + ); | |
| 241 | 207 | } |
| 242 | 208 | |
| 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 | - )); | |
| 209 | + $request_url = NOTIFIER_APP_API_URL . $endpoint . '?key=' . $api_key; | |
| 292 | 210 | $request_args = array( |
| 293 | 211 | 'method' => $method, |
| 294 | 212 | 'headers' => $headers, |
| 295 | - 'body' => $args | |
| 213 | + 'timeout' => 120, | |
| 214 | + 'body' => json_encode($args), | |
| 215 | + 'sslverify' => false | |
| 296 | 216 | ); |
| 217 | + | |
| 297 | 218 | $response = wp_remote_request( $request_url, $request_args); |
| 219 | + | |
| 220 | + $response_body = wp_remote_retrieve_body( $response ); | |
| 221 | + | |
| 298 | 222 | if ( is_wp_error( $response ) ) { |
| 299 | 223 | error_log( $response->get_error_message() ); |
| 300 | 224 | return false; |
| 301 | - } elseif (isset($response->error)) { | |
| 302 | - error_log($response->error_user_title . ' - ' . $response->eerror_user_msg); | |
| 303 | - return json_decode($response_body); | |
| 304 | 225 | } else { |
| 305 | 226 | $response_body = wp_remote_retrieve_body( $response ); |
| 306 | 227 | return json_decode($response_body); |
| 307 | 228 | } |
| @@ -307,98 +228,67 @@ | ||
| 307 | 228 | } |
| 308 | 229 | } |
| 309 | 230 | |
| 310 | 231 | /** |
| 311 | - * For uploading profile pic to app | |
| 232 | + * Load Woocommerce class if it's present is activated | |
| 312 | 233 | */ |
| 313 | - public static function wa_cloud_api_upload_profile_pic($attachment_id) { | |
| 314 | - $file_path = get_attached_file($attachment_id); | |
| 315 | - $file_size = filesize($file_path); | |
| 234 | + public static function maybe_include_integrations () { | |
| 235 | + // Woocommerce | |
| 236 | + if ( class_exists( 'WooCommerce' ) ) { | |
| 237 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-woocommerce.php'; | |
| 238 | + Notifier_Woocommerce::init(); | |
| 239 | + } | |
| 240 | + if ( ! class_exists( 'WC_Session' ) ) { | |
| 241 | + include_once( WP_PLUGIN_DIR . '/woocommerce/includes/abstracts/abstract-wc-session.php' ); | |
| 242 | + } | |
| 316 | 243 | |
| 317 | - if (!$file_path) { | |
| 318 | - return; | |
| 244 | + // Gravity Forms | |
| 245 | + if ( class_exists( 'GFCommon' ) ) { | |
| 246 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-gravityforms.php'; | |
| 247 | + Notifier_GravityForms::init(); | |
| 319 | 248 | } |
| 320 | 249 | |
| 321 | - $file_args = array ( | |
| 322 | - 'file_length' => $file_size, | |
| 323 | - 'file_type' => get_post_mime_type($attachment_id) | |
| 324 | - ); | |
| 250 | + // Contact Form 7 | |
| 251 | + if ( class_exists( 'WPCF7' ) ) { | |
| 252 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-cf7.php'; | |
| 253 | + Notifier_ContactForm7::init(); | |
| 254 | + } | |
| 325 | 255 | |
| 326 | - // $phone_number_id = get_option('notifier_phone_number_id'); | |
| 327 | - // $request_url = NOTIFIER_WA_API_URL . $phone_number_id . '/media'; | |
| 328 | - $permanent_access_token = get_option('notifier_permanent_access_token'); | |
| 256 | + // WPForms | |
| 257 | + if ( class_exists( 'WPForms' ) ) { | |
| 258 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-wpforms.php'; | |
| 259 | + Notifier_WPForms::init(); | |
| 260 | + } | |
| 329 | 261 | |
| 330 | - // Create session ID for upload | |
| 331 | - $upload_session = self::wa_graph_api_request('app/uploads', $file_args); | |
| 332 | - if (!isset($upload_session->id)) { | |
| 333 | - error_log('Error creating WhatsApp image upload session: ' . $upload_session); | |
| 334 | - return false; | |
| 262 | + // Ninja Forms | |
| 263 | + if ( class_exists( 'Ninja_Forms' ) ) { | |
| 264 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-ninjaforms.php'; | |
| 265 | + Notifier_NinjaForms::init(); | |
| 335 | 266 | } |
| 336 | 267 | |
| 337 | - // Upload the file | |
| 338 | - $file = @fopen( $file_path, 'r' ); | |
| 339 | - $file_data = fread( $file, $file_size ); | |
| 340 | - | |
| 341 | - $upload_headers = array( | |
| 342 | - 'Authorization' => 'OAuth ' . $permanent_access_token, | |
| 343 | - 'file_offset' => 0, | |
| 344 | - 'Connection' => 'Close', | |
| 345 | - 'Host' => 'graph.facebook.com', | |
| 346 | - 'Content-Type' => 'multipart/form-data' | |
| 347 | - ); | |
| 348 | - | |
| 349 | - $upload_handle = self::wa_graph_api_request( $upload_session->id, $file_data, null, $upload_headers ); | |
| 350 | - | |
| 351 | - if (!isset($upload_handle->h)) { | |
| 352 | - error_log('Error while uploading profile image: ' . $upload_handle); | |
| 353 | - return false; | |
| 268 | + //FrmForm | |
| 269 | + if ( class_exists( 'FrmForm' ) ) { | |
| 270 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-formidable.php'; | |
| 271 | + Notifier_Formidable::init(); | |
| 354 | 272 | } |
| 355 | 273 | |
| 356 | - return $upload_handle->h; | |
| 357 | - } | |
| 358 | - | |
| 359 | - /** | |
| 360 | - * Remove query args from WP backend | |
| 361 | - */ | |
| 362 | - public static function remove_admin_query_args ($args) { | |
| 363 | - $remove_args = array('wa_import_count', 'wa_import_skipped', 'wa_contacts_import', 'import_contacts_from_users', 'refresh_status'); | |
| 364 | - return array_merge($args, $remove_args); | |
| 365 | - } | |
| 366 | - | |
| 367 | - /** | |
| 368 | - * Load Woocommerce class if it's present is activated | |
| 369 | - */ | |
| 370 | - public static function maybe_include_woocoomerce_class () { | |
| 371 | - if ( class_exists( 'WooCommerce' ) ) { | |
| 372 | - require_once NOTIFIER_PATH . 'includes/classes/class-notifier-woocommerce.php'; | |
| 373 | - Notifier_Woocommerce::init(); | |
| 274 | + //WPFluentForm | |
| 275 | + if ( function_exists( 'fluentFormApi' ) ) { | |
| 276 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-fluentforms.php'; | |
| 277 | + Notifier_FluentForms::init(); | |
| 374 | 278 | } |
| 375 | 279 | } |
| 376 | 280 | |
| 377 | 281 | /** |
| 378 | - * Add admin html templates to footer | |
| 282 | + * Is connection to WANotifier.com active? | |
| 379 | 283 | */ |
| 380 | - public static function add_admin_html_templates () { | |
| 381 | - if (!self::is_notifier_page()) { | |
| 382 | - return; | |
| 284 | + public static function is_api_active () { | |
| 285 | + $activated = get_option(NOTIFIER_PREFIX . 'api_activated'); | |
| 286 | + if('yes' == $activated) { | |
| 287 | + return true; | |
| 383 | 288 | } |
| 384 | - | |
| 385 | - $templates = apply_filters('notifier_admin_html_templates', array()); | |
| 386 | - | |
| 387 | - if (count($templates) == 0) { | |
| 388 | - return; | |
| 289 | + else{ | |
| 290 | + return false; | |
| 389 | 291 | } |
| 390 | - | |
| 391 | - echo '<div class="notifier-templates">'; | |
| 392 | - foreach ($templates as $template) { | |
| 393 | - $file_path = NOTIFIER_PATH . '/views/templates/admin-' . $template . '.php'; | |
| 394 | - if ( ! file_exists($file_path) ) { | |
| 395 | - continue; | |
| 396 | - } | |
| 397 | - echo '<template id="notifier-template-' . esc_attr($template) . '">'; | |
| 398 | - require_once $file_path; | |
| 399 | - echo '</template>'; | |
| 400 | - } | |
| 401 | - echo '</div>'; | |
| 402 | 292 | } |
| 403 | 293 | |
| 404 | 294 | } |