| 1 |
<?php // Theme Switcha - Enqueue Resources |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) exit; |
| 4 |
|
| 5 |
function theme_switcha_enqueue_resources_admin() { |
| 6 |
|
| 7 |
$screen_id = theme_switcha_get_current_screen_id(); |
| 8 |
|
| 9 |
if ($screen_id === 'settings_page_theme_switcha_settings') { |
| 10 |
|
| 11 |
// wp_enqueue_style($handle, $src, $deps, $ver, $media) |
| 12 |
|
| 13 |
wp_enqueue_style('wp-jquery-ui-dialog'); |
| 14 |
|
| 15 |
wp_enqueue_style('theme-switcha-font-icons', THEME_SWITCHA_URL .'css/font-icons.css', array(), THEME_SWITCHA_VERSION); |
| 16 |
|
| 17 |
wp_enqueue_style('theme-switcha-settings', THEME_SWITCHA_URL .'css/settings.css', array(), THEME_SWITCHA_VERSION); |
| 18 |
|
| 19 |
// wp_enqueue_script($handle, $src, $deps, $ver, $in_footer) |
| 20 |
|
| 21 |
$js_deps = array('jquery', 'jquery-ui-core', 'jquery-ui-dialog'); |
| 22 |
|
| 23 |
wp_enqueue_script('theme_switcha_settings', THEME_SWITCHA_URL .'js/settings.js', $js_deps, THEME_SWITCHA_VERSION); |
| 24 |
|
| 25 |
$data = theme_switcha_print_js_vars_admin(); |
| 26 |
|
| 27 |
wp_localize_script('theme_switcha_settings', 'theme_switcha_settings', $data); |
| 28 |
|
| 29 |
} |
| 30 |
|
| 31 |
} |
| 32 |
|
| 33 |
function theme_switcha_print_js_vars_admin() { |
| 34 |
|
| 35 |
$data = array( |
| 36 |
'reset_title' => __('Confirm Reset', 'theme-switcha'), |
| 37 |
'reset_message' => __('Restore default options?', 'theme-switcha'), |
| 38 |
'reset_true' => __('Yes, make it so.', 'theme-switcha'), |
| 39 |
'reset_false' => __('No, abort mission.', 'theme-switcha'), |
| 40 |
); |
| 41 |
|
| 42 |
return $data; |
| 43 |
|
| 44 |
} |
| 45 |
|
| 46 |
function theme_switcha_get_current_screen_id() { |
| 47 |
|
| 48 |
if (!function_exists('get_current_screen')) require_once ABSPATH .'/wp-admin/includes/screen.php'; |
| 49 |
|
| 50 |
$screen = get_current_screen(); |
| 51 |
|
| 52 |
if ($screen && property_exists($screen, 'id')) return $screen->id; |
| 53 |
|
| 54 |
return false; |
| 55 |
|
| 56 |
} |
| 57 |
|