/** * Load metabox scripts */ public function add_scripts($page) { $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; $scripts_url = plugins_url('js', BU_NAV_PLUGIN); $styles_url = plugins_url('css', BU_NAV_PLUGIN); // Scripts wp_register_script('bu-navigation-metabox', $scripts_url . '/navigation-metabox' . $suffix . '.js', array('bu-navigation', 'thickbox', 'media-upload'), BU_Navigation_Plugin::VERSION, true); // Setup dynamic script context for navigation-metabox.js $post_type = get_post_type_object($this->post_type); $ancestors = $this->get_formatted_ancestors(); // Strings for localization $nav_menu_label = __('Appearance > Primary Navigation', 'bu-navigation'); $strings = array('topLevelDisabled' => sprintf(__('Displaying top-level %s in navigation lists is currently disabled.', 'bu-navigation'), strtolower($post_type->labels->name)), 'topLevelNotice' => sprintf(__('To change this behavior, visit %s and enable the "Allow Top-Level Pages" setting.', 'bu-navigation'), $nav_menu_label), 'topLevelLabel' => sprintf(__('Top level %s', 'bu-navigation'), strtolower($post_type->labels->singular_name))); $script_context = array('postTypes' => $this->post_type, 'postStatuses' => array('publish', 'private'), 'currentPost' => $this->post_id, 'ancestors' => $ancestors, 'lazyLoad' => false, 'showCounts' => false, 'nodePrefix' => 'na', 'deselectOnDocumentClick' => false); // Navigation tree view will handle actual enqueuing of our script $treeview = new BU_Navigation_Tree_View('nav_metabox', array_merge($script_context, $strings)); $treeview->enqueue_script('bu-navigation-metabox'); // Styles wp_enqueue_style('bu-navigation-metabox', $styles_url . '/navigation-metabox.css', array(), BU_Navigation_Plugin::VERSION); }
/** * Register dependent Javscript and CSS files */ public function add_scripts($page) { if (is_array($this->pages) && in_array($page, $this->pages)) { $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; $scripts_url = plugins_url('js', BU_NAV_PLUGIN); $vendor_url = plugins_url('js/vendor', BU_NAV_PLUGIN); $styles_url = plugins_url('css', BU_NAV_PLUGIN); // Scripts wp_register_script('bu-jquery-validate', $vendor_url . '/jquery.validate' . $suffix . '.js', array('jquery'), '1.8.1', true); wp_register_script('bu-navman', $scripts_url . '/manage' . $suffix . '.js', array('bu-navigation', 'jquery-ui-dialog', 'bu-jquery-validate'), BU_Navigation_Plugin::VERSION, true); // Strings for localization $nav_menu_label = __('Appearance > Primary Navigation', 'bu-navigation'); $strings = array('optionsLabel' => __('options', 'bu-navigation'), 'optionsEditLabel' => __('Edit', 'bu-navigation'), 'optionsViewLabel' => __('View', 'bu-navigation'), 'optionsDeleteLabel' => __('Delete', 'bu-navigation'), 'optionsTrashLabel' => __('Move to Trash', 'bu-navigation'), 'addLinkDialogTitle' => __('Add a Link', 'bu-navigation'), 'editLinkDialogTitle' => __('Edit Link', 'bu-navigation'), 'cancelLinkBtn' => __('Cancel', 'bu-navigation'), 'confirmLinkBtn' => __('Ok', 'bu-navigation'), 'noTopLevelNotice' => __('You are not allowed to create top level published content.', 'bu-navigation'), 'noLinksNotice' => __('You are not allowed to add links', 'bu-navigation'), 'createLinkNotice' => __('Select a page that you can edit and click "Add a Link" to create a new link below the selected page.', 'bu-navigation'), 'allowTopNotice' => sprintf(__('Site administrators can change this behavior by visiting %s and enabling the "Allow Top-Level Pages" setting.', 'bu-navigation'), $nav_menu_label), 'noChildLinkNotice' => __('Links are not permitted to have children.', 'bu-navigation'), 'unloadWarning' => __('You have made changes to your navigation that have not yet been saved.', 'bu-navigation'), 'saveNotice' => __('Saving navigation changes...', 'bu-navigation')); // Setup dynamic script context for manage.js $script_context = array('postTypes' => $this->post_type, 'postStatuses' => array('publish', 'private'), 'nodePrefix' => 'nm', 'lazyLoad' => true, 'showCounts' => true); // Navigation tree view will handle actual enqueuing of our script $treeview = new BU_Navigation_Tree_View('bu_navman', array_merge($script_context, $strings)); $treeview->enqueue_script('bu-navman'); // Register custom jQuery UI stylesheet if it isn't already if (!wp_style_is('bu-jquery-ui', 'registered')) { if ('classic' == get_user_option('admin_color')) { wp_register_style('bu-jquery-ui', $styles_url . '/jquery-ui-classic.css', array(), BU_Navigation_Plugin::VERSION); } else { wp_register_style('bu-jquery-ui', $styles_url . '/jquery-ui-fresh.css', array(), BU_Navigation_Plugin::VERSION); } } wp_enqueue_style('bu-navman', $styles_url . '/manage.css', array('bu-jquery-ui'), BU_Navigation_Plugin::VERSION); } }