View difference between Paste ID: u711ee75 and 1xi3x7kE
SHOW: | | - or go back to the newest paste.
1
add_filter('wcfma_country_state_list', function($wcfma_country_state_list) {
2-
    if(!isset($wcfma_country_state_list['BG'])) {
2+
    if(!isset($wcfma_country_state_list['MX'])) {
3-
        $bulgaria_state_list = array(
3+
        $mx_state_list = array(
4-
            'BG' => array(
4+
            'MX' => array(
5-
                'label' => 'Bulgaria',
5+
                'label' => 'Mexico',
6
                'state' => array(
7-
                    'BG342' =>	"Sliven",
7+
                    'MX-AGU' => 'Aguascalientes',
8-
                    'BG422' =>	"Haskovo",
8+
                    'MX-BCN' => 'Baja California',
9-
                    'BG222' =>	"Stara Zagora",
9+
                    'MX-BCS' => 'Baja California Sur',
10-
                    'BG224' =>	"Pazardzhik",
10+
                    'MX-CAM' => 'Campeche',
11-
                    'BG421' =>	"Plovdiv",
11+
                    'MX-CHP' => 'Chiapas',
12-
                    'BG225' =>	"Smolyan",
12+
                    'MX-CHH' => 'Chihuahua',
13-
                    'BG425' =>	"Kardzhali",
13+
                    'MX-COA' => 'Coahuila',
14-
                    'BG411' =>	"Sofia City",
14+
                    'MX-COL' => 'Colima',
15-
                    'BG412' =>	"Sofia",
15+
                    'MX-CMX' => 'Mexico City',
16-
                    'BG414' =>	"Pernik",
16+
                    'MX-DUR' => 'Durango',
17-
                    'BG124' =>	"Gabrovo",
17+
                    'MX-GUA' => 'Guanajuato',
18-
                    'BG122' =>	"Lovech",
18+
                    'MX-GRO' => 'Guerrero',
19-
                    'BG314' =>	"Pleven",
19+
                    'MX-HID' => 'Hidalgo',
20-
                    'BG321' =>	"Veliko Tarnovo",
20+
                    'MX-JAL' => 'Jalisco',
21-
                    'BG112' =>	"Montana",
21+
                    'MX-MEX' => 'México',
22-
                    'BG113' =>	"Vratsa",
22+
                    'MX-MIC' => 'Michoacán',
23-
                    'BG215' =>	"Kyustendil",
23+
                    'MX-MOR' => 'Morelos',
24-
                    'BG311' =>	"Vidin",
24+
                    'MX-NAY' => 'Nayarit',
25-
                    'BG231' =>	"Burgas",
25+
                    'MX-NLE' => 'Nuevo León',
26-
                    'BG233' =>	"Yambol",
26+
                    'MX-OAX' => 'Oaxaca',
27-
                    'BG324' =>	"Razgrad",
27+
                    'MX-PUE' => 'Puebla',
28-
                    'BG334' =>	"Targovishte",
28+
                    'MX-QUE' => 'Querétaro',
29-
                    'BG133' =>	"Shumen",
29+
                    'MX-ROO' => 'Quintana Roo',
30-
                    'BG332' =>	"Dobrich",
30+
                    'MX-SLP' => 'San Luis Potosí',
31-
                    'BG131' =>	"Varna",
31+
                    'MX-SIN' => 'Sinaloa',
32-
                    'BG136' =>	"Silistra",
32+
                    'MX-SON' => 'Sonora',
33-
                    'BG323' =>	"Ruse",
33+
                    'MX-TAB' => 'Tabasco',
34-
                    'BG413' =>	"Blagoevgrad",
34+
                    'MX-TAM' => 'Tamaulipas',
35
                    'MX-TLA' => 'Tlaxcala',
36
                    'MX-VER' => 'Veracruz',
37
                    'MX-YUC' => 'Yucatán',
38-
        return array_slice( $wcfma_country_state_list, 0, 1, true ) + $bulgaria_state_list + array_slice( $wcfma_country_state_list, 1, count( $wcfma_country_state_list ) - 1, true );
38+
                    'MX-ZAC' => 'Zacatecas',
39
                ),
40
            ),
41
        );
42
        return array_slice( $wcfma_country_state_list, 0, 1, true ) + $mx_state_list + array_slice( $wcfma_country_state_list, 1, count( $wcfma_country_state_list ) - 1, true );
43
    }
44
    return $wcfma_country_state_list;
45
});
46
47
add_action( 'wcfm_load_scripts', 'load_script_enhanced_region', 9 );
48
add_action( 'after_wcfm_load_scripts', 'load_script_enhanced_region', 9 );
49
50
function load_script_enhanced_region($end_point) {
51-
	    	if ( $is_wcfm_analytics_enable = is_wcfm_analytics() ) {
51+
52-
	    		if ( $wcfm_is_allow_analytics = apply_filters( 'wcfm_is_allow_analytics', true ) ) {
52+
53
    switch( $end_point ) {
54
	    case 'wcfm-dashboard':
55
	    	if ( is_wcfm_analytics() ) {
56
	    		if ( apply_filters( 'wcfm_is_allow_analytics', true ) ) {
57
						load_jvectormap_lib();
58
						wp_enqueue_script( 'wcfma_analytics_js', $WCFMa->library->js_lib_url . 'wcfma-script-analytics-dashboard.js', array('jquery'), $WCFMa->version, true );
59
					}
60
				}
61
	  	break;
62
	  	case 'wcfm-analytics':
63
	  		load_jvectormap_lib();
64
            $WCFM->library->load_select2_lib();
65
            $WCFM->library->load_chartjs_lib();
66
            $WCFM->library->load_daterangepicker_lib();
67
	    	wp_enqueue_script( 'wcfma_analytics_js', $WCFMa->library->js_lib_url . 'wcfma-script-analytics.js', array('jquery'), $WCFMa->version, true );
68
	    	wp_enqueue_script( 'wcfma_analytics_dashboard_js', $WCFMa->library->js_lib_url . 'wcfma-script-analytics-dashboard.js', array('jquery'), $WCFMa->version, true );
69
      break;
70
      
71
    }
72
}
73
74
function load_jvectormap_lib(){
75
    global $WCFMa;
76
    wp_enqueue_script( 'jquery-jvectormap_js', $WCFMa->plugin_url . 'includes/jvectormap/jquery-jvectormap-2.0.3.min.js', array('jquery'), $WCFMa->version, true );
77
    $user_id = apply_filters( 'wcfm_current_vendor_id', get_current_user_id() );
78-
    if($wcfm_analytics_region=='bg') {
78+
79
    if( !$wcfm_analytics_region ) $wcfm_analytics_region = 'world';
80
    $wcfm_analytics_region = strtolower( $wcfm_analytics_region );
81
    $path = $WCFMa->plugin_url . 'includes/jvectormap/';
82
    if($wcfm_analytics_region=='mx') {
83
        $path = get_stylesheet_directory_uri() . '/js/';
84
    }
85
    wp_enqueue_script( 'jquery-jvectormap-world_js', $path.$wcfm_analytics_region.'-mill.js', array('jquery', 'jquery-jvectormap_js'), $WCFMa->version, true );
86-
    $list['bg'] = 'bg_regions';
86+
87
}
88
89
add_filter('get_wcfma_map_name_list', function($list) {
90
    $list['mx'] = 'mx_regions';
91
    return $list;
92
});