Plugin Directory

Changeset 3060497


Ignore:
Timestamp:
03/28/2024 11:57:45 AM (2 years ago)
Author:
hfdepost
Message:

Performance Improvement

Location:
hfd-epost-integration/trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • hfd-epost-integration/trunk/class/Admin.php

    r3059826 r3060497  
    6060        $out = array( "success" => 0, "msg" => __( "Something Went wrong", 'hfd-integration' ) );
    6161        if( !is_admin() ){
    62             echo json_encode( $out );
     62            echo wp_json_encode( $out );
    6363            exit;
    6464        }
    6565       
    66         if( isset( $_POST['orderRef'] ) && !empty( $_POST['orderRef'] ) ){
     66        if( isset( $_POST['orderRef'] ) && !empty( $_POST['orderRef'] ) && wp_verify_nonce( $_POST['_ajax_nonce'], 'cancel_shipment' ) ){
    6767            $orN = sanitize_text_field( $_POST['orderRef'] );
    6868            $orderID = sanitize_text_field( $_POST['orderID'] );
     
    8484                    $out = array( "success" => 0, "msg" => __( "Shipment not tracked", 'hfd-integration' ) );
    8585                }else{
    86                     $api_response_run  = json_encode( $api_response_run );
     86                    $api_response_run  = wp_json_encode( $api_response_run );
    8787                    $api_response_run = json_decode( $api_response_run, true );
    8888                    update_post_meta( $orderID, 'hfd_ship_cancel_response', maybe_serialize( $api_response_run ) );
     
    105105            }
    106106        }
    107         echo json_encode( $out );
     107        echo wp_json_encode( $out );
    108108        exit;
    109109    }
     
    188188                    saveSpotInfoUrl: '<?php echo esc_html( admin_url( "admin-ajax.php" ) ); ?>',
    189189                    getSpotsUrl: '<?php echo esc_html( admin_url( "admin-ajax.php?action=get_spots" ) ); ?>',
    190                     cities: <?php echo json_encode($helper->getCities())?>
     190                    cities: <?php echo wp_json_encode($helper->getCities())?>
    191191                });
    192192            });
     
    275275        wp_enqueue_script( 'epost-translator-script', HFD_EPOST_PLUGIN_URL.'/js/translator.js' );
    276276        wp_enqueue_script( 'epost-admin-scr', HFD_EPOST_PLUGIN_URL.'/js/epost-admin.js' );
     277        //pass data to js file
     278        wp_localize_script( 'epost-admin-scr', 'hfd_admin_obj',
     279            array(
     280                'ajaxurl'   => admin_url( 'admin-ajax.php' ),
     281                'nonce'     => wp_create_nonce( 'cancel_shipment' )
     282            )
     283        );
    277284    }
    278285
  • hfd-epost-integration/trunk/class/App.php

    r3059826 r3060497  
    259259    public function saveCartPickup()
    260260    {
    261         if( isset( $_POST['spot_info'] ) ){
     261        $out = array( "success" => 0, "msg" => __( "Something went wrong", "hfd-integration" ) );
     262        if( isset( $_POST['spot_info'] ) && wp_verify_nonce( $_POST['_ajax_nonce'], 'save_pickup' ) ){
    262263            $spotInfo = array_map( 'sanitize_text_field', $_POST['spot_info'] );
    263264            /* @var \Hfd\Woocommerce\Cart\Pickup $cartPickup */
    264265            $cartPickup = Container::get('Hfd\Woocommerce\Cart\Pickup');
    265266            $cartPickup->saveSpotInfo( $spotInfo );
    266         }
     267           
     268            $out = array( "success" => 1, "msg" => __( "Pickup saved", "hfd-integration" ) );
     269        }else{
     270            $out = array( "success" => 1, "msg" => __( "Incorrect nonce or spot info missing", "hfd-integration" ) );
     271        }
     272        echo wp_json_encode( $out );
     273        exit;
    267274    }
    268275
     
    279286        $spots = $helper->getSpots();
    280287        header('Content-type: application/json');
    281         echo json_encode($spots);
     288        echo wp_json_encode($spots);
    282289        exit;
    283290    }
     
    288295        $spots = $helper->getSpotsByCity($city);
    289296        header('Content-type: application/json');
    290         echo json_encode($spots);
     297        echo wp_json_encode($spots);
    291298        exit;
    292299    }
     
    408415                $response['messages'] = sprintf($message, __('Please choose pickup branch', 'hfd-integration'));
    409416                header('Content-type: application/json');
    410                 echo json_encode($response);
     417                echo wp_json_encode( $response );
    411418                exit;
    412419            }
  • hfd-epost-integration/trunk/class/AutoLoad.php

    r2766592 r3060497  
    3636        $filePath = $this->basePath . DIRECTORY_SEPARATOR . $path .'.php';
    3737
    38         if (!file_exists($filePath)) {
    39             throw new \Exception(__('Invalid class '. $className, 'betanet_epost'));
     38        if( !file_exists( $filePath ) ){
     39            throw new \Exception( sprintf( __( 'Invalid class %s', 'hfd-integration' ), $className ) );
    4040        }
    4141
  • hfd-epost-integration/trunk/class/Cache.php

    r2766592 r3060497  
    6565        }
    6666
    67         $data = json_encode($this->cached);
     67        $data = wp_json_encode($this->cached);
    6868        file_put_contents($cachePath, $data);
    6969
  • hfd-epost-integration/trunk/class/DataObject.php

    r2766592 r3060497  
    231231        }
    232232        throw new \Exception(
    233             __(sprintf('Invalid method %1::%2(%3)'), get_class($this), $method, print_r($args, 1))
     233            sprintf( __( 'Invalid method %1::%2(%3)', 'hfd-integration' ), get_class($this), $method, print_r( $args, 1 ) )
    234234        );
    235235    }
  • hfd-epost-integration/trunk/class/Helper/Hfd/Api.php

    r3059826 r3060497  
    132132            $response = wp_remote_retrieve_body( $response );
    133133            $xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
    134             $arrResponse = json_decode(json_encode($xml), true);
     134            $arrResponse = json_decode(wp_json_encode($xml), true);
    135135
    136136            if ($this->isApiDebug()) {
    137137                $_response = $arrResponse;
    138138                if (is_array($_response)) {
    139                     $_response = json_encode($_response);
     139                    $_response = wp_json_encode($_response);
    140140                }
    141141                $_logInfo = PHP_EOL .'===== Begin =====';
    142                 $_logInfo .= PHP_EOL . '> Request parameters: '. json_encode($pParam);
     142                $_logInfo .= PHP_EOL . '> Request parameters: '. wp_json_encode($pParam);
    143143                $_logInfo .= PHP_EOL .'> Call API: '. $url;
    144144                $_logInfo .= PHP_EOL .'> Response: '. $_response;
  • hfd-epost-integration/trunk/class/Helper/Spot.php

    r3059826 r3060497  
    3838       
    3939        $xml = simplexml_load_string( $response, 'SimpleXMLElement', LIBXML_NOCDATA );
    40         $arrResponse = json_decode(json_encode($xml), true);
     40        $arrResponse = json_decode(wp_json_encode($xml), true);
    4141
    4242        $spots = array();
     
    6969       
    7070        $xml = simplexml_load_string( $response, 'SimpleXMLElement', LIBXML_NOCDATA );
    71         $arrResponse = json_decode( json_encode( $xml ), true );
     71        $arrResponse = json_decode( wp_json_encode( $xml ), true );
    7272
    7373        $spots = array();
  • hfd-epost-integration/trunk/hfd-woocommerce-epost.php

    r3059826 r3060497  
    55Plugin URI:
    66Description: Add shipping method of ePost, allowing the user on the checkout, to select the pickup location point from a google map popup. Also allows to synch the order to HFD API after the order is created.
    7 Version: 1.9
     7Version: 2.0
    88Author: HFD
    99Author URI: https://www.hfd.co.il
     
    1111Text Domain: hfd-integration
    1212*/
     13
     14if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    1315
    1416//return if woocommerce not installed
  • hfd-epost-integration/trunk/js/epost-admin.js

    r2766592 r3060497  
    9999            'action': 'hfd_epost_cancel_shipment',
    100100            'orderRef': orderRef,
     101            '_ajax_nonce': hfd_admin_obj.nonce,
    101102            'orderID': orderID
    102103        };
  • hfd-epost-integration/trunk/js/epost-list.js

    r2884972 r3060497  
    6262            var data = {
    6363              action: 'save_pickup',
     64              _ajax_nonce: hfd_ajax_obj.nonce,
    6465              spot_info: spot
    6566            };
  • hfd-epost-integration/trunk/js/pickup-post.js

    r2889280 r3060497  
    9696        var data = {
    9797            action: 'save_pickup',
     98            _ajax_nonce: hfd_ajax_obj.nonce,
    9899            spot_info: spot
    99100        };
  • hfd-epost-integration/trunk/readme.txt

    r3059826 r3060497  
    55Requires at least: 4.0
    66Tested up to: 6.5
    7 Stable tag: 1.9
     7Stable tag: 2.0
    88Requires PHP: 5.4
    99License: GPLv2 or later
     
    6666לאחר סנכרון מוצלח הלחצן Sync to HFD יהפוך ל- Print Label שמאפשר להדפיס מדבקה
    6767
     68Plugin uses third party Google Maps API to add pickup branch in google map
     69
     70== Privacy Policy ==
     71HFD - https://www.hfd.co.il/privacy-policy/
     72
     73== Third Party API ==
     74Google Maps - maps.googleapis.com
     75HFD - run.hfd.co.il
     76
    6877== Changelog ==
    6978= 1.0 =
    7079* Initial release
    7180
     81= 2.0 =
     82* Performance Improvement
     83* Integrated Latest google maps api
    7284
    7385== Frequently Asked Questions ==
     
    8294Need to choose the Shipping Methods you want in order to synchronize with HFD
    8395
     96= How many HFD pickup branch layout exist in plugin =
     97There are two layout exists
     981. Map( Google Map )
     992. List
     100
    84101== Screenshots ==
    851021. HFD Settings
  • hfd-epost-integration/trunk/templates/admin/notice.php

    r2768357 r3060497  
    11<?php
     2if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
     3
    24/**
    35 * Created by PhpStorm.
  • hfd-epost-integration/trunk/templates/admin/setting.php

    r3011172 r3060497  
    11<?php
     2if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
     3
    24/**
    35 * Created by PhpStorm.
  • hfd-epost-integration/trunk/templates/cart/footer.php

    r3059826 r3060497  
    4343    wp_enqueue_script( 'hfd-checkout-js', $this->getSkinUrl( 'js/checkout.js' ) );
    4444    wp_enqueue_script( 'hfd-translator-js', $this->getSkinUrl( 'js/translator.js' ) );
     45   
     46    //pass data to js file
     47    wp_localize_script( 'hfd-pickup-post', 'hfd_ajax_obj',
     48        array(
     49            'ajaxurl'   => admin_url( 'admin-ajax.php' ),
     50            'nonce'     => wp_create_nonce( 'save_pickup' )
     51        )
     52    );
    4553    ?>
    4654    <script type="text/javascript">
     
    103111    wp_enqueue_script( 'hfd-translator', $this->getSkinUrl( 'js/translator.js' ) );
    104112    wp_enqueue_script( 'hfd-epost-list', $this->getSkinUrl( 'js/epost-list.js' ), array(), time() );
     113    //pass data to js file
     114    wp_localize_script( 'hfd-epost-list', 'hfd_ajax_obj',
     115        array(
     116            'ajaxurl'   => admin_url( 'admin-ajax.php' ),
     117            'nonce'     => wp_create_nonce( 'save_pickup' )
     118        )
     119    );
    105120    ?>
    106121    <script type="text/javascript">
     
    118133                            saveSpotInfoUrl: '<?php echo esc_html( admin_url( 'admin-ajax.php' ) ); ?>',
    119134                            getSpotsUrl: '<?php echo esc_html( admin_url( 'admin-ajax.php?action=get_spots' ) ); ?>',
    120                             cities: <?php echo json_encode( $helper->getCities() ); ?>
     135                            cities: <?php echo wp_json_encode( $helper->getCities() ); ?>
    121136                        });
    122137                        cityLoaded = true;
     
    135150                            saveSpotInfoUrl: '<?php echo esc_html( admin_url( 'admin-ajax.php' ) ); ?>',
    136151                            getSpotsUrl: '<?php echo esc_html( admin_url( 'admin-ajax.php?action=get_spots' ) ); ?>',
    137                             cities: <?php echo json_encode( $helper->getCities() ); ?>
     152                            cities: <?php echo wp_json_encode( $helper->getCities() ); ?>
    138153                        });
    139154                        cityLoaded = true;
  • hfd-epost-integration/trunk/templates/order/pickup.php

    r2768357 r3060497  
    11<?php
     2if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    23/**
    34 * Created by PhpStorm.
Note: See TracChangeset for help on using the changeset viewer.