/** * Load the plugin's Style Sheet and Javascript files * * @since 0.1 * * @param string Name of the page being loaded * * @return void */ public static function mla_admin_enqueue_scripts_action($page_hook) { global $wp_locale; $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; if ('checked' != MLAOptions::mla_get_option(MLAOptions::MLA_SCREEN_DISPLAY_LIBRARY)) { wp_register_style(self::STYLESHEET_SLUG . '-nolibrary', MLA_PLUGIN_URL . 'css/mla-nolibrary.css', false, self::CURRENT_MLA_VERSION); wp_enqueue_style(self::STYLESHEET_SLUG . '-nolibrary'); } if ('edit-tags.php' == $page_hook) { wp_register_style(self::STYLESHEET_SLUG, MLA_PLUGIN_URL . 'css/mla-edit-tags-style.css', false, self::CURRENT_MLA_VERSION); wp_enqueue_style(self::STYLESHEET_SLUG); return; } if ('media_page_' . self::ADMIN_PAGE_SLUG != $page_hook) { return; } /* * Add the styles for variable-size icon and WP 4.3 primary column display */ add_action('admin_print_styles', 'MLA::mla_admin_print_styles_action'); if ($wp_locale->is_rtl()) { wp_register_style(self::STYLESHEET_SLUG, MLA_PLUGIN_URL . 'css/mla-style-rtl.css', false, self::CURRENT_MLA_VERSION); } else { wp_register_style(self::STYLESHEET_SLUG, MLA_PLUGIN_URL . 'css/mla-style.css', false, self::CURRENT_MLA_VERSION); } wp_enqueue_style(self::STYLESHEET_SLUG); wp_register_style(self::STYLESHEET_SLUG . '-set-parent', MLA_PLUGIN_URL . 'css/mla-style-set-parent.css', false, self::CURRENT_MLA_VERSION); wp_enqueue_style(self::STYLESHEET_SLUG . '-set-parent'); wp_enqueue_script(self::JAVASCRIPT_INLINE_EDIT_SLUG, MLA_PLUGIN_URL . "js/mla-inline-edit-scripts{$suffix}.js", array('wp-lists', 'suggest', 'jquery'), self::CURRENT_MLA_VERSION, false); wp_enqueue_script(self::JAVASCRIPT_INLINE_EDIT_SLUG . '-set-parent', MLA_PLUGIN_URL . "js/mla-set-parent-scripts{$suffix}.js", array('wp-lists', 'suggest', 'jquery', self::JAVASCRIPT_INLINE_EDIT_SLUG), self::CURRENT_MLA_VERSION, false); MLAModal::mla_add_terms_search_scripts(); $fields = array('post_title', 'post_name', 'post_excerpt', 'post_content', 'image_alt', 'post_parent', 'post_parent_title', 'menu_order', 'post_author'); $custom_fields = MLAOptions::mla_custom_field_support('quick_edit'); $custom_fields = array_merge($custom_fields, MLAOptions::mla_custom_field_support('bulk_edit')); foreach ($custom_fields as $slug => $details) { $fields[] = $slug; } $fields = apply_filters('mla_list_table_inline_fields', $fields); $script_variables = array('fields' => $fields, 'ajaxFailError' => __('An ajax.fail error has occurred. Please reload the page and try again.', 'media-library-assistant'), 'ajaxDoneError' => __('An ajax.done error has occurred. Please reload the page and try again.', 'media-library-assistant'), 'error' => __('Error while saving the changes.', 'media-library-assistant'), 'ntdelTitle' => __('Remove From Bulk Edit', 'media-library-assistant'), 'noTitle' => __('(no title)', 'media-library-assistant'), 'bulkTitle' => __('Bulk Edit items', 'media-library-assistant'), 'bulkWaiting' => __('Waiting', 'media-library-assistant'), 'bulkComplete' => __('Complete', 'media-library-assistant'), 'bulkUnchanged' => __('Unchanged', 'media-library-assistant'), 'bulkSuccess' => __('Succeeded', 'media-library-assistant'), 'bulkFailure' => __('Failed', 'media-library-assistant'), 'bulkCanceled' => __('CANCELED', 'media-library-assistant'), 'bulkChunkSize' => MLAOptions::mla_get_option(MLAOptions::MLA_BULK_CHUNK_SIZE), 'comma' => _x(',', 'tag_delimiter', 'media-library-assistant'), 'useSpinnerClass' => false, 'ajax_action' => self::JAVASCRIPT_INLINE_EDIT_SLUG, 'ajax_nonce' => wp_create_nonce(self::MLA_ADMIN_NONCE_ACTION, MLA::MLA_ADMIN_NONCE_NAME)); if (version_compare(get_bloginfo('version'), '4.2', '>=')) { $script_variables['useSpinnerClass'] = true; } wp_localize_script(self::JAVASCRIPT_INLINE_EDIT_SLUG, self::JAVASCRIPT_INLINE_EDIT_OBJECT, $script_variables); }
/** * Enqueues the mla-media-modal-scripts.js file, adding it to the Media Manager scripts. * Declared public because it is an action. * * @since 1.20 * * @return void */ public static function mla_wp_enqueue_media_action() { global $wp_locale; /* * If we know what screen we're on we can test our enabling options */ if (function_exists('get_current_screen')) { $screen = get_current_screen(); if (is_object($screen)) { if ('upload' == $screen->base) { if ('checked' != MLACore::mla_get_option(MLACoreOptions::MLA_MEDIA_GRID_TOOLBAR)) { return; } } elseif ('checked' != MLACore::mla_get_option(MLACoreOptions::MLA_MEDIA_MODAL_TOOLBAR)) { return; } } } $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; if ($wp_locale->is_rtl()) { wp_register_style(self::JAVASCRIPT_MEDIA_MODAL_STYLES, MLA_PLUGIN_URL . 'css/mla-media-modal-style-rtl.css', false, MLACore::CURRENT_MLA_VERSION); } else { wp_register_style(self::JAVASCRIPT_MEDIA_MODAL_STYLES, MLA_PLUGIN_URL . 'css/mla-media-modal-style.css', false, MLACore::CURRENT_MLA_VERSION); } wp_enqueue_style(self::JAVASCRIPT_MEDIA_MODAL_STYLES); wp_enqueue_script(self::JAVASCRIPT_MEDIA_MODAL_SLUG, MLA_PLUGIN_URL . "js/mla-media-modal-scripts{$suffix}.js", array('media-views', 'wp-lists', 'suggest'), MLACore::CURRENT_MLA_VERSION, false); if ('checked' == MLACore::mla_get_option(MLACoreOptions::MLA_MEDIA_MODAL_TERMS_SEARCH)) { MLAModal::mla_add_terms_search_scripts(); } }