Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 305
0.00% covered (danger)
0.00%
0 / 34
CRAP
n/a
0 / 0
zeroBSCRM_scriptStyles_initStyleRegister
0.00% covered (danger)
0.00%
0 / 39
0.00% covered (danger)
0.00%
0 / 1
12
zeroBSCRM_scriptStyles_enqueueJSRoot
0.00% covered (danger)
0.00%
0 / 67
0.00% covered (danger)
0.00%
0 / 1
20
jpcrm_get_jp_green
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_scriptStyles_admin_quoteBuilder
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_scriptStyles_admin_invoiceBuilder
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_scriptStyles_admin_transactionBuilder
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_scriptStyles_admin_formBuilder
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_global_admin_styles
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
20
zeroBSCRM_extension_admin_styles
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_intro_admin_styles
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_email_styles
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_admin_styles_ui2_listview
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_admin_styles_ui2_editview
0.00% covered (danger)
0.00%
0 / 25
0.00% covered (danger)
0.00%
0 / 1
72
zeroBSCRM_settingspage_admin_styles
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
12
zeroBSCRM_admin_styles_ui2_semantic
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_admin_styles_ui2_semantic_settingspage
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_admin_styles_singleview
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
jpcrm_admin_scripts_systems_page
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_admin_styles_homedash
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_admin_scripts_editcust
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_calendar_admin_styles
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_dequeueJSModal
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_add_admin_styles
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 1
1482
zeroBSCRM_load_libs_js_momentdatepicker
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_enqueue_libs_js_momentdatepicker
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_load_libs_js_customerfilters
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_enqueue_libs_js_customerfilters
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_enqueue_media_manager
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_add_admin_segmenteditor_scripts
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
30
zeroBSCRM_mailTemplatesEnqueue
0.00% covered (danger)
0.00%
0 / 24
0.00% covered (danger)
0.00%
0 / 1
90
zeroBSCRM_admin_styles_exportTools
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
jpcrm_crm_resources_page_styles_scripts
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
jpcrm_support_page_styles_scripts
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
zeroBSCRM_forms_scriptsStylesRegister
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/*
3 * Jetpack CRM
4 * https://jetpackcrm.com
5 * V2.4+
6 *
7 * Copyright 2020 Automattic
8 *
9 * Date: 06/02/18
10 */
11// phpcs:disable WordPress.WP.EnqueuedResourceParameters.NotInFooter
12
13#} ===============================================================================
14#} === INIT registration & Global Style & Script setups
15#} ===============================================================================
16
17// WH moved this from core.php in v3.0 (filing)
18// Registers globally used stuff (mostly)
19function zeroBSCRM_scriptStyles_initStyleRegister() {
20
21    global $zbs;
22
23        // ===========================================
24        // ================  Global  =================
25
26            // registers the styles on admin init
27            wp_register_style( 'jpcrm-semanticui-lib', plugins_url( '/build/lib/semantic-ui-css/semantic.min.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
28            wp_register_style( 'zbs-wp-semanticui', plugins_url( '/css/ZeroBSCRM.admin.semantic-ui' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array( 'jpcrm-semanticui-lib' ), $zbs::VERSION );
29            wp_register_script( 'semanticuijs', plugins_url( '/build/lib/semantic-ui-css/semantic.min.js', ZBS_ROOTFILE ), array(), $zbs::VERSION );
30
31            // global
32            wp_register_style( 'zerobscrmadmcss', plugins_url( '/css/ZeroBSCRM.admin.global' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array( 'zbs-wp-semanticui' ), $zbs::VERSION );
33            wp_enqueue_script( 'zerobscrmadmjs', plugins_url( '/js/ZeroBSCRM.admin.global' . wp_scripts_get_suffix() . '.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
34
35            // emerald styles
36            wp_register_style( 'jpcrm-emerald', plugins_url( '/css/jpcrm-emerald' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
37
38        // ================ / Global  ================
39        // ===========================================
40
41        // ===========================================
42        // ============  Page-specific  ==============
43
44            // list view
45            wp_register_style( 'zerobscrmlistview', plugins_url( '/css/ZeroBSCRM.admin.listview' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
46            wp_register_script( 'zerobscrmlistviewjs', plugins_url( '/js/ZeroBSCRM.admin.listview' . wp_scripts_get_suffix() . '.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
47
48                #} localise the list view...
49                // WH note: Pretty sure we do this on page, so should janitor this up (later)
50                $zbs_translation_array = array(
51                    'zbs_edit' => __( 'Edit', 'zero-bs-crm' ),
52                    'zbs_view' => __( 'View', 'zero-bs-crm' ),
53                );
54                wp_localize_script( 'zerobscrmlistviewjs', 'zbs_lang', $zbs_translation_array );
55
56                // Single view
57                wp_register_style( 'zerobscrmsingleview', plugins_url( '/css/ZeroBSCRM.admin.singleview' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
58                wp_register_script( 'zerobscrmsingleview', plugins_url( '/js/ZeroBSCRM.admin.singleview' . wp_scripts_get_suffix() . '.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
59
60                // edit view
61                wp_register_style( 'zerobscrmeditview', plugins_url( '/css/ZeroBSCRM.admin.editview' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
62                wp_register_script( 'zerobscrmeditviewjs', plugins_url( '/js/ZeroBSCRM.admin.editview' . wp_scripts_get_suffix() . '.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
63                wp_register_script( 'zerobscrmtagmetaboxjs', plugins_url( '/js/ZeroBSCRM.admin.tags.metabox' . wp_scripts_get_suffix() . '.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
64
65                // Metabox manager (rearrange them)
66                wp_register_script( 'zerobscrmmm', plugins_url( '/js/ZeroBSCRM.admin.metabox.manager' . wp_scripts_get_suffix() . '.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
67
68                // Segment Editor
69                wp_register_style( 'zbs-segmentedit-css', plugins_url( '/css/ZeroBSCRM.admin.segmentedit' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
70                wp_register_script( 'zbs-segmentedit-js', ZEROBSCRM_URL . '/js/ZeroBSCRM.admin.segmentedit' . wp_scripts_get_suffix() . '.js', array( 'jquery' ), $zbs::VERSION );
71
72                // home dash
73                wp_register_style( 'zerobscrmhomedash', plugins_url( '/css/ZeroBSCRM.admin.homedash' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array( 'zbs-wp-semanticui' ), $zbs::VERSION );
74
75                // settings page
76                wp_register_style( 'zerobscrmsettings', plugins_url( '/css/ZeroBSCRM.admin.settings' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
77
78                // mail delivery wizard
79                wp_register_style( 'zerobscrmmaildeliverywizard', plugins_url( '/css/ZeroBSCRM.admin.maildeliverywizard' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
80
81                // systems page:
82                wp_register_script( 'jpcrmadminsystem', plugins_url( '/js/jpcrm-admin-system' . wp_scripts_get_suffix() . '.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
83
84                // ============ / Page-specific ==============
85                // ===========================================
86
87                // ===========================================
88                // ============  Libs  =======================
89
90                // jq ui
91                wp_register_script( 'zerobscrmadmjqui', plugins_url( '/js/lib/jquery-ui.min.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
92                // above didn't seem to include all libs req for draggable, this does, specific build for listviews
93                // 29/07/2017 http://jqueryui.com/download/#!version=1.12.1&components=111111111111111110000000010000000000000000000000
94                wp_register_script( 'zerobscrmadmjquidraggable', plugins_url( '/js/lib/jquery-ui.1.12.1.dragdrop.listview.min.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
95
96                // jq modal
97                wp_register_style( 'jpcrm-jquery-modal', plugins_url( '/build/lib/jquery-modal/jquery.modal.min.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
98                wp_register_script( 'jpcrm-jquery-modal', plugins_url( '/build/lib/jquery-modal/jquery.modal.min.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
99
100                // font awesome
101                wp_register_style( 'jpcrm-fontawesome', plugins_url( '/build/lib/font-awesome/css/font-awesome.min.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
102
103                // chart.js
104                wp_register_script( 'jpcrm-chartjs', plugins_url( '/build/lib/chart.js/chart.umd.min.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION, true );
105
106                // SweetAlert2
107                wp_register_style( 'zerobscrmswa', plugins_url( '/build/lib/sweetalert2/sweetalert2.min.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
108                wp_enqueue_script( 'zerobscrmswa', plugins_url( '/build/lib/sweetalert2/sweetalert2.min.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
109
110                // typeahead.js
111                wp_enqueue_script( 'jpcrm-typeahead', plugins_url( '/build/lib/typeahead.js/typeahead.bundle.min.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
112
113                // ============ / Libs =======================
114                // ===========================================
115
116                // ===========================================
117                // ============  Whitelabel  =================
118
119                // WL css overrides (3/11/18 ++)
120                // if the file exists, this registers + enqueues css
121                if ( file_exists( dirname( ZBS_ROOTFILE ) . '/css/wl.adm.override.css' ) ) {
122                    wp_enqueue_style( 'zbswladmcss', plugins_url( '/css/wl.adm.override.css', ZBS_ROOTFILE ), array( 'zerobscrmadmcss', 'zerobscrmlistview', 'zerobscrmeditview' ), $zbs::VERSION );
123                }
124
125                // ============ / Whitelabel =================
126                // ===========================================
127
128                // LEGACY SUPPORT for ext's with menus
129                if ( zeroBSCRM_isAdminPage() ) {
130                    zeroBSCRM_global_admin_styles();
131                }
132}
133
134// This builds our globally available jpcrm_root object with formatting etc. settings
135function zeroBSCRM_scriptStyles_enqueueJSRoot() {
136
137    global $zbs;
138
139    // =================================================
140    // ================  Global JS ROOT =================
141    // here we expose root for js /i refs etc.
142    // WH: we also give locale for datetimepickers everywhere (was zbsDateLocaleOverride, now window.zbs_root.localeOptions)
143    /*
144        var localeOpt = {
145        format: "DD.MM.YYYY",
146        cancelLabel: 'Clear'
147    }; */
148    // WH: We also expose our number formats (for js $ formating)
149    $zbscrm_currency_position                  = $zbs->settings->get( 'currency_position' );
150    $zbscrm_currency_format_thousand_separator = $zbs->settings->get( 'currency_format_thousand_separator' );
151    $zbscrm_currency_format_decimal_separator  = $zbs->settings->get( 'currency_format_decimal_separator' );
152    $zbscrm_currency_format_number_of_decimals = $zbs->settings->get( 'currency_format_number_of_decimals' );
153
154    $jpcrm_root = array(
155        'crmname'              => 'Jetpack CRM',
156        'root'                 => ZEROBSCRM_URL,
157        'localeOptions'        => zeroBSCRM_date_localeForDaterangePicker(),
158        'locale'               => get_locale(),
159        'locale_short'         => zeroBSCRM_getLocale( false ),
160        'currencyOptions'      => array(
161            'symbol'            => zeroBSCRM_getCurrencyChr(),
162            'currencyStr'       => zeroBSCRM_getCurrencyStr(),
163            'position'          => $zbscrm_currency_position,
164            'thousandSeparator' => $zbscrm_currency_format_thousand_separator,
165            'decimalSeparator'  => $zbscrm_currency_format_decimal_separator,
166            'noOfDecimals'      => $zbscrm_currency_format_number_of_decimals,
167        ),
168        'timezone_offset'      => (int) get_option( 'gmt_offset' ),
169        'timezone_offset_mins' => ( (int) get_option( 'gmt_offset' ) * 60 ),
170        'wl'                   => ( zeroBSCRM_isWL() ? 1 : -1 ),
171        'dal'                  => 3,
172    );
173
174    // this is for wl peeps, if set it'll override WYSIWYG logo + settings logo
175    $jpcrm_root['crmlogo'] = 'i/icon-32.png';
176
177    // Language strings for global JavaScript usage
178    $lang_array = array(
179        // General action strings
180        'send'              => __( 'Send', 'zero-bs-crm' ),
181        'sent'              => __( 'Sent', 'zero-bs-crm' ),
182        'notsent'           => __( 'Not Sent', 'zero-bs-crm' ),
183        'cancel'            => __( 'Cancel', 'zero-bs-crm' ),
184        'contact'           => __( 'Contact', 'zero-bs-crm' ),
185        'company'           => __( 'Company', 'zero-bs-crm' ),
186        'viewall'           => __( 'View all', 'zero-bs-crm' ),
187
188        // Statement functionality
189        'sendstatement'     => __( 'Send Statement', 'zero-bs-crm' ),
190        'sendstatementaddr' => __( 'Send Statement to Email:', 'zero-bs-crm' ),
191        'enteremail'        => __( 'Enter an Email Address..', 'zero-bs-crm' ),
192        'statementsent'     => __( 'Statement was successfully sent', 'zero-bs-crm' ),
193        'statementnotsent'  => __( 'Statement could not be sent at this time', 'zero-bs-crm' ),
194
195        // Entity types and totals
196        'total'             => __( 'Total', 'zero-bs-crm' ),
197        'totals'            => __( 'Totals', 'zero-bs-crm' ),
198        'quote'             => __( 'Quote', 'zero-bs-crm' ),
199        'quotes'            => __( 'Quotes', 'zero-bs-crm' ),
200        'invoice'           => __( 'Invoice', 'zero-bs-crm' ),
201        'invoices'          => __( 'Invoices', 'zero-bs-crm' ),
202        'transaction'       => __( 'Transaction', 'zero-bs-crm' ),
203        'transactions'      => __( 'Transactions', 'zero-bs-crm' ),
204
205        // daterangepicker ranges
206        'today'             => __( 'Today', 'zero-bs-crm' ),
207        'yesterday'         => __( 'Yesterday', 'zero-bs-crm' ),
208        'last_7_days'       => __( 'Last 7 days', 'zero-bs-crm' ),
209        'last_30_days'      => __( 'Last 30 days', 'zero-bs-crm' ),
210        'this_month'        => __( 'This month', 'zero-bs-crm' ),
211        'last_month'        => __( 'Last month', 'zero-bs-crm' ),
212    );
213
214    $lang_array = apply_filters( 'zbs_globaljs_lang', $lang_array );
215
216    if ( is_array( $lang_array ) && count( $lang_array ) > 0 ) {
217        $jpcrm_root['lang'] = $lang_array;
218    }
219
220    $jpcrm_root['zbsnonce'] = wp_create_nonce( 'zbscrmjs-glob-ajax-nonce' );
221
222    // GENERIC links for building view/edit links in JS globally:
223
224    // v3.0+ - returns a link with _TYPE_ instead of 'contact' etc. used by js func zeroBSCRMJS_obj_viewLink (globally avail)
225    $generic_view_link = str_replace( 'contact', '_TYPE_', jpcrm_esc_link( 'view', -1, 'zerobs_customer', true ) );
226    // v3.0+ - returns a link with _TYPE_ instead of 'contact' etc. used by js func zeroBSCRMJS_obj_editLink (globally avail)
227    $generic_edit_link = str_replace( 'contact', '_TYPE_', jpcrm_esc_link( 'edit', -1, 'zerobs_customer', true ) );
228
229    $jpcrm_root['links'] = array(
230        'generic_view' => $generic_view_link,
231        'generic_edit' => $generic_edit_link,
232    );
233
234    ##WLREMOVE
235    unset( $jpcrm_root['crmlogo'] );
236    ##/WLREMOVE
237
238    $jpcrm_root['jp_green'] = jpcrm_get_jp_green();
239
240    // filter jpcrm_root, allows us to pass js vars directly into the js global via filter
241    $jpcrm_root = apply_filters( 'zbs_globaljs_vars', $jpcrm_root );
242
243    wp_localize_script( 'zerobscrmadmjs', 'zbs_root', $jpcrm_root ); // This relies on the script being registered by zeroBSCRM_initStyleRegister() above
244}
245
246/**
247 * Return an array of JP Green values
248 */
249function jpcrm_get_jp_green() {
250    $jp_green = array(
251        '0'   => '#f0f2eb',
252        '5'   => '#d0e6b8',
253        '10'  => '#9dd977',
254        '20'  => '#64ca43',
255        '30'  => '#2fb41f',
256        '40'  => '#069e08',
257        '50'  => '#008710',
258        '60'  => '#007117',
259        '70'  => '#005b18',
260        '80'  => '#004515',
261        '90'  => '#003010',
262        '100' => '#001c09',
263    );
264
265    return $jp_green;
266}
267
268#} ===============================================================================
269#} === /  INIT registration & Global Style & Script setups
270#} ===============================================================================
271
272#} ===============================================================================
273#} === Edit View individual type functions (e.g. quotebuilder)
274#} ===============================================================================
275
276// Cleaned from messy core.php routine in v3.0
277function zeroBSCRM_scriptStyles_admin_quoteBuilder() {
278
279    global $zbs;
280    wp_enqueue_style( 'zerobscrm-quotebuilder', plugins_url( '/css/ZeroBSCRM.admin.quotebuilder' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
281    wp_enqueue_script( 'zerobscrm-quotebuilderjs', plugins_url( '/js/ZeroBSCRM.admin.quotebuilder' . wp_scripts_get_suffix() . '.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
282}
283
284// Cleaned from messy core.php routine in v3.0
285// NOTE, this was firing on Invoice List View (WH removed 3.0), now only fires on invoice editor (correctly)
286function zeroBSCRM_scriptStyles_admin_invoiceBuilder() {
287
288    global $zbs;
289
290    #}  MS invoice stuff. xxx
291    wp_enqueue_style( 'zerobscrm-invoicebuilder', plugins_url( '/css/ZeroBSCRM.admin.invoicebuilder' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
292    wp_enqueue_script( 'zerobscrm-invoicebuilderjs', plugins_url( '/js/ZeroBSCRM.admin.invoicebuilder' . wp_scripts_get_suffix() . '.js', ZBS_ROOTFILE ), array( 'jquery', 'semanticuijs' ), $zbs::VERSION );
293
294            // localise the invoice builder strings...
295    $zbs_invtranslation_array = array(
296        'zbs_item_name'  => __( 'Item Name', 'zero-bs-crm' ),
297        'zbs_item_desc'  => __( 'Enter a detailed description (optional)', 'zero-bs-crm' ),
298        'zbs_add_row'    => __( 'Add Row', 'zero-bs-crm' ),
299        'zbs_remove_row' => __( 'Remove Row', 'zero-bs-crm' ),
300    );
301
302    $zbs_links = array(
303        'admin_url' => admin_url(),
304    );
305
306    wp_localize_script( 'zerobscrm-invoicebuilderjs', 'zbs_lang', $zbs_invtranslation_array );
307    wp_localize_script( 'zerobscrm-invoicebuilderjs', 'zbs_links', $zbs_links );
308}
309
310// edit transaction page scripts.
311function zeroBSCRM_scriptStyles_admin_transactionBuilder() {
312
313    global $zbs;
314    wp_enqueue_style( 'zerobscrmtranscss', plugins_url( '/css/ZeroBSCRM.admin.transactionedit' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
315    wp_enqueue_script( 'zerobscrm-transedit-js', ZEROBSCRM_URL . 'js/ZeroBSCRM.admin.transactioneditor' . wp_scripts_get_suffix() . '.js', array( 'jquery' ), $zbs::VERSION );
316}
317
318// Cleaned from messy core.php routine in v3.0
319function zeroBSCRM_scriptStyles_admin_formBuilder() {
320
321    global $zbs;
322    wp_enqueue_style( 'zerobscrmformcss', plugins_url( '/css/ZeroBSCRM.admin.frontendforms' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
323}
324
325#} ===============================================================================
326#} === /  Edit View individual type functions (e.g. quotebuilder)
327#} ===============================================================================
328
329#} ===============================================================================
330#} === Unsorted Styles from pre v3.0
331#} ===============================================================================
332function zeroBSCRM_global_admin_styles() {
333
334    global $zbs;
335
336    // It seems we've got this firing multiple times, (WH spotted 2.4), so am putting this lame protection place.
337    // Ideally need to stop it firing twice
338    if ( ! defined( 'ZBS_GAS' ) ) {
339
340        // enqueue these (via the admin_print_styles-{$page})
341
342        // prev core
343        wp_enqueue_style( 'zerobscrmadmcss' );
344        wp_enqueue_style( 'jpcrm-jquery-modal' );
345        wp_enqueue_style( 'jpcrm-fontawesome' );
346        wp_enqueue_style( 'zerobscrmswa' );
347        wp_enqueue_script( 'jpcrm-jquery-modal' );
348
349        // emerald styles
350        wp_enqueue_style( 'jpcrm-emerald' );
351
352        // moment everywhere (from 2.98)
353        wp_enqueue_script( 'jpcrm-moment', ZEROBSCRM_URL . 'build/lib/moment/moment-with-locales.min.js', array( 'jquery' ), $zbs::VERSION, false );
354
355        // semantic everywhere (on our pages)
356        wp_enqueue_style( 'zbs-wp-semanticui' );
357        wp_enqueue_script( 'semanticuijs' );
358
359        do_action( 'zbs-global-admin-styles' );
360
361        // DEFINE ZBS page :)
362        if ( ! defined( 'ZBS_PAGE' ) ) {
363            define( 'ZBS_PAGE', true );
364        }
365
366        // DEFINE ZBS styles fired / dupe check protection
367        if ( ! defined( 'ZBS_GAS' ) ) {
368            define( 'ZBS_GAS', true );
369        }
370    } // / dupe check protection
371}
372
373// 2.98.2 - MS styles tidy up that were inline
374// for the Extension Manager page (was inline)
375function zeroBSCRM_extension_admin_styles() {
376    global $zbs;
377    wp_register_style( 'zerobscrmexts', ZEROBSCRM_URL . 'css/ZeroBSCRM.admin.extensions-page' . wp_scripts_get_suffix() . '.css', array(), $zbs::VERSION );
378    wp_enqueue_style( 'zerobscrmexts' );
379}
380
381// 2.98.2 - MS tidy up of style into compressed sheet (was inline)
382function zeroBSCRM_intro_admin_styles() {
383    global $zbs;
384    wp_register_style( 'zerobscrmintro', ZEROBSCRM_URL . 'css/ZeroBSCRM.admin.intro' . wp_scripts_get_suffix() . '.css', array(), $zbs::VERSION );
385    wp_enqueue_style( 'zerobscrmintro' );
386}
387
388function zeroBSCRM_email_styles() {
389    global $zbs;
390    wp_register_style( 'zerobscrmemails', ZEROBSCRM_URL . 'css/ZeroBSCRM.admin.email' . wp_scripts_get_suffix() . '.css', array(), $zbs::VERSION );
391    wp_enqueue_style( 'zerobscrmemails' );
392    wp_register_script( 'zerobsjsemail', ZEROBSCRM_URL . 'js/ZeroBSCRM.admin.email' . wp_scripts_get_suffix() . '.js', array( 'jquery' ), $zbs::VERSION );
393    wp_enqueue_script( 'zerobsjsemail' );
394    do_action( 'zbs_extra_email_script_styles' );
395}
396function zeroBSCRM_admin_styles_ui2_listview() {
397
398    wp_enqueue_style( 'zerobscrmlistview' );
399    wp_enqueue_script( 'semanticuijs' );
400    // Removed at request of plugin reviewers. (used wp core ver) wp_enqueue_script( 'zerobscrmadmjqui');
401    wp_enqueue_script( 'jquery-ui-sortable' );
402
403    // our list view css
404    wp_enqueue_script( 'zerobscrmlistviewjs' );
405
406    zeroBSCRM_enqueue_libs_js_momentdatepicker();
407
408    // hook to allow modules etc. to add list view stylesheets
409    do_action( 'jpcrm_enqueue_styles_listview' );
410}
411function zeroBSCRM_admin_styles_ui2_editview() {
412
413    // enqueue these (via the admin_print_styles-{$page})
414
415            // Removed at request of plugin reviewers. (used wp core ver) wp_enqueue_script( 'zerobscrmadmjqui');
416            wp_enqueue_script( 'jquery-ui-sortable' );
417            wp_enqueue_style( 'zerobscrmeditview' );
418            wp_enqueue_script( 'semanticuijs' );
419            wp_enqueue_script( 'zerobscrmeditviewjs' );
420            wp_enqueue_script( 'zerobscrmtagmetaboxjs' );
421            wp_enqueue_script( 'zerobscrmmm' ); // metabox manager
422
423            // daterange + moment
424            zeroBSCRM_enqueue_libs_js_momentdatepicker();
425
426            // catch type-specific includes :)
427    if ( isset( $_GET['zbstype'] ) && ! empty( $_GET['zbstype'] ) ) {
428
429        switch ( $_GET['zbstype'] ) {
430
431            case 'quote':
432                zeroBSCRM_scriptStyles_admin_quoteBuilder();
433                break;
434
435            case 'invoice':
436                zeroBSCRM_scriptStyles_admin_invoiceBuilder();
437                break;
438
439            case 'transaction':
440                zeroBSCRM_scriptStyles_admin_transactionBuilder();
441                break;
442
443            case 'form':
444                zeroBSCRM_scriptStyles_admin_formBuilder();
445                break;
446
447            case 'event':
448                zeroBSCRM_calendar_admin_styles();
449                break;
450
451        }
452    }
453
454            // extra scripts (e.g. Twilio Connect hooks into this - otherwise the button will not do anything)
455            do_action( 'zbs_postenqueue_editview' ); // zbs_extra_custeditscripts
456}
457function zeroBSCRM_settingspage_admin_styles() {
458
459    global $zbs;
460
461    // needs datepicker (MS needed for paypal sync, was a gross hack elsewhere so put here)
462    wp_enqueue_script( 'jpcrm-daterangepicker', ZEROBSCRM_URL . 'build/lib/daterangepicker/daterangepicker.js', array( 'jquery' ), $zbs::VERSION );
463
464    wp_enqueue_style( 'zerobscrmsettings' );
465    wp_register_script( 'zerobscrm-settingspage-js', ZEROBSCRM_URL . 'js/ZeroBSCRM.admin.settings' . wp_scripts_get_suffix() . '.js', array( 'jquery' ), $zbs::VERSION );
466    wp_enqueue_script( 'zerobscrm-settingspage-js' );
467
468    #} Field Sorts
469    if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'fieldsorts' ) {
470        wp_enqueue_script( 'zerobscrmadmjqui' );
471
472        #} Our custom sortables css
473        wp_enqueue_style( 'zerobscrmsortscss', plugins_url( '/css/ZeroBSCRM.admin.sortables' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
474    }
475}
476
477/* Placeholder function for Invoicing Pro <= 2.8.3. */
478function zeroBSCRM_admin_styles_ui2_semantic() {}
479
480function zeroBSCRM_admin_styles_ui2_semantic_settingspage() {
481            wp_enqueue_style( 'zerobscrmmaildeliverywizard' );
482            wp_enqueue_style( 'zerobscrmsettings' );
483}
484
485function zeroBSCRM_admin_styles_singleview() {
486
487    // single item view
488    wp_enqueue_style( 'zerobscrmsingleview' );
489    wp_enqueue_script( 'zerobscrmsingleview' );
490}
491
492function jpcrm_admin_scripts_systems_page() {
493
494    wp_enqueue_script( 'jpcrmadminsystem' );
495}
496
497function zeroBSCRM_admin_styles_homedash() {
498    global $zbs;
499    // home dashboard styles and script
500    wp_enqueue_style( 'zerobscrmhomedash' );
501    wp_enqueue_style( 'jpcrm-funnel', ZEROBSCRM_URL . 'css/jpcrm-admin-funnel' . wp_scripts_get_suffix() . '.css', array(), $zbs::VERSION );
502    wp_enqueue_script( 'jpcrm-funnel', ZEROBSCRM_URL . 'js/jpcrm-admin-funnel' . wp_scripts_get_suffix() . '.js', array(), $zbs::VERSION, true );
503    wp_enqueue_script( 'jpcrm-chartjs' );
504    zeroBSCRM_enqueue_libs_js_momentdatepicker();
505    wp_enqueue_script( 'jpcrm-dash', ZEROBSCRM_URL . 'js/ZeroBSCRM.admin.dash' . wp_scripts_get_suffix() . '.js', array( 'jquery' ), $zbs::VERSION, true );
506}
507
508function zeroBSCRM_admin_scripts_editcust() {
509
510    zeroBSCRM_dequeueJSModal();
511
512    // scripts here for the edit customer page (for the "Quick Add Company, Tasks, etc")
513    wp_enqueue_script( 'zerobscrmcustjs' );
514}
515
516function zeroBSCRM_calendar_admin_styles() {
517    global $zbs;
518    zeroBSCRM_enqueue_libs_js_momentdatepicker();
519    wp_enqueue_script( 'jpcrm-fullcalendar', ZEROBSCRM_URL . 'build/lib/fullcalendar/index.global.min.js', array(), $zbs::VERSION, true );
520    wp_enqueue_script( 'jpcrm-tasks', ZEROBSCRM_URL . 'js/jpcrm-admin-tasks' . wp_scripts_get_suffix() . '.js', array( 'jpcrm-fullcalendar' ), $zbs::VERSION, true );
521    wp_enqueue_style( 'jpcrm-tasks', ZEROBSCRM_URL . 'css/jpcrm-admin-tasks' . wp_scripts_get_suffix() . '.css', array(), $zbs::VERSION );
522}
523
524function zeroBSCRM_dequeueJSModal() {
525    wp_dequeue_style( 'jpcrm-jquery-modal' );
526    wp_dequeue_script( 'jpcrm-jquery-modal' );
527}
528
529function zeroBSCRM_add_admin_styles( $hook ) {
530
531    global $post;
532    $zeroBSCRM_custom_slug = '';
533    if ( isset( $_GET['zbsslug'] ) ) {
534        $zeroBSCRM_custom_slug = sanitize_text_field( $_GET['zbsslug'] );
535    }
536
537    if ( $hook == 'post-new.php' || $hook == 'post.php' || $hook == 'edit-tags.php' || 'edit.php' ) { // || $hook == 'edit.php'
538        if ( is_object( $post ) ) {
539            if ( 'zerobs_customer' === $post->post_type || 'zerobs_quote' === $post->post_type || 'zerobs_company' === $post->post_type || 'zerobs_invoice' === $post->post_type || 'zerobs_transaction' === $post->post_type || 'zerobs_form' === $post->post_type || 'zerobs_mailcampaign' === $post->post_type || 'zerobs_event' === $post->post_type || 'zerobs_quo_template' === $post->post_type ) {
540                zeroBSCRM_global_admin_styles();
541                // semantic throughout...
542                if ( 'zerobs_customer' === $post->post_type || 'zerobs_quo_template' === $post->post_type || 'zerobs_transaction' === $post->post_type || 'zerobs_quote' === $post->post_type || 'zerobs_invoice' === $post->post_type || 'zerobs_form' === $post->post_type || 'zerobs_company' === $post->post_type || 'zerobs_event' === $post->post_type ) {
543                    // semantic roll out (in stages)
544                    // These now get rolled into zeroBSCRM_global_admin_styles zeroBSCRM_admin_styles_ui2_semantic();
545
546                    // single customer stuff (like click to SMS etc...)
547                    zeroBSCRM_admin_scripts_editcust();
548
549                    do_action( 'zbs_extra_custeditscripts' );
550                }
551
552                if ( 'zerobs_event' === $post->post_type ) {
553                    zeroBSCRM_calendar_admin_styles();
554                }
555            }
556        } elseif ( isset( $_GET['post_type'] ) && ( $_GET['post_type'] == 'zerobs_customer' || $_GET['post_type'] == 'zerobs_quo_template' || $_GET['post_type'] == 'zerobs_event' || $_GET['post_type'] == 'zerobs_transaction' || $_GET['post_type'] == 'zerobs_company' ) ) {
557            zeroBSCRM_global_admin_styles();
558            // These now get rolled into zeroBSCRM_global_admin_styles zeroBSCRM_admin_styles_ui2_semantic();
559        } elseif ( isset( $_GET['post_type'] ) && ( $_GET['post_type'] == 'zerobs_form' || $_GET['post_type'] == 'zerobs_event' ) ) {
560            zeroBSCRM_global_admin_styles();
561            // These now get rolled into zeroBSCRM_global_admin_styles zeroBSCRM_admin_styles_ui2_semantic();
562        } elseif ( $zeroBSCRM_custom_slug == 'zbs-add-user' || $zeroBSCRM_custom_slug == 'zbs-edit-user' ) {
563            zeroBSCRM_global_admin_styles();
564            // These now get rolled into zeroBSCRM_global_admin_styles zeroBSCRM_admin_styles_ui2_semantic();
565        }
566
567        // this needed to be separate to the above for some reason on some hosts.
568        if ( isset( $_GET['page'] ) && $_GET['page'] == 'zbs-add-edit' ) {
569
570            zeroBSCRM_admin_styles_singleview();
571        }
572    }
573}
574add_action( 'admin_enqueue_scripts', 'zeroBSCRM_add_admin_styles', 10, 1 );
575
576    // THIS IS LEGACY! It's used for <3.0 on CPT edit pages. Otherwise enqueue properly like in zeroBSCRM_settingspage_admin_styles via menus :)
577function zeroBSCRM_load_libs_js_momentdatepicker() {
578    add_action( 'admin_enqueue_scripts', 'zeroBSCRM_enqueue_libs_js_momentdatepicker' );
579}
580
581function zeroBSCRM_enqueue_libs_js_momentdatepicker() {
582
583    global $zbs;
584    wp_enqueue_script( 'jpcrm-daterangepicker', ZEROBSCRM_URL . 'build/lib/daterangepicker/daterangepicker.js', array( 'jquery' ), $zbs::VERSION );
585    #} CSS is wrapped into main plugin css
586}
587
588    #} Customer Filters
589function zeroBSCRM_load_libs_js_customerfilters() {
590    add_action( 'admin_enqueue_scripts', 'zeroBSCRM_enqueue_libs_js_customerfilters' );
591}
592function zeroBSCRM_enqueue_libs_js_customerfilters() {
593
594    global $zbs;
595    #} Customer Filters
596    wp_enqueue_script( 'zbs-js-customerfilters-v1', ZEROBSCRM_URL . '/js/ZeroBSCRM.admin.customerfilters' . wp_scripts_get_suffix() . '.js', array( 'jquery' ), $zbs::VERSION );
597}
598
599    #} Media Manager
600function zeroBSCRM_enqueue_media_manager() {
601    wp_enqueue_media();
602    wp_enqueue_script( 'custom-header' );
603}
604    add_action( 'admin_enqueue_scripts', 'zeroBSCRM_enqueue_media_manager' );
605
606function zeroBSCRM_add_admin_segmenteditor_scripts( $hook ) {
607
608    global $zbs;
609
610    // if our page page=zbs-add-edit&action=edit&zbstype=segment
611    if ( isset( $_GET['page'] ) && $_GET['page'] == $zbs->slugs['addedit'] && isset( $_GET['zbstype'] ) && $_GET['zbstype'] == 'segment' ) {
612
613        // NOTE: these are used in mail campaigns v2, make sure if change name here, change there
614        wp_enqueue_script( 'zbs-segmentedit-js' );
615        wp_enqueue_style( 'zbs-segmentedit-css' );
616        zeroBSCRM_enqueue_libs_js_momentdatepicker();
617    }
618}
619add_action( 'admin_enqueue_scripts', 'zeroBSCRM_add_admin_segmenteditor_scripts' );
620
621// MAIL TEMPLATES
622#} Code Editor - limit to only our edit templates slug... :)
623function zeroBSCRM_mailTemplatesEnqueue() {
624    global $zbs, $pagenow;
625
626    $slug = '';
627    if ( isset( $_GET['page'] ) ) {
628        $slug = sanitize_text_field( $_GET['page'] );
629    }
630    if ( $slug != $zbs->slugs['email-templates'] ) {
631        return;
632    }
633
634    if ( isset( $_GET['zbs_template_editor'] ) && ! empty( $_GET['zbs_template_editor'] ) ) {
635        if ( $_GET['zbs_template_editor'] != 1 ) {
636            return;
637        }
638    }
639
640    if ( ! isset( $_GET['zbs_template_editor'] ) ) {
641        return;
642    }
643
644    // Enqueue code editor and settings for manipulating HTML.
645    $settings = wp_enqueue_code_editor( array( 'type' => 'text/html' ) );
646
647    // Bail if user disabled CodeMirror.
648    if ( false === $settings ) {
649        return;
650    }
651
652    // pass codemirror setting for read-only
653    if ( ! isset( $settings['codemirror'] ) ) {
654        $settings['codemirror'] = array();
655    }
656    $settings['codemirror']['readOnly'] = true;
657
658    wp_add_inline_script(
659        'code-editor',
660        sprintf(
661            'jQuery( function() { wp.codeEditor.initialize( "zbstemplatehtml", %s ); } );',
662            wp_json_encode( $settings )
663        )
664    );
665}
666add_action( 'admin_enqueue_scripts', 'zeroBSCRM_mailTemplatesEnqueue' );
667
668#} ===============================================================================
669#} === / Unsorted Styles from pre v3.0
670#} ===============================================================================
671
672function zeroBSCRM_admin_styles_exportTools() {
673
674    global $zbs;
675
676    wp_register_style( 'zbs-adm-css-export', plugins_url( '/css/ZeroBSCRM.admin.export' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array( 'zbs-wp-semanticui' ), $zbs::VERSION );
677
678    wp_enqueue_style( 'zbs-adm-css-export' );
679}
680
681/**
682 * Styles and scripts for resources page
683 */
684function jpcrm_crm_resources_page_styles_scripts() {
685
686    global $zbs;
687    wp_enqueue_style( 'jpcrm-crm-sync-resources-page', plugins_url( '/css/JetpackCRM.admin.resources-page' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ) );
688}
689
690/**
691 * Styles and scripts for support page
692 */
693function jpcrm_support_page_styles_scripts() {
694
695    global $zbs;
696
697    wp_enqueue_style( 'jpcrm-support-page', plugins_url( 'css/jpcrm.admin.support-page' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
698}
699
700// used in form templates & shortcode outputted forms.
701// https://wordpress.stackexchange.com/questions/165754/enqueue-scripts-styles-when-shortcode-is-present
702function zeroBSCRM_forms_scriptsStylesRegister() {
703
704    global $zbs;
705
706    // js
707    wp_register_script( 'zbsfrontendformsjs', plugins_url( '/js/ZeroBSCRM.public.leadform' . wp_scripts_get_suffix() . '.js', ZBS_ROOTFILE ), array( 'jquery' ), $zbs::VERSION );
708
709    // css
710    wp_register_style( 'zbsfrontendformscss', plugins_url( '/css/ZeroBSCRM.public.frontendforms' . wp_scripts_get_suffix() . '.css', ZBS_ROOTFILE ), array(), $zbs::VERSION );
711}
712add_action( 'wp_enqueue_scripts', 'zeroBSCRM_forms_scriptsStylesRegister' );