/** * Enqueues styles and scripts for the admin settings page. * @param $hook string The hook. */ public static function enqueueScriptsAndStyles($hook) { include_once DG_PATH . 'admin/class-feature-pointers.php'; DG_FeaturePointers::enqueueScripts(); if (in_array($hook, array(DG_Admin::$hook, 'post.php', 'post-new.php'), true)) { // Settings Page DG_Util::enqueueAsset('document-gallery-admin', 'assets/css/admin.css'); if ($hook !== self::$hook && get_post_type(get_the_ID()) !== 'attachment') { //if $hook is 'post.php' or 'post-new.php' and it's not an attachment page global $dg_options; // Media Manager integration add_action('admin_print_footer_scripts', array('DG_Admin', 'loadCustomTemplates')); //wp_print_scripts || wp_footer DG_Util::enqueueAsset('dg-media-manager', 'assets/js/media_manager.js', array('media-views')); wp_localize_script('dg-media-manager', 'DGl10n', array('dgMenuTitle' => __('Create Document Gallery', 'document-gallery'), 'dgButton' => __('Create a new Document Gallery', 'document-gallery'), 'canceldgTitle' => '← ' . __('Cancel Document Gallery', 'document-gallery'), 'updatedg' => __('Update Document Gallery', 'document-gallery'), 'insertdg' => __('Insert Document Gallery', 'document-gallery'), 'addTodg' => __('Add to Document Gallery', 'document-gallery'), 'addTodgTitle' => __('Add to Document Gallery', 'document-gallery'), 'editdgTitle' => __('Edit Document Gallery', 'document-gallery'), 'unfitSCalert' => __('This DG shortcode is an advanced one. ' . 'Sorry there is no way to use standard edit dialog for it. ' . 'You should switch to text mode to edit shortcode itself.', 'document-gallery'))); wp_localize_script('dg-media-manager', 'dgDefaults', $dg_options['gallery']); // TinyMCE visual editor add_filter('mce_external_plugins', array(__CLASS__, 'mce_external_plugins')); add_filter('mce_css', array(__CLASS__, 'dg_plugin_mce_css')); } else { DG_Util::enqueueAsset('document-gallery-admin', 'assets/js/admin.js', array('jquery')); wp_localize_script('document-gallery-admin', 'dg_admin_vars', array('upload_limit' => wp_max_upload_size())); } } }
/** * Enqueue script for Document Gallery frontend. */ public static function enqueueGalleryScript() { DG_Util::enqueueAsset('document-gallery', 'assets/js/gallery.js', array('jquery')); }