Пример #1
0
foreach ((array) $nav_menus as $key => $_nav_menu) {
    $nav_menus[$key]->truncated_name = wp_html_excerpt($_nav_menu->name, 40, '…');
}
// Retrieve menu locations
if (current_theme_supports('menus')) {
    $locations = get_registered_nav_menus();
    $menu_locations = get_nav_menu_locations();
}
// Ensure the user will be able to scroll horizontally
// by adding a class for the max menu depth.
global $_wp_nav_menu_max_depth;
$_wp_nav_menu_max_depth = 0;
// Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth
if (is_nav_menu($nav_menu_selected_id)) {
    $menu_items = wp_get_nav_menu_items($nav_menu_selected_id, array('post_status' => 'any'));
    $edit_markup = wp_get_nav_menu_to_edit($nav_menu_selected_id);
}
function wp_nav_menu_max_depth($classes)
{
    global $_wp_nav_menu_max_depth;
    return "{$classes} menu-max-depth-{$_wp_nav_menu_max_depth}";
}
add_filter('admin_body_class', 'wp_nav_menu_max_depth');
wp_nav_menu_setup();
wp_initial_nav_menu_meta_boxes();
if (!current_theme_supports('menus') && !$num_locations) {
    $messages[] = '<div id="message" class="updated"><p>' . sprintf(__('Your theme does not natively support menus, but you can use them in sidebars by adding a &#8220;Custom Menu&#8221; widget on the <a href="%s">Widgets</a> screen.'), admin_url('widgets.php')) . '</p></div>';
}
if (!$locations_screen) {
    // Main tab
    $overview = '<p>' . __('This screen is used for managing your custom navigation menus.') . '</p>';
Пример #2
0
 /**
  * Returns the available menu items.
  *
  * @since Client Dash 1.6
  *
  * @return array|bool The menu items, if they exist, otherwise false.
  */
 public function get_current_menu_items()
 {
     global $ClientDash, $errors;
     /**
      * Whether or not to use transients in getting the menu output. (big time saver)
      *
      * @since Client Dash 1.6
      */
     $use_transients = apply_filters('cd_nav_menu_transients', true);
     // Save the information in a transient and get it for faster page loads
     // Only use a transient when debugging is off
     if ((!defined('WP_DEBUG') || !WP_DEBUG) && $use_transients) {
         $output = get_transient("cd_adminmenu_output_{$this->menu_ID}");
     } else {
         $output = false;
     }
     if (!$output && is_nav_menu($this->menu_ID)) {
         // Our modified walker class
         include_once $ClientDash->path . '/core/tabs/settings/menus/walkerclass.php';
         $menu_items = wp_get_nav_menu_items($this->menu_ID, array('post_status' => 'any'));
         $edit_markup = wp_get_nav_menu_to_edit($this->menu_ID);
         $output = array('menu_items' => $menu_items, 'edit_markup' => $edit_markup, 'errors' => $errors);
         // Save the transient data if not disabled
         if ($use_transients) {
             set_transient("cd_adminmenu_output_{$this->menu_ID}", $output, DAY_IN_SECONDS);
         }
     }
     return $output;
 }