Plugin Directory

Changeset 2676945


Ignore:
Timestamp:
02/11/2022 09:12:16 AM (4 years ago)
Author:
lalamove
Message:

release 1.0.4

Location:
lalamove
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • lalamove/tags/1.0.4/includes/class-lalamove-app.php

    r2661191 r2676945  
    1515        public static $menu_slug               = 'Lalamove';
    1616        public static $wc_llm_web_app_host     = 'https://web.lalamove.com';
     17        public static $sa_url                  = 'https://uba.huolalamove.net/sa?project=default';
    1718        public static $llm_order_column_key    = 'Lalamove';
    1819        public static $llm_order_column_title  = 'Lalamove';
     
    2223        );
    2324        public static $wc_llm_dc               = array(
    24             'sg' => array( 'sg', 30000 ),
    25             'my' => array( 'sg', 40000 ),
    26             'ph' => array( 'sg', 50000 ),
    27             'tw' => array( 'sg', 80000 ),
    28             'hk' => array( 'sg', 90000 ),
    29             'vn' => array( 'sg', 100000 ),
    30             'th' => array( 'sg', 110000 ),
    31             'id' => array( 'sg', 120000 ),
    32             'br' => array( 'br', 20000 ),
    33             'mx' => array( 'br', 60000 ),
     25            'sg' => array( 'sg', 30000, 'SIN' ),
     26            'my' => array( 'sg', 40000, 'SIN' ),
     27            'ph' => array( 'sg', 50000, 'SIN' ),
     28            'tw' => array( 'sg', 80000, 'SIN' ),
     29            'hk' => array( 'sg', 90000, 'SIN' ),
     30            'vn' => array( 'sg', 100000, 'SIN' ),
     31            'th' => array( 'sg', 110000, 'SIN' ),
     32            'id' => array( 'sg', 120000, 'SIN' ),
     33            'br' => array( 'br', 20000, 'SAO' ),
     34            'mx' => array( 'br', 60000, 'SAO' ),
    3435        );
    3536
  • lalamove/tags/1.0.4/includes/utility-functions.php

    r2661191 r2676945  
    198198
    199199function lalamove_get_current_plugin_param( $key ) {
    200     if ( empty( $_SERVER['REQUEST_URI'] ) ) {
     200    if ( empty( $_SERVER['QUERY_STRING'] ) ) {
    201201        return '';
    202202    }
    203     $url_query_str = wp_parse_url( admin_url( basename( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ), PHP_URL_QUERY );
    204     parse_str( $url_query_str, $query );
     203    parse_str( $_SERVER['QUERY_STRING'], $query );
    205204    if ( empty( $query[ $key ] ) ) {
    206205        return '';
     
    240239    error_log( $out );
    241240}
     241
     242function lalamove_track( $event, $payload = array() ) {
     243    $shop             = preg_replace( '/^http:\/\/|^https:\/\//i', '', get_option( 'siteurl' ) );
     244    $wc_country       = WC()->countries->get_base_country();
     245    $lalamove_country = lalamove_get_country( strtolower( $wc_country ) );
     246    $dc               = $lalamove_country ? $lalamove_country[2] : $wc_country;
     247
     248    if ( strtoupper( substr( PHP_OS, 0, 3 ) ) == 'WIN' ) {
     249        $event_time = substr( ( microtime( true ) * 1000 ), 0, 13 );
     250    } else {
     251        $event_time = (int) ( microtime( true ) * 1000 );
     252    }
     253
     254    $lib_properties = array(
     255        '$lib'         => 'php',
     256        '$lib_version' => '1.0',
     257        '$lib_method'  => 'code',
     258    );
     259
     260    $default_properties = array(
     261        'llm_source'   => 'woocommerce',
     262        'trigger_time' => gmdate( 'c', time() ),
     263        'shopName'     => $shop,
     264        'country'      => $wc_country,
     265        'city'         => WC()->countries->get_base_city(),
     266        'language'     => get_locale(),
     267        'data_center'  => $dc,
     268        'app_version'  => lalamove_get_version(),
     269        'php_version'  => PHP_VERSION,
     270        'env'          => 'prd',
     271    );
     272
     273    $data = array(
     274        'type'        => 'track',
     275        'properties'  => array_merge( $default_properties, $payload ),
     276        'time'        => $event_time,
     277        'event'       => $event,
     278        'distinct_id' => "{$dc}-{$shop}",
     279        'lib'         => $lib_properties,
     280    );
     281
     282    $packed_data = base64_encode( gzencode( '[' . json_encode( $data ) . ']' ) );
     283
     284    $body = 'data_list=' . urlencode( $packed_data ) . '&gzip=1';
     285
     286    wp_remote_post(
     287        Lalamove_App::$sa_url,
     288        array(
     289            'timeout'    => 2,
     290            'blocking'   => false,
     291            'headers'    => array( 'Content-Type' => 'text/plain' ),
     292            'user-agent' => 'PHP SDK',
     293            'body'       => $body,
     294        )
     295    );
     296}
     297
  • lalamove/tags/1.0.4/lalamove.php

    r2661191 r2676945  
    44 * Plugin URI:        https://wordpress.org/plugins/lalamove
    55 * Description:       A 24/7 on-demand delivery app
    6  * Version:           1.0.3
     6 * Version:           1.0.4
    77 * Author:            partner.support@lalamove.com
    88 * Author URI:        https://lalamove.com/
     
    4444        $page_menu_display,
    4545        $page_menu_display,
    46         'manage_options',
     46        'manage_woocommerce',
    4747        'Lalamove',
    4848        'lalamove_web',
     
    7676    $sub_page = lalamove_get_current_plugin_param( 'sub-page' );
    7777
     78    if ( lalamove_get_current_plugin_param( 'success' ) ) {
     79        lalamove_track( 'plugin_authorized' );
     80    }
     81
    7882    if ( $sub_page === 'place-order' ) {
    7983        $place_order_url = lalamove_get_service_url() . '/place-order?id=' . lalamove_get_current_plugin_param( 'id' ) . '&name=' . lalamove_get_current_user_name()
     
    111115    class WC_Integration_Lalamove {
    112116        public function __construct() {
    113             register_deactivation_hook( __FILE__, 'lalamove_remove_rest_api_key' );
    114117            if ( lalamove_check_is_woocommerce_active() ) {
    115118                add_action( 'admin_menu', 'lalamove_menu' );
     
    121124                add_action( 'admin_notices', array( $this, 'notice_activate_wc' ) );
    122125            }
     126            register_activation_hook( __FILE__, 'WC_Integration_Lalamove::activation_hook' );
     127            register_deactivation_hook( __FILE__, 'WC_Integration_Lalamove::deactivation_hook' );
     128            register_uninstall_hook( __FILE__, 'WC_Integration_Lalamove::uninstall_hook' );
     129        }
     130
     131        static function activation_hook() {
     132            lalamove_track( 'plugin_activated' );
     133        }
     134
     135        static function deactivation_hook() {
     136            lalamove_remove_rest_api_key();
     137            lalamove_track( 'plugin_deactivated' );
     138        }
     139
     140        static function uninstall_hook() {
     141            lalamove_track( 'plugin_uninstalled' );
    123142        }
    124143
  • lalamove/tags/1.0.4/readme.txt

    r2661193 r2676945  
    66Tested up to: 5.8.2
    77Requires PHP: 7.0
    8 Stable tag: 1.0.3
     8Stable tag: 1.0.4
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    8383This will most likely happen when your account information has been updated after you installed our plugin. The fastest way to solve is to deactivate and activate again. If you are still seeing same issue, please reach out to partner.support@lalamove.com with your email and shop domain.
    8484
     85= I cannot install or approve permission =
     86
     87This will most likely happen when your account information has been updated after you installed our plugin. The fastest solution is to try deactivating and activating again. If you are still seeing same issue, please follow the instructions [here](https://docs.google.com/document/d/1kK0SuHgZpOzXJJlMGiIT7slxT8ToL2QKsMkCC_OzneU/edit)
    8588
    8689= Additional FAQs? =
     
    104107== Changelog ==
    105108
     109= 1.0.4 =
     110* Added guideline for troubleshooting
     111* Updated the Lalamove menu view permission
     112
    106113= 1.0.3 =
    107114* Lalamove Quotation at Checkout
  • lalamove/trunk/includes/class-lalamove-app.php

    r2661191 r2676945  
    1515        public static $menu_slug               = 'Lalamove';
    1616        public static $wc_llm_web_app_host     = 'https://web.lalamove.com';
     17        public static $sa_url                  = 'https://uba.huolalamove.net/sa?project=default';
    1718        public static $llm_order_column_key    = 'Lalamove';
    1819        public static $llm_order_column_title  = 'Lalamove';
     
    2223        );
    2324        public static $wc_llm_dc               = array(
    24             'sg' => array( 'sg', 30000 ),
    25             'my' => array( 'sg', 40000 ),
    26             'ph' => array( 'sg', 50000 ),
    27             'tw' => array( 'sg', 80000 ),
    28             'hk' => array( 'sg', 90000 ),
    29             'vn' => array( 'sg', 100000 ),
    30             'th' => array( 'sg', 110000 ),
    31             'id' => array( 'sg', 120000 ),
    32             'br' => array( 'br', 20000 ),
    33             'mx' => array( 'br', 60000 ),
     25            'sg' => array( 'sg', 30000, 'SIN' ),
     26            'my' => array( 'sg', 40000, 'SIN' ),
     27            'ph' => array( 'sg', 50000, 'SIN' ),
     28            'tw' => array( 'sg', 80000, 'SIN' ),
     29            'hk' => array( 'sg', 90000, 'SIN' ),
     30            'vn' => array( 'sg', 100000, 'SIN' ),
     31            'th' => array( 'sg', 110000, 'SIN' ),
     32            'id' => array( 'sg', 120000, 'SIN' ),
     33            'br' => array( 'br', 20000, 'SAO' ),
     34            'mx' => array( 'br', 60000, 'SAO' ),
    3435        );
    3536
  • lalamove/trunk/includes/utility-functions.php

    r2661191 r2676945  
    198198
    199199function lalamove_get_current_plugin_param( $key ) {
    200     if ( empty( $_SERVER['REQUEST_URI'] ) ) {
     200    if ( empty( $_SERVER['QUERY_STRING'] ) ) {
    201201        return '';
    202202    }
    203     $url_query_str = wp_parse_url( admin_url( basename( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ), PHP_URL_QUERY );
    204     parse_str( $url_query_str, $query );
     203    parse_str( $_SERVER['QUERY_STRING'], $query );
    205204    if ( empty( $query[ $key ] ) ) {
    206205        return '';
     
    240239    error_log( $out );
    241240}
     241
     242function lalamove_track( $event, $payload = array() ) {
     243    $shop             = preg_replace( '/^http:\/\/|^https:\/\//i', '', get_option( 'siteurl' ) );
     244    $wc_country       = WC()->countries->get_base_country();
     245    $lalamove_country = lalamove_get_country( strtolower( $wc_country ) );
     246    $dc               = $lalamove_country ? $lalamove_country[2] : $wc_country;
     247
     248    if ( strtoupper( substr( PHP_OS, 0, 3 ) ) == 'WIN' ) {
     249        $event_time = substr( ( microtime( true ) * 1000 ), 0, 13 );
     250    } else {
     251        $event_time = (int) ( microtime( true ) * 1000 );
     252    }
     253
     254    $lib_properties = array(
     255        '$lib'         => 'php',
     256        '$lib_version' => '1.0',
     257        '$lib_method'  => 'code',
     258    );
     259
     260    $default_properties = array(
     261        'llm_source'   => 'woocommerce',
     262        'trigger_time' => gmdate( 'c', time() ),
     263        'shopName'     => $shop,
     264        'country'      => $wc_country,
     265        'city'         => WC()->countries->get_base_city(),
     266        'language'     => get_locale(),
     267        'data_center'  => $dc,
     268        'app_version'  => lalamove_get_version(),
     269        'php_version'  => PHP_VERSION,
     270        'env'          => 'prd',
     271    );
     272
     273    $data = array(
     274        'type'        => 'track',
     275        'properties'  => array_merge( $default_properties, $payload ),
     276        'time'        => $event_time,
     277        'event'       => $event,
     278        'distinct_id' => "{$dc}-{$shop}",
     279        'lib'         => $lib_properties,
     280    );
     281
     282    $packed_data = base64_encode( gzencode( '[' . json_encode( $data ) . ']' ) );
     283
     284    $body = 'data_list=' . urlencode( $packed_data ) . '&gzip=1';
     285
     286    wp_remote_post(
     287        Lalamove_App::$sa_url,
     288        array(
     289            'timeout'    => 2,
     290            'blocking'   => false,
     291            'headers'    => array( 'Content-Type' => 'text/plain' ),
     292            'user-agent' => 'PHP SDK',
     293            'body'       => $body,
     294        )
     295    );
     296}
     297
  • lalamove/trunk/lalamove.php

    r2661191 r2676945  
    44 * Plugin URI:        https://wordpress.org/plugins/lalamove
    55 * Description:       A 24/7 on-demand delivery app
    6  * Version:           1.0.3
     6 * Version:           1.0.4
    77 * Author:            partner.support@lalamove.com
    88 * Author URI:        https://lalamove.com/
     
    4444        $page_menu_display,
    4545        $page_menu_display,
    46         'manage_options',
     46        'manage_woocommerce',
    4747        'Lalamove',
    4848        'lalamove_web',
     
    7676    $sub_page = lalamove_get_current_plugin_param( 'sub-page' );
    7777
     78    if ( lalamove_get_current_plugin_param( 'success' ) ) {
     79        lalamove_track( 'plugin_authorized' );
     80    }
     81
    7882    if ( $sub_page === 'place-order' ) {
    7983        $place_order_url = lalamove_get_service_url() . '/place-order?id=' . lalamove_get_current_plugin_param( 'id' ) . '&name=' . lalamove_get_current_user_name()
     
    111115    class WC_Integration_Lalamove {
    112116        public function __construct() {
    113             register_deactivation_hook( __FILE__, 'lalamove_remove_rest_api_key' );
    114117            if ( lalamove_check_is_woocommerce_active() ) {
    115118                add_action( 'admin_menu', 'lalamove_menu' );
     
    121124                add_action( 'admin_notices', array( $this, 'notice_activate_wc' ) );
    122125            }
     126            register_activation_hook( __FILE__, 'WC_Integration_Lalamove::activation_hook' );
     127            register_deactivation_hook( __FILE__, 'WC_Integration_Lalamove::deactivation_hook' );
     128            register_uninstall_hook( __FILE__, 'WC_Integration_Lalamove::uninstall_hook' );
     129        }
     130
     131        static function activation_hook() {
     132            lalamove_track( 'plugin_activated' );
     133        }
     134
     135        static function deactivation_hook() {
     136            lalamove_remove_rest_api_key();
     137            lalamove_track( 'plugin_deactivated' );
     138        }
     139
     140        static function uninstall_hook() {
     141            lalamove_track( 'plugin_uninstalled' );
    123142        }
    124143
  • lalamove/trunk/readme.txt

    r2661193 r2676945  
    66Tested up to: 5.8.2
    77Requires PHP: 7.0
    8 Stable tag: 1.0.3
     8Stable tag: 1.0.4
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    8383This will most likely happen when your account information has been updated after you installed our plugin. The fastest way to solve is to deactivate and activate again. If you are still seeing same issue, please reach out to partner.support@lalamove.com with your email and shop domain.
    8484
     85= I cannot install or approve permission =
     86
     87This will most likely happen when your account information has been updated after you installed our plugin. The fastest solution is to try deactivating and activating again. If you are still seeing same issue, please follow the instructions [here](https://docs.google.com/document/d/1kK0SuHgZpOzXJJlMGiIT7slxT8ToL2QKsMkCC_OzneU/edit)
    8588
    8689= Additional FAQs? =
     
    104107== Changelog ==
    105108
     109= 1.0.4 =
     110* Added guideline for troubleshooting
     111* Updated the Lalamove menu view permission
     112
    106113= 1.0.3 =
    107114* Lalamove Quotation at Checkout
Note: See TracChangeset for help on using the changeset viewer.