Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('wcfma_country_state_list', function($wcfma_country_state_list) {
- if(!isset($wcfma_country_state_list['MY'])) {
- $my_state_list = array(
- 'MY' => array(
- 'label' => 'Malaysia',
- 'state' => array(
- "MY-01" => "Johor",
- "MY-02" => "Kedah",
- "MY-03" => "Kelantan",
- "MY-04" => "Melaka",
- "MY-05" => "Negeri Sembilan",
- "MY-06" => "Pahang",
- "MY-07" => "Pulau Pinang",
- "MY-08" => "Perak",
- "MY-09" => "Perlis",
- "MY-10" => "Selangor",
- "MY-11" => "Terengganu",
- "MY-12" => "Sabah",
- "MY-13" => "Sarawak",
- "MY-14" => "Kuala Lumpur",
- "MY-15" => "Labuan",
- "MY-16" => "Putrajaya",
- ),
- ),
- );
- return array_slice( $wcfma_country_state_list, 0, 1, true ) + $my_state_list + array_slice( $wcfma_country_state_list, 1, count( $wcfma_country_state_list ) - 1, true );
- }
- return $wcfma_country_state_list;
- });
- add_action( 'wcfm_load_scripts', 'load_script_enhanced_region', 9 );
- add_action( 'after_wcfm_load_scripts', 'load_script_enhanced_region', 9 );
- function load_script_enhanced_region($end_point) {
- global $WCFM, $WCFMa;
- remove_action( current_filter(), array($WCFMa->library, 'load_scripts') );
- switch( $end_point ) {
- case 'wcfm-dashboard':
- if ( $is_wcfm_analytics_enable = is_wcfm_analytics() ) {
- if ( $wcfm_is_allow_analytics = apply_filters( 'wcfm_is_allow_analytics', true ) ) {
- load_jvectormap_lib();
- wp_enqueue_script( 'wcfma_analytics_js', $WCFMa->library->js_lib_url . 'wcfma-script-analytics-dashboard.js', array('jquery'), $WCFMa->version, true );
- }
- }
- break;
- case 'wcfm-analytics':
- load_jvectormap_lib();
- $WCFM->library->load_select2_lib();
- $WCFM->library->load_chartjs_lib();
- $WCFM->library->load_daterangepicker_lib();
- wp_enqueue_script( 'wcfma_analytics_js', $WCFMa->library->js_lib_url . 'wcfma-script-analytics.js', array('jquery'), $WCFMa->version, true );
- wp_enqueue_script( 'wcfma_analytics_dashboard_js', $WCFMa->library->js_lib_url . 'wcfma-script-analytics-dashboard.js', array('jquery'), $WCFMa->version, true );
- break;
- }
- }
- function load_jvectormap_lib(){
- global $WCFMa;
- wp_enqueue_script( 'jquery-jvectormap_js', $WCFMa->plugin_url . 'includes/jvectormap/jquery-jvectormap-2.0.3.min.js', array('jquery'), $WCFMa->version, true );
- $user_id = apply_filters( 'wcfm_current_vendor_id', get_current_user_id() );
- $wcfm_analytics_region = get_user_meta( $user_id, 'wcfm_analytics_region', true );
- if( !$wcfm_analytics_region ) $wcfm_analytics_region = 'world';
- $wcfm_analytics_region = strtolower( $wcfm_analytics_region );
- $path = $WCFMa->plugin_url . 'includes/jvectormap/';
- if($wcfm_analytics_region=='my') {
- $path = get_stylesheet_directory_uri() . '/js/';
- }
- wp_enqueue_script( 'jquery-jvectormap-world_js', $path.$wcfm_analytics_region.'-mill.js', array('jquery', 'jquery-jvectormap_js'), $WCFMa->version, true );
- wp_enqueue_style( 'wcfm_timepicker_css', $WCFMa->plugin_url . 'includes/jvectormap/jquery-jvectormap-2.0.3.css', array(), $WCFMa->version );
- }
- add_filter('get_wcfma_map_name_list', function($list) {
- $list['my'] = 'my_regions';
- return $list;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement