Changeset 3344313
- Timestamp:
- 08/14/2025 05:46:18 AM (8 months ago)
- Location:
- buildecom/trunk
- Files:
-
- 1 added
- 6 edited
-
buildecom.php (modified) (1 diff)
-
inc/api/class-api-controller.php (modified) (3 diffs)
-
inc/helpers.php (modified) (20 diffs)
-
notify/class-buildecom-notify-email.php (added)
-
notify/class-buildecom-notify.php (modified) (3 diffs)
-
notify/class-buildecom-notifyprocess.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
buildecom/trunk/buildecom.php
r3344056 r3344313 7 7 * Plugin URI: https://buildecom.app/wp-plugin/ 8 8 * Description: The official WordPress plugin for BuildEcom. Build eCommerce mobile application through woocommerce and wordpress 9 * Version: 1.0. 79 * Version: 1.0.8 10 10 * Author: BuildEcom 11 11 * Author URI: https://buildecom.app -
buildecom/trunk/inc/api/class-api-controller.php
r3319894 r3344313 906 906 $user = $this->getUser(); 907 907 908 $user_id = $user ? $user->ID : 0; 909 908 910 if (!$user) { 909 911 return buildecom_response_error('authentication_error', 'User is not authenticated', [], 401); … … 912 914 $params = $request->get_body_params(); 913 915 914 $first_name = sanitize_text_field($params['first_name'] );915 $last_name = sanitize_text_field($params['last_name'] );916 $phone = sanitize_text_field($params['phone'] );917 $address = sanitize_text_field($params['address'] );918 $city = sanitize_text_field($params['city'] );919 $state = sanitize_text_field($params['state'] );920 $postcode = sanitize_text_field($params['postcode'] );921 $country = sanitize_text_field($params['country'] );916 $first_name = sanitize_text_field($params['first_name'] ?? ''); 917 $last_name = sanitize_text_field($params['last_name'] ?? ''); 918 $phone = sanitize_text_field($params['phone'] ?? ''); 919 $address = sanitize_text_field($params['address'] ?? ''); 920 $city = sanitize_text_field($params['city'] ?? ''); 921 $state = sanitize_text_field($params['state'] ?? ''); 922 $postcode = sanitize_text_field($params['postcode'] ?? ''); 923 $country = sanitize_text_field($params['country'] ?? ''); 922 924 923 925 if (empty($first_name) || empty($last_name)) { … … 984 986 return buildecom_response_error('invalid_file_type', 'Only JPG, JPEG, and PNG files are allowed', [], 400); 985 987 } 986 } else { 987 return buildecom_response_error('no_file_uploaded', 'No file was uploaded', [], 400); 988 } 988 } 989 989 990 990 return buildecom_response_success('profile_updated', 'Profile updated successfully'); -
buildecom/trunk/inc/helpers.php
r3316130 r3344313 1 1 <?php 2 2 3 if (!defined('ABSPATH')) exit; 3 if (!defined('ABSPATH')) 4 exit; 4 5 5 6 … … 79 80 function buildecom_generate_password_reset_token() 80 81 { 81 $characters = '0123456789';82 $characters = '0123456789'; 82 83 $randomString = ''; 83 84 … … 86 87 } 87 88 88 return $randomString;89 return $randomString; 89 90 } 90 91 } … … 106 107 { 107 108 $response = [ 108 'status' => 'error',109 'remark' => $remark,110 'message' => ['error' => is_array($message) ? $message : [$message]],109 'status' => 'error', 110 'remark' => $remark, 111 'message' => ['error' => is_array($message) ? $message : [$message]], 111 112 ...$data 112 113 ]; … … 120 121 function buildecom_get_formatted_date($time = false) 121 122 { 122 if (! $time) {123 if (!$time) { 123 124 $time = strtotime('now'); 124 125 } … … 135 136 136 137 137 if (! function_exists('buildecom_wp_timezone')) {138 if (!function_exists('buildecom_wp_timezone')) { 138 139 function buildecom_wp_timezone() 139 140 { … … 143 144 144 145 145 if (! function_exists('buildecom_wp_timezone_string')) {146 if (!function_exists('buildecom_wp_timezone_string')) { 146 147 function buildecom_wp_timezone_string() 147 148 { … … 152 153 } 153 154 154 $offset = (float) get_option('gmt_offset');155 $hours = (int) $offset;155 $offset = (float) get_option('gmt_offset'); 156 $hours = (int) $offset; 156 157 $minutes = ($offset - $hours); 157 158 158 $sign = ($offset < 0) ? '-' : '+';159 $abs_hour = abs($hours);160 $abs_mins = abs($minutes * 60);159 $sign = ($offset < 0) ? '-' : '+'; 160 $abs_hour = abs($hours); 161 $abs_mins = abs($minutes * 60); 161 162 $tz_offset = sprintf('%s%02d:%02d', $sign, $abs_hour, $abs_mins); 162 163 … … 170 171 { 171 172 $response = [ 172 'status' => 'success',173 'remark' => $remark,174 'message' => ['success' => is_array($message) ? $message : [$message]],173 'status' => 'success', 174 'remark' => $remark, 175 'message' => ['success' => is_array($message) ? $message : [$message]], 175 176 ...$data 176 177 ]; … … 195 196 { 196 197 197 $all_roles = wp_roles()->roles;198 $all_roles = wp_roles()->roles; 198 199 $roles_array = array(); 199 200 … … 216 217 function buildecom_get_new_code_expiration_time($valid_seconds = 900) 217 218 { 218 $time_string = '+' . $valid_seconds . ' seconds';219 $time_string = '+' . $valid_seconds . ' seconds'; 219 220 return strtotime($time_string); 220 221 } … … 223 224 function buildecom_send_password_reset_code_email($email = false, $code = false, $expiry = 0) 224 225 { 225 if (! $email) {226 if (!$email) { 226 227 throw new Exception(esc_html__('An email address is required for the reset code email.', 'buildecom')); 227 228 } 228 229 229 if (! $code) {230 if (!$code) { 230 231 throw new Exception(esc_html__('No code was provided for the password reset email.', 'buildecom')); 231 232 } … … 237 238 include $template_path; 238 239 } else { 239 echo esc_html__( 'A password reset was requested for your account. Your code: ', 'buildecom' ) . esc_html( $code);240 echo esc_html__('A password reset was requested for your account. Your code: ', 'buildecom') . esc_html($code); 240 241 } 241 242 … … 246 247 $html_message = apply_filters('buildecom_code_email_text', $html_message, $email, $code, $expiry); 247 248 248 $siteName = get_bloginfo('name');249 $mailFrom = get_option('admin_email');250 $headers = [];249 $siteName = get_bloginfo('name'); 250 $mailFrom = get_option('admin_email'); 251 $headers = []; 251 252 $headers[] = "From: $siteName <$mailFrom>"; 252 253 $headers[] = "Reply-To: $siteName <$mailFrom>"; … … 300 301 301 302 $userInfo = [ 302 'id' => $user->ID,303 'email' => $user->user_email,303 'id' => $user->ID, 304 'email' => $user->user_email, 304 305 'fullname' => $user->display_name, 305 306 'username' => $user->user_login … … 310 311 } 311 312 312 $userInfo = buildecom_to_object($userInfo);313 $shortCodes = array_merge($shortCodes ?? [], $globalShortCodes);314 $notify = new Buildecom_Notify($sendVia);313 $userInfo = buildecom_to_object($userInfo); 314 $shortCodes = array_merge($shortCodes ?? [], $globalShortCodes); 315 $notify = new Buildecom_Notify($sendVia); 315 316 $notify->templateName = $templateName; 316 $notify->shortCodes = $shortCodes;317 $notify->user = $userInfo;318 $notify->createLog = $createLog;317 $notify->shortCodes = $shortCodes; 318 $notify->user = $userInfo; 319 $notify->createLog = $createLog; 319 320 $notify->send(); 320 321 } … … 349 350 { 350 351 $args = [ 351 'method' => 'POST',352 'body' => is_array($postData) ? wp_json_encode($postData) : $postData,353 'headers' => array_merge(['Content-Type' => 'application/json'], $headers),352 'method' => 'POST', 353 'body' => is_array($postData) ? wp_json_encode($postData) : $postData, 354 'headers' => array_merge(['Content-Type' => 'application/json'], $headers), 354 355 'sslverify' => true 355 356 ]; … … 374 375 if ($order) { 375 376 $shortCodesArr = [ 376 'status' => $order->get_status(),377 'currency' => $order->get_currency(),378 'shipping_tax' => $order->get_shipping_tax(),379 'total' => $order->get_total(),380 'total_tax' => $order->get_total_tax(),381 'order_key' => $order->get_order_key(),382 'billing_first_name' => $order->get_billing_first_name(),383 'billing_last_name' => $order->get_billing_last_name(),384 'billing_company' => $order->get_billing_company(),385 'billing_address_1' => $order->get_billing_address_1(),386 'billing_address_2' => $order->get_billing_address_2(),387 'billing_city' => $order->get_billing_city(),388 'billing_state' => $order->get_billing_state(),389 'billing_postcode' => $order->get_billing_postcode(),390 'billing_country' => $order->get_billing_country(),391 'billing_email' => $order->get_billing_email(),392 'billing_phone' => $order->get_billing_phone(),393 'shipping_first_name' => $order->get_shipping_first_name(),394 'shipping_last_name' => $order->get_shipping_last_name(),395 'shipping_company' => $order->get_shipping_company(),396 'shipping_address_1' => $order->get_shipping_address_1(),397 'shipping_address_2' => $order->get_shipping_address_2(),398 'shipping_city' => $order->get_shipping_city(),399 'shipping_state' => $order->get_shipping_state(),400 'shipping_postcode' => $order->get_shipping_postcode(),401 'shipping_country' => $order->get_shipping_country(),402 'shipping_phone' => $order->get_shipping_phone(),403 'payment_method' => $order->get_payment_method(),377 'status' => $order->get_status(), 378 'currency' => $order->get_currency(), 379 'shipping_tax' => $order->get_shipping_tax(), 380 'total' => $order->get_total(), 381 'total_tax' => $order->get_total_tax(), 382 'order_key' => $order->get_order_key(), 383 'billing_first_name' => $order->get_billing_first_name(), 384 'billing_last_name' => $order->get_billing_last_name(), 385 'billing_company' => $order->get_billing_company(), 386 'billing_address_1' => $order->get_billing_address_1(), 387 'billing_address_2' => $order->get_billing_address_2(), 388 'billing_city' => $order->get_billing_city(), 389 'billing_state' => $order->get_billing_state(), 390 'billing_postcode' => $order->get_billing_postcode(), 391 'billing_country' => $order->get_billing_country(), 392 'billing_email' => $order->get_billing_email(), 393 'billing_phone' => $order->get_billing_phone(), 394 'shipping_first_name' => $order->get_shipping_first_name(), 395 'shipping_last_name' => $order->get_shipping_last_name(), 396 'shipping_company' => $order->get_shipping_company(), 397 'shipping_address_1' => $order->get_shipping_address_1(), 398 'shipping_address_2' => $order->get_shipping_address_2(), 399 'shipping_city' => $order->get_shipping_city(), 400 'shipping_state' => $order->get_shipping_state(), 401 'shipping_postcode' => $order->get_shipping_postcode(), 402 'shipping_country' => $order->get_shipping_country(), 403 'shipping_phone' => $order->get_shipping_phone(), 404 'payment_method' => $order->get_payment_method(), 404 405 'payment_method_title' => $order->get_payment_method_title(), 405 'transaction_id' => $order->get_transaction_id(),406 'date_paid' => $order->get_date_paid(),406 'transaction_id' => $order->get_transaction_id(), 407 'date_paid' => $order->get_date_paid(), 407 408 ]; 408 409 } … … 411 412 } 412 413 } 414 413 415 414 416 if (!function_exists('buildecom_wc_order_status_changed')) { … … 422 424 423 425 if ($newStatus === 'pending') { 424 buildecom_notify($user, 'WC_PENDING', $shortCodesArr, [' push']);426 buildecom_notify($user, 'WC_PENDING', $shortCodesArr, ['email']); 425 427 } else if ($newStatus === 'processing') { 426 buildecom_notify($user, 'WC_PROCESSING', $shortCodesArr, [' push']);428 buildecom_notify($user, 'WC_PROCESSING', $shortCodesArr, ['email']); 427 429 } else if ($newStatus === 'shipped') { 428 buildecom_notify($user, 'WC_SHIPPED', $shortCodesArr, [' push']);430 buildecom_notify($user, 'WC_SHIPPED', $shortCodesArr, ['email']); 429 431 } else if ($newStatus === 'on-hold') { 430 buildecom_notify($user, 'WC_ONHOLD', $shortCodesArr, [' push']);432 buildecom_notify($user, 'WC_ONHOLD', $shortCodesArr, ['email']); 431 433 } else if ($newStatus === 'cancelled') { 432 buildecom_notify($user, 'WC_CANCELLED', $shortCodesArr, [' push']);434 buildecom_notify($user, 'WC_CANCELLED', $shortCodesArr, ['email']); 433 435 } else if ($newStatus === 'refunded') { 434 buildecom_notify($user, 'WC_REFUNDED', $shortCodesArr, [' push']);436 buildecom_notify($user, 'WC_REFUNDED', $shortCodesArr, ['email']); 435 437 } else if ($newStatus === 'failed') { 436 buildecom_notify($user, 'WC_FAILED', $shortCodesArr, [' push']);438 buildecom_notify($user, 'WC_FAILED', $shortCodesArr, ['email']); 437 439 } else if ($newStatus === 'completed') { 438 buildecom_notify($user, 'WC_COMPLETED', $shortCodesArr, [' push']);440 buildecom_notify($user, 'WC_COMPLETED', $shortCodesArr, ['email']); 439 441 } else { 440 442 $status = 'WC_' . strtoupper(str_replace('-', '_', $newStatus)); 441 buildecom_notify($user, $status, $shortCodesArr, [' push']);442 } 443 } 444 } 443 buildecom_notify($user, $status, $shortCodesArr, ['email']); 444 } 445 } 446 } -
buildecom/trunk/notify/class-buildecom-notify.php
r3316130 r3344313 1 1 <?php 2 2 3 if (!defined('ABSPATH')) exit; 3 if (!defined('ABSPATH')) 4 exit; 4 5 5 if (!class_exists('Buildecom_Notify_Push')) { 6 require_once __DIR__ . '/class-buildecom-notify-push.php'; 6 if ( ! class_exists( 'Buildecom_Notify_Push' ) ) { 7 require_once plugin_dir_path(__FILE__) . 'class-buildecom-notify-push.php'; 8 } 9 10 if ( ! class_exists( 'Buildecom_Notify_Email' ) ) { 11 require_once plugin_dir_path(__FILE__) . 'class-buildecom-notify-email.php'; 7 12 } 8 13 … … 97 102 //send the notification via methods one by one 98 103 foreach ($methods as $method) { 99 $notify = new $method;104 $notify = new $method; 100 105 $notify->templateName = $this->templateName; 101 $notify->shortCodes = $this->shortCodes;102 $notify->user = $this->user;103 $notify->createLog = $this->createLog;104 $notify->userColumn = $this->userColumn;106 $notify->shortCodes = $this->shortCodes; 107 $notify->user = $this->user; 108 $notify->createLog = $this->createLog; 109 $notify->userColumn = $this->userColumn; 105 110 $notify->send(); 106 111 } … … 116 121 { 117 122 $methods = [ 118 'push' => Buildecom_Notify_Push::class 123 'email' => Buildecom_Notify_Email::class, 124 'push' => Buildecom_Notify_Push::class 119 125 ]; 120 126 if ($sendVia) { -
buildecom/trunk/notify/class-buildecom-notifyprocess.php
r3316130 r3344313 1 1 <?php 2 2 3 if (!defined('ABSPATH')) exit; 3 if (!defined('ABSPATH')) 4 exit; 4 5 5 6 class Buildecom_NotifyProcess … … 145 146 protected function getMessage() 146 147 { 148 global $wpdb; 149 147 150 $this->prevConfiguration(); 148 151 … … 150 153 $user = $this->user; 151 154 $globalTemplate = $this->globalTemplate; 152 //finding the notification template 153 $template = NotificationTemplate::where('act', $this->templateName)->where($this->statusField, 1)->first(); 155 156 //finding the notification template (raw DB query instead of NotificationTemplate model) 157 $table_name = $wpdb->prefix . 'buildecom_notification_templates'; 158 $template = $wpdb->get_row( 159 $wpdb->prepare( 160 "SELECT * FROM {$table_name} WHERE act = %s LIMIT 1", 161 $this->templateName 162 ) 163 ); 154 164 $this->template = $template; 155 165 156 //Getting the notification message from database if use and template exist157 //If not exist, get the message which have sent via method166 //Getting the notification message from database if user and template exist 167 //If not exist, get the message which have been sent via method 158 168 if ($user && $template) { 159 $message = $this->replaceShortCode($user->fullname, $user->username, get_option($globalTemplate), $template->body); 169 $message = $this->replaceShortCode( 170 $user->fullname, 171 $user->username, 172 get_option($globalTemplate), 173 $template->body 174 ); 160 175 if (empty($message)) { 161 176 $message = $template->$body; 162 177 } 163 178 } else { 164 $message = $this->replaceShortCode($this->receiverName, $this->toAddress, get_option($globalTemplate), $this->message); 165 } 166 167 //replace the all short cod of template 179 $message = $this->replaceShortCode( 180 $this->receiverName, 181 $this->toAddress, 182 get_option($globalTemplate), 183 $this->message 184 ); 185 } 186 187 //replace all shortcodes of template 168 188 if ($this->shortCodes) { 169 189 $message = $this->replaceTemplateShortCode($message); … … 171 191 172 192 //Check email enable 173 if (!$this->template && $this->templateName) return false; 193 if (!$this->template && $this->templateName) 194 return false; 174 195 175 196 //set subject to property 176 197 $this->getSubject(); 177 178 198 179 199 $this->finalMessage = html_entity_decode(stripslashes($message)); -
buildecom/trunk/readme.txt
r3344056 r3344313 4 4 Requires at least: 4.7 5 5 Tested up to: 6.8 6 Stable tag: 1.0. 76 Stable tag: 1.0.8 7 7 License: GPL-2.0+ 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.