public function _actionRegisterViewsButton() { if (!class_exists('WP_Views')) { remove_action('wp_enqueue_scripts', array($this, '_actionScriptsAndStyles')); $this->isLoaded(); return; } $view = new WP_Views(); $view->wpv_register_assets(); $view->add_dialog_to_editors(); }
function init() { add_filter('custom_menu_order', array($this, 'enable_custom_menu_order')); add_filter('menu_order', array($this, 'custom_menu_order')); global $wp_version; if (version_compare($wp_version, '3.3', '>=')) { add_action('admin_head-edit.php', array($this, 'admin_add_help')); add_action('admin_head-post.php', array($this, 'admin_add_help')); add_action('admin_head-post-new.php', array($this, 'admin_add_help')); } add_action('admin_head-post.php', array($this, 'admin_add_errors')); add_action('admin_head-post-new.php', array($this, 'admin_add_errors')); parent::init(); add_action('wp_ajax_wpv_get_types_field_name', array($this, 'wpv_ajax_wpv_get_types_field_name')); add_action('wp_ajax_wpv_get_taxonomy_name', array($this, 'wpv_ajax_wpv_get_taxonomy_name')); if (is_admin()) { add_action('admin_print_scripts', array($this, 'add_views_settings_js')); add_action('admin_print_scripts', array($this, 'add_views_syntax_highlighting_js')); } /* Add hooks for Module Manager Integration */ if (defined('MODMAN_PLUGIN_NAME')) { add_filter('wpmodules_register_sections', array($this, 'register_modules_sections'), 20, 1); add_filter('wpmodules_register_items_' . _VIEWS_MODULE_MANAGER_KEY_, array($this, 'register_modules_views_items'), 30, 1); add_filter('wpmodules_export_items_' . _VIEWS_MODULE_MANAGER_KEY_, array($this, 'export_modules_views_items'), 10, 2); add_filter('wpmodules_import_items_' . _VIEWS_MODULE_MANAGER_KEY_, array($this, 'import_modules_views_items'), 10, 3); add_filter('wpmodules_items_check_' . _VIEWS_MODULE_MANAGER_KEY_, array($this, 'check_modules_views_items'), 10, 1); add_filter('wpmodules_register_items_' . _VIEW_TEMPLATES_MODULE_MANAGER_KEY_, array($this, 'register_modules_view_templates_items'), 20, 1); add_filter('wpmodules_export_items_' . _VIEW_TEMPLATES_MODULE_MANAGER_KEY_, array($this, 'export_modules_view_templates_items'), 10, 2); add_filter('wpmodules_import_items_' . _VIEW_TEMPLATES_MODULE_MANAGER_KEY_, array($this, 'import_modules_view_templates_items'), 10, 3); add_filter('wpmodules_items_check_' . _VIEW_TEMPLATES_MODULE_MANAGER_KEY_, array($this, 'check_modules_view_templates_items'), 10, 1); } }
function init() { add_filter('custom_menu_order', array($this, 'enable_custom_menu_order')); add_filter('menu_order', array($this, 'custom_menu_order')); global $wp_version; if (version_compare($wp_version, '3.3', '>=')) { add_action('admin_head-edit.php', array($this, 'admin_add_help')); add_action('admin_head-post.php', array($this, 'admin_add_help')); add_action('admin_head-post-new.php', array($this, 'admin_add_help')); } parent::init(); add_action('wp_ajax_wpv_get_types_field_name', array($this, 'wpv_ajax_wpv_get_types_field_name')); add_action('wp_ajax_wpv_get_taxonomy_name', array($this, 'wpv_ajax_wpv_get_taxonomy_name')); if (is_admin()) { add_action('admin_print_scripts', array($this, 'add_views_settings_js')); } }
function wpv_admin_enqueue_scripts($hook) { // echo $hook; TODO this function needs a lot of love /** * Registering all scripts */ /** * Register scripts and styles needed in the embedded version too: * * Scripts: * toolset-colorbox * select2 * views-utils-script * CodeMirror * Pointers * * Styles: * toolset-font-awesome * toolset-colorbox * views-notifications-css * views-dialogs-css * select2 * views-codemirror-css */ parent::wpv_admin_enqueue_scripts($hook); // Views, WPA and CT edit screens JS // @todo on a future revision, once common is spread, make **_editor.js depend on icl_editor-script and remove fallbacks wp_register_script('views-editor-js', WPV_URL . "/res/js/redesign/views_editor.js", array('jquery', 'wp-pointer', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tooltip', 'views-codemirror-conf-script', 'underscore', 'views-utils-script', 'quicktags', 'wplink'), WPV_VERSION, true); wp_register_script('views-filters-js', WPV_URL . "/res/js/redesign/views_section_filters.js", array('views-editor-js'), WPV_VERSION, true); wp_register_script('views-pagination-js', WPV_URL . "/res/js/redesign/views_section_pagination.js", array('views-editor-js'), WPV_VERSION, true); wp_register_script('views-update-js', WPV_URL . "/res/js/redesign/views_sections_update.js", array('views-editor-js'), WPV_VERSION, true); wp_register_script('views-archive-editor-js', WPV_URL . "/res/js/redesign/views_archive_editor.js", array('jquery', 'wp-pointer', 'jquery-ui-sortable', 'jquery-ui-draggable', 'views-codemirror-conf-script', 'underscore', 'views-utils-script', 'quicktags', 'wplink'), WPV_VERSION, true); wp_register_script('views-archive-update-js', WPV_URL . "/res/js/redesign/views_archives_sections_update.js", array('views-archive-editor-js'), WPV_VERSION, true); wp_register_script('views-layout-template-js', WPV_URL . "/res/js/redesign/views_section_layout_template.js", array('jquery'), WPV_VERSION, true); wp_register_script('views-redesign-media-manager-js', WPV_URL . "/res/js/redesign/views_media_manager.js", array('jquery'), WPV_VERSION, true); wp_register_script('views-layout-wizard-script', WPV_URL . '/res/js/redesign/views_layout_edit_wizard.js', array('jquery'), WPV_VERSION, true); wp_register_script('views-content-template-js', WPV_URL . '/res/js/redesign/views_content_template.js', array('jquery', 'wp-pointer', 'jquery-ui-sortable', 'jquery-ui-draggable', 'views-codemirror-conf-script', 'underscore', 'views-utils-script', 'quicktags', 'wplink'), WPV_VERSION, true); // Suggestion Script for Views edit screen wp_register_script('views-suggestion_script', WPV_URL . "/res/js/redesign/suggestion_script.js", array(), WPV_VERSION, true); wp_register_style('views_suggestion_style', WPV_URL . '/res/css/token-input.css', array(), WPV_VERSION); wp_register_style('views_suggestion_style2', WPV_URL . '/res/css/token-input-wpv-theme.css', array(), WPV_VERSION); // Listing JS wp_register_script('views-listing-common-script', WPV_URL . '/res/js/redesign/wpv_listing_common.js', array('jquery'), WPV_VERSION, true); wp_register_script('views-listing-script', WPV_URL . '/res/js/redesign/views_listing_page.js', array('jquery', 'views-listing-common-script'), WPV_VERSION, true); wp_register_script('views-archive-listing-script', WPV_URL . '/res/js/redesign/views_wordpress_archive_listing_page.js', array('jquery', 'views-listing-common-script'), WPV_VERSION, true); wp_register_script('views-content-template-listing-script', WPV_URL . '/res/js/redesign/wpv_content_template_listing.js', array('jquery', 'views-listing-common-script'), WPV_VERSION, true); // Update help wp_register_script('views-update-help-js', WPV_URL . '/res/js/views_admin_update_help.js', array('jquery'), WPV_VERSION, true); // NOTE knockout and parametric.js files need to be enqueued at admin_header time for some reason, registered and enqueued in editor-addon-parametric-class.php in common /** * Enqueue actions */ // Basic WordPress scripts & styles wp_enqueue_script('wp-pointer'); wp_enqueue_style('wp-pointer'); wp_enqueue_script('thickbox'); // TODO maybe DEPRECATED wp_enqueue_style('thickbox'); // TODO maybe DEPRECATED // External libraries scripts if (isset($_GET['page']) && ($_GET['page'] == 'views' || $_GET['page'] == 'view-archives' || $_GET['page'] == 'view-templates' || $_GET['page'] == 'views-editor' || $_GET['page'] == 'view-archives-editor' || strpos($_SERVER['QUERY_STRING'], 'help.php') !== false)) { if ($_GET['page'] == 'views-editor') { // TODO WTF is it doing here? delete_transient('wpv_layout_wizard_save_settings'); } wp_enqueue_script('views-utils-script'); $help_box_translations = array('wpv_dont_show_it_again' => __("Got it! Don't show this message again", 'wpv-views'), 'wpv_close' => __("Close", 'wpv-views')); wp_localize_script('views-utils-script', 'wpv_help_box_texts', $help_box_translations); // Views shortcodes GUI script wp_enqueue_script('views-shortcodes-gui-script'); // CodeMirror NOTE add to Views and Content Templates edit screen only if ($_GET['page'] == 'views-editor' || $_GET['page'] == 'view-archives-editor') { wp_enqueue_script('views-codemirror-script'); wp_enqueue_script('views-codemirror-overlay-script'); wp_enqueue_script('views-codemirror-xml-script'); wp_enqueue_script('views-codemirror-css-script'); wp_enqueue_script('views-codemirror-js-script'); wp_enqueue_script('views-codemirror-addon-searchcursor-script'); wp_enqueue_script('views-codemirror-addon-panel-script'); wp_enqueue_script('views-codemirror-conf-script'); wp_enqueue_style('views-codemirror-css'); //Codemirror:Quicktags:Add link popup styles and html wp_enqueue_style('editor-buttons'); } // Shared ToolSet CSS wp_enqueue_style('toolset-font-awesome'); // General Views CSS wp_enqueue_style('views-admin-css'); } // Views screens - import/export and help if ($hook == 'views_page_views-import-export' || $hook == 'wp-views/menu/help.php') { wp_enqueue_style('views-admin-css'); } // Views listing page if (isset($_GET['page']) && $_GET['page'] == 'views') { wp_enqueue_script('views-listing-script'); } if (isset($_GET['page']) && $_GET['page'] == 'view-archives') { wp_enqueue_script('views-archive-listing-script'); } if (isset($_GET['page']) && $_GET['page'] == 'view-templates') { wp_enqueue_script('views-content-template-listing-script'); } // Views and WPA editors // To Juan: check this code after 2-3 versions $media_manager_translations = array('only_img_allowed_here' => __("You can only use an image file here", 'wpv-views')); $editor_translations = array('meta_html_extra_css_open' => __('Open CSS editor', 'wpv-views'), 'meta_html_extra_css_close' => __('Close CSS editor', 'wpv-views'), 'meta_html_extra_js_open' => __('Open JS editor', 'wpv-views'), 'meta_html_extra_js_close' => __('Close JS editor', 'wpv-views')); $inline_content_templates_translations = array('new_template_name_in_use' => __('A Content Template with that name already exists. Please try with another name.', 'wpv-views'), 'pointer_close' => __('Close', 'wpv-views'), 'pointer_scroll_to_template' => __('Scroll to the Content Template', 'wpv-views')); $layout_wizard_translations = array('button_next' => __('Next', 'wpv-views'), 'button_insert' => __('Finish', 'wpv-views'), 'unknown_error' => __('Something wrong happened, please try again', 'wpv-views')); if (isset($_GET['page']) && $_GET['page'] == 'views-editor') { wp_enqueue_script('suggest'); // for author filter, although it is declared as dependency wp_enqueue_script('views-editor-js'); // general js file wp_localize_script('views-editor-js', 'wpv_editor_strings', $editor_translations); wp_enqueue_script('views-filters-js'); // general js file for filters, each filter registers and enqueues its own scripts depending on this $filters_strings = array('select_empty' => __("Please select an option", 'wpv-views'), 'param_missing' => __("This field can not be empty", 'wpv-views'), 'param_url_ilegal' => __("Only lowercase letters, numbers, hyphens and underscores allowed as URL parameters", 'wpv-views'), 'param_shortcode_ilegal' => __("Only lowercase letters and numbers allowed as shortcode attributes", 'wpv-views'), 'param_year_ilegal' => __('Years can only be a four digits number', 'wpv-views'), 'param_month_ilegal' => __('Months can only be a number between 1 and 12', 'wpv-views'), 'param_week_ilegal' => __('Weeks can only be numbers between 1 and 53', 'wpv-views'), 'param_day_ilegal' => __('Days can only be a number between 1 and 31', 'wpv-views'), 'param_hour_ilegal' => __('Hours can only be numbers between 0 and 23', 'wpv-views'), 'param_minute_ilegal' => __('Minutes can only be numbers between 0 and 59', 'wpv-views'), 'param_second_ilegal' => __('Seconds can only be numbers between 0 and 59', 'wpv-views'), 'param_dayofyear_ilegal' => __('Days of the year can only be numbers between 1 and 366', 'wpv-views'), 'param_dayofweek_ilegal' => __('Days of the week can only be numbers between 1 and 7', 'wpv-views'), 'param_numeric_natural_ilegal' => __('This needs to be a non-negative number', 'wpv-views'), 'param_forbidden_wordpress' => __("This is a word reserved by WordPress", 'wpv-views'), 'param_forbidden_toolset' => __("This is a word reserved by any of the ToolSet plugins", 'wpv-views'), 'param_forbidden_toolset_attr' => __("This is an attribute reserved by any of the ToolSet plugins", 'wpv-views'), 'param_forbidden_post_type' => __("There is a post type named like that", 'wpv-views'), 'param_forbidden_taxonomy' => __("There is a taxonomy named like that", 'wpv-views'), 'parent_type_not_hierarchical' => __("The posts you want to display are not hierarchical, so this filter will not work", 'wpv-views'), 'taxonomy_parent_changed' => __("The taxonomy you want to display has changed, so this filter needs some action", 'wpv-views'), 'taxonomy_term_changed' => __("The taxonomy you want to display has changed, so this filter needs some action", 'wpv-views')); wp_localize_script('views-filters-js', 'wpv_filters_strings', $filters_strings); wp_enqueue_script('views-pagination-js'); $pagination_translation = array('close' => __('Close', 'wpv-views'), 'wpv_page_pagination_shortcode_definition' => __('This is an optional placeholder to wrap the pagination shortcodes. The content of this shortcode will only be displayed if there is more than one page of results.', 'wpv-views'), 'wpv_page_num_shortcode_definition' => __('Displays the current page number', 'wpv-views'), 'wpv_page_total_shortcode_definition' => __('Displays the maximum number of pages found by the Views Query.', 'wpv-views'), 'wpv_page_selector_shortcode_definition' => __('Displays a pager with the current page selected. Depending on the value of the <em>style</em> parameter it displays a list of links to the other pages or a drop-down list to select another page.', 'wpv-views'), 'wpv_page_pre_shortcode_definition' => __('Display a <em>Previous</em> link to move to the previous page.', 'wpv-views'), 'wpv_page_next_shortcode_definition' => __('Display a <em>Next</em> link to move to the next page.', 'wpv-views')); wp_localize_script('views-pagination-js', 'wpv_pagination_texts', $pagination_translation); //Enqueue suggestion script wp_enqueue_script('views-suggestion_script'); wp_enqueue_style('views_suggestion_style'); wp_enqueue_style('views_suggestion_style2'); wp_enqueue_script('views-update-js'); wp_enqueue_script('views-layout-template-js'); wp_localize_script('views-layout-template-js', 'wpv_inline_templates_strings', $inline_content_templates_translations); wp_enqueue_script('views-layout-wizard-script'); wp_localize_script('views-layout-wizard-script', 'wpv_layout_wizard_strings', $layout_wizard_translations); if (function_exists('wp_enqueue_media') && !wp_script_is('icl_media-manager-js', 'enqueued')) { wp_enqueue_media(); wp_enqueue_script('views-redesign-media-manager-js'); wp_localize_script('views-redesign-media-manager-js', 'wpv_media_manager', $media_manager_translations); } } if (isset($_GET['page']) && $_GET['page'] == 'view-archives-editor') { wp_enqueue_script('suggest'); wp_enqueue_script('views-archive-editor-js'); // general js file wp_localize_script('views-archive-editor-js', 'wpv_editor_strings', $editor_translations); wp_enqueue_script('views-archive-update-js'); wp_enqueue_script('views-layout-template-js'); wp_localize_script('views-layout-template-js', 'wpv_inline_templates_strings', $inline_content_templates_translations); wp_enqueue_script('views-layout-wizard-script'); wp_localize_script('views-layout-wizard-script', 'wpv_layout_wizard_strings', $layout_wizard_translations); if (function_exists('wp_enqueue_media') && !wp_script_is('icl_media-manager-js', 'enqueued')) { wp_enqueue_media(); wp_enqueue_script('views-redesign-media-manager-js'); wp_localize_script('views-redesign-media-manager-js', 'wpv_media_manager', $media_manager_translations); } } // Update help screen if (isset($_GET['page']) && $_GET['page'] == 'views-update-help') { wp_enqueue_script('views-update-help-js'); } }
function wpv_admin_enqueue_scripts($hook) { // echo $hook; TODO this function needs a lot of love /** * Registering all scripts */ // Register scripts and styles needed in the embedded version too parent::wpv_admin_enqueue_scripts($hook); // CodeMirror wp_register_script('views-codemirror-script', WPV_URL . '/res/js/codemirror311/lib/codemirror.js', array(), WPV_VERSION, false); wp_register_script('views-codemirror-overlay-script', WPV_URL . '/res/js/codemirror311/addon/mode/overlay.js', array('views-codemirror-script'), WPV_VERSION, false); wp_register_script('views-codemirror-xml-script', WPV_URL . '/res/js/codemirror311/mode/xml/xml.js', array('views-codemirror-overlay-script'), WPV_VERSION, false); wp_register_script('views-codemirror-css-script', WPV_URL . '/res/js/codemirror311/mode/css/css.js', array('views-codemirror-overlay-script'), WPV_VERSION, false); wp_register_script('views-codemirror-js-script', WPV_URL . '/res/js/codemirror311/mode/javascript/javascript.js', array('views-codemirror-overlay-script'), WPV_VERSION, false); wp_register_script('views-codemirror-conf-script', WPV_URL . '/res/js/views_codemirror_conf.js', array('jquery', 'views-codemirror-script'), WPV_VERSION, false); // Views, WPA and CT edit screens JS wp_register_script('views-redesign-js', WPV_URL . "/res/js/redesign/views_editor.js", array('jquery', 'wp-pointer', 'jquery-ui-sortable', 'jquery-ui-draggable', 'views-codemirror-script'), WPV_VERSION, true); wp_register_script('views-redesign-filters-js', WPV_URL . "/res/js/redesign/views_section_filters.js", array('views-redesign-js'), WPV_VERSION, true); wp_register_script('views-redesign-status-js', WPV_URL . "/res/js/redesign/views_filter_status.js", array('views-redesign-filters-js'), WPV_VERSION, true); wp_register_script('views-redesign-author-js', WPV_URL . "/res/js/redesign/views_filter_author.js", array('suggest', 'views-redesign-filters-js'), WPV_VERSION, true); wp_register_script('views-redesign-users-js', WPV_URL . "/res/js/redesign/views_filter_users.js", array('suggest', 'views-redesign-filters-js'), WPV_VERSION, true); wp_register_script('views-redesign-parent-js', WPV_URL . "/res/js/redesign/views_filter_parent.js", array('views-redesign-filters-js'), WPV_VERSION, true); wp_register_script('views-redesign-search-js', WPV_URL . "/res/js/redesign/views_filter_search.js", array('views-redesign-filters-js'), WPV_VERSION, true); wp_register_script('views-redesign-id-js', WPV_URL . "/res/js/redesign/views_filter_id.js", array('suggest', 'views-redesign-filters-js'), WPV_VERSION, true); wp_register_script('views-redesign-post-relationship-js', WPV_URL . "/res/js/redesign/views_filter_post_relationship.js", array('suggest', 'views-redesign-filters-js'), WPV_VERSION, true); wp_register_script('views-redesign-category-js', WPV_URL . "/res/js/redesign/views_filter_category.js", array('views-redesign-filters-js'), WPV_VERSION, true); wp_register_script('views-redesign-custom-field-js', WPV_URL . "/res/js/redesign/views_filter_custom_field.js", array('views-redesign-filters-js'), WPV_VERSION, true); wp_register_script('views-redesign-usermeta-field-js', WPV_URL . "/res/js/redesign/views_filter_usermeta_field.js", array('views-redesign-filters-js'), WPV_VERSION, true); wp_register_script('views-redesign-taxonomy-term-js', WPV_URL . "/res/js/redesign/views_filter_taxonomy_term.js", array('views-redesign-filters-js'), WPV_VERSION, true); wp_register_script('views-redesign-pagination-js', WPV_URL . "/res/js/redesign/views_section_pagination.js", array('views-redesign-js'), WPV_VERSION, true); wp_register_script('views-redesign-update-js', WPV_URL . "/res/js/redesign/views_sections_update.js", array('views-redesign-js'), WPV_VERSION, true); wp_register_script('views-archive-redesign-js', WPV_URL . "/res/js/redesign/views_archive_editor.js", array('jquery', 'wp-pointer', 'jquery-ui-sortable', 'jquery-ui-draggable', 'views-codemirror-script'), WPV_VERSION, true); wp_register_script('views-redesign-update-archive-js', WPV_URL . "/res/js/redesign/views_archives_sections_update.js", array('views-archive-redesign-js'), WPV_VERSION, true); wp_register_script('views-redesign-layout-template-js', WPV_URL . "/res/js/redesign/views_section_layout_template.js", array('jquery'), WPV_VERSION, true); wp_register_script('views-redesign-media-manager-js', WPV_URL . "/res/js/redesign/views_media_manager.js", array('jquery'), WPV_VERSION, true); wp_register_script('views-layout-wizard-script', WPV_URL . '/res/js/redesign/views_layout_edit_wizard.js', array('jquery'), WPV_VERSION, true); wp_register_script('views-template-redesign-js', WPV_URL . '/res/js/redesign/views_content_template.js', array('jquery', 'wp-pointer', 'jquery-ui-sortable', 'jquery-ui-draggable', 'views-codemirror-script'), WPV_VERSION, true); // Settings JS wp_register_script('views-settings-script', WPV_URL . '/res/js/views_settings.js', array('jquery'), WPV_VERSION, true); // Suggestion Script for Views edit screen wp_register_script('views-suggestion_script', WPV_URL . "/res/js/redesign/suggestion_script.js", array(), WPV_VERSION, true); wp_register_style('views_suggestion_style', WPV_URL . '/res/css/token-input.css', array(), WPV_VERSION); wp_register_style('views_suggestion_style2', WPV_URL . '/res/css/token-input-wpv-theme.css', array(), WPV_VERSION); // Listing JS wp_register_script('views-listing-script', WPV_URL . '/res/js/redesign/views_listing_page.js', array('jquery'), WPV_VERSION, true); wp_register_script('views-archive-listing-script', WPV_URL . '/res/js/redesign/views_wordpress_archive_listing_page.js', array('jquery'), WPV_VERSION, true); wp_register_script('views-content-templates-listing-script', WPV_URL . '/res/js/redesign/wpv_content_template_listing.js', array('jquery'), WPV_VERSION, true); // NOTE knockout and parametric.js files need to be enqueued at admin_header time for some reason, registered and enqueued in editor-addon-parametric-class.php in common /** * Registering all styles */ // CodeMirror style wp_register_style('views-codemirror-css', WPV_URL . '/res/js/codemirror311/lib/codemirror.css', array(), WPV_VERSION); // General Views redesign style wp_register_style('views-admin-css', WPV_URL . '/res/css/views-admin.css', array('toolset-font-awesome', 'toolset-colorbox', 'views-notifications-css', 'views-dialogs-css', 'views-select2-css'), WPV_VERSION); /** * Enqueue actions */ // Basic WordPress scripts & styles wp_enqueue_script('wp-pointer'); // TODO maybe DEPRECATED wp_enqueue_style('wp-pointer'); // TODO maybe DEPRECATED wp_enqueue_script('thickbox'); // TODO maybe DEPRECATED wp_enqueue_style('thickbox'); // TODO maybe DEPRECATED // External libraries scripts if (isset($_GET['page']) && ($_GET['page'] == 'views' || $_GET['page'] == 'view-archives' || $_GET['page'] == 'view-templates' || $_GET['page'] == 'views-editor' || $_GET['page'] == 'view-archives-editor' || strpos($_SERVER['QUERY_STRING'], 'help.php') !== false)) { if ($_GET['page'] == 'views-editor') { delete_transient('wpv_layout_wizard_save_settings'); } wp_enqueue_script('views-utils-script'); $help_box_translations = array('wpv_dont_show_it_again' => __("Got it! Don't show this message again", 'wpv-views'), 'wpv_close' => __("Close", 'wpv-views')); wp_localize_script('views-utils-script', 'wpv_help_box_texts', $help_box_translations); // CodeMirror NOTE add to Views and Content Templates edit screen only if ($_GET['page'] == 'views-editor' || $_GET['page'] == 'view-archives-editor') { wp_enqueue_script('views-codemirror-script'); wp_enqueue_script('views-codemirror-overlay-script'); wp_enqueue_script('views-codemirror-xml-script'); wp_enqueue_script('views-codemirror-css-script'); wp_enqueue_script('views-codemirror-js-script'); wp_enqueue_script('views-codemirror-conf-script'); wp_enqueue_style('views-codemirror-css'); } // Shared ToolSet CSS wp_enqueue_style('toolset-font-awesome'); // General Views CSS wp_enqueue_style('views-admin-css'); } // Views settings script if (isset($_GET['page']) && ($_GET['page'] == 'views-settings' || $_GET['page'] == 'views-settings-new')) { // TODO rename settings page so -new is not needed anymore wp_enqueue_script('views-settings-script'); wp_enqueue_style('views-admin-css'); } // Views screens - import/export and help if ($hook == 'views_page_views-import-export' || $hook == 'wp-views/menu/help.php' || $hook == 'views_page_views-settings-new') { // TODO rename settings page so -new is not needed anymore wp_enqueue_style('views-admin-css'); } // Views listing page if (isset($_GET['page']) && $_GET['page'] == 'views') { wp_enqueue_script('views-listing-script'); } if (isset($_GET['page']) && $_GET['page'] == 'view-archives') { wp_enqueue_script('views-archive-listing-script'); } if (isset($_GET['page']) && $_GET['page'] == 'view-templates') { wp_enqueue_script('views-content-templates-listing-script'); } // Views and WPA editors if (isset($_GET['page']) && $_GET['page'] == 'views-editor') { wp_enqueue_script('suggest'); // for author filter wp_enqueue_script('views-redesign-js'); // general js file wp_enqueue_script('views-redesign-filters-js'); // general js file for filters wp_enqueue_script('views-redesign-status-js'); wp_enqueue_script('views-redesign-author-js'); wp_enqueue_script('views-redesign-users-js'); wp_enqueue_script('views-redesign-parent-js'); wp_enqueue_script('views-redesign-search-js'); wp_enqueue_script('views-redesign-id-js'); wp_enqueue_script('views-redesign-post-relationship-js'); wp_enqueue_script('views-redesign-category-js'); wp_enqueue_script('views-redesign-custom-field-js'); wp_enqueue_script('views-redesign-usermeta-field-js'); wp_enqueue_script('views-redesign-taxonomy-term-js'); wp_enqueue_script('views-redesign-pagination-js'); //Enquey suggestion script wp_enqueue_script('views-suggestion_script'); wp_enqueue_style('views_suggestion_style'); wp_enqueue_style('views_suggestion_style2'); $pagination_translation = array('wpv_insert_wrong_cursor_position' => __('You need to place your cursor between the [wpv-filter-start] and the [wpv-filter-end] shortcodes', 'wpv-views'), 'wpv_page_pagination_shortcode_definition' => __('This is an optional placeholder to wrap the pagination shortcodes. The content of this shortcode will only be displayed if there is more than one page of results.', 'wpv-views'), 'wpv_page_num_shortcode_definition' => __('Displays the current page number', 'wpv-views'), 'wpv_page_total_shortcode_definition' => __('Displays the maximum number of pages found by the Views Query.', 'wpv-views'), 'wpv_page_selector_shortcode_definition' => __('Displays a pager with the current page selected. Depending on the value of the <em>style</em> parameter it displays a list of links to the other pages or a drop-down list to select another page.', 'wpv-views'), 'wpv_page_pre_shortcode_definition' => __('Display a <em>Previous</em> link to move to the previous page.', 'wpv-views'), 'wpv_page_next_shortcode_definition' => __('Display a <em>Next</em> link to move to the next page.', 'wpv-views')); wp_localize_script('views-redesign-pagination-js', 'wpv_pagination_texts', $pagination_translation); wp_enqueue_script('views-redesign-update-js'); wp_enqueue_script('views-redesign-layout-template-js'); wp_enqueue_script('views-layout-wizard-script'); if (function_exists('wp_enqueue_media')) { wp_enqueue_media(); wp_enqueue_script('views-redesign-media-manager-js'); } } if (isset($_GET['page']) && $_GET['page'] == 'view-archives-editor') { wp_enqueue_script('views-archive-redesign-js'); // general js file wp_enqueue_script('views-redesign-update-archive-js'); wp_enqueue_script('views-redesign-layout-template-js'); wp_enqueue_script('views-layout-wizard-script'); if (function_exists('wp_enqueue_media')) { wp_enqueue_media(); wp_enqueue_script('views-redesign-media-manager-js'); } } }
function wpv_admin_enqueue_scripts( $hook ) {// echo $hook; TODO this function needs a lot of love parent::wpv_admin_enqueue_scripts( $hook ); $page = wpv_getget( 'page' ); // Basic WordPress scripts & styles if ( ! wp_script_is( 'wp-pointer' ) ) { wp_enqueue_script('wp-pointer'); } if ( ! wp_style_is( 'wp-pointer' ) ) { wp_enqueue_style('wp-pointer'); } if ( ! wp_script_is( 'thickbox' ) ) { wp_enqueue_script('thickbox'); // TODO maybe DEPRECATED } if ( ! wp_style_is( 'thickbox' ) ) { wp_enqueue_style('thickbox'); // TODO maybe DEPRECATED } $wpv_custom_admin_pages = array( 'views', 'view-archives', 'view-templates', 'views-editor', 'view-archives-editor', WPV_CT_EDITOR_PAGE_NAME, 'views-update-help' ); $wpv_custom_admin_pages = apply_filters( 'wpv_filter_wpv_custom_admin_pages', $wpv_custom_admin_pages ); $wpv_custom_admin_edit_pages = array( 'views-editor', 'view-archives-editor', WPV_CT_EDITOR_PAGE_NAME ); $wpv_custom_admin_edit_pages = apply_filters( 'wpv_filter_wpv_custom_admin_edit_pages', $wpv_custom_admin_edit_pages ); if ( in_array( $page, $wpv_custom_admin_pages ) || strpos( $_SERVER['QUERY_STRING'], 'help.php') !== false ) { if ( ! wp_script_is( 'views-utils-script' ) ) { wp_enqueue_script( 'views-utils-script'); } if ( ! wp_style_is( 'views-admin-css' ) ) { wp_enqueue_style( 'views-admin-css' ); } } if ( $page == 'views' && ! wp_script_is( 'views-listing-script' ) ) { wp_enqueue_script( 'views-listing-script' ); } if ( $page == 'view-archives' && ! wp_script_is( 'views-archive-listing-script' ) ) { wp_enqueue_script( 'views-archive-listing-script' ); } if ( $page == 'view-templates' && ! wp_script_is( 'views-content-template-listing-script' ) ) { wp_enqueue_script( 'views-content-template-listing-script' ); } if ( $page == 'views-editor' ) {// TODO WTF is it doing here? delete_transient('wpv_layout_wizard_save_settings'); } if ( in_array( $page, $wpv_custom_admin_edit_pages ) ) { // Custom edit pages need the shortcodes GUI and Codemirror if ( ! wp_script_is( 'views-shortcodes-gui-script' ) ) { wp_enqueue_script( 'views-shortcodes-gui-script' ); } if ( ! wp_script_is( 'views-codemirror-conf-script' ) ) { wp_enqueue_script( 'views-codemirror-conf-script' ); } if ( ! wp_style_is( 'views-codemirror-css' ) ) { wp_enqueue_style( 'views-codemirror-css' ); } if ( ! wp_style_is( 'views-admin-css' ) ) { wp_enqueue_style( 'views-admin-css' ); } // Quicktags styles if ( ! wp_style_is( 'editor-buttons' ) ) { wp_enqueue_style( 'editor-buttons' ); } } // Views help screen // @todo transform this into a real page if ( $hook == 'wp-views/menu/help.php' ) { wp_enqueue_style( 'views-admin-css' ); } if ( 'views-editor' == $page ) { if ( ! wp_script_is( 'views-editor-js' ) ) { wp_enqueue_script( 'views-editor-js' ); } if ( ! wp_script_is( 'views-filters-js' ) ) { wp_enqueue_script( 'views-filters-js' ); } if ( ! wp_script_is( 'views-pagination-js' ) ) { wp_enqueue_script( 'views-pagination-js' ); } if ( ! wp_script_is( 'views-update-js' ) ) { wp_enqueue_script( 'views-update-js' ); } if ( ! wp_script_is( 'views-layout-template-js' ) ) { wp_enqueue_script( 'views-layout-template-js' ); } if ( ! wp_script_is( 'views-layout-wizard-script' ) ) { wp_enqueue_script( 'views-layout-wizard-script' ); } if ( function_exists( 'wp_enqueue_media' ) && ! wp_script_is( 'icl_media-manager-js' ) ) { wp_enqueue_media(); if ( ! wp_script_is( 'views-redesign-media-manager-js' ) ) { wp_enqueue_script( 'views-redesign-media-manager-js' ); } } //Enqueue suggestion script wp_enqueue_script( 'views-suggestion_script' ); wp_enqueue_style ('views_suggestion_style'); wp_enqueue_style ('views_suggestion_style2'); } if ( 'view-archives-editor' == $page ) { if ( ! wp_script_is( 'views-archive-editor-js' ) ) { wp_enqueue_script( 'views-archive-editor-js' ); } if ( ! wp_script_is( 'views-archive-update-js' ) ) { wp_enqueue_script( 'views-archive-update-js' ); } if ( ! wp_script_is( 'views-layout-template-js' ) ) { wp_enqueue_script( 'views-layout-template-js' ); } if ( ! wp_script_is( 'views-layout-wizard-script' ) ) { wp_enqueue_script( 'views-layout-wizard-script' ); } if ( function_exists( 'wp_enqueue_media' ) && ! wp_script_is( 'icl_media-manager-js' ) ) { wp_enqueue_media(); if ( ! wp_script_is( 'views-redesign-media-manager-js' ) ) { wp_enqueue_script( 'views-redesign-media-manager-js' ); } } } if ( $page == 'views-update-help' ) { wp_enqueue_script( 'views-update-help-js' ); } }