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['MX'])) {
- $mx_state_list = array(
- 'MX' => array(
- 'label' => 'Mexico',
- 'state' => array(
- 'MX-AGU' => 'Aguascalientes',
- 'MX-BCN' => 'Baja California',
- 'MX-BCS' => 'Baja California Sur',
- 'MX-CAM' => 'Campeche',
- 'MX-CHP' => 'Chiapas',
- 'MX-CHH' => 'Chihuahua',
- 'MX-COA' => 'Coahuila',
- 'MX-COL' => 'Colima',
- 'MX-CMX' => 'Mexico City',
- 'MX-DUR' => 'Durango',
- 'MX-GUA' => 'Guanajuato',
- 'MX-GRO' => 'Guerrero',
- 'MX-HID' => 'Hidalgo',
- 'MX-JAL' => 'Jalisco',
- 'MX-MEX' => 'México',
- 'MX-MIC' => 'Michoacán',
- 'MX-MOR' => 'Morelos',
- 'MX-NAY' => 'Nayarit',
- 'MX-NLE' => 'Nuevo León',
- 'MX-OAX' => 'Oaxaca',
- 'MX-PUE' => 'Puebla',
- 'MX-QUE' => 'Querétaro',
- 'MX-ROO' => 'Quintana Roo',
- 'MX-SLP' => 'San Luis Potosí',
- 'MX-SIN' => 'Sinaloa',
- 'MX-SON' => 'Sonora',
- 'MX-TAB' => 'Tabasco',
- 'MX-TAM' => 'Tamaulipas',
- 'MX-TLA' => 'Tlaxcala',
- 'MX-VER' => 'Veracruz',
- 'MX-YUC' => 'Yucatán',
- 'MX-ZAC' => 'Zacatecas',
- ),
- ),
- );
- 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 );
- }
- 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() ) {
- if ( 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=='mx') {
- $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['mx'] = 'mx_regions';
- return $list;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement