Changeset 2867587
- Timestamp:
- 02/19/2023 08:29:09 AM (3 years ago)
- Location:
- alpha-sms
- Files:
-
- 47 added
- 11 edited
-
tags/1.0.4 (added)
-
tags/1.0.4/LICENSE.txt (added)
-
tags/1.0.4/README.txt (added)
-
tags/1.0.4/admin (added)
-
tags/1.0.4/admin/class-alpha_sms-admin.php (added)
-
tags/1.0.4/admin/css (added)
-
tags/1.0.4/admin/css/alpha_sms-admin.css (added)
-
tags/1.0.4/admin/index.php (added)
-
tags/1.0.4/admin/js (added)
-
tags/1.0.4/admin/js/alpha_sms-admin.js (added)
-
tags/1.0.4/admin/partials (added)
-
tags/1.0.4/admin/partials/alpha_sms-admin-display_campaign.php (added)
-
tags/1.0.4/admin/partials/alpha_sms-admin-display_settings.php (added)
-
tags/1.0.4/alpha_sms.php (added)
-
tags/1.0.4/assets (added)
-
tags/1.0.4/assets/banner-1544x500.png (added)
-
tags/1.0.4/assets/banner-772x250.png (added)
-
tags/1.0.4/assets/icon-128x128.png (added)
-
tags/1.0.4/assets/icon-256x256.png (added)
-
tags/1.0.4/assets/screenshot-1.png (added)
-
tags/1.0.4/assets/screenshot-2.png (added)
-
tags/1.0.4/assets/smsBanner.ai (added)
-
tags/1.0.4/includes (added)
-
tags/1.0.4/includes/class-alpha_sms-activator.php (added)
-
tags/1.0.4/includes/class-alpha_sms-deactivator.php (added)
-
tags/1.0.4/includes/class-alpha_sms-i18n.php (added)
-
tags/1.0.4/includes/class-alpha_sms-loader.php (added)
-
tags/1.0.4/includes/class-alpha_sms.php (added)
-
tags/1.0.4/includes/index.php (added)
-
tags/1.0.4/includes/sms.class.php (added)
-
tags/1.0.4/index.php (added)
-
tags/1.0.4/languages (added)
-
tags/1.0.4/languages/alpha_sms.pot (added)
-
tags/1.0.4/public (added)
-
tags/1.0.4/public/class-alpha_sms-public.php (added)
-
tags/1.0.4/public/css (added)
-
tags/1.0.4/public/css/alpha_sms-public.css (added)
-
tags/1.0.4/public/css/otp-login-form.css (added)
-
tags/1.0.4/public/index.php (added)
-
tags/1.0.4/public/js (added)
-
tags/1.0.4/public/js/alpha_sms-public.js (added)
-
tags/1.0.4/public/js/otp-login-form.js (added)
-
tags/1.0.4/public/partials (added)
-
tags/1.0.4/public/partials/add-otp-checkout-form.php (added)
-
tags/1.0.4/public/partials/add-otp-on-login-form.php (added)
-
tags/1.0.4/public/partials/add-otp-on-wc-reg-form.php (added)
-
tags/1.0.4/uninstall.php (added)
-
trunk (modified) (1 prop)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/admin/class-alpha_sms-admin.php (modified) (9 diffs)
-
trunk/admin/css/alpha_sms-admin.css (modified) (2 diffs)
-
trunk/admin/partials/alpha_sms-admin-display_settings.php (modified) (9 diffs)
-
trunk/alpha_sms.php (modified) (2 diffs)
-
trunk/assets/screenshot-1.png (modified) (previous)
-
trunk/assets/screenshot-2.png (modified) (previous)
-
trunk/includes/class-alpha_sms.php (modified) (1 diff)
-
trunk/includes/sms.class.php (modified) (2 diffs)
-
trunk/public/class-alpha_sms-public.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
alpha-sms/trunk
-
Property
svn:ignore
set to
.git
.idea
-
Property
svn:ignore
set to
-
alpha-sms/trunk/README.txt
r2812472 r2867587 5 5 Tested up to: 6.1 6 6 Requires PHP: 5.6 7 Stable tag: 1.0. 37 Stable tag: 1.0.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 55 55 = 1.0.0 = 56 56 * First version of plugin. 57 58 = 1.0.4 = 59 * Separated message for order status change -
alpha-sms/trunk/admin/class-alpha_sms-admin.php
r2629594 r2867587 1 1 <?php 2 2 // If this file is called directly, abort. 3 if ( ! defined( 'WPINC' )) {3 if (!defined('WPINC')) { 4 4 die; 5 5 } … … 114 114 public function display_setting_page() 115 115 { 116 require_once ('partials/' . $this->plugin_name . '-admin-display_settings.php');116 require_once 'partials/' . $this->plugin_name . '-admin-display_settings.php'; 117 117 } 118 118 … … 124 124 public function display_campaign_page() 125 125 { 126 require_once ('partials/' . $this->plugin_name . '-admin-display_campaign.php');126 require_once 'partials/' . $this->plugin_name . '-admin-display_campaign.php'; 127 127 } 128 128 … … 178 178 } 179 179 180 181 180 /** 182 181 * Validate fields from admin area plugin settings form ('exopite-lazy-load-xt-admin-display.php') … … 188 187 $options = get_option($this->plugin_name); 189 188 190 if (strpos(esc_attr($input['api_key']), str_repeat('*', 24), '12')) { 189 if (!empty($input['api_key']) && strpos(esc_attr($input['api_key']), str_repeat('*', 24), '12')) { 190 191 191 $input['api_key'] = $options['api_key']; 192 192 193 } 193 194 … … 201 202 $options['wc_login'] = (isset($input['wc_login']) && !empty($input['wc_login'])) ? 1 : 0; 202 203 $options['otp_checkout'] = (isset($input['otp_checkout']) && !empty($input['otp_checkout'])) ? 1 : 0; 203 204 204 $options['admin_phones'] = (isset($input['admin_phones']) && !empty($input['admin_phones'])) ? esc_attr($input['admin_phones']) : ''; 205 205 206 $options['order_status_buyer'] = (isset($input['order_status_buyer']) && !empty($input['order_status_buyer'])) ? 1 : 0; 207 $options['BUYER_STATUS_SMS'] = (isset($input['BUYER_STATUS_SMS']) && !empty($input['BUYER_STATUS_SMS'])) ? esc_attr($input['BUYER_STATUS_SMS']) : ''; 208 206 $options['order_status_pending'] = (isset($input['order_status_pending']) && !empty($input['order_status_pending'])) ? 1 : 0; 207 $options['order_status_processing'] = (isset($input['order_status_processing']) && !empty($input['order_status_processing'])) ? 1 : 0; 208 $options['order_status_on_hold'] = (isset($input['order_status_on_hold']) && !empty($input['order_status_on_hold'])) ? 1 : 0; 209 $options['order_status_completed'] = (isset($input['order_status_completed']) && !empty($input['order_status_completed'])) ? 1 : 0; 210 $options['order_status_cancelled'] = (isset($input['order_status_cancelled']) && !empty($input['order_status_cancelled'])) ? 1 : 0; 211 $options['order_status_refunded'] = (isset($input['order_status_refunded']) && !empty($input['order_status_refunded'])) ? 1 : 0; 212 $options['order_status_failed'] = (isset($input['order_status_failed']) && !empty($input['order_status_failed'])) ? 1 : 0; 209 213 $options['order_status_admin'] = (isset($input['order_status_admin']) && !empty($input['order_status_admin'])) ? 1 : 0; 214 215 $options['ORDER_STATUS_PENDING_SMS'] = (isset($input['ORDER_STATUS_PENDING_SMS']) && !empty($input['ORDER_STATUS_PENDING_SMS'])) ? esc_attr($input['ORDER_STATUS_PENDING_SMS']) : ''; 216 $options['ORDER_STATUS_PROCESSING_SMS'] = (isset($input['ORDER_STATUS_PROCESSING_SMS']) && !empty($input['ORDER_STATUS_PROCESSING_SMS'])) ? esc_attr($input['ORDER_STATUS_PROCESSING_SMS']) : ''; 217 $options['ORDER_STATUS_ON_HOLD_SMS'] = (isset($input['ORDER_STATUS_ON_HOLD_SMS']) && !empty($input['ORDER_STATUS_ON_HOLD_SMS'])) ? esc_attr($input['ORDER_STATUS_ON_HOLD_SMS']) : ''; 218 $options['ORDER_STATUS_COMPLETED_SMS'] = (isset($input['ORDER_STATUS_COMPLETED_SMS']) && !empty($input['ORDER_STATUS_COMPLETED_SMS'])) ? esc_attr($input['ORDER_STATUS_COMPLETED_SMS']) : ''; 219 $options['ORDER_STATUS_CANCELLED_SMS'] = (isset($input['ORDER_STATUS_CANCELLED_SMS']) && !empty($input['ORDER_STATUS_CANCELLED_SMS'])) ? esc_attr($input['ORDER_STATUS_CANCELLED_SMS']) : ''; 220 $options['ORDER_STATUS_REFUNDED_SMS'] = (isset($input['ORDER_STATUS_REFUNDED_SMS']) && !empty($input['ORDER_STATUS_REFUNDED_SMS'])) ? esc_attr($input['ORDER_STATUS_REFUNDED_SMS']) : ''; 221 $options['ORDER_STATUS_FAILED_SMS'] = (isset($input['ORDER_STATUS_FAILED_SMS']) && !empty($input['ORDER_STATUS_FAILED_SMS'])) ? esc_attr($input['ORDER_STATUS_FAILED_SMS']) : ''; 210 222 $options['ADMIN_STATUS_SMS'] = (isset($input['ADMIN_STATUS_SMS']) && !empty($input['ADMIN_STATUS_SMS'])) ? esc_attr($input['ADMIN_STATUS_SMS']) : ''; 211 212 223 213 224 if (!$this->checkAPI($options['api_key'])) { 214 $options['order_status'] = $options['wp_reg'] = $options['wp_login'] = $options['wc_reg'] = $options['wc_login'] = $options['otp_checkout'] = $options['order_status_buyer'] = $options['order_status_admin'] = 0; 215 add_settings_error( 225 226 $options['order_status'] = 227 $options['wp_reg'] = 228 $options['wp_login'] = 229 $options['wc_reg'] = 230 $options['wc_login'] = 231 $options['otp_checkout'] = 232 $options['order_status_pending'] = 233 $options['order_status_processing'] = 234 $options['order_status_on_hold'] = 235 $options['order_status_completed'] = 236 $options['order_status_cancelled'] = 237 $options['order_status_refunded'] = 238 $options['order_status_failed'] = 239 $options['order_status_admin'] = 0; 240 241 add_settings_error( 216 242 $this->plugin_name, // Slug title of setting 217 243 $this->plugin_name, // Slug-name , Used as part of 'id' attribute in HTML output. 218 244 __('Please configure a valid SMS API Key.', $this->plugin_name), 219 // message text, will be shown inside styled <div> and <p> tags245 // message text, will be shown inside styled <div> and <p> tags 220 246 'error' // Message type, controls HTML class. Accepts 'error' or 'updated'. 221 247 ); … … 235 261 } 236 262 237 require_once ALPHA_SMS_PATH . 'includes/sms.class.php';263 require_once ALPHA_SMS_PATH . 'includes/sms.class.php'; 238 264 239 265 $smsPortal = new AlphaSMS($api_key); … … 299 325 $numbers = implode(',', $numbersArr); 300 326 301 require_once ALPHA_SMS_PATH . 'includes/sms.class.php';327 require_once ALPHA_SMS_PATH . 'includes/sms.class.php'; 302 328 303 329 $sms = new AlphaSMS($api_key); … … 341 367 // We add our new notice. 342 368 $notices[] = [ 343 "notice" => $notice,344 "type" => $type,345 "dismissible" => $dismissible_text 369 "notice" => $notice, 370 "type" => $type, 371 "dismissible" => $dismissible_text, 346 372 ]; 347 373 -
alpha-sms/trunk/admin/css/alpha_sms-admin.css
r2627862 r2867587 125 125 } 126 126 127 #order_status_admin, 128 #order_status_buyer { 127 .alpha-collapsable { 129 128 overflow: hidden; 130 129 opacity: 0; … … 134 133 } 135 134 136 #alpha_sms-order_status_buyer:checked ~ #order_status_buyer, #alpha_sms-order_status_admin:checked ~ #order_status_admin{135 .alpha-collapse:checked ~ .alpha-collapsable{ 137 136 opacity: 1; 138 137 user-select: auto; -
alpha-sms/trunk/admin/partials/alpha_sms-admin-display_settings.php
r2629594 r2867587 23 23 <!-- This file should primarily consist of HTML with a little bit of PHP. --> 24 24 <div class="wrap"> 25 <h2><span class="dashicons dashicons-admin-tools"></span> Alpha SMS <?php esc_attr_e('Options', $this->plugin_name); ?></h2> 25 <h2><span class="dashicons dashicons-admin-tools"></span> Alpha SMS 26 <?php esc_attr_e('Options', $this->plugin_name); ?></h2> 26 27 <p>Here you can set all the options for using the API</p> 27 28 … … 30 31 31 32 <form method="post" name="<?php echo esc_attr($this->plugin_name); ?>" action="options.php" 32 id="<?php echo esc_attr($this->plugin_name); ?>">33 id="<?php echo esc_attr($this->plugin_name); ?>"> 33 34 <?php 34 35 35 $order_alerts = 36 [ 37 'DEFAULT_BUYER_STATUS_SMS' => __( 38 'Thank you for your order [billing_first_name], The status of order #[order_id] with [store_name] is [order_status]', 39 $this->plugin_name 40 ), 41 'DEFAULT_ADMIN_STATUS_SMS' => __( 42 '[store_name]: You have a new order #[order_id] for value [order_currency] [order_amount]. Please check your admin dashboard for complete details.', 43 $this->plugin_name 44 ) 45 ]; 36 [ 37 "DEFAULT_ORDER_STATUS_PENDING_SMS" => __( 38 "[store_name] - Payment required for Order #[order_id]\nYour order #[order_id] at [store_name] is currently pending payment. Please complete payment as soon as possible.", 39 $this->plugin_name 40 ), 41 "DEFAULT_ORDER_STATUS_PROCESSING_SMS" => __( 42 "[store_name] - Order #[order_id] is being processed\nYour order #[order_id] at [store_name] is currently being processed.", 43 $this->plugin_name 44 ), 45 "DEFAULT_ORDER_STATUS_ON_HOLD_SMS" => __( 46 "[store_name] - Order #[order_id] is on hold\nYour order #[order_id] at [store_name] is currently on hold. Our customer service team will be reaching out to you shortly.", 47 $this->plugin_name 48 ), 49 "DEFAULT_ORDER_STATUS_COMPLETED_SMS" => __( 50 "[store_name] - Order #[order_id] has been completed\nYour order #[order_id] at [store_name] has been completed and is on its way to you.", 51 $this->plugin_name 52 ), 53 "DEFAULT_ORDER_STATUS_CANCELLED_SMS" => __( 54 "[store_name] - Order #[order_id] has been cancelled\nYour order #[order_id] at [store_name] has been cancelled. Please contact our customer service team for any questions or concerns.", 55 $this->plugin_name 56 ), 57 "DEFAULT_ORDER_STATUS_REFUNDED_SMS" => __( 58 "[store_name] - Order #[order_id] has been refunded\nYour order #[order_id] at [store_name] has been refunded. Please contact our customer service team for any questions or concerns.", 59 $this->plugin_name 60 ), 61 "DEFAULT_ORDER_STATUS_FAILED_SMS" => __( 62 "[store_name] - Order #[order_id] has failed\nYour order #[order_id] at [store_name] has failed. Please contact our customer service team for any questions or concerns.", 63 $this->plugin_name 64 ), 65 "DEFAULT_ADMIN_STATUS_SMS" => __( 66 "[store_name] - A new order #[order_id] for value [order_currency] [order_amount] has just been placed. Please check your admin dashboard for complete details.", 67 $this->plugin_name 68 ) 69 70 ]; 46 71 47 72 //Grab all options … … 63 88 $admin_phones = (isset($options['admin_phones']) && !empty($options['admin_phones'])) ? esc_attr($options['admin_phones']) : ''; 64 89 65 $order_status_buyer = (isset($options['order_status_buyer']) && !empty($options['order_status_buyer'])) ? 1 : 0; 66 $buyer_status_sms = (isset($options['BUYER_STATUS_SMS']) && !empty($options['BUYER_STATUS_SMS'])) ? $options['BUYER_STATUS_SMS'] : $order_alerts['DEFAULT_BUYER_STATUS_SMS']; 67 68 $order_status_admin = (isset($options['order_status_admin']) && !empty($options['order_status_admin'])) ? 1 : 0; 69 $admin_status_sms = (isset($options['ADMIN_STATUS_SMS']) && !empty($options['ADMIN_STATUS_SMS'])) ? $options['ADMIN_STATUS_SMS'] : $order_alerts['DEFAULT_ADMIN_STATUS_SMS']; 90 91 $order_status_pending = (isset($options['order_status_pending']) && !empty($options['order_status_pending'])) ? 1 : 0; 92 $order_status_pending_sms = (isset($options['ORDER_STATUS_PENDING_SMS']) && !empty($options['ORDER_STATUS_PENDING_SMS'])) ? $options['ORDER_STATUS_PENDING_SMS'] : $order_alerts['DEFAULT_ORDER_STATUS_PENDING_SMS']; 93 $order_status_processing = (isset($options['order_status_processing']) && !empty($options['order_status_processing'])) ? 1 : 0; 94 $order_status_processing_sms = (isset($options['ORDER_STATUS_PROCESSING_SMS']) && !empty($options['ORDER_STATUS_PROCESSING_SMS'])) ? $options['ORDER_STATUS_PROCESSING_SMS'] : $order_alerts['DEFAULT_ORDER_STATUS_PROCESSING_SMS']; 95 $order_status_on_hold = (isset($options['order_status_on_hold']) && !empty($options['order_status_on_hold'])) ? 1 : 0; 96 $order_status_on_hold_sms = (isset($options['ORDER_STATUS_ON_HOLD_SMS']) && !empty($options['ORDER_STATUS_ON_HOLD_SMS'])) ? $options['ORDER_STATUS_ON_HOLD_SMS'] : $order_alerts['DEFAULT_ORDER_STATUS_ON_HOLD_SMS']; 97 $order_status_completed = (isset($options['order_status_completed']) && !empty($options['order_status_completed'])) ? 1 : 0; 98 $order_status_completed_sms = (isset($options['ORDER_STATUS_COMPLETED_SMS']) && !empty($options['ORDER_STATUS_COMPLETED_SMS'])) ? $options['ORDER_STATUS_COMPLETED_SMS'] : $order_alerts['DEFAULT_ORDER_STATUS_COMPLETED_SMS']; 99 $order_status_cancelled = (isset($options['order_status_cancelled']) && !empty($options['order_status_cancelled'])) ? 1 : 0; 100 $order_status_cancelled_sms = (isset($options['ORDER_STATUS_CANCELLED_SMS']) && !empty($options['ORDER_STATUS_CANCELLED_SMS'])) ? $options['ORDER_STATUS_CANCELLED_SMS'] : $order_alerts['DEFAULT_ORDER_STATUS_CANCELLED_SMS']; 101 $order_status_refunded = (isset($options['order_status_refunded']) && !empty($options['order_status_refunded'])) ? 1 : 0; 102 $order_status_refunded_sms = (isset($options['ORDER_STATUS_REFUNDED_SMS']) && !empty($options['ORDER_STATUS_REFUNDED_SMS'])) ? $options['ORDER_STATUS_REFUNDED_SMS'] : $order_alerts['DEFAULT_ORDER_STATUS_REFUNDED_SMS']; 103 $order_status_failed = (isset($options['order_status_failed']) && !empty($options['order_status_failed'])) ? 1 : 0; 104 $order_status_failed_sms = (isset($options['ORDER_STATUS_FAILED_SMS']) && !empty($options['ORDER_STATUS_FAILED_SMS'])) ? $options['ORDER_STATUS_FAILED_SMS'] : $order_alerts['DEFAULT_ORDER_STATUS_FAILED_SMS']; 105 $order_status_admin = (isset($options['order_status_admin']) && !empty($options['order_status_admin'])) ? 1 : 0; 106 $admin_status_sms = (isset($options['ADMIN_STATUS_SMS']) && !empty($options['ADMIN_STATUS_SMS'])) ? $options['ADMIN_STATUS_SMS'] : $order_alerts['DEFAULT_ADMIN_STATUS_SMS']; 107 70 108 71 109 if (!empty($api_key)) { … … 102 140 <td> 103 141 <input id="<?php echo esc_attr( $this->plugin_name . '-api_key' ); ?>" 104 name="<?php echo esc_attr( $this->plugin_name . '[api_key]' ); ?>" 105 type="text" size="55" 106 placeholder="Enter API Key" 107 value="<?php if ( !empty($api_key) ) { echo esc_attr($api_key); } ?>" /> 142 name="<?php echo esc_attr( $this->plugin_name . '[api_key]' ); ?>" type="text" size="55" 143 placeholder="Enter API Key" 144 value="<?php if ( !empty($api_key) ) { echo esc_attr($api_key); } ?>" /> 108 145 </td> 109 146 </tr> … … 117 154 <td> 118 155 <input id="<?php echo esc_attr( $this->plugin_name . '-sender_id' ); ?>" 119 name="<?php echo esc_attr( $this->plugin_name . '[sender_id]' ); ?>" 120 type="text" size="55" 121 value="<?php esc_attr_e( $sender_id, $this->plugin_name ); ?>"/> 156 name="<?php echo esc_attr( $this->plugin_name . '[sender_id]' ); ?>" type="text" size="55" 157 value="<?php esc_attr_e( $sender_id, $this->plugin_name ); ?>" /> 122 158 </td> 123 159 </tr> … … 128 164 </th> 129 165 <td> 130 <span id="<?php echo esc_attr( $this->plugin_name . '-balance' ); ?>"> 131 <?php if ($balance === 'empty') : ?> 132 <strong>Don't have an account? <a href='https://alpha.net.bd/SMS/SignUp/'>Register Now</a> (Free SMS Credit after Sign-up).</strong> 133 <?php elseif (is_numeric($balance)) : ?> 134 <strong>Balance:</strong> BDT <?php echo esc_html( number_format((float)$balance, 2, '.', ',') ) ?> 135 <?php else : ?> 136 <strong class="text-danger"><?php echo esc_html($balance); ?></strong> 137 <?php endif; ?> 138 </span> 166 <span id="<?php echo esc_attr( $this->plugin_name . '-balance' ); ?>"> 167 <?php if ($balance === 'empty') : ?> 168 <strong>Don't have an account? <a href='https://alpha.net.bd/SMS/SignUp/'>Register Now</a> (Free 169 SMS Credit after Sign-up).</strong> 170 <?php elseif (is_numeric($balance)) : ?> 171 <strong>Balance:</strong> BDT 172 <?php echo esc_html( number_format((float)$balance, 2, '.', ',') ) ?> 173 <?php else : ?> 174 <strong class="text-danger"><?php echo esc_html($balance); ?></strong> 175 <?php endif; ?> 176 </span> 139 177 </td> 140 178 </tr> … … 147 185 <li> 148 186 <input type="checkbox" id="<?php echo esc_attr( $this->plugin_name . '-wp_reg' ); ?>" 149 name="<?php echo esc_attr( $this->plugin_name . '[wp_reg]' ); ?>" <?php checked($wp_reg, 1); ?> />187 name="<?php echo esc_attr( $this->plugin_name . '[wp_reg]' ); ?>" <?php checked($wp_reg, 1); ?> /> 150 188 <label for="<?php echo esc_attr( $this->plugin_name . '-wp_reg' ); ?>"> 151 189 <span class="toggle_btn"></span> … … 156 194 <li> 157 195 <input type="checkbox" id="<?php echo esc_attr( $this->plugin_name . '-wp_login' ); ?>" 158 name="<?php echo esc_attr( $this->plugin_name . '[wp_login]' ); ?>" <?php checked($wp_login, 1); ?> /> 196 name="<?php echo esc_attr( $this->plugin_name . '[wp_login]' ); ?>" 197 <?php checked($wp_login, 1); ?> /> 159 198 <label for="<?php echo esc_attr( $this->plugin_name . '-wp_login' ); ?>"> 160 199 <span class="toggle_btn"></span> … … 168 207 <?php 169 208 if ($has_woocommerce) { ?> 170 <h3><?php esc_attr_e('Woocommerce', $this->plugin_name); ?></h3> 171 172 <ol class="switches"> 173 <li> 174 <input type="checkbox" id="<?php echo esc_attr( $this->plugin_name . '-wc_reg' ); ?>" 175 name="<?php echo esc_attr( $this->plugin_name . '[wc_reg]' ); ?>" <?php checked($wc_reg, 1); ?> /> 176 <label for="<?php echo esc_attr( $this->plugin_name . '-wc_reg' ); ?>"> 177 <span class="toggle_btn"></span> 178 <span><?php esc_attr_e('Two Factor OTP Verification For Woocommerce Register Form', $this->plugin_name); ?></span> 179 </label> 180 </li> 181 182 <li> 183 <input type="checkbox" id="<?php echo esc_attr( $this->plugin_name . '-wc_login' ); ?>" 184 name="<?php echo esc_attr( $this->plugin_name . '[wc_login]' ); ?>" <?php checked($wc_login, 1); ?> /> 185 <label for="<?php echo esc_attr( $this->plugin_name . '-wc_login' ); ?>"> 186 <span class="toggle_btn"></span> 187 <span><?php esc_attr_e('Two Factor OTP Verification For Woocommerce Login Form', $this->plugin_name); ?></span> 188 </label> 189 </li> 190 191 <li> 192 <input type="checkbox" id="<?php echo esc_attr( $this->plugin_name . '-otp_checkout' ); ?>" 193 name="<?php echo esc_attr( $this->plugin_name . '[otp_checkout]'); ?>" <?php checked($otp_checkout, 1); ?> /> 194 <label for="<?php echo esc_attr( $this->plugin_name . '-otp_checkout' ); ?>"> 195 <span class="toggle_btn"></span> 196 <span><?php esc_attr_e('OTP Verification For Guest Customer Checkout', $this->plugin_name); ?></span> 197 </label> 198 </li> 199 200 <li> 201 <input type="checkbox" id="<?php echo esc_attr( $this->plugin_name . '-order_status_buyer' ); ?>" 202 name="<?php echo esc_attr( $this->plugin_name . '[order_status_buyer]' ); ?>" <?php checked($order_status_buyer, 1); ?> /> 203 <label for="<?php echo esc_attr( $this->plugin_name . '-order_status_buyer' ); ?>"> 204 <span class="toggle_btn"></span> 205 <span><?php esc_attr_e('Notify Customer on Order Status Change', $this->plugin_name); ?></span> 206 </label> 207 <div id="order_status_buyer"> 208 209 <fieldset class="notify_template"> 210 <legend> 211 <span class="sms_tokens my-2 d-block"><span>[store_name]</span> | <span>[billing_first_name]</span> | 212 <span>[order_id]</span> | 213 <span>[order_status]</span> | 214 <span>[order_currency]</span> | <span>[order_amount]</span> 215 </span> 216 </legend> 217 218 <textarea 219 id="<?php echo esc_attr( $this->plugin_name . '-buyer_status_sms' ); ?>" 220 name="<?php echo esc_attr( $this->plugin_name . '[BUYER_STATUS_SMS]' ); ?>" 221 rows="4" 222 cols="85"><?php echo esc_html__($buyer_status_sms); ?></textarea> 223 </fieldset> 224 225 </div> 226 </li> 227 228 <li> 229 <input type="checkbox" id="<?php echo esc_attr( $this->plugin_name . '-order_status_admin' ); ?>" 230 name="<?php echo esc_attr( $this->plugin_name . '[order_status_admin]' ); ?>" <?php checked($order_status_admin, 209 <h3><?php esc_attr_e('Woocommerce', $this->plugin_name); ?></h3> 210 211 <ol class="switches"> 212 <li> 213 <input type="checkbox" id="<?php echo esc_attr( $this->plugin_name . '-wc_reg' ); ?>" 214 name="<?php echo esc_attr( $this->plugin_name . '[wc_reg]' ); ?>" <?php checked($wc_reg, 1); ?> /> 215 <label for="<?php echo esc_attr( $this->plugin_name . '-wc_reg' ); ?>"> 216 <span class="toggle_btn"></span> 217 <span><?php esc_attr_e('Two Factor OTP Verification For Woocommerce Register Form', $this->plugin_name); ?></span> 218 </label> 219 </li> 220 221 <li> 222 <input type="checkbox" id="<?php echo esc_attr( $this->plugin_name . '-wc_login' ); ?>" 223 name="<?php echo esc_attr( $this->plugin_name . '[wc_login]' ); ?>" 224 <?php checked($wc_login, 1); ?> /> 225 <label for="<?php echo esc_attr( $this->plugin_name . '-wc_login' ); ?>"> 226 <span class="toggle_btn"></span> 227 <span><?php esc_attr_e('Two Factor OTP Verification For Woocommerce Login Form', $this->plugin_name); ?></span> 228 </label> 229 </li> 230 231 <li> 232 <input type="checkbox" id="<?php echo esc_attr( $this->plugin_name . '-otp_checkout' ); ?>" 233 name="<?php echo esc_attr( $this->plugin_name . '[otp_checkout]'); ?>" 234 <?php checked($otp_checkout, 1); ?> /> 235 <label for="<?php echo esc_attr( $this->plugin_name . '-otp_checkout' ); ?>"> 236 <span class="toggle_btn"></span> 237 <span><?php esc_attr_e('OTP Verification For Guest Customer Checkout', $this->plugin_name); ?></span> 238 </label> 239 </li> 240 241 <li> 242 <input class="alpha-collapse" type="checkbox" 243 id="<?php echo esc_attr( $this->plugin_name . '-order_status_admin' ); ?>" 244 name="<?php echo esc_attr( $this->plugin_name . '[order_status_admin]' ); ?>" <?php checked($order_status_admin, 231 245 1); ?> /> 232 <label for="<?php echo esc_attr( $this->plugin_name . '-order_status_admin' ); ?>">233 <span class="toggle_btn"></span>234 <span><?php esc_attr_e( 'Notify Admin on New Order', $this->plugin_name ); ?></span>235 </label>236 <divid="order_status_admin">237 <fieldset class="notify_template">238 <legend>239 <h4 class="mb-2">240 <label for="<?php echo esc_attr( $this->plugin_name . '-admin_phones' ); ?>">241 <?php esc_attr_e('Admin Phone Numbers (comma separated)',246 <label for="<?php echo esc_attr( $this->plugin_name . '-order_status_admin' ); ?>"> 247 <span class="toggle_btn"></span> 248 <span><?php esc_attr_e( 'Notify Admin on New Order', $this->plugin_name ); ?></span> 249 </label> 250 <div class="alpha-collapsable" id="order_status_admin"> 251 <fieldset class="notify_template"> 252 <legend> 253 <h4 class="mb-2"> 254 <label for="<?php echo esc_attr( $this->plugin_name . '-admin_phones' ); ?>"> 255 <?php esc_attr_e('Admin Phone Numbers (comma separated)', 242 256 $this->plugin_name); ?> 243 </label> 244 </h4> 245 <input id="<?php echo esc_attr( $this->plugin_name . '-admin_phones' ); ?>" 246 name="<?php echo esc_attr( $this->plugin_name . '[admin_phones]' ) ; ?>" 247 type="text" size="82" 248 class="mb-2" 249 value="<?php echo esc_attr( $admin_phones ); ?>"/> 250 <span class="my-2 d-block sms_tokens"><span>[store_name]</span> | <span>[billing_first_name]</span> | 251 <span>[order_id]</span> | 252 <span>[order_status]</span> | 253 <span>[order_currency]</span> | <span>[order_amount]</span> 254 </span> 255 </legend> 256 <textarea id="<<?php echo esc_attr( $this->plugin_name . '-admin_status_sms' ); ?>" 257 name="<?php echo esc_attr( $this->plugin_name . '[ADMIN_STATUS_SMS]' ) ; ?>" rows="4" 258 cols="85"><?php echo esc_html__( $admin_status_sms ); ?> 259 </textarea> 260 </fieldset> 261 262 </div> 263 </li> 264 265 </ol> 257 </label> 258 </h4> 259 <input id="<?php echo esc_attr( $this->plugin_name . '-admin_phones' ); ?>" 260 name="<?php echo esc_attr( $this->plugin_name . '[admin_phones]' ) ; ?>" type="text" 261 size="82" class="mb-2" value="<?php echo esc_attr( $admin_phones ); ?>" /> 262 <span class="my-2 d-block sms_tokens"><span>[store_name]</span> | 263 <span>[billing_first_name]</span> | 264 <span>[order_id]</span> | 265 <span>[order_status]</span> | 266 <span>[order_currency]</span> | <span>[order_amount]</span> 267 </span> 268 </legend> 269 <textarea id="<<?php echo esc_attr( $this->plugin_name . '-admin_status_sms' ); ?>" 270 name="<?php echo esc_attr( $this->plugin_name . '[ADMIN_STATUS_SMS]' ) ; ?>" rows="3" 271 cols="85"><?php echo esc_html__( $admin_status_sms ); ?></textarea> 272 </fieldset> 273 274 </div> 275 </li> 276 277 278 <!-- working start --> 279 280 281 <h3>Notify Customer</h3> 282 283 284 <li> 285 <input class="alpha-collapse" type="checkbox" 286 id="<?php echo esc_attr( $this->plugin_name . '-order_status_pending' ); ?>" 287 name="<?php echo esc_attr( $this->plugin_name . '[order_status_pending]' ); ?>" 288 <?php checked($order_status_pending, 1); ?> /> 289 <label for="<?php echo esc_attr( $this->plugin_name . '-order_status_pending' ); ?>"> 290 <span class="toggle_btn"></span> 291 <span><?php esc_attr_e('On Order Pending payment', $this->plugin_name); ?></span> 292 </label> 293 <div class="alpha-collapsable" id="order_status_pending"> 294 295 <fieldset class="notify_template"> 296 <legend> 297 <span class="sms_tokens my-2 d-block"><span>[store_name]</span> | 298 <span>[billing_first_name]</span> | 299 <span>[order_id]</span> | 300 <span>[order_status_pending]</span> | 301 <span>[order_currency]</span> | <span>[order_amount]</span> 302 </span> 303 </legend> 304 305 <textarea id="<?php echo esc_attr( $this->plugin_name . '-order_status_pending_sms' ); ?>" 306 name="<?php echo esc_attr( $this->plugin_name . '[ORDER_STATUS_PENDING_SMS]' ); ?>" rows="4" 307 cols="85"><?php echo esc_html__($order_status_pending_sms); ?></textarea> 308 </fieldset> 309 310 </div> 311 </li> 312 313 314 <li> 315 <input class="alpha-collapse" type="checkbox" 316 id="<?php echo esc_attr( $this->plugin_name . '-order_status_processing' ); ?>" 317 name="<?php echo esc_attr( $this->plugin_name . '[order_status_processing]' ); ?>" 318 <?php checked($order_status_processing, 1); ?> /> 319 <label for="<?php echo esc_attr( $this->plugin_name . '-order_status_processing' ); ?>"> 320 <span class="toggle_btn"></span> 321 <span><?php esc_attr_e('On Order Processing', $this->plugin_name); ?></span> 322 </label> 323 <div class="alpha-collapsable" id="order_status_processing"> 324 325 <fieldset class="notify_template"> 326 <legend> 327 <span class="sms_tokens my-2 d-block"><span>[store_name]</span> | 328 <span>[billing_first_name]</span> | 329 <span>[order_id]</span> | 330 <span>[order_status]</span> | 331 <span>[order_currency]</span> | <span>[order_amount]</span> 332 </span> 333 </legend> 334 335 <textarea id="<?php echo esc_attr( $this->plugin_name . '-order_status_processing_sms' ); ?>" 336 name="<?php echo esc_attr( $this->plugin_name . '[ORDER_STATUS_PROCESSING_SMS]' ); ?>" 337 rows="4" cols="85"><?php echo esc_html__($order_status_processing_sms); ?></textarea> 338 </fieldset> 339 340 </div> 341 </li> 342 343 <li> 344 <input class="alpha-collapse" type="checkbox" 345 id="<?php echo esc_attr( $this->plugin_name . '-order_status_on_hold' ); ?>" 346 name="<?php echo esc_attr( $this->plugin_name . '[order_status_on_hold]' ); ?>" 347 <?php checked($order_status_on_hold, 1); ?> /> 348 <label for="<?php echo esc_attr( $this->plugin_name . '-order_status_on_hold' ); ?>"> 349 <span class="toggle_btn"></span> 350 <span><?php esc_attr_e('On Order On hold', $this->plugin_name); ?></span> 351 </label> 352 <div class="alpha-collapsable" id="order_status_on_hold"> 353 354 <fieldset class="notify_template"> 355 <legend> 356 <span class="sms_tokens my-2 d-block"><span>[store_name]</span> | 357 <span>[billing_first_name]</span> | 358 <span>[order_id]</span> | 359 <span>[order_status]</span> | 360 <span>[order_currency]</span> | <span>[order_amount]</span> 361 </span> 362 </legend> 363 364 <textarea id="<?php echo esc_attr( $this->plugin_name . '-order_status_on_hold_sms' ); ?>" 365 name="<?php echo esc_attr( $this->plugin_name . '[ORDER_STATUS_ON_HOLD_SMS]' ); ?>" rows="4" 366 cols="85"><?php echo esc_html__($order_status_on_hold_sms); ?></textarea> 367 </fieldset> 368 369 </div> 370 </li> 371 372 373 374 <li> 375 <input class="alpha-collapse" type="checkbox" 376 id="<?php echo esc_attr( $this->plugin_name . '-order_status_completed' ); ?>" 377 name="<?php echo esc_attr( $this->plugin_name . '[order_status_completed]' ); ?>" 378 <?php checked($order_status_completed, 1); ?> /> 379 <label for="<?php echo esc_attr( $this->plugin_name . '-order_status_completed' ); ?>"> 380 <span class="toggle_btn"></span> 381 <span><?php esc_attr_e('On Order Completed', $this->plugin_name); ?></span> 382 </label> 383 <div class="alpha-collapsable" id="order_status_completed"> 384 385 <fieldset class="notify_template"> 386 <legend> 387 <span class="sms_tokens my-2 d-block"><span>[store_name]</span> | 388 <span>[billing_first_name]</span> | 389 <span>[order_id]</span> | 390 <span>[order_status]</span> | 391 <span>[order_currency]</span> | <span>[order_amount]</span> 392 </span> 393 </legend> 394 395 <textarea id="<?php echo esc_attr( $this->plugin_name . '-order_status_completed_sms' ); ?>" 396 name="<?php echo esc_attr( $this->plugin_name . '[ORDER_STATUS_COMPLETED_SMS]' ); ?>" 397 rows="4" cols="85"><?php echo esc_html__($order_status_completed_sms); ?></textarea> 398 </fieldset> 399 400 </div> 401 </li> 402 403 404 <li> 405 <input class="alpha-collapse" type="checkbox" 406 id="<?php echo esc_attr( $this->plugin_name . '-order_status_cancelled' ); ?>" 407 name="<?php echo esc_attr( $this->plugin_name . '[order_status_cancelled]' ); ?>" 408 <?php checked($order_status_cancelled, 1); ?> /> 409 <label for="<?php echo esc_attr( $this->plugin_name . '-order_status_cancelled' ); ?>"> 410 <span class="toggle_btn"></span> 411 <span><?php esc_attr_e('On Order Cancelled', $this->plugin_name); ?></span> 412 </label> 413 <div class="alpha-collapsable" id="order_status_cancelled"> 414 415 <fieldset class="notify_template"> 416 <legend> 417 <span class="sms_tokens my-2 d-block"><span>[store_name]</span> | 418 <span>[billing_first_name]</span> | 419 <span>[order_id]</span> | 420 <span>[order_status]</span> | 421 <span>[order_currency]</span> | <span>[order_amount]</span> 422 </span> 423 </legend> 424 425 <textarea id="<?php echo esc_attr( $this->plugin_name . '-order_status_cancelled_sms' ); ?>" 426 name="<?php echo esc_attr( $this->plugin_name . '[ORDER_STATUS_CANCELLED_SMS]' ); ?>" 427 rows="4" cols="85"><?php echo esc_html__($order_status_cancelled_sms); ?></textarea> 428 </fieldset> 429 430 </div> 431 </li> 432 433 434 <li> 435 <input class="alpha-collapse" type="checkbox" 436 id="<?php echo esc_attr( $this->plugin_name . '-order_status_refunded' ); ?>" 437 name="<?php echo esc_attr( $this->plugin_name . '[order_status_refunded]' ); ?>" 438 <?php checked($order_status_refunded, 1); ?> /> 439 <label for="<?php echo esc_attr( $this->plugin_name . '-order_status_refunded' ); ?>"> 440 <span class="toggle_btn"></span> 441 <span><?php esc_attr_e('On Order Refunded', $this->plugin_name); ?></span> 442 </label> 443 <div class="alpha-collapsable" id="order_status_refunded"> 444 445 <fieldset class="notify_template"> 446 <legend> 447 <span class="sms_tokens my-2 d-block"><span>[store_name]</span> | 448 <span>[billing_first_name]</span> | 449 <span>[order_id]</span> | 450 <span>[order_status]</span> | 451 <span>[order_currency]</span> | <span>[order_amount]</span> 452 </span> 453 </legend> 454 455 <textarea id="<?php echo esc_attr( $this->plugin_name . '-order_status_refunded_sms' ); ?>" 456 name="<?php echo esc_attr( $this->plugin_name . '[ORDER_STATUS_REFUNDED_SMS]' ); ?>" 457 rows="4" cols="85"><?php echo esc_html__($order_status_refunded_sms); ?></textarea> 458 </fieldset> 459 460 </div> 461 </li> 462 463 464 465 <li> 466 <input class="alpha-collapse" type="checkbox" 467 id="<?php echo esc_attr( $this->plugin_name . '-order_status_failed' ); ?>" 468 name="<?php echo esc_attr( $this->plugin_name . '[order_status_failed]' ); ?>" 469 <?php checked($order_status_failed, 1); ?> /> 470 <label for="<?php echo esc_attr( $this->plugin_name . '-order_status_failed' ); ?>"> 471 <span class="toggle_btn"></span> 472 <span><?php esc_attr_e('On Order Failed', $this->plugin_name); ?></span> 473 </label> 474 <div class="alpha-collapsable" id="order_status_failed"> 475 476 <fieldset class="notify_template"> 477 <legend> 478 <span class="sms_tokens my-2 d-block"><span>[store_name]</span> | 479 <span>[billing_first_name]</span> | 480 <span>[order_id]</span> | 481 <span>[order_status]</span> | 482 <span>[order_currency]</span> | <span>[order_amount]</span> 483 </span> 484 </legend> 485 486 <textarea id="<?php echo esc_attr( $this->plugin_name . '-order_status_failed_sms' ); ?>" 487 name="<?php echo esc_attr( $this->plugin_name . '[ORDER_STATUS_FAILED_SMS]' ); ?>" rows="4" 488 cols="85"><?php echo esc_html__($order_status_failed_sms); ?></textarea> 489 </fieldset> 490 491 </div> 492 </li> 493 494 495 496 <!-- working end --> 497 498 499 500 </ol> 266 501 <?php } 267 502 ?> -
alpha-sms/trunk/alpha_sms.php
r2812475 r2867587 17 17 * Plugin URI: https://sms.net.bd/plugins/wordpress 18 18 * Description: WP 2FA Login. SMS OTP Verification for Registration and Login forms, WooCommerce SMS Notification for your shop orders. 19 * Version: 1.0. 319 * Version: 1.0.4 20 20 * Author: Alpha Net 21 21 * Author URI: https://sms.net.bd/ … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define('ALPHA_SMS_VERSION', '1.0. 3');38 define('ALPHA_SMS_VERSION', '1.0.4'); 39 39 40 40 // plugin constants -
alpha-sms/trunk/includes/class-alpha_sms.php
r2659811 r2867587 281 281 $this->loader->add_action('wp_ajax_nopriv_wc_send_otp', $plugin_public, 'send_otp_for_reg'); 282 282 283 // otp for guest checkout 283 // otp for guest checkout form 284 284 $this->loader->add_action('woocommerce_review_order_before_submit', $plugin_public, 'otp_form_at_checkout'); 285 286 // otp validation on guest checkout 287 $this->loader->add_action('woocommerce_checkout_process', $plugin_public, 'validate_guest_checkout_otp'); 285 288 286 289 -
alpha-sms/trunk/includes/sms.class.php
r2627862 r2867587 25 25 public function Send() 26 26 { 27 28 27 29 $postFields = [ 28 30 'api_key' => $this->api_key, … … 33 35 34 36 $response = $this->sendRequest($this->api_url . '/sendsms', 'POST', $postFields); 37 38 39 40 35 41 36 42 return json_decode($response); -
alpha-sms/trunk/public/class-alpha_sms-public.php
r2812471 r2867587 2 2 3 3 // If this file is called directly, abort. 4 if ( !defined('WPINC')) {5 die;4 if ( ! defined( 'WPINC' ) ) { 5 die; 6 6 } 7 7 … … 16 16 * @author Alpha Net Developer Team <support@alpha.net.bd> 17 17 */ 18 class Alpha_sms_Public 19 { 20 21 /** 22 * The ID of this plugin. 23 * 24 * @since 1.0.0 25 * @access private 26 * @var string $plugin_name The ID of this plugin. 27 */ 28 private $plugin_name; 29 30 /** 31 * The version of this plugin. 32 * 33 * @since 1.0.0 34 * @access private 35 * @var string $version The current version of this plugin. 36 */ 37 private $version; 38 private $options; 39 /** 40 * @var false 41 */ 42 private $pluginActive; 43 44 /** 45 * Initialize the class and set its properties. 46 * 47 * @param string $plugin_name The name of the plugin. 48 * @param string $version The version of this plugin. 49 * 50 * @since 1.0.0 51 */ 52 public function __construct($plugin_name, $version) 53 { 54 $this->plugin_name = $plugin_name; 55 $this->version = $version; 56 $this->options = get_option($this->plugin_name); 57 $this->pluginActive = !empty($this->options['api_key']) && $this->checkAPI($this->options['api_key']); 58 } 59 60 /** 61 * Check if entered api key is valid or not 62 * 63 * @return bool 64 */ 65 private function checkAPI($api_key) 66 { 67 require_once ALPHA_SMS_PATH . 'includes/sms.class.php'; 68 69 $smsPortal = new AlphaSMS($api_key); 70 71 $response = $smsPortal->getBalance(); 72 73 return $response && $response->error === 0; 74 } 75 76 /** 77 * @return void 78 * @since 1.0.0 79 * start session if not started 80 */ 81 public function start_session_wp() 82 { 83 if (!session_id()) { 84 session_start(); 85 } 86 } 87 88 /** 89 * Register the stylesheets for the public-facing side of the site. 90 * 91 * @since 1.0.0 92 */ 93 public function enqueue_styles() 94 { 95 /** 96 * This function is provided for demonstration purposes only. 97 * 98 * An instance of this class should be passed to the run() function 99 * defined in Alpha_sms_Loader as all of the hooks are defined 100 * in that particular class. 101 * 102 * The Alpha_sms_Loader will then create the relationship 103 * between the defined hooks and the functions defined in this 104 * class. 105 */ 106 107 wp_enqueue_style( 108 $this->plugin_name, 109 plugin_dir_url(__FILE__) . 'css/alpha_sms-public.css', 110 [], 111 $this->version, 112 'all' 113 ); 114 } 115 116 /** 117 * Register the JavaScript for the public-facing side of the site. 118 * 119 * @since 1.0.0 120 */ 121 public function enqueue_scripts() 122 { 123 /** 124 * This function is provided for demonstration purposes only. 125 * 126 * An instance of this class should be passed to the run() function 127 * defined in Alpha_sms_Loader as all of the hooks are defined 128 * in that particular class. 129 * 130 * The Alpha_sms_Loader will then create the relationship 131 * between the defined hooks and the functions defined in this 132 * class. 133 */ 134 135 wp_enqueue_script( 136 $this->plugin_name, 137 plugin_dir_url(__FILE__) . 'js/alpha_sms-public.js', 138 ['jquery'], 139 $this->version, 140 false 141 ); 142 143 // adding a js variable for ajax form submit url 144 wp_localize_script( 145 $this->plugin_name, 146 $this->plugin_name . '_object', 147 ['ajaxurl' => admin_url('admin-ajax.php')] 148 ); 149 } 150 151 /** 152 * Woocommerce 153 * show phone number on register page and my account 154 */ 155 public function wc_phone_on_register() 156 { 157 if (!$this->pluginActive || !$this->options['wc_reg']) { 158 return; 159 } 160 161 $user = wp_get_current_user(); 162 $value = isset($_POST['billing_phone']) ? sanitize_text_field($_POST['billing_phone']) 163 : $user->billing_phone; 164 ?> 18 class Alpha_sms_Public { 19 20 /** 21 * The ID of this plugin. 22 * 23 * @since 1.0.0 24 * @access private 25 * @var string $plugin_name The ID of this plugin. 26 */ 27 private $plugin_name; 28 29 /** 30 * The version of this plugin. 31 * 32 * @since 1.0.0 33 * @access private 34 * @var string $version The current version of this plugin. 35 */ 36 private $version; 37 private $options; 38 /** 39 * @var false 40 */ 41 private $pluginActive; 42 43 /** 44 * Initialize the class and set its properties. 45 * 46 * @param string $plugin_name The name of the plugin. 47 * @param string $version The version of this plugin. 48 * 49 * @since 1.0.0 50 */ 51 public function __construct( $plugin_name, $version ) { 52 $this->plugin_name = $plugin_name; 53 $this->version = $version; 54 $this->options = get_option( $this->plugin_name ); 55 $this->pluginActive = ! empty( $this->options['api_key'] ) && $this->checkAPI( $this->options['api_key'] ); 56 } 57 58 /** 59 * @return void 60 * @since 1.0.0 61 * start session if not started 62 */ 63 public function start_session_wp() { 64 if ( ! session_id() ) { 65 session_start(); 66 } 67 } 68 69 /** 70 * Register the stylesheets for the public-facing side of the site. 71 * 72 * @since 1.0.0 73 */ 74 public function enqueue_styles() { 75 /** 76 * This function is provided for demonstration purposes only. 77 * 78 * An instance of this class should be passed to the run() function 79 * defined in Alpha_sms_Loader as all of the hooks are defined 80 * in that particular class. 81 * 82 * The Alpha_sms_Loader will then create the relationship 83 * between the defined hooks and the functions defined in this 84 * class. 85 */ 86 87 wp_enqueue_style( 88 $this->plugin_name, 89 plugin_dir_url( __FILE__ ) . 'css/alpha_sms-public.css', 90 [], 91 $this->version, 92 'all' 93 ); 94 } 95 96 /** 97 * Register the JavaScript for the public-facing side of the site. 98 * 99 * @since 1.0.0 100 */ 101 public function enqueue_scripts() { 102 /** 103 * This function is provided for demonstration purposes only. 104 * 105 * An instance of this class should be passed to the run() function 106 * defined in Alpha_sms_Loader as all of the hooks are defined 107 * in that particular class. 108 * 109 * The Alpha_sms_Loader will then create the relationship 110 * between the defined hooks and the functions defined in this 111 * class. 112 */ 113 114 wp_enqueue_script( 115 $this->plugin_name, 116 plugin_dir_url( __FILE__ ) . 'js/alpha_sms-public.js', 117 [ 'jquery' ], 118 $this->version, 119 false 120 ); 121 122 // adding a js variable for ajax form submit url 123 wp_localize_script( 124 $this->plugin_name, 125 $this->plugin_name . '_object', 126 [ 'ajaxurl' => admin_url( 'admin-ajax.php' ) ] 127 ); 128 } 129 130 /** 131 * Woocommerce 132 * show phone number on register page and my account 133 */ 134 public function wc_phone_on_register() { 135 if ( ! $this->pluginActive || ! $this->options['wc_reg'] ) { 136 return; 137 } 138 139 $user = wp_get_current_user(); 140 $value = isset( $_POST['billing_phone'] ) ? sanitize_text_field( $_POST['billing_phone'] ) 141 : $user->billing_phone; 142 ?> 165 143 166 144 <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide"> 167 <label for="reg_billing_phone"><?php _e( 'Phone', 'woocommerce'); ?> <span class="required">*</span>145 <label for="reg_billing_phone"><?php _e( 'Phone', 'woocommerce' ); ?> <span class="required">*</span> 168 146 </label> 169 <input type="tel" minlength="11" maxlength="11" class="input-text" name="billing_phone" id="reg_billing_phone" value="<?php echo esc_attr( $value) ?>" required/>147 <input type="tel" minlength="11" maxlength="11" class="input-text" name="billing_phone" id="reg_billing_phone" value="<?php echo esc_attr( $value ) ?>" required/> 170 148 </p> 171 149 <div class="clear"></div> 172 150 173 <?php 174 } 175 176 /** 177 * Default WordPress 178 * show otp form in registration form 179 */ 180 public function add_otp_field_on_wp_reg_form() 181 { 182 if (!$this->pluginActive || !$this->options['wp_reg']) { 183 return; 184 } 185 require_once('partials/add-otp-on-login-form.php'); 186 ?> 187 <input type='hidden' name='action_type' id='action_type' value='wp_reg' /> 188 <?php 189 } 190 191 /** 192 * Woocommerce 193 * show otp form in registration form 194 */ 195 public function add_otp_field_on_wc_reg_form() 196 { 197 if (!$this->pluginActive || !$this->options['wc_reg']) { 198 return; 199 } 200 201 require_once('partials/add-otp-on-wc-reg-form.php'); 202 ?> 203 <input type='hidden' name='action_type' id='action_type' value='wc_reg' /> 204 <?php 205 } 206 207 /** 208 * Woocommerce + Default WordPress 209 * ajax otp send on post phone number * 210 */ 211 public function send_otp_for_reg() 212 { 213 $user_phone = $user_email = ''; 214 215 if (isset($_POST['billing_phone'], $_POST['email'])) { 216 $user_phone = $this->validateNumber(sanitize_text_field($_POST['billing_phone'])); 217 $user_email = sanitize_text_field($_POST['email']); 218 } 219 220 if (!$user_email && !empty($_POST['billing_email'])) { 221 $user_email = sanitize_text_field($_POST['billing_email']); 222 } 223 224 if (!filter_var($user_email, FILTER_VALIDATE_EMAIL)) { 225 $response = ['status' => 400, 'message' => __('The email address you entered is not valid!')]; 226 echo wp_kses_post(json_encode($response)); 227 wp_die(); 228 exit; 229 } 230 231 if (isset($_POST['password']) && empty($_POST['password']) && strlen($_POST['password']) < 8) { 232 $response = ['status' => 400, 'message' => __('Weak - Please enter a stronger password.')]; 233 echo wp_kses_post(json_encode($response)); 234 wp_die(); 235 exit; 236 } 237 238 if (!$user_phone) { 239 $response = ['status' => 400, 'message' => __('The phone number you entered is not valid!')]; 240 echo wp_kses_post(json_encode($response)); 241 wp_die(); 242 exit; 243 } 244 245 //we will send sms 246 $otp_code = $this->generateOTP(); 247 248 $body = 'Your OTP for '.get_bloginfo().' Registration is ' . $otp_code . ' . Only valid for 2 min.'; 249 250 if (!empty($_POST['action_type']) && $_POST['action_type'] === 'wc_checkout') { 251 $body = 'Your '.get_bloginfo().' OTP for Order Checkout is ' . $otp_code . ' . Only valid for 2 min.'; 252 } 253 254 $sms_response = $this->SendSMS($user_phone, $body); 255 256 if ($sms_response->error === 0) { 257 // save info in database for later verification 258 if ($this->log_login_register_action( 259 $user_phone, 260 $otp_code 261 )) { 262 $response = [ 263 'status' => 200, 264 'message' => 'A OTP (One Time Passcode) has been sent. Please enter the OTP in the field below to verify your phone.', 265 ]; 266 } else { 267 $response = ['status' => 400, 'message' => __('Error occurred while sending OTP. Please try again.')]; 268 } 269 270 echo wp_kses_post(json_encode($response)); 271 wp_die(); 272 exit; 273 } 274 275 $response = ['status' => '400', 'message' => __('Error occurred while sending OTP. Contact Administrator.')]; 276 echo wp_kses_post(json_encode($response)); 277 wp_die(); 278 exit; 279 } 280 281 /** 282 * Validate Bangladeshi phone number format 283 * 284 * @param $num 285 * 286 * @return false|int|string 287 */ 288 public function validateNumber($num) 289 { 290 if (!$num) { 291 return false; 292 } 293 294 $num = ltrim(trim($num), "+88"); 295 $number = '88' . ltrim($num, "88"); 296 297 $ext = ["88017", "88013", "88016", "88015", "88018", "88019", "88014"]; 298 if (is_numeric($number) && strlen($number) === 13 && in_array(substr($number, 0, 5), $ext, true)) { 299 return $number; 300 } 301 302 return false; 303 } 304 305 /** 306 * Generate 6 digit otp code 307 * 308 * @return string 309 */ 310 public function generateOTP() 311 { 312 $otp = ''; 313 314 for ($i = 0; $i < 6; $i++) { 315 $otp .= mt_rand(0, 9); 316 } 317 318 return $otp; 319 } 320 321 /** 322 * Send SMS via sms api 323 * 324 * @param $to 325 * @param $body 326 * 327 * @return false|mixed 328 */ 329 public function SendSMS($to, $body) 330 { 331 if (!$this->pluginActive) { 332 return false; 333 } 334 335 $api_key = !empty($this->options['api_key']) ? $this->options['api_key'] : ''; 336 $sender_id = !empty($this->options['sender_id']) ? trim($this->options['sender_id']) : ''; 337 338 require_once ALPHA_SMS_PATH . 'includes/sms.class.php'; 339 340 $sms = new AlphaSMS($api_key); 341 $sms->numbers = $to; 342 $sms->body = $body; 343 $sms->sender_id = $sender_id; 344 345 return $sms->Send(); 346 } 347 348 /** 349 * after sending otp to user, log the otp and data in db 350 * 351 * @param $mobile_phone 352 * @param $otp_code 353 * 354 * @return bool 355 */ 356 public function log_login_register_action( 357 $mobile_phone, 358 $otp_code 359 ) { 360 $dateTime = new DateTime(ALPHA_SMS_TIMESTAMP); 361 $dateTime->modify('+2 minutes'); 362 363 $_SESSION['alpha_sms_otp_code'] = $otp_code; 364 $_SESSION['alpha_sms_expires'] = $dateTime->format('Y-m-d H:i:s'); 365 366 if (!empty($_SESSION['alpha_sms_otp_code'])) { 367 return true; 368 } 369 370 return false; 371 } 372 373 /** 374 * Verify otp and register the user 375 * 376 * @param $customer_id 377 */ 378 public function register_the_customer($customer_id) 379 { 380 if (!$this->pluginActive || (!$this->options['wp_reg'] && !$this->options['wc_reg'])) { 381 return; 382 } 383 if (isset($_POST['billing_phone']) && $this->validateNumber(sanitize_text_field($_POST['billing_phone']))) { 384 update_user_meta( 385 $customer_id, 386 'billing_phone', 387 sanitize_text_field($this->validateNumber($_POST['billing_phone'])) 388 ); 389 } 390 } 391 392 /** 393 * Default WordPress 394 * show phone number on register page 395 */ 396 public function wp_phone_on_register() 397 { 398 if (!$this->pluginActive || !$this->options['wp_reg']) { 399 return; 400 } 401 402 $billing_phone = (!empty($_POST['billing_phone'])) ? sanitize_text_field($_POST['billing_phone']) : ''; 403 404 ?> 151 <?php 152 } 153 154 /** 155 * Default WordPress 156 * show otp form in registration form 157 */ 158 public function add_otp_field_on_wp_reg_form() { 159 if ( ! $this->pluginActive || ! $this->options['wp_reg'] ) { 160 return; 161 } 162 require_once 'partials/add-otp-on-login-form.php'; 163 ?> 164 <input type='hidden' name='action_type' id='action_type' value='wp_reg'/> 165 <?php 166 } 167 168 /** 169 * Woocommerce 170 * show otp form in registration form 171 */ 172 public function add_otp_field_on_wc_reg_form() { 173 if ( ! $this->pluginActive || ! $this->options['wc_reg'] ) { 174 return; 175 } 176 177 require_once 'partials/add-otp-on-wc-reg-form.php'; 178 ?> 179 <input type='hidden' name='action_type' id='action_type' value='wc_reg'/> 180 <?php 181 } 182 183 /** 184 * Woocommerce + Default WordPress 185 * ajax otp send on post phone number * 186 */ 187 public function send_otp_for_reg() { 188 $user_phone = $user_email = ''; 189 190 if ( isset( $_POST['billing_phone'], $_POST['email'] ) ) { 191 $user_phone = $this->validateNumber( sanitize_text_field( $_POST['billing_phone'] ) ); 192 $user_email = sanitize_text_field( $_POST['email'] ); 193 } 194 195 if ( ! $user_email && ! empty( $_POST['billing_email'] ) ) { 196 $user_email = sanitize_text_field( $_POST['billing_email'] ); 197 } 198 199 if ( ! filter_var( $user_email, FILTER_VALIDATE_EMAIL ) ) { 200 $response = [ 'status' => 400, 'message' => __( 'The email address you entered is not valid!' ) ]; 201 echo wp_kses_post( json_encode( $response ) ); 202 wp_die(); 203 exit; 204 } 205 206 if ( isset( $_POST['password'] ) && empty( $_POST['password'] ) && strlen( $_POST['password'] ) < 8 ) { 207 $response = [ 'status' => 400, 'message' => __( 'Weak - Please enter a stronger password.' ) ]; 208 echo wp_kses_post( json_encode( $response ) ); 209 wp_die(); 210 exit; 211 } 212 213 if ( ! $user_phone ) { 214 $response = [ 'status' => 400, 'message' => __( 'The phone number you entered is not valid!' ) ]; 215 echo wp_kses_post( json_encode( $response ) ); 216 wp_die(); 217 exit; 218 } 219 220 //we will send sms 221 $otp_code = $this->generateOTP(); 222 223 $body = 'Your OTP for ' . get_bloginfo() . ' registration is ' . $otp_code . '. Valid for 2 min. Contact us if you need help.'; 224 225 if ( ! empty( $_POST['action_type'] ) && $_POST['action_type'] === 'wc_checkout' ) { 226 $body = 'Your OTP for secure order checkout on ' . get_bloginfo() . ' is ' . $otp_code . '. Use it within 2 min to complete the checkout process.'; 227 } 228 229 $sms_response = $this->SendSMS( $user_phone, $body ); 230 231 if ( $sms_response->error === 0 ) { 232 // save info in database for later verification 233 if ( $this->log_login_register_action( 234 $user_phone, 235 $otp_code 236 ) ) { 237 $response = [ 238 'status' => 200, 239 'message' => 'A OTP (One Time Passcode) has been sent. Please enter the OTP in the field below to verify your phone.', 240 ]; 241 } else { 242 $response = [ 'status' => 400, 'message' => __( 'Error occurred while sending OTP. Please try again.' ) ]; 243 } 244 245 echo wp_kses_post( json_encode( $response ) ); 246 wp_die(); 247 exit; 248 } 249 250 $response = [ 'status' => '400', 'message' => __( 'Error occurred while sending OTP. Contact Administrator.' ) ]; 251 echo wp_kses_post( json_encode( $response ) ); 252 wp_die(); 253 exit; 254 } 255 256 /** 257 * Validate Bangladeshi phone number format 258 * 259 * @param $num 260 * 261 * @return false|int|string 262 */ 263 public function validateNumber( $num ) { 264 if ( ! $num ) { 265 return false; 266 } 267 268 $num = ltrim( trim( $num ), "+88" ); 269 $number = '88' . ltrim( $num, "88" ); 270 271 $ext = [ "88017", "88013", "88016", "88015", "88018", "88019", "88014" ]; 272 if ( is_numeric( $number ) && strlen( $number ) === 13 && in_array( substr( $number, 0, 5 ), $ext, true ) ) { 273 return $number; 274 } 275 276 return false; 277 } 278 279 /** 280 * Generate 6 digit otp code 281 * 282 * @return string 283 */ 284 public function generateOTP() { 285 $otp = ''; 286 287 for ( $i = 0; $i < 6; $i ++ ) { 288 $otp .= mt_rand( 0, 9 ); 289 } 290 291 return $otp; 292 } 293 294 /** 295 * Send SMS via sms api 296 * 297 * @param $to 298 * @param $body 299 * 300 * @return false|mixed 301 */ 302 public function SendSMS( $to, $body ) { 303 if ( ! $this->pluginActive ) { 304 return false; 305 } 306 307 $api_key = ! empty( $this->options['api_key'] ) ? $this->options['api_key'] : ''; 308 $sender_id = ! empty( $this->options['sender_id'] ) ? trim( $this->options['sender_id'] ) : ''; 309 310 require_once ALPHA_SMS_PATH . 'includes/sms.class.php'; 311 312 $sms = new AlphaSMS( $api_key ); 313 $sms->numbers = $to; 314 $sms->body = $body; 315 $sms->sender_id = $sender_id; 316 317 return $sms->Send(); 318 } 319 320 /** 321 * after sending otp to user, log the otp and data in db 322 * 323 * @param $mobile_phone 324 * @param $otp_code 325 * 326 * @return bool 327 */ 328 public function log_login_register_action( 329 $mobile_phone, 330 $otp_code 331 ) { 332 $dateTime = new DateTime( ALPHA_SMS_TIMESTAMP ); 333 $dateTime->modify( '+2 minutes' ); 334 335 $_SESSION['alpha_sms_otp_code'] = $otp_code; 336 $_SESSION['alpha_sms_expires'] = $dateTime->format( 'Y-m-d H:i:s' ); 337 338 if ( ! empty( $_SESSION['alpha_sms_otp_code'] ) ) { 339 return true; 340 } 341 342 return false; 343 } 344 345 /** 346 * Verify otp and register the user 347 * 348 * @param $customer_id 349 */ 350 public function register_the_customer( $customer_id ) { 351 if ( ! $this->pluginActive || ( ! $this->options['wp_reg'] && ! $this->options['wc_reg'] ) ) { 352 return; 353 } 354 if ( isset( $_POST['billing_phone'] ) && $this->validateNumber( sanitize_text_field( $_POST['billing_phone'] ) ) ) { 355 update_user_meta( 356 $customer_id, 357 'billing_phone', 358 sanitize_text_field( $this->validateNumber( $_POST['billing_phone'] ) ) 359 ); 360 } 361 } 362 363 /** 364 * Default WordPress 365 * show phone number on register page 366 */ 367 public function wp_phone_on_register() { 368 if ( ! $this->pluginActive || ! $this->options['wp_reg'] ) { 369 return; 370 } 371 372 $billing_phone = ( ! empty( $_POST['billing_phone'] ) ) ? sanitize_text_field( $_POST['billing_phone'] ) : ''; 373 374 ?> 405 375 <p> 406 <label for="billing_phone"><?php _e( 'Phone', $this->plugin_name) ?><br/>407 <input type="text" name="billing_phone" id="reg_billing_phone" class="input" value="<?php echo esc_attr( $billing_phone); ?>" size="25"/></label>376 <label for="billing_phone"><?php _e( 'Phone', $this->plugin_name ) ?><br/> 377 <input type="text" name="billing_phone" id="reg_billing_phone" class="input" value="<?php echo esc_attr( $billing_phone ); ?>" size="25"/></label> 408 378 </p> 409 <?php 410 } 411 412 413 /** 414 * WordPress validate phone and validate otp 415 * 416 * @param $errors 417 * @param $sanitized_user_login 418 * @param $user_email 419 * 420 * @return mixed 421 */ 422 public function wp_register_form_validation($errors, $sanitized_user_login, $user_email) 423 { 424 if ( 425 $this->pluginActive && $this->options['wp_reg'] && !empty($_POST['action_type']) && 426 $_POST['action_type'] === 'wp_reg' 427 ) { 428 $this->register_form_validation($errors, $sanitized_user_login, $user_email); 429 } 430 431 return $errors; 432 } 433 434 /** 435 * Register Form Validation 436 * 437 * @param $errors 438 * @param $sanitized_user_login 439 * @param $user_email 440 * 441 * @return mixed 442 */ 443 public function register_form_validation($errors, $sanitized_user_login, $user_email) 444 { 445 if ( 446 empty($_REQUEST['billing_phone']) || !is_numeric($_REQUEST['billing_phone']) || 447 !$this->validateNumber(sanitize_text_field($_REQUEST['billing_phone'])) 448 ) { 449 $errors->add('phone_error', __('You phone number is not valid.', $this->plugin_name)); 450 } 451 452 $billing_phone = $this->validateNumber(sanitize_text_field($_REQUEST['billing_phone'])); 453 454 $hasPhoneNumber = get_users('meta_value=' . $billing_phone); 455 456 if (!empty($hasPhoneNumber)) { 457 $errors->add('duplicate_phone_error', __('Mobile number is already used!', $this->plugin_name)); 458 } 459 460 if (!empty($_REQUEST['otp_code'])) { 461 $otp_code = sanitize_text_field($_REQUEST['otp_code']); 462 463 $email = sanitize_email($user_email); 464 $action = 'Registration'; 465 466 $valid_user = $this->authenticate_otp(trim($otp_code)); 467 468 if ($valid_user) { 469 $this->deletePastData(); 470 471 return $errors; 472 } 473 } 474 // otp validation failed or no otp provided 475 $errors->add('otp_error', __('Invalid OTP entered!', $this->plugin_name)); 476 477 return $errors; 478 } 479 480 /** 481 * Select otp from db and compare 482 * 483 * @param $username 484 * @param $action 485 * @param $otp_code 486 * 487 * @return bool 488 */ 489 public function authenticate_otp($otp_code) 490 { 491 if (!empty($_SESSION['alpha_sms_otp_code']) && !empty($_SESSION['alpha_sms_expires'])) { 492 if (strtotime($_SESSION['alpha_sms_expires']) > strtotime(ALPHA_SMS_TIMESTAMP)) { 493 if ($otp_code === $_SESSION['alpha_sms_otp_code']) { 494 return true; 495 } 496 } 497 } 498 499 return false; 500 } 501 502 /** 503 * delete db data of current ip address user 504 * 505 * @param $user_login 506 * @param $user_email 507 * @param $action 508 */ 509 public function deletePastData() 510 { 511 if (isset($_SESSION['alpha_sms_otp_code'], $_SESSION['alpha_sms_expires'])) { 512 unset($_SESSION['alpha_sms_otp_code'], $_SESSION['alpha_sms_expires']); 513 } 514 } 515 516 /** 517 * Woocommerce validate phone and validate otp 518 * 519 * @param $errors 520 * @param $sanitized_user_login 521 * @param $user_email 522 * 523 * @return mixed 524 */ 525 public function wc_register_form_validation($errors, $sanitized_user_login, $user_email) 526 { 527 if (!$this->pluginActive) { 528 return $errors; 529 } 530 531 if ($this->options['otp_checkout'] || ($this->options['wc_reg'] && $_POST['action_type'] === 'wc_reg')) { 532 $this->register_form_validation($errors, $sanitized_user_login, $user_email); 533 } 534 535 return $errors; 536 } 537 538 /** 539 * Alert customer and admins when a new order is placed 540 * 541 * @param $order_id 542 */ 543 public function wc_new_order_alert($order_id) 544 { 545 if (!$order_id) { 546 return; 547 } 548 549 // option not enabled 550 if (!$this->pluginActive || (!$this->options['order_status_buyer'] && !$this->options['order_status_admin'])) { 551 return; 552 } 553 554 $this->wc_order_status_change_alert($order_id, 'pending', 'pending'); 555 556 557 // send sms to all admins if enabled 558 if ($this->options['order_status_admin']) { 559 $order = new WC_Order($order_id); 560 561 $admin_msg = $this->options['ADMIN_STATUS_SMS']; 562 563 $search = [ 564 '[store_name]', 565 '[billing_first_name]', 566 '[order_id]', 567 '[order_status]', 568 '[order_currency]', 569 '[order_amount]', 570 ]; 571 572 $replace = [ 573 get_bloginfo(), 574 $order->get_billing_first_name(), 575 $order_id, 576 'pending', 577 $order->get_currency(), 578 $order->get_total(), 579 ]; 580 581 $admin_msg = str_replace($search, $replace, $admin_msg); 582 583 // if admin phone is not provided then send to all admins 584 $admin_phones[] = $this->options['admin_phones']; 585 586 if (empty($admin_phones)) { 587 $admin_phones = $this->admin_phones(); 588 } 589 590 if (!empty($admin_phones)) { 591 $numbers = implode(',', $admin_phones); 592 $this->SendSMS($numbers, $admin_msg); 593 } 594 } 595 } 596 597 598 /** 599 * Alert customer and user when order status changes 600 * 601 * @param $order_id 602 * @param $old_status 603 * @param $new_status 604 */ 605 public function wc_order_status_change_alert($order_id, $old_status, $new_status) 606 { 607 if (!$order_id) { 608 return; 609 } 610 611 // option not enabled 612 if ( 613 !$this->pluginActive || (!$this->options['order_status_buyer'] && !$this->options['order_status_admin']) 614 ) { 615 return; 616 } 617 618 $order = new WC_Order($order_id); 619 620 // Get the Customer billing phone 621 $billing_phone = $order->get_billing_phone(); 622 623 //we will send sms 624 625 $buyer_msg = $this->options['BUYER_STATUS_SMS']; 626 627 $search = [ 628 '[store_name]', 629 '[billing_first_name]', 630 '[order_id]', 631 '[order_status]', 632 '[order_currency]', 633 '[order_amount]', 634 ]; 635 636 $replace = [ 637 get_bloginfo(), 638 $order->get_billing_first_name(), 639 $order_id, 640 $new_status, 641 $order->get_currency(), 642 $order->get_total(), 643 ]; 644 645 $buyer_msg = str_replace($search, $replace, $buyer_msg); 646 647 // if buyer notification is enabled, 648 if ($this->options['order_status_buyer']) { 649 $response = $this->SendSMS($billing_phone, $buyer_msg); 650 651 if ($response->error === 0) { 652 $order->add_order_note(__('SMS Send to buyer Successfully.', $this->plugin_name)); 653 } else { 654 $order->add_order_note(__('Could not send sms to buyer', $this->plugin_name)); 655 } 656 } 657 } 658 659 /** 660 * Get all the phone number associated with administration role 661 * 662 * @return array 663 */ 664 public function admin_phones() 665 { 666 $admin_ids = get_users(['fields' => 'ID', 'role' => 'administrator']); 667 $numbers = []; 668 foreach ($admin_ids as $userid) { 669 $number = $this->validateNumber(get_user_meta($userid, 'mobile_phone', true)); 670 if ($number) { 671 $numbers[] = $number; 672 } 673 } 674 675 return $numbers; 676 } 677 678 /** 679 * WordPress login with Phone Number methods 680 * 681 */ 682 683 public function login_enqueue_style() 684 { 685 if ($this->options['wp_login'] || $this->options['wp_reg']) { 686 wp_enqueue_style( 687 $this->plugin_name, 688 plugin_dir_url(__FILE__) . 'css/otp-login-form.css', 689 [], 690 $this->version, 691 'all' 692 ); 693 } 694 } 695 696 public function login_enqueue_script() 697 { 698 if (!$this->pluginActive) { 699 return; 700 } 701 702 if ($this->options['wp_login'] || $this->options['wp_reg']) { 703 wp_enqueue_script( 704 $this->plugin_name, 705 plugin_dir_url(__FILE__) . 'js/otp-login-form.js', 706 ['jquery'], 707 $this->version, 708 false 709 ); 710 wp_localize_script( 711 $this->plugin_name, 712 $this->plugin_name . '_object', 713 ['ajaxurl' => admin_url('admin-ajax.php')] 714 ); 715 } 716 } 717 718 /** 719 * Add OTP view in Wp login form 720 * 721 */ 722 public function add_otp_field_in_wp_login_form() 723 { 724 if (!$this->pluginActive || !$this->options['wp_login']) { 725 return; 726 } 727 728 require_once('partials/add-otp-on-login-form.php'); 729 ?> 730 <input type='hidden' name='action_type' id='action_type' value='wp_login' /> 731 <?php 732 } 733 734 /** 735 * Add OTP view in Wc login form 736 * 737 */ 738 public function add_otp_field_in_wc_login_form() 739 { 740 if (!$this->pluginActive || !$this->options['wc_login']) { 741 return; 742 } 743 require_once('partials/add-otp-on-login-form.php'); 744 ?> 745 <input type='hidden' name='action_type' id='action_type' value='wc_login' /> 746 <?php 747 } 748 749 750 /** 751 * Verify number and send otp 752 * 753 */ 754 public function save_and_send_otp_login() 755 { 756 // First check the nonce, if it fails the function will break 757 check_ajax_referer('ajax-login-nonce', $this->plugin_name); 758 759 //Nonce is checked, get the POST data and sign user on 760 $info = []; 761 $info['user_login'] = sanitize_text_field($_POST['log']); 762 $info['user_password'] = sanitize_text_field($_POST['pwd']); 763 $info['remember'] = sanitize_text_field($_POST['rememberme']); 764 765 $userdata = get_user_by('login', $info['user_login']); 766 767 if (!$userdata) { 768 $userdata = get_user_by('email', $info['user_login']); 769 } 770 // wp_authenticate() 771 $user_id = $userdata->data->ID; 772 773 $result = wp_check_password($info['user_password'], $userdata->data->user_pass, $user_id); 774 775 if (!$user_id || !$result) { 776 $response = ['status' => 401, 'message' => __('Wrong username or password!')]; 777 echo wp_kses_post(json_encode($response)); 778 wp_die(); 779 exit; 780 } 781 782 $user_phone = get_user_meta($user_id, 'mobile_phone', true); 783 784 if (!$user_phone) { 785 $user_phone = get_user_meta($user_id, 'billing_phone', true); 786 } 787 788 // if user phone number is not valid then login without verification 789 if (!$user_phone || !$this->validateNumber($user_phone)) { 790 $response = ['status' => 402, 'message' => __('No phone number found')]; 791 echo wp_kses_post(json_encode($response)); 792 wp_die(); 793 exit; 794 } 795 796 //we will send sms 797 $otp_code = $this->generateOTP(); 798 799 $number = $user_phone; 800 $body = 'Your one time password for '.get_bloginfo().' login is '. $otp_code . ' . Only valid for 2 min.'; 801 802 $sms_response = $this->SendSMS($number, $body); 803 804 if ($sms_response->error === 0) { 805 // save info in database for later verification 806 $log_info = $this->log_login_register_action($user_phone, $otp_code); 807 808 if ($log_info) { 809 $response = ['status' => 200, 'message' => 'Please enter the verification code sent to your phone.']; 810 } else { 811 $response = ['status' => 500, 'message' => 'Something went wrong. Please try again.']; 812 } 813 814 echo wp_kses_post(json_encode($response)); 815 exit; 816 } 817 818 $response = ['status' => '400', 'message' => 'Error sending Otp Code. Please contact administrator.']; 819 echo wp_kses_post(json_encode($response)); 820 wp_die(); 821 exit; 822 } 823 824 /** 825 * Login the user verifying otp code 826 * 827 * @param $user 828 * @param $username 829 * 830 * @return User|WP_Error 831 */ 832 public function login_user($user, $username) 833 { 834 if (empty($user->data)) { 835 return $user; 836 } 837 if (!$this->pluginActive || (!$this->options['wp_login'] && !$this->options['wc_login'])) { 838 return $user; 839 } 840 841 if (empty($_POST['action_type'])) { 842 $error = new WP_Error(); 843 844 $error->add( 845 'empty_password', 846 __('<strong>Error</strong>: Authentication Error!', $this->plugin_name) 847 ); 848 } 849 850 if (($this->options['wp_login'] && $_POST['action_type'] == 'wp_login') || 851 ($this->options['wc_login'] && $_POST['action_type'] == 'wc_login') 852 ) { 853 return $this->startOTPChallenge($user, $username); 854 } 855 856 return $user; 857 } 858 859 /** 860 * @param $user 861 * @param $username 862 * 863 * @return mixed|WP_Error 864 */ 865 public function startOTPChallenge($user, $username) 866 { 867 $user_phone = get_user_meta($user->data->ID, 'mobile_phone', true); 868 869 if (!$user_phone) { 870 $user_phone = get_user_meta($user->data->ID, 'billing_phone', true); 871 } 872 873 if (!$user_phone || !$this->validateNumber($user_phone)) { 874 return $user; 875 } 876 877 if (empty($_REQUEST['otp_code'])) { 878 $error = new WP_Error(); 879 880 $error->add( 881 'empty_password', 882 __('<strong>Error</strong>: Wrong OTP Code!', $this->plugin_name) 883 ); 884 885 return $error; 886 } 887 888 $otp_code = sanitize_text_field($_REQUEST['otp_code']); 889 890 $valid_user = $this->authenticate_otp($otp_code); 891 892 if ($valid_user) { 893 $this->deletePastData(); 894 895 return $user; 896 } 897 898 return new WP_Error( 899 'invalid_password', 900 __('OTP is not valid', $this->plugin_name) 901 ); 902 } 903 904 /** 905 * Woocommerce otp form in checkout 906 */ 907 public function otp_form_at_checkout() 908 { 909 if (!$this->pluginActive || !$this->options['otp_checkout']) { 910 return; 911 } 912 913 if (!is_user_logged_in() && get_option('woocommerce_enable_signup_and_login_from_checkout')) { 914 require_once('partials/add-otp-checkout-form.php'); 915 ?> 916 <input type='hidden' name='action_type' id='action_type' value='wc_checkout' /> 917 <?php 918 } 919 } 379 <?php 380 } 381 382 /** 383 * WordPress validate phone and validate otp 384 * 385 * @param $errors 386 * @param $sanitized_user_login 387 * @param $user_email 388 * 389 * @return mixed 390 */ 391 public function wp_register_form_validation( $errors, $sanitized_user_login, $user_email ) { 392 if ( 393 $this->pluginActive && $this->options['wp_reg'] && ! empty( $_POST['action_type'] ) && 394 $_POST['action_type'] === 'wp_reg' 395 ) { 396 $this->register_form_validation( $errors, $sanitized_user_login, $user_email ); 397 } 398 399 return $errors; 400 } 401 402 /** 403 * Register Form Validation 404 * 405 * @param $errors 406 * @param $sanitized_user_login 407 * @param $user_email 408 * 409 * @return mixed 410 */ 411 public function register_form_validation( $errors, $sanitized_user_login, $user_email ) { 412 413 $enable_guest_checkout = get_option( 'woocommerce_enable_guest_checkout' ); 414 $enable_guest_checkout = $enable_guest_checkout === 'yes' ? true : false; 415 416 if($enable_guest_checkout){ 417 return $errors; 418 } 419 420 if ( 421 empty( $_REQUEST['billing_phone'] ) || ! is_numeric( $_REQUEST['billing_phone'] ) || 422 ! $this->validateNumber( sanitize_text_field( $_REQUEST['billing_phone'] ) ) 423 ) { 424 $errors->add( 'phone_error', __( 'You phone number is not valid.', $this->plugin_name ) ); 425 } 426 427 $billing_phone = $this->validateNumber( sanitize_text_field( $_REQUEST['billing_phone'] ) ); 428 429 $hasPhoneNumber = get_users( 'meta_value=' . $billing_phone ); 430 431 if ( ! empty( $hasPhoneNumber ) ) { 432 $errors->add( 'duplicate_phone_error', __( 'Mobile number is already used!', $this->plugin_name ) ); 433 } 434 435 if ( ! empty( $_REQUEST['otp_code'] ) ) { 436 $otp_code = sanitize_text_field( $_REQUEST['otp_code'] ); 437 438 $valid_user = $this->authenticate_otp( trim( $otp_code ) ); 439 440 if ( $valid_user ) { 441 $this->deletePastData(); 442 443 return $errors; 444 } 445 } 446 447 448 // otp validation failed or no otp provided 449 $errors->add( 'otp_error', __( 'Invalid OTP entered!', $this->plugin_name ) ); 450 451 return $errors; 452 } 453 454 /** 455 * Validate guest checkout otp 456 * 457 * @param $errors 458 * @param $sanitized_user_login 459 * @param $user_email 460 * 461 * @return mixed 462 */ 463 public function validate_guest_checkout_otp(){ 464 465 $enable_guest_checkout = get_option( 'woocommerce_enable_guest_checkout' ); 466 $enable_guest_checkout = $enable_guest_checkout === 'yes' ? true : false; 467 468 if(!$enable_guest_checkout){ 469 return; 470 } 471 472 if ( ! empty( $_REQUEST['otp_code'] ) ) { 473 $otp_code = sanitize_text_field( $_REQUEST['otp_code'] ); 474 475 $valid_user = $this->authenticate_otp( trim( $otp_code ) ); 476 477 if ( $valid_user ) { 478 $this->deletePastData(); 479 } else { 480 wc_add_notice( __( 'Please enter a valid OTP.', 'woocommerce' ), 'error' ); 481 } 482 } else { 483 wc_add_notice( __( 'Please enter a valid OTP.', 'woocommerce' ), 'error' ); 484 } 485 486 } 487 488 /** 489 * Select otp from db and compare 490 * 491 * @param $otp_code 492 * 493 * @return bool 494 */ 495 public function authenticate_otp( $otp_code ) { 496 497 498 if ( ! empty( $_SESSION['alpha_sms_otp_code'] ) && ! empty( $_SESSION['alpha_sms_expires'] ) ) { 499 500 if ( strtotime( $_SESSION['alpha_sms_expires'] ) > strtotime( ALPHA_SMS_TIMESTAMP ) ) { 501 if ( $otp_code === $_SESSION['alpha_sms_otp_code'] ) { 502 return true; 503 } 504 } 505 506 } 507 508 return false; 509 } 510 511 /** 512 * delete db data of current ip address user 513 * 514 */ 515 public function deletePastData() { 516 if ( isset( $_SESSION['alpha_sms_otp_code'], $_SESSION['alpha_sms_expires'] ) ) { 517 unset( $_SESSION['alpha_sms_otp_code'], $_SESSION['alpha_sms_expires'] ); 518 } 519 } 520 521 /** 522 * Woocommerce validate phone and validate otp 523 * 524 * @param $errors 525 * @param $sanitized_user_login 526 * @param $user_email 527 * 528 * @return mixed 529 */ 530 public function wc_register_form_validation( $errors, $sanitized_user_login, $user_email ) { 531 if ( ! $this->pluginActive ) { 532 return $errors; 533 } 534 535 if ( $this->options['otp_checkout'] || ( $this->options['wc_reg'] && $_POST['action_type'] === 'wc_reg' ) ) { 536 $this->register_form_validation( $errors, $sanitized_user_login, $user_email ); 537 } 538 539 return $errors; 540 } 541 542 /** 543 * Alert customer and admins when a new order is placed 544 * 545 * @param $order_id 546 */ 547 public function wc_new_order_alert( $order_id ) { 548 if ( ! $order_id ) { 549 return; 550 } 551 552 // option not enabled 553 if ( ! $this->pluginActive || ! isset( $this->options['order_status_admin'] ) || ! $this->options['order_status_admin'] ) { 554 return; 555 } 556 557 // $this->wc_order_status_change_alert($order_id, 'pending', 'pending'); 558 559 // send sms to all admins if enabled 560 $order = new WC_Order( $order_id ); 561 562 $admin_msg = $this->options['ADMIN_STATUS_SMS']; 563 564 $search = [ 565 '[store_name]', 566 '[billing_first_name]', 567 '[order_id]', 568 '[order_status]', 569 '[order_currency]', 570 '[order_amount]', 571 ]; 572 573 $replace = [ 574 get_bloginfo(), 575 $order->get_billing_first_name(), 576 $order_id, 577 'pending', 578 $order->get_currency(), 579 $order->get_total(), 580 ]; 581 582 $admin_msg = str_replace( $search, $replace, $admin_msg ); 583 584 // if admin phone is not provided then send to all admins 585 $admin_phones[] = $this->options['admin_phones']; 586 587 if ( empty( $admin_phones ) ) { 588 $admin_phones = $this->admin_phones(); 589 } 590 591 if ( ! empty( $admin_phones ) ) { 592 $numbers = implode( ',', $admin_phones ); 593 $this->SendSMS( $numbers, $admin_msg ); 594 } 595 596 } 597 598 /** 599 * Alert customer and user when order status changes 600 * 601 * @param $order_id 602 * @param $old_status 603 * @param $new_status 604 */ 605 606 public function wc_order_status_change_alert( $order_id, $old_status, $new_status ) { 607 if ( ! $order_id ) { 608 return; 609 } 610 611 $order = new WC_Order( $order_id ); 612 613 // Get the Customer billing phone 614 $billing_phone = $order->get_billing_phone(); 615 616 //we will send sms 617 $status = str_replace( '-', '_', $order->data['status'] ); 618 619 // option not enabled 620 if ( 621 ! $this->pluginActive || ! isset( $this->options[ 'order_status_' . $status ] ) || ! $this->options[ 'order_status_' . $status ] 622 ) { 623 return; 624 } 625 626 $buyer_msg = ! empty( $this->options[ 'ORDER_STATUS_' . strtoupper( $status ) . '_SMS' ] ) ? $this->options[ 'ORDER_STATUS_' . strtoupper( $status ) . '_SMS' ] : NULL; 627 628 $search = [ 629 '[store_name]', 630 '[billing_first_name]', 631 '[order_id]', 632 '[order_status]', 633 '[order_currency]', 634 '[order_amount]', 635 ]; 636 637 $replace = [ 638 get_bloginfo(), 639 $order->get_billing_first_name(), 640 $order_id, 641 $new_status, 642 $order->get_currency(), 643 $order->get_total(), 644 ]; 645 646 $buyer_msg = str_replace( $search, $replace, $buyer_msg ); 647 648 if ( empty( $buyer_msg ) ) { 649 $order->add_order_note( __( $this->plugin_name . ': Order message not found.', $this->plugin_name ) ); 650 651 return; 652 } 653 654 $response = $this->SendSMS( $billing_phone, $buyer_msg ); 655 656 if ( $response->error === 0 ) { 657 658 $order->add_order_note( __( 'Alpha SMS : Notified customer about his order ' . $order->data['status'] . ' status', $this->plugin_name ) ); 659 } else { 660 $order->add_order_note( __( 'Alpha SMS : ' . $response->msg, $this->plugin_name ) ); 661 } 662 663 } 664 665 /** 666 * Get all the phone number associated with administration role 667 * 668 * @return array 669 */ 670 public function admin_phones() { 671 $admin_ids = get_users( [ 'fields' => 'ID', 'role' => 'administrator' ] ); 672 $numbers = []; 673 foreach ( $admin_ids as $userid ) { 674 $number = $this->validateNumber( get_user_meta( $userid, 'mobile_phone', true ) ); 675 if ( $number ) { 676 $numbers[] = $number; 677 } 678 } 679 680 return $numbers; 681 } 682 683 /** 684 * WordPress login with Phone Number methods 685 * 686 */ 687 688 public function login_enqueue_style() { 689 if ( $this->options['wp_login'] || $this->options['wp_reg'] ) { 690 wp_enqueue_style( 691 $this->plugin_name, 692 plugin_dir_url( __FILE__ ) . 'css/otp-login-form.css', 693 [], 694 $this->version, 695 'all' 696 ); 697 } 698 } 699 700 public function login_enqueue_script() { 701 if ( ! $this->pluginActive ) { 702 return; 703 } 704 705 if ( $this->options['wp_login'] || $this->options['wp_reg'] ) { 706 wp_enqueue_script( 707 $this->plugin_name, 708 plugin_dir_url( __FILE__ ) . 'js/otp-login-form.js', 709 [ 'jquery' ], 710 $this->version, 711 false 712 ); 713 wp_localize_script( 714 $this->plugin_name, 715 $this->plugin_name . '_object', 716 [ 'ajaxurl' => admin_url( 'admin-ajax.php' ) ] 717 ); 718 } 719 } 720 721 /** 722 * Add OTP view in Wp login form 723 * 724 */ 725 public function add_otp_field_in_wp_login_form() { 726 if ( ! $this->pluginActive || ! $this->options['wp_login'] ) { 727 return; 728 } 729 730 require_once 'partials/add-otp-on-login-form.php'; 731 ?> 732 <input type='hidden' name='action_type' id='action_type' value='wp_login'/> 733 <?php 734 } 735 736 /** 737 * Add OTP view in Wc login form 738 * 739 */ 740 public function add_otp_field_in_wc_login_form() { 741 if ( ! $this->pluginActive || ! $this->options['wc_login'] ) { 742 return; 743 } 744 require_once 'partials/add-otp-on-login-form.php'; 745 ?> 746 <input type='hidden' name='action_type' id='action_type' value='wc_login'/> 747 <?php 748 } 749 750 /** 751 * Verify number and send otp 752 * 753 */ 754 public function save_and_send_otp_login() { 755 // First check the nonce, if it fails the function will break 756 check_ajax_referer( 'ajax-login-nonce', $this->plugin_name ); 757 758 //Nonce is checked, get the POST data and sign user on 759 $info = []; 760 $info['user_login'] = sanitize_text_field( $_POST['log'] ); 761 $info['user_password'] = sanitize_text_field( $_POST['pwd'] ); 762 $info['remember'] = sanitize_text_field( $_POST['rememberme'] ); 763 764 $userdata = get_user_by( 'login', $info['user_login'] ); 765 766 if ( ! $userdata ) { 767 $userdata = get_user_by( 'email', $info['user_login'] ); 768 } 769 // wp_authenticate() 770 $user_id = $userdata->data->ID; 771 772 $result = wp_check_password( $info['user_password'], $userdata->data->user_pass, $user_id ); 773 774 if ( ! $user_id || ! $result ) { 775 $response = [ 'status' => 401, 'message' => __( 'Wrong username or password!' ) ]; 776 echo wp_kses_post( json_encode( $response ) ); 777 wp_die(); 778 exit; 779 } 780 781 $user_phone = get_user_meta( $user_id, 'mobile_phone', true ); 782 783 if ( ! $user_phone ) { 784 $user_phone = get_user_meta( $user_id, 'billing_phone', true ); 785 } 786 787 // if user phone number is not valid then login without verification 788 if ( ! $user_phone || ! $this->validateNumber( $user_phone ) ) { 789 $response = [ 'status' => 402, 'message' => __( 'No phone number found' ) ]; 790 echo wp_kses_post( json_encode( $response ) ); 791 wp_die(); 792 exit; 793 } 794 795 //we will send sms 796 $otp_code = $this->generateOTP(); 797 798 $number = $user_phone; 799 $body = 'Your one time password for ' . get_bloginfo() . ' login is ' . $otp_code . ' . Only valid for 2 min.'; 800 801 $sms_response = $this->SendSMS( $number, $body ); 802 803 if ( $sms_response->error === 0 ) { 804 // save info in database for later verification 805 $log_info = $this->log_login_register_action( $user_phone, $otp_code ); 806 807 if ( $log_info ) { 808 $response = [ 'status' => 200, 'message' => 'Please enter the verification code sent to your phone.' ]; 809 } else { 810 $response = [ 'status' => 500, 'message' => 'Something went wrong. Please try again.' ]; 811 } 812 813 echo wp_kses_post( json_encode( $response ) ); 814 exit; 815 } 816 817 $response = [ 'status' => '400', 'message' => 'Error sending Otp Code. Please contact administrator.' ]; 818 echo wp_kses_post( json_encode( $response ) ); 819 wp_die(); 820 exit; 821 } 822 823 /** 824 * Login the user verifying otp code 825 * 826 * @param $user 827 * @param $username 828 * 829 * @return User|WP_Error 830 */ 831 public function login_user( $user, $username ) { 832 if ( empty( $user->data ) ) { 833 return $user; 834 } 835 if ( ! $this->pluginActive || ( ! $this->options['wp_login'] && ! $this->options['wc_login'] ) ) { 836 return $user; 837 } 838 839 if ( empty( $_POST['action_type'] ) ) { 840 $error = new WP_Error(); 841 842 $error->add( 843 'empty_password', 844 __( '<strong>Error</strong>: Authentication Error!', $this->plugin_name ) 845 ); 846 } 847 848 if ( ( $this->options['wp_login'] && $_POST['action_type'] == 'wp_login' ) || 849 ( $this->options['wc_login'] && $_POST['action_type'] == 'wc_login' ) 850 ) { 851 return $this->startOTPChallenge( $user, $username ); 852 } 853 854 return $user; 855 } 856 857 /** 858 * @param $user 859 * @param $username 860 * 861 * @return mixed|WP_Error 862 */ 863 public function startOTPChallenge( $user, $username ) { 864 $user_phone = get_user_meta( $user->data->ID, 'mobile_phone', true ); 865 866 if ( ! $user_phone ) { 867 $user_phone = get_user_meta( $user->data->ID, 'billing_phone', true ); 868 } 869 870 if ( ! $user_phone || ! $this->validateNumber( $user_phone ) ) { 871 return $user; 872 } 873 874 if ( empty( $_REQUEST['otp_code'] ) ) { 875 $error = new WP_Error(); 876 877 $error->add( 878 'empty_password', 879 __( '<strong>Error</strong>: Wrong OTP Code!', $this->plugin_name ) 880 ); 881 882 return $error; 883 } 884 885 $otp_code = sanitize_text_field( $_REQUEST['otp_code'] ); 886 887 $valid_user = $this->authenticate_otp( $otp_code ); 888 889 if ( $valid_user ) { 890 $this->deletePastData(); 891 892 return $user; 893 } 894 895 return new WP_Error( 896 'invalid_password', 897 __( 'OTP is not valid', $this->plugin_name ) 898 ); 899 } 900 901 /** 902 * Woocommerce otp form in checkout 903 */ 904 public function otp_form_at_checkout() { 905 if ( ! $this->pluginActive || ! $this->options['otp_checkout'] ) { 906 return; 907 } 908 909 if ( ! is_user_logged_in()) { 910 require_once 'partials/add-otp-checkout-form.php'; 911 ?> 912 <input type='hidden' name='action_type' id='action_type' value='wc_checkout'/> 913 <?php 914 } 915 } 916 917 /** 918 * Check if entered api key is valid or not 919 * 920 * @return bool 921 */ 922 private function checkAPI( $api_key ) { 923 require_once ALPHA_SMS_PATH . 'includes/sms.class.php'; 924 925 $smsPortal = new AlphaSMS( $api_key ); 926 927 $response = $smsPortal->getBalance(); 928 929 return $response && $response->error === 0; 930 } 920 931 }
Note: See TracChangeset
for help on using the changeset viewer.