Plugin Directory

Changeset 3228676


Ignore:
Timestamp:
01/26/2025 08:45:28 AM (14 months ago)
Author:
hfdepost
Message:

Performance Improvement

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

Legend:

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

    r3227946 r3228676  
    6666        add_filter( 'admin_init', array( $this, 'flushRewriteUrls' ) );
    6767       
    68         //render wc_get_orders query
    69         add_filter( 'woocommerce_order_data_store_cpt_get_orders_query', array( $this, 'hfd_handle_order_custom_query_vars' ), 10, 2 );
    70        
    7168        //add wordpress ron for auto sync
    7269        add_filter( 'cron_schedules', array( $this, 'hfdAutoSyncOrderCron' ) );
     
    7875            wp_schedule_event( time(), 'hfd_auto_sync', 'hfd_schedule_auto_sync' );
    7976        }
    80                
     77
     78        //update plugin settings if its not saved
     79        add_action( 'plugins_loaded', array( $this, 'hfdUpdatePluginsOptions' ) );
     80       
    8181        //action for gutenberg
    8282        if( $this->is_block_checkout() && !is_admin() ){
     
    9090        add_action( 'wp_ajax_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData' ) );
    9191        add_action( 'wp_ajax_nopriv_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData' ) );
    92        
    93         //update plugin settings if its not saved
    94         add_action( 'plugins_loaded', array( $this, 'hfdUpdatePluginsOptions' ) );
    95        
    96         //update option on plugin upgrade
    97         add_action( 'upgrader_process_complete', array( $this, 'hfd_run_on_plugin_update' ), 10, 2 );
    98     }
    99    
    100     public function hfd_run_on_plugin_update( $upgrader_object, $options ){
    101         if( $options['action'] == 'update' && $options['type'] == 'plugin' && isset( $options['plugins'] ) ){
    102             // Iterate through the plugins being updated and check if ours is there
    103             if( $options['plugins'] ){
    104                 foreach( $options['plugins'] as $plugin ){
    105                     if( $plugin == HFD_EPOST_PLUGIN_FILE ){
    106                         $this->hfdUpdatePluginsOptions();
    107                     }
    108                 }
    109             }
    110         }
    111     }
    112    
    113     public function hfd_handle_order_custom_query_vars( $query, $query_vars ){
    114         if( isset( $query_vars['hfd_cron'] ) && ! empty( $query_vars['hfd_cron'] ) ){
    115             $query['meta_query'][] = array(
    116                 'key'     => 'hfd_ship_number',
    117                 'compare' => 'NOT EXISTS',
    118             );
    119             $query['meta_query'][] = array(
    120                 'key'     => 'hfd_sync_flag',
    121                 'compare' => 'NOT EXISTS',
    122             );
    123         }
    124        
    125         return $query;
    126     }
     92    }
    12793   
    12894    public function is_block_checkout(){
     
    147113        $hfd_epost_service_url = get_option( 'betanet_epost_service_url' );
    148114        if( strpos( $hfd_epost_service_url, "http://" ) !== false || empty( $hfd_epost_service_url ) ){
    149             update_option( 'betanet_epost_service_url', 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ws_spotslist&ARGUMENTS=-Aall' );
    150         } 
     115            update_option( 'betanet_epost_service_url', 'https://run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ws_spotslist&ARGUMENTS=-Aall' );
     116        }
    151117        if( empty( $track_shipment_url ) ){
    152             update_option( 'betanet_epost_hfd_track_shipment_url', 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_locate_random&ARGUMENTS=-A{RAND}' );
     118            update_option( 'betanet_epost_hfd_track_shipment_url', 'https://run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_locate_random&ARGUMENTS=-A{RAND}' );
    153119        }
    154120        if( empty( $cancel_shipment_url ) ){
    155             update_option( 'betanet_epost_hfd_cancel_shipment_url', 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=bitul_mishloah&ARGUMENTS=-A{shipping_number},-A,-A,-A,-N' );
     121            update_option( 'betanet_epost_hfd_cancel_shipment_url', 'https://run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=bitul_mishloah&ARGUMENTS=-A{shipping_number},-A,-A,-A,-N' );
    156122        }
    157123        if( empty( $print_label_url ) ){
    158             update_option( 'betanet_epost_hfd_print_label_url', 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{RAND}' );
     124            update_option( 'betanet_epost_hfd_print_label_url', 'https://run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{RAND}' );
    159125        }
    160126        if( empty( $hfd_order_auto_sync ) ){
     
    166132       
    167133        //replace old urls to new
    168         if( ( strpos( $hfd_epost_service_url, "run.hfd.co.il" ) !== false || strpos( $hfd_epost_service_url, "uniscripts/MGrqispi.dll" ) !== false ) && filter_var( $hfd_epost_service_url, FILTER_VALIDATE_URL ) == true ){
    169             $hfd_epost_service_url = str_replace( array( 'uniscripts/MGrqispi.dll', 'run.hfd.co.il' ), array( 'RunCom.Server/Request.aspx', 'ws.hfd.co.il' ), $hfd_epost_service_url );
    170                        
     134        if( strpos( $hfd_epost_service_url, "uniscripts/MGrqispi.dll" ) !== false && filter_var( $hfd_epost_service_url, FILTER_VALIDATE_URL ) == true ){
     135            $hfd_epost_service_url = str_replace( 'uniscripts/MGrqispi.dll', 'RunCom.Server/Request.aspx', $hfd_epost_service_url );
     136           
    171137            update_option( 'betanet_epost_service_url', $hfd_epost_service_url );
    172138        }
    173139       
    174140        $betanet_epost_hfd_service_url = get_option( 'betanet_epost_hfd_service_url' );
    175         if( ( strpos( $betanet_epost_hfd_service_url, "uniscripts/MGrqispi.dll" ) !== false || strpos( $betanet_epost_hfd_service_url, "run.hfd.co.il" ) !== false ) && filter_var( $betanet_epost_hfd_service_url, FILTER_VALIDATE_URL ) == true ){
    176             $betanet_epost_hfd_service_url = str_replace( array( 'uniscripts/MGrqispi.dll', 'run.hfd.co.il' ), array( 'RunCom.Server/Request.aspx', 'ws.hfd.co.il' ), $betanet_epost_hfd_service_url );
     141        if( strpos( $betanet_epost_hfd_service_url, "uniscripts/MGrqispi.dll" ) !== false && filter_var( $betanet_epost_hfd_service_url, FILTER_VALIDATE_URL ) == true ){
     142            $betanet_epost_hfd_service_url = str_replace( 'uniscripts/MGrqispi.dll', 'RunCom.Server/Request.aspx', $betanet_epost_hfd_service_url );
    177143           
    178144            update_option( 'betanet_epost_hfd_service_url', $betanet_epost_hfd_service_url );
    179145        }
    180146       
    181         if( ( strpos( $track_shipment_url, "uniscripts/MGrqispi.dll" ) !== false || strpos( $track_shipment_url, "run.hfd.co.il" ) !== false ) && filter_var( $track_shipment_url, FILTER_VALIDATE_URL ) == true ){
    182             $track_shipment_url = str_replace( array( 'uniscripts/MGrqispi.dll', 'run.hfd.co.il' ), array( 'RunCom.Server/Request.aspx', 'ws.hfd.co.il' ), $track_shipment_url );
     147        if( strpos( $track_shipment_url, "uniscripts/MGrqispi.dll" ) !== false && filter_var( $track_shipment_url, FILTER_VALIDATE_URL ) == true ){
     148            $track_shipment_url = str_replace( 'uniscripts/MGrqispi.dll', 'RunCom.Server/Request.aspx', $track_shipment_url );
    183149           
    184150            update_option( 'betanet_epost_hfd_track_shipment_url', $track_shipment_url );
    185151        }
    186152       
    187         if( ( strpos( $cancel_shipment_url, "uniscripts/MGrqispi.dll" ) !== false || strpos( $cancel_shipment_url, "run.hfd.co.il" ) !== false ) && filter_var( $cancel_shipment_url, FILTER_VALIDATE_URL ) == true ){
    188             $cancel_shipment_url = str_replace( array( 'uniscripts/MGrqispi.dll', 'run.hfd.co.il' ), array( 'RunCom.Server/Request.aspx', 'ws.hfd.co.il' ), $cancel_shipment_url );
     153        if( strpos( $cancel_shipment_url, "uniscripts/MGrqispi.dll" ) !== false && filter_var( $cancel_shipment_url, FILTER_VALIDATE_URL ) == true ){
     154            $cancel_shipment_url = str_replace( 'uniscripts/MGrqispi.dll', 'RunCom.Server/Request.aspx', $cancel_shipment_url );
    189155           
    190156            update_option( 'betanet_epost_hfd_cancel_shipment_url', $cancel_shipment_url );
    191157        }
    192158       
    193         if( ( strpos( $print_label_url, "uniscripts/MGrqispi.dll" ) !== false || strpos( $print_label_url, "run.hfd.co.il" ) !== false ) && filter_var( $print_label_url, FILTER_VALIDATE_URL ) == true ){
    194             $print_label_url = str_replace( array( 'uniscripts/MGrqispi.dll', 'run.hfd.co.il' ), array( 'RunCom.Server/Request.aspx', 'ws.hfd.co.il' ), $print_label_url );
     159        if( strpos( $print_label_url, "uniscripts/MGrqispi.dll" ) !== false && filter_var( $print_label_url, FILTER_VALIDATE_URL ) == true ){
     160            $print_label_url = str_replace( 'uniscripts/MGrqispi.dll', 'RunCom.Server/Request.aspx', $print_label_url );
    195161           
    196162            update_option( 'betanet_epost_hfd_print_label_url', $print_label_url );
     
    205171            return;
    206172       
    207         $args = array(
    208             'limit' => -1,
    209             'status' => array( $hfd_auto_sync_status ),
    210             'return' => 'ids',
    211             'hfd_cron' => 'yes',
     173        $orderIds = get_posts( array(
     174            'numberposts' => - 1,
     175            'post_type'   => array( 'shop_order' ),
     176            'post_status' => array( $hfd_auto_sync_status ),
    212177            'date_query' => array(
    213                 'before' => date( 'Y-m-d H:i:s', strtotime( '-'.$hfd_auto_sync_time.' minutes' ) )
     178                'after' => date( 'Y-m-d H:i:s', strtotime( '-'.$hfd_auto_sync_time.' minutes' ) ),
     179                'before' => date( 'Y-m-d H:i:s', time() )
    214180            ),
    215         );
    216         $orderIds = wc_get_orders( $args );
     181            'meta_query' => array(
     182                array(
     183                    'key' => 'hfd_ship_number',
     184                    'compare' => 'NOT EXISTS' // this should work...
     185                )
     186            ),
     187            'fields' => 'ids'
     188        ) );
    217189       
    218190        if( $orderIds ){
  • hfd-epost-integration/trunk/class/Setting.php

    r3227930 r3228676  
    3434    {
    3535        $_settings = array(
    36             'betanet_epost_service_url' => 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ws_spotslist&ARGUMENTS=-Aall',
     36            'betanet_epost_service_url' => 'https://run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ws_spotslist&ARGUMENTS=-Aall',
    3737            'betanet_epost_google_api_key' => '',
    3838            'betanet_epost_hfd_active' => 1,
    39             'betanet_epost_hfd_service_url' => 'https://ws.hfd.co.il/RunCom.Server/Request.aspx',
     39            'betanet_epost_hfd_service_url' => 'https://run.hfd.co.il/RunCom.Server/Request.aspx',
    4040            'betanet_epost_hfd_shipping_method' => array(\Hfd\Woocommerce\Shipping\Epost::METHOD_ID),
    4141            'betanet_epost_hfd_sender_name' => 'default',
    4242            'betanet_epost_hfd_customer_number' => 0,
    43             'betanet_epost_hfd_print_pdf_url' => 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{shipping_number}',
    44             'betanet_epost_hfd_track_shipment_url' => 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_locate_random&ARGUMENTS=-A{RAND}',
    45             'betanet_epost_hfd_cancel_shipment_url' => 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=bitul_mishloah&ARGUMENTS=-A{shipping_number},-A,-A,-A,-N',
    46             'betanet_epost_hfd_print_label_url' => 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{RAND}',
     43            'betanet_epost_hfd_print_pdf_url' => 'https://run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{shipping_number}',
     44            'betanet_epost_hfd_track_shipment_url' => 'https://run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_locate_random&ARGUMENTS=-A{RAND}',
     45            'betanet_epost_hfd_cancel_shipment_url' => 'https://run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=bitul_mishloah&ARGUMENTS=-A{shipping_number},-A,-A,-A,-N',
     46            'betanet_epost_hfd_print_label_url' => 'https://run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{RAND}',
    4747            'hfd_order_auto_sync' => 'no',
    4848            'hfd_sync_order_items' => 'no',
  • hfd-epost-integration/trunk/hfd-woocommerce-epost.php

    r3227946 r3228676  
    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: 2.13
     7Version: 2.14
    88Author: HFD
    99Author URI: https://www.hfd.co.il
     
    2020
    2121define( 'HFD_EPOST_PATH', dirname( __FILE__ ) );
    22 define( 'HFD_EPOST_PLUGIN_FILE', plugin_basename( __FILE__ ) );
    2322define( 'HFD_EPOST_PLUGIN_DIR', basename( __DIR__ ) );
    2423define( 'HFD_EPOST_PLUGIN_URL', plugins_url( HFD_EPOST_PLUGIN_DIR ) );
  • hfd-epost-integration/trunk/readme.txt

    r3227946 r3228676  
    55Requires at least: 4.0
    66Tested up to: 6.7
    7 Stable tag: 2.13
     7Stable tag: 2.14
    88Requires PHP: 5.4
    99License: GPLv2 or later
     
    7575== Third Party API ==
    7676Google Maps - maps.googleapis.com
    77 HFD - ws.hfd.co.il
     77HFD - run.hfd.co.il
    7878
    7979== Changelog ==
     
    116116* Performance Improvement
    117117
     118= 2.14 =
     119* Performance Improvement
     120
    118121== Frequently Asked Questions ==
    119122= Why Google Maps isnt loading =
Note: See TracChangeset for help on using the changeset viewer.