| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
class WPCargo_Admin_Scripts{ |
| 6 |
function __construct(){ |
| 7 |
add_action( 'admin_enqueue_scripts', array( $this,'admin_scripts' ) ); |
| 8 |
} |
| 9 |
|
| 10 |
function admin_scripts() { |
| 11 |
global $pagenow, $wpcargo, $post_type; |
| 12 |
$screen = get_current_screen(); |
| 13 |
$options = get_option( 'wpc_mp_settings' ); |
| 14 |
$vat_percentage = !empty($options['wpc_mp_vat_percentage']) ? esc_html($options['wpc_mp_vat_percentage']) : '0'; |
| 15 |
$translation_array = array( |
| 16 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 17 |
'vat_percentage' => '.'.$vat_percentage, |
| 18 |
'deleteElementMessage' => __('Are you sure you want to delete this element?', 'wpcargo' ), |
| 19 |
'autoFillPlaceholder' => __('--Please Select Client--', 'wpcargo' ), |
| 20 |
'date_format' => $wpcargo->date_format, |
| 21 |
'time_format' => $wpcargo->time_format, |
| 22 |
'datetime_format' => $wpcargo->datetime_format, |
| 23 |
); |
| 24 |
// Register Scripts |
| 25 |
wp_register_script( 'wpcargo-datetimepicker', WPCARGO_PLUGIN_URL . 'admin/assets/js/jquery.datetimepicker.full.min.js', array( 'jquery' ), WPCARGO_VERSION, false ); |
| 26 |
wp_register_script( 'wpcargo-repeater-js', WPCARGO_PLUGIN_URL.'admin/assets/js/jquery.repeater.js', array( 'jquery' ), WPCARGO_VERSION, false ); |
| 27 |
wp_register_script( 'wpcargo-admin-js', WPCARGO_PLUGIN_URL.'admin/assets/js/wpcargo-admin.js', array( 'jquery' ), WPCARGO_VERSION, false ); |
| 28 |
wp_register_script( 'wpcargo-select2-js', WPCARGO_PLUGIN_URL.'admin/assets/js/select2.full.min.js', array( 'jquery' ), WPCARGO_VERSION, false ); |
| 29 |
// Register Styles |
| 30 |
wp_register_style('wpcargo-datetimepicker', WPCARGO_PLUGIN_URL . 'admin/assets/css/jquery.datetimepicker.min.css', array(), WPCARGO_VERSION ); |
| 31 |
wp_register_style('wpcargo-select2-css', WPCARGO_PLUGIN_URL . 'admin/assets/css/select2.min.css', array(), WPCARGO_VERSION ); |
| 32 |
wp_register_style('wpcargo-admin-css', WPCARGO_PLUGIN_URL . 'admin/assets/css/admin-style.css', array(), WPCARGO_VERSION ); |
| 33 |
// Enqueue Scripts |
| 34 |
wp_enqueue_script('jquery'); |
| 35 |
// if( $screen->id == 'toplevel_page_wpcargo-settings' ){ |
| 36 |
if( isset($_GET['page'] ) && $_GET['page'] == 'wpcargo-settings' ) { |
| 37 |
wp_enqueue_style( 'wp-color-picker' ); |
| 38 |
// Include our custom jQuery file with WordPress Color Picker dependency |
| 39 |
wp_enqueue_script( 'color-picker-handle', WPCARGO_PLUGIN_URL . 'admin/assets/js/color-picker.js', array( 'wp-color-picker' ), WPCARGO_VERSION, true ); |
| 40 |
} |
| 41 |
|
| 42 |
if(isset($_GET['page']) && strpos($_GET['page'], "wpc") !== false){ |
| 43 |
wp_enqueue_style( 'wpcargo-admin-css' ); |
| 44 |
} |
| 45 |
|
| 46 |
if( ((isset($_GET['post_type']) && $_GET['post_type'] == 'wpcargo_shipment') || $post_type == "wpcargo_shipment") || (isset($_GET['page']) && $_GET['page'] == 'wpcargo-settings') || $post_type == "wpcargo_shipment" ) { |
| 47 |
// Enqueue Styles |
| 48 |
wp_enqueue_style( 'wpcargo-datetimepicker' ); |
| 49 |
wp_enqueue_style( 'wpcargo-admin-css' ); |
| 50 |
wp_enqueue_style( 'wpcargo-multiple-package-style-admin', WPCARGO_PLUGIN_URL. 'admin/assets/css/wpc-mp-admin.css', array(), WPCARGO_VERSION ); |
| 51 |
wp_enqueue_style( 'wpcargo-select2-css' ); |
| 52 |
wp_enqueue_script('wpcargo-datetimepicker'); |
| 53 |
wp_enqueue_script( 'wpcargo-select2-js'); |
| 54 |
wp_enqueue_script( 'wpcargo-repeater-js'); |
| 55 |
wp_enqueue_script( 'wpcargo-admin-js'); |
| 56 |
wp_localize_script( 'wpcargo-admin-js', 'wpcargoAJAXHandler', $translation_array ); |
| 57 |
} |
| 58 |
|
| 59 |
if( isset($_GET['page'] ) && $_GET['page'] == 'wpc-report-export' ) { |
| 60 |
wp_enqueue_script( 'wpcargo-multiselect-export', WPCARGO_PLUGIN_URL. 'admin/assets/js/wpc-multiselect-reports.js' , array( 'jquery' ), WPCARGO_VERSION, false ); |
| 61 |
wp_enqueue_script( 'jquery-ui-autocomplete' ); |
| 62 |
wp_enqueue_script( 'wpc-autocomplete-ajax', WPCARGO_PLUGIN_URL . 'admin/assets/js/wpc-autocomplete-reports.js', array('jquery'), WPCARGO_VERSION, false ); |
| 63 |
wp_localize_script( 'wpc-autocomplete-ajax', 'wpc_ie_ajaxscripthandler', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); |
| 64 |
} |
| 65 |
if(isset( $_GET['page'] ) && ( $_GET['page'] == 'wpcargo-settings' || $_GET['page'] == 'wpc-shmap-settings' ) ){ |
| 66 |
wp_enqueue_media(); |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
new WPCargo_Admin_Scripts; |
| 71 |
|
| 72 |
add_action('admin_head', function(){ |
| 73 |
$options = get_option('wpcargo_option_settings'); |
| 74 |
$baseColor = '#00A924'; |
| 75 |
if( $options ){ |
| 76 |
if( array_key_exists('wpcargo_base_color', $options) ){ |
| 77 |
$baseColor = ( $options['wpcargo_base_color'] ) ? esc_html($options['wpcargo_base_color']) : $baseColor ; |
| 78 |
} |
| 79 |
} |
| 80 |
?> |
| 81 |
<style type="text/css"> |
| 82 |
:root{ |
| 83 |
--main-bg-color: #eee; |
| 84 |
--wpcargo: <?php echo esc_html($baseColor); ?>; |
| 85 |
} |
| 86 |
.dashboard_wpcargo_license_helper_page td input.button.button-primary[name="activate"], |
| 87 |
.wpc-cf-setting-admin input#submit.button.button-primary, |
| 88 |
.email-setting-admin-form input#submit.button.button-primary, |
| 89 |
.book-submit input.button.button-primary.button-wpcargo.button-submit, |
| 90 |
#address-list #book .update .edit-address.button.button-quotation, |
| 91 |
.sms-admin-form input#submit.button, |
| 92 |
.sms-admin-form input[type=checkbox]:checked:before, |
| 93 |
.email-setting-admin-form input[type=checkbox]:checked:before, |
| 94 |
.wpc-cf-setting-admin input[type=checkbox]:checked:before, |
| 95 |
#wpcargo-settings-nav .nav-tab-active, |
| 96 |
#wpcargo-settings-nav .nav-tab-active:focus, |
| 97 |
#wpcargo-settings-nav .nav-tab-active:hover, |
| 98 |
#wpcargo-settings-nav .nav-tab:focus, |
| 99 |
#wpcargo-settings-nav .nav-tab:hover, |
| 100 |
.wpc-ie-tab .nav-tab-active, .wpc-ie-tab .nav-tab:hover, |
| 101 |
#wpc-ie-form .button-primary, #wpc-ie-form .button-primary:hover, |
| 102 |
.wpcargo_shipment_page_wpc-ie-export #multi-select-export .col-xs-2 .btn.btn-block, |
| 103 |
.wpcargo_shipment_page_wpc-ie-import #multi-select-export .col-xs-2 .btn.btn-block, |
| 104 |
.wpcargo-settings table.form-table tr #choose-image, |
| 105 |
.wpcargo-settings input.button.button-primary, |
| 106 |
.post-type-wpcargo_shipment form#post input.wpc-add, |
| 107 |
.post-type-wpcargo_shipment form#post #shipment-history .button-primary, |
| 108 |
.post-type-wpcargo_shipment form#post .wpcargo-pod #wpcargo_select_gallery_pod, |
| 109 |
.post-type-wpcargo_shipment form#post .button, |
| 110 |
.post-type-wpcargo_shipment #shipment-history thead th, |
| 111 |
.post-type-wpcargo_shipment #wpcargo-multiple-package thead th, |
| 112 |
.post-type-shipment_container form#post input.wpc-add, |
| 113 |
.post-type-shipment_container form#post .button, |
| 114 |
.post-type-pq_order form#post #pq-add, |
| 115 |
.post-type-pq_order form#post #publish, |
| 116 |
.post-type-pq_order #send-quotation, |
| 117 |
.post-type-parcel form#post #publish, |
| 118 |
#wpc_add_meta_box input[type=checkbox]:checked:before, |
| 119 |
.wpcargo-settings input[type=checkbox]:checked:before, |
| 120 |
#wpc-import-export-checklist #categorychecklist li input[type=checkbox]:checked:before, |
| 121 |
#multi-select-export .col-xs-2 .btn.btn-block, |
| 122 |
input[type=checkbox].wpc-checkbox:checked:before, |
| 123 |
.wpc-button{ |
| 124 |
background-color: var(--wpcargo) !important; |
| 125 |
color:#fff; |
| 126 |
} |
| 127 |
</style> |
| 128 |
<?php |
| 129 |
}); |