PluginProbe
PostNL for WooCommerce / 3.1.4
PostNL for WooCommerce v3.1.4
5.9.12 5.9.11 5.9.10 5.9.9 5.9.8 5.9.7 5.9.6 trunk 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.1.4 3.1.5 3.1.6 3.1.7 4.0.0 4.0.1 4.0.2 4.3.2 4.3.3 4.4.0 4.4.1 All 72 releases
woo-postnl / includes / class-wcmp-assets.php

class-wcmp-assets.php in PostNL for WooCommerce 3.1.4, at includes/class-wcmp-assets.php

136 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
4
5 if ( ! class_exists('WooCommerce_PostNL_Assets')) :
6
7 class WooCommerce_PostNL_Assets {
8
9 function __construct() {
10 add_action('wp_enqueue_scripts', array($this, 'frontend_scripts_styles'));
11 add_action('admin_enqueue_scripts', array($this, 'backend_scripts_styles'));
12 }
13
14 /**
15 * Load styles & scripts
16 */
17 public function frontend_scripts_styles() {
18 // return if not checkout or order received page
19 if ( ! is_checkout() && ! is_order_received_page()) return;
20
21 // if using split fields
22 if (isset(WooCommerce_PostNL()->checkout_settings['use_split_address_fields'])) {
23 wp_enqueue_script(
24 'wcmp-checkout-fields',
25 WooCommerce_PostNL()->plugin_url() . '/assets/js/wcmp-checkout-fields.js',
26 array('jquery', 'wc-checkout'),
27 WC_POSTNL_VERSION
28 );
29 }
30
31 // return if postnl checkout is not active
32 if ( ! isset(WooCommerce_PostNL()->checkout_settings['postnl_checkout'])) return;
33
34 wp_enqueue_script(
35 'wc-postnl',
36 WooCommerce_PostNL()->plugin_url() . '/assets/js/postnl.js',
37 array('jquery'),
38 WC_POSTNL_VERSION
39 );
40
41 wp_enqueue_script(
42 'wc-postnl-frontend',
43 WooCommerce_PostNL()->plugin_url() . '/assets/js/wcmp-frontend.js',
44 array('jquery', 'wc-postnl'),
45 WC_POSTNL_VERSION
46 );
47
48 wp_localize_script(
49 'wc-postnl-frontend',
50 'wcmp_display_settings',
51 array(
52 'isUsingSplitAddressFields' => isset(
53 WooCommerce_PostNL()->checkout_settings['use_split_address_fields']
54 )
55 )
56 );
57 }
58
59 /**
60 * Load styles & scripts
61 */
62 public function backend_scripts_styles() {
63 global $post_type;
64 $screen = get_current_screen();
65
66 if ($post_type == 'shop_order' || (is_object($screen) && strpos($screen->id, 'postnl') !== false)) {
67 // WC2.3+ load all WC scripts for shipping_method search!
68 if (version_compare(WOOCOMMERCE_VERSION, '2.3', '>=')) {
69 wp_enqueue_script('woocommerce_admin');
70 wp_enqueue_script('iris');
71 if ( ! wp_script_is('wc-enhanced-select', 'registered')) {
72 $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
73 wp_register_script(
74 'wc-enhanced-select',
75 WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js',
76 array('jquery', version_compare(WC()->version, '3.2.0', '>=') ? 'selectWoo' : 'select2'),
77 WC_VERSION
78 );
79 }
80 wp_enqueue_script('wc-enhanced-select');
81 wp_enqueue_script('jquery-ui-sortable');
82 wp_enqueue_script('jquery-ui-autocomplete');
83 wp_enqueue_style(
84 'woocommerce_admin_styles',
85 WC()->plugin_url() . '/assets/css/admin.css',
86 array(),
87 WC_VERSION
88 );
89 }
90
91 // Add the color picker css file
92 wp_enqueue_style('wp-color-picker');
93 wp_enqueue_script('thickbox');
94 wp_enqueue_style('thickbox');
95 wp_enqueue_script(
96 'wcpostnl-export',
97 WooCommerce_PostNL()->plugin_url() . '/assets/js/wcmp-admin.js',
98 array('jquery', 'thickbox', 'wp-color-picker'),
99 WC_POSTNL_VERSION
100 );
101 wp_localize_script(
102 'wcpostnl-export', 'wc_postnl', array(
103 'ajax_url' => admin_url('admin-ajax.php'),
104 'nonce' => wp_create_nonce('wc_postnl'),
105 'download_display' => isset(WooCommerce_PostNL()->general_settings['download_display'])
106 ? WooCommerce_PostNL()->general_settings['download_display']
107 : '',
108 'offset' => isset(WooCommerce_PostNL()->general_settings['print_position_offset'])
109 ? WooCommerce_PostNL()->general_settings['print_position_offset']
110 : '',
111 'offset_icon' => WooCommerce_PostNL()->plugin_url() . '/assets/img/print-offset-icon.png',
112 'offset_label' => __('Labels to skip', 'woocommerce-postnl'),
113 )
114 );
115
116 wp_enqueue_style(
117 'wcmp-admin-styles',
118 WooCommerce_PostNL()->plugin_url() . '/assets/css/wcmp-admin-styles.css',
119 array(),
120 WC_POSTNL_VERSION,
121 'all'
122 );
123
124 // Legacy styles (WC 2.1+ introduced MP6 style with larger buttons)
125 if (version_compare(WOOCOMMERCE_VERSION, '2.1', '<=')) {
126 wp_enqueue_style(
127 'wcmp-admin-styles-legacy', WooCommerce_PostNL()->plugin_url() . '/assets/css/wcmp-admin-styles-legacy.css', array(), WC_POSTNL_VERSION, 'all'
128 );
129 }
130 }
131 }
132 }
133
134 endif; // class_exists
135
136 return new WooCommerce_PostNL_Assets();