Changeset 3248145
- Timestamp:
- 02/28/2025 12:30:46 AM (13 months ago)
- Location:
- cod24-shipping
- Files:
-
- 22 added
- 1 deleted
- 3 edited
-
tags/3.4.5/readme.txt (deleted)
-
tags/3.4.6 (added)
-
tags/3.4.6/assets (added)
-
tags/3.4.6/assets/css (added)
-
tags/3.4.6/assets/css/cod24-woo-admin.css (added)
-
tags/3.4.6/assets/css/sweetalert2.css (added)
-
tags/3.4.6/assets/index.php (added)
-
tags/3.4.6/assets/js (added)
-
tags/3.4.6/assets/js/city-select.js (added)
-
tags/3.4.6/assets/js/cod24-shcod-fee.js (added)
-
tags/3.4.6/assets/js/cod24-woo-admin.js (added)
-
tags/3.4.6/assets/js/sweetalert2.js (added)
-
tags/3.4.6/cod24-shipping.php (added)
-
tags/3.4.6/inc (added)
-
tags/3.4.6/inc/class-cod24-api.php (added)
-
tags/3.4.6/inc/class-cod24-pishtaz.php (added)
-
tags/3.4.6/inc/class-cod24-settings.php (added)
-
tags/3.4.6/inc/class-cod24-shcod.php (added)
-
tags/3.4.6/inc/class-cod24-special.php (added)
-
tags/3.4.6/inc/class-cod24-woo.php (added)
-
tags/3.4.6/inc/index.php (added)
-
tags/3.4.6/index.php (added)
-
tags/3.4.6/readme.txt (added)
-
trunk/cod24-shipping.php (modified) (2 diffs)
-
trunk/inc/class-cod24-api.php (modified) (13 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cod24-shipping/trunk/cod24-shipping.php
r3246260 r3248145 3 3 Plugin Name: COD24 Shipping For Woocommerce 4 4 Description: This plugin is adding COD24 shipping methods to woocommerce. 5 Version: 3.4. 55 Version: 3.4.6 6 6 Author: COD24 7 7 Author URI: https://cod24.ir … … 27 27 public function __construct() 28 28 { 29 define('COD24_PLUGIN_VERSION', '3.4. 5');29 define('COD24_PLUGIN_VERSION', '3.4.6'); 30 30 define('COD24_PLUGIN_DIR', plugin_dir_path(__FILE__)); 31 31 define('COD24_PLUGIN_URL', plugin_dir_url(__FILE__)); -
cod24-shipping/trunk/inc/class-cod24-api.php
r3246260 r3248145 6 6 * Package: COD24 Shipping 7 7 * Author: COD24 8 * Last Modified Time: 202 4/09/16 22:53:318 * Last Modified Time: 2025/02/28 03:40:53 9 9 * License: GPL-2.0+ 10 10 * License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 31 31 32 32 /** 33 * Admin bar wallet balance 34 * 35 * @param admin_bar 36 * @return void 37 */ 38 public function admin_bar_wallet_balance( $admin_bar ) 39 { 40 if( current_user_can('manage_options') ) 41 { 42 global $pagenow; 43 $cod24_token = get_option('cod24_shipping_token'); 44 45 if( ! empty( $cod24_token ) ) 46 { 47 // send to api 48 $api_protocol = ( get_option('cod24_shipping_api_secure_connection_enabled')=='yes' ) ? 'https://' : 'http://'; 49 $url = $api_protocol.'api.cod24.ir/api/Wallet/getWalletAmount'; 50 $body = []; 51 $body = wp_json_encode( $body ); 33 * Admin bar wallet balance 34 * 35 * @param WP_Admin_Bar $admin_bar 36 * @return void 37 */ 38 public function admin_bar_wallet_balance( $admin_bar ) 39 { 40 if ( current_user_can('manage_options') ) 41 { 42 global $pagenow; 43 $cod24_token = get_option('cod24_shipping_token'); 44 45 if ( ! empty( $cod24_token ) ) 46 { 47 // Check if cached data exists 48 $cache_key = 'cod24_wallet_amount'; 49 $cached_wallet_amount = get_transient( $cache_key ); 52 50 53 // api arguments 54 $args = array( 55 'method' => 'POST', 56 'timeout' => 500, 57 'sslverify' => false, 58 'headers' => array( 59 'Authorization' => 'Bearer '.$cod24_token, 60 'Content-Type' => 'application/json', 61 ), 62 'body' => $body, 63 ); 51 if ( false === $cached_wallet_amount ) 52 { 53 // Cache is empty or expired, fetch data from API 54 $api_protocol = ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? 'https://' : 'http://'; 55 $url = $api_protocol . 'api.cod24.ir/api/Wallet/getWalletAmount'; 56 $body = []; 57 $body = wp_json_encode( $body ); 64 58 65 $request = wp_remote_post( $url, $args ); 59 // API arguments 60 $args = array( 61 'method' => 'POST', 62 'timeout' => 500, 63 'sslverify' => ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? true : false, 64 'headers' => array( 65 'Authorization' => 'Bearer ' . $cod24_token, 66 'Content-Type' => 'application/json', 67 ), 68 'body' => $body, 69 ); 66 70 67 if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) != 200 ) 68 { 69 $result['code'] = wp_remote_retrieve_response_code( $request ); 70 if( $result['code'] == 401 ) 71 { 72 self::get_token(); 73 } 74 } 75 else 76 { 77 $response = wp_remote_retrieve_body( $request ); 78 $result = json_decode( $response, true ); 79 $cod24_wallet_amount = number_format( $result['walletAmount'], 0 ) ." ".get_woocommerce_currency_symbol(); 80 // Translators: %s is the amount in the COD24 wallet. 81 $admin_bar->add_menu( array( 'id' => 'cod24_wallet_amount' , 'title' => sprintf( esc_attr__('COD24 Wallet Amount: %s', 'cod24-shipping' ), $cod24_wallet_amount ) ) ); 82 } 83 } 84 } 85 } 71 $request = wp_remote_post( $url, $args ); 72 73 if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) != 200 ) 74 { 75 $result['code'] = wp_remote_retrieve_response_code( $request ); 76 if ( $result['code'] == 401 ) 77 { 78 self::get_token(); 79 } 80 } 81 else 82 { 83 $response = wp_remote_retrieve_body( $request ); 84 $result = json_decode( $response, true ); 85 $cod24_wallet_amount = number_format( $result['walletAmount'], 0 ) . " " . get_woocommerce_currency_symbol(); 86 87 // Cache the result for 2 minutes 88 set_transient( $cache_key, $cod24_wallet_amount, 2 * MINUTE_IN_SECONDS ); 89 90 // Translators: %s is the amount in the COD24 wallet. 91 $admin_bar->add_menu( array( 'id' => 'cod24_wallet_amount', 'title' => sprintf( esc_attr__('COD24 Wallet Amount: %s', 'cod24-shipping' ), $cod24_wallet_amount ) ) ); 92 } 93 } 94 else 95 { 96 // Use cached data 97 $admin_bar->add_menu( array( 'id' => 'cod24_wallet_amount', 'title' => sprintf( esc_attr__('COD24 Wallet Amount: %s', 'cod24-shipping' ), $cached_wallet_amount ) ) ); 98 } 99 } 100 } 101 } 86 102 87 103 /** … … 110 126 $args = array( 111 127 'method' => 'POST', 112 'sslverify' => false,128 'sslverify' => ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? true : false, 113 129 'headers' => array( 114 130 'Content-Type' => 'application/json', … … 163 179 'method' => 'POST', 164 180 'timeout' => 500, 165 'sslverify' => true,181 'sslverify' => ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? true : false, 166 182 'headers' => array( 167 183 'Authorization' => 'Bearer '.$cod24_token, … … 386 402 'method' => 'POST', 387 403 'timeout' => 500, 388 'sslverify' => true,404 'sslverify' => ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? true : false, 389 405 'headers' => array( 390 406 'Authorization' => 'Bearer '.$cod24_token, … … 465 481 'method' => 'POST', 466 482 'timeout' => 500, 467 'sslverify' => true,483 'sslverify' => ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? true : false, 468 484 'headers' => array( 469 485 'Authorization' => 'Bearer '.$cod24_token, … … 535 551 'method' => 'POST', 536 552 'timeout' => 500, 537 'sslverify' => true,553 'sslverify' => ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? true : false, 538 554 'headers' => array( 539 555 'Authorization' => 'Bearer '.$cod24_token, … … 589 605 'method' => 'POST', 590 606 'timeout' => 500, 591 'sslverify' => true,607 'sslverify' => ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? true : false, 592 608 'headers' => array( 593 609 'Authorization' => 'Bearer '.$cod24_token, … … 643 659 'method' => 'POST', 644 660 'timeout' => 500, 645 'sslverify' => true,661 'sslverify' => ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? true : false, 646 662 'headers' => array( 647 663 'Authorization' => 'Bearer '.$cod24_token, … … 696 712 'method' => 'POST', 697 713 'timeout' => 500, 698 'sslverify' => true,714 'sslverify' => ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? true : false, 699 715 'headers' => array( 700 716 'Authorization' => 'Bearer '.$cod24_token, … … 725 741 'method' => 'POST', 726 742 'timeout' => 500, 727 'sslverify' => true,743 'sslverify' => ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? true : false, 728 744 'headers' => array( 729 745 'Authorization' => esc_attr( $result['token'] ), … … 770 786 'method' => 'POST', 771 787 'timeout' => 500, 772 'sslverify' => true,788 'sslverify' => ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? true : false, 773 789 'headers' => array( 774 790 'Authorization' => 'Bearer '.$cod24_token, … … 799 815 'method' => 'POST', 800 816 'timeout' => 500, 801 'sslverify' => true,817 'sslverify' => ( get_option('cod24_shipping_api_secure_connection_enabled') == 'yes' ) ? true : false, 802 818 'headers' => array( 803 819 'Authorization' => esc_attr( $result['token'] ), -
cod24-shipping/trunk/readme.txt
r3246260 r3248145 4 4 Requires at least: 5.0 5 5 Tested up to: 6.7 6 Stable tag: 3.4. 56 Stable tag: 3.4.6 7 7 License: GPL-2.0+ 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.