admin
4 years ago
field-groups
4 years ago
fields
4 years ago
fields-settings
4 years ago
forms
4 years ago
locations
4 years ago
modules
4 years ago
acfe-field-functions.php
4 years ago
acfe-field-group-functions.php
4 years ago
acfe-file-functions.php
4 years ago
acfe-form-functions.php
4 years ago
acfe-helper-functions.php
4 years ago
acfe-meta-functions.php
4 years ago
acfe-post-functions.php
4 years ago
acfe-screen-functions.php
4 years ago
acfe-template-functions.php
4 years ago
acfe-term-functions.php
4 years ago
acfe-user-functions.php
4 years ago
acfe-wp-functions.php
4 years ago
assets.php
4 years ago
compatibility.php
4 years ago
hooks.php
4 years ago
init.php
4 years ago
local-meta.php
4 years ago
multilang.php
4 years ago
settings.php
4 years ago
upgrades.php
4 years ago
assets.php
112 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')) |
| 4 | exit; |
| 5 | |
| 6 | if(!class_exists('acfe_assets')): |
| 7 | |
| 8 | class acfe_assets{ |
| 9 | |
| 10 | /* |
| 11 | * Construct |
| 12 | */ |
| 13 | function __construct(){ |
| 14 | |
| 15 | // Hooks |
| 16 | add_action('init', array($this, 'init')); |
| 17 | add_action('admin_enqueue_scripts', array($this, 'wp_admin_enqueue_scripts')); |
| 18 | add_action('acf/input/admin_enqueue_scripts', array($this, 'acf_admin_enqueue_scripts')); |
| 19 | |
| 20 | } |
| 21 | |
| 22 | /* |
| 23 | * Init |
| 24 | */ |
| 25 | function init(){ |
| 26 | |
| 27 | $version = ACFE_VERSION; |
| 28 | $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
| 29 | |
| 30 | // register scripts |
| 31 | wp_register_script('acf-extended', acfe_get_url("assets/js/acfe{$min}.js"), array('acf-input'), $version); |
| 32 | wp_register_script('acf-extended-input', acfe_get_url("assets/js/acfe-input{$min}.js"), array('acf-extended'), $version); |
| 33 | wp_register_script('acf-extended-admin', acfe_get_url("assets/js/acfe-admin{$min}.js"), array('acf-extended'), $version); |
| 34 | wp_register_script('acf-extended-field-group', acfe_get_url("assets/js/acfe-field-group{$min}.js"), array('acf-field-group'), $version); |
| 35 | wp_register_script('acf-extended-ui', acfe_get_url("assets/js/acfe-ui{$min}.js"), array('acf-extended'), $version); |
| 36 | |
| 37 | // register styles |
| 38 | wp_register_style('acf-extended', acfe_get_url("assets/css/acfe{$min}.css"), array(), $version); |
| 39 | wp_register_style('acf-extended-input', acfe_get_url("assets/css/acfe-input{$min}.css"), array(), $version); |
| 40 | wp_register_style('acf-extended-admin', acfe_get_url("assets/css/acfe-admin{$min}.css"), array(), $version); |
| 41 | wp_register_style('acf-extended-field-group', acfe_get_url("assets/css/acfe-field-group{$min}.css"), array(), $version); |
| 42 | wp_register_style('acf-extended-ui', acfe_get_url("assets/css/acfe-ui{$min}.css"), array(), $version); |
| 43 | |
| 44 | } |
| 45 | |
| 46 | /* |
| 47 | * WP Admin Enqueue Scripts |
| 48 | */ |
| 49 | function wp_admin_enqueue_scripts(){ |
| 50 | |
| 51 | // Admin |
| 52 | wp_enqueue_style('acf-extended-admin'); |
| 53 | |
| 54 | // Field Group |
| 55 | if(acf_is_screen(array('edit-acf-field-group', 'acf-field-group'))){ |
| 56 | |
| 57 | wp_enqueue_style('acf-extended-field-group'); |
| 58 | |
| 59 | } |
| 60 | |
| 61 | } |
| 62 | |
| 63 | /* |
| 64 | * ACF Admin Enqueue Scripts |
| 65 | */ |
| 66 | function acf_admin_enqueue_scripts(){ |
| 67 | |
| 68 | // Global |
| 69 | wp_enqueue_style('acf-extended'); |
| 70 | wp_enqueue_script('acf-extended'); |
| 71 | |
| 72 | // Input |
| 73 | wp_enqueue_style('acf-extended-input'); |
| 74 | wp_enqueue_script('acf-extended-input'); |
| 75 | |
| 76 | // Admin |
| 77 | if(is_admin()){ |
| 78 | |
| 79 | wp_enqueue_script('acf-extended-admin'); |
| 80 | |
| 81 | } |
| 82 | |
| 83 | // Field Group |
| 84 | if(acf_is_screen(array('acf-field-group'))){ |
| 85 | |
| 86 | wp_enqueue_script('acf-extended-field-group'); |
| 87 | |
| 88 | } |
| 89 | |
| 90 | acf_localize_data(array( |
| 91 | 'acfe' => array( |
| 92 | 'version' => ACFE_VERSION, |
| 93 | 'home_url' => home_url(), |
| 94 | 'is_admin' => is_admin(), |
| 95 | 'is_user_logged_in' => is_user_logged_in(), |
| 96 | ) |
| 97 | )); |
| 98 | |
| 99 | acf_localize_text(array( |
| 100 | 'Close' => __('Close', 'acfe'), |
| 101 | 'Read more' => __('Read more', 'acfe'), |
| 102 | 'Details' => __('Details', 'acfe'), |
| 103 | 'Debug' => __('Debug', 'acfe'), |
| 104 | )); |
| 105 | |
| 106 | } |
| 107 | |
| 108 | } |
| 109 | |
| 110 | new acfe_assets(); |
| 111 | |
| 112 | endif; |