WooCommerce_MyParcel_Assets

The WooCommerce MyParcel WooCommerce MyParcel Assets class.

Defined (1)

The class is defined in the following location(s).

/includes/class-wcmp-assets.php  
  1. class WooCommerce_MyParcel_Assets { 
  2.  
  3. function __construct() { 
  4. add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts_styles' ) ); 
  5. add_action( 'admin_enqueue_scripts', array( $this, 'backend_scripts_styles' ) ); 
  6.  
  7. /** 
  8. * Load styles & scripts 
  9. */ 
  10. public function frontend_scripts_styles ( $hook ) { 
  11. if ( is_checkout() && isset(WooCommerce_MyParcel()->checkout_settings['myparcel_checkout']) && is_order_received_page() === false ) { 
  12. // checkout scripts 
  13. wp_enqueue_script( 
  14. 'wc-myparcel-frontend',  
  15. WooCommerce_MyParcel()->plugin_url() . '/assets/js/wcmp-frontend.js',  
  16. array( 'jquery' ),  
  17. WC_MYPARCEL_VERSION 
  18. ); 
  19.  
  20. /** 
  21. * Load styles & scripts 
  22. */ 
  23. public function backend_scripts_styles ( $hook ) { 
  24. global $post_type; 
  25. $screen = get_current_screen(); 
  26.  
  27. if( $post_type == 'shop_order' || ( is_object( $screen ) && strpos( $screen->id, 'myparcel' ) !== false ) ) { 
  28. // WC2.3+ load all WC scripts for shipping_method search! 
  29. if ( version_compare( WOOCOMMERCE_VERSION, '2.3', '>=' ) ) { 
  30. wp_enqueue_script( 'woocommerce_admin' ); 
  31. wp_enqueue_script( 'iris' ); 
  32. if (!wp_script_is( 'wc-enhanced-select', 'registered' )) { 
  33. $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 
  34. wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'select2' ), WC_VERSION ); 
  35. wp_enqueue_script( 'wc-enhanced-select' ); 
  36. wp_enqueue_script( 'jquery-ui-sortable' ); 
  37. wp_enqueue_script( 'jquery-ui-autocomplete' ); 
  38. wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION ); 
  39.  
  40. // Add the color picker css file  
  41. wp_enqueue_style( 'wp-color-picker' );  
  42. wp_enqueue_script( 'thickbox' ); 
  43. wp_enqueue_style( 'thickbox' ); 
  44. wp_enqueue_script( 
  45. 'wcmyparcel-export',  
  46. WooCommerce_MyParcel()->plugin_url() . '/assets/js/wcmp-admin.js',  
  47. array( 'jquery', 'thickbox', 'wp-color-picker' ),  
  48. WC_MYPARCEL_VERSION 
  49. ); 
  50. wp_localize_script( 
  51. 'wcmyparcel-export',  
  52. 'wc_myparcel',  
  53. array(  
  54. 'ajax_url' => admin_url( 'admin-ajax.php' ),  
  55. 'nonce' => wp_create_nonce('wc_myparcel'),  
  56. 'download_display' => isset(WooCommerce_MyParcel()->general_settings['download_display'])?WooCommerce_MyParcel()->general_settings['download_display']:'',  
  57. ); 
  58.  
  59. wp_enqueue_style( 
  60. 'wcmp-admin-styles',  
  61. WooCommerce_MyParcel()->plugin_url() . '/assets/css/wcmp-admin-styles.css',  
  62. array(),  
  63. WC_MYPARCEL_VERSION,  
  64. 'all' 
  65. ); 
  66.  
  67. // Legacy styles (WC 2.1+ introduced MP6 style with larger buttons) 
  68. if ( version_compare( WOOCOMMERCE_VERSION, '2.1', '<=' ) ) { 
  69. wp_enqueue_style( 
  70. 'wcmp-admin-styles-legacy',  
  71. WooCommerce_MyParcel()->plugin_url() . '/assets/css/wcmp-admin-styles-legacy.css',  
  72. array(),  
  73. WC_MYPARCEL_VERSION,  
  74. 'all' 
  75. );