当前位置: 首页>>代码示例>>PHP>>正文


PHP is_nav_menu_item函数代码示例

本文整理汇总了PHP中is_nav_menu_item函数的典型用法代码示例。如果您正苦于以下问题:PHP is_nav_menu_item函数的具体用法?PHP is_nav_menu_item怎么用?PHP is_nav_menu_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_nav_menu_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete_menu_item_image_action

 /**
  * When menu item removed remove menu image metadata.
  */
 public function delete_menu_item_image_action()
 {
     $menu_item_id = (int) $_REQUEST['menu-item'];
     check_admin_referer('delete-menu_item_image_' . $menu_item_id);
     if (is_nav_menu_item($menu_item_id) && has_post_thumbnail($menu_item_id)) {
         delete_post_thumbnail($menu_item_id);
         delete_post_meta($menu_item_id, 'menu_item_icon');
         delete_post_meta($menu_item_id, 'menu-item-bg-img');
     }
 }
开发者ID:dccmarketing,项目名称:dpd-2015,代码行数:13,代码来源:menu-images.php

示例2: save_post

 /**
  *
  * @param type $post_id
  */
 public function save_post($post_id = false)
 {
     // Get the post object
     $post = get_post($post_id);
     // Bail if post is an autosave, revision, or menu item
     if (wp_is_post_autosave($post) || wp_is_post_revision($post) || is_nav_menu_item($post)) {
         return;
     }
     // Run autolink callbacks on post content
     parent::input($post->post_content, $post);
 }
开发者ID:wir,项目名称:wp-auto-linker,代码行数:15,代码来源:class-wp-auto-linker.php

示例3: create_page

 private function create_page()
 {
     $page = array('post_type' => 'page', 'post_status' => 'publish', 'post_name' => 'wordlift-entity', 'post_content' => '[wordlift.entity]', 'post_title' => 'WordLift Entity');
     $error = null;
     $page_id = wp_insert_post($page, $error);
     // add the entity page option and remove the page from menus.
     if (is_numeric($page_id) && 0 !== $page_id) {
         update_option('_wordlift_entity_page_id', $page_id);
         $args = array('meta_key' => '_menu_item_object_id', 'meta_value' => $page_id, 'post_type' => 'nav_menu_item');
         $menu_items = get_posts($args);
         foreach ($menu_items as $menu_item) {
             if (is_nav_menu_item($menu_item->ID)) {
                 wp_delete_post($menu_item->ID, true);
             }
         }
     }
     $this->logger->info(var_export($error, true));
 }
开发者ID:gitter-badger,项目名称:wordlift-plugin,代码行数:18,代码来源:ActivationService.php

示例4: iconize_menu_item_title_all

 /**
  * Add icon before menu item title and wrap them with <span class="iconized-hover-trigger"> tag if needed ( if function attached to "iconize_menu_items_with" filter is returning "title" string ).
  *
  * @since 1.1.2
  *
  * @param string  $title
  * @param string  $id
  * @return string $title
  */
 public function iconize_menu_item_title_all($title, $id)
 {
     if (is_nav_menu_item($id)) {
         $icon_args['icon_name'] = get_post_meta($id, '_menu_item_icon_name', true);
         $icon_args['icon_set'] = get_post_meta($id, '_menu_item_icon_set', true);
         $icon_args['icon_transform'] = get_post_meta($id, '_menu_item_icon_transform', true);
         $icon_args['icon_color'] = get_post_meta($id, '_menu_item_icon_color', true);
         $icon_args['icon_size'] = get_post_meta($id, '_menu_item_icon_size', true);
         $icon_args['icon_align'] = get_post_meta($id, '_menu_item_icon_align', true);
         $icon_args['icon_custom_classes'] = get_post_meta($id, '_menu_item_icon_custom_classes', true);
         $icon_args['icon_position'] = get_post_meta($id, '_menu_item_icon_position', true);
         $icon = iconize_get_icon($icon_args, 'menu_item');
         $hovers = $this->get_iconize_dialog_dropdown_options_for('hover');
         $hovers = array_keys($hovers);
         if (!empty($icon_args['icon_transform']) && in_array($icon_args['icon_transform'], $hovers)) {
             $title = '<span class="iconized-hover-trigger">' . $icon . $title . '</span>';
         } else {
             if ('after' === $icon_args['icon_position']) {
                 $title = $title . $icon;
             } else {
                 $title = $icon . $title;
             }
         }
     }
     return $title;
 }
开发者ID:nickkoskowski,项目名称:Work-Depot,代码行数:35,代码来源:class-iconize-wp.php

示例5: menu_customizer_update_menu_item_order

/**
 * Updates the order for and publishes an existing menu item.
 *
 * Skips the mess that is wp_update_nav_menu_item() and avoids
 * handling menu item fields that are not changed.
 *
 * Based on the parts of wp_update_nav_menu_item() that are needed here.
 * $menu_id must already be validated before running this function (to avoid re-validating for each item in the menu).
 *
 * @param int $menu_id The valid ID of the menu.
 * @param int $item_id The ID of the (existing) menu item.
 * @param int $order   The menu item's new order/position.
 * @return int|WP_Error The menu item's database ID or WP_Error object on failure.
 */
function menu_customizer_update_menu_item_order($menu_id, $item_id, $order)
{
    $item_id = (int) $item_id;
    // Make sure that we don't convert non-nav_menu_item objects into nav_menu_item objects.
    if (!is_nav_menu_item($item_id)) {
        return new WP_Error('update_nav_menu_item_failed', __('The given object ID is not that of a menu item.'));
    }
    // Associate the menu item with the menu term.
    // Only set the menu term if it isn't set to avoid unnecessary wp_get_object_terms().
    if ($menu_id && !is_object_in_term($item_id, 'nav_menu', (int) $menu_id)) {
        wp_set_object_terms($item_id, array($menu_id), 'nav_menu');
    }
    // Populate the potentially-changing fields of the menu item object.
    $post = array('ID' => $item_id, 'menu_order' => $order, 'post_status' => 'publish');
    // Update the menu item object.
    wp_update_post($post);
    return $item_id;
}
开发者ID:dauidus,项目名称:woof,代码行数:32,代码来源:menu-customizer.php

示例6: update_menu_items

 /**
  * Saves the current nav menu.
  *
  * Taken and modified for Client Dash needs from wp-admin/includes/nav-menu.php:~1257
  *
  * @param int $menu_ID The ID of the nav menu to save to.
  *
  * @since Client Dash 1.6
  */
 public static function update_menu_items($menu_ID)
 {
     // Get our old menu items
     $unsorted_menu_items = wp_get_nav_menu_items($menu_ID, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID'));
     // Index menu items by db ID
     $menu_items = array();
     foreach ($unsorted_menu_items as $_item) {
         $menu_items[$_item->db_id] = $_item;
     }
     wp_defer_term_counting(true);
     // Loop through all the menu items' POST variables
     if (!empty($_POST['menu-item-db-id'])) {
         foreach ((array) $_POST['menu-item-db-id'] as $db_ID) {
             // Setup args
             $args = array();
             foreach (self::$menu_item_defaults as $field => $default) {
                 // Skip some static properties
                 if (in_array($field, array('original-title', 'cd-type', 'cd-page-title', 'cd-submenu-parent', 'db-id'))) {
                     continue;
                 }
                 $args[$field] = isset($_POST["menu-item-{$field}"][$db_ID]) ? $_POST["menu-item-{$field}"][$db_ID] : '';
             }
             $menu_item_db_id = self::update_menu_item($menu_ID, $_POST['menu-item-db-id'][$db_ID] != $db_ID ? 0 : $db_ID, $args);
             // Saved it, now remove it (for comparison later) and move on
             unset($menu_items[$menu_item_db_id]);
         }
     }
     // Remove menu items from the menu that weren't in $_POST
     if (!empty($menu_items)) {
         foreach (array_keys($menu_items) as $menu_item_id) {
             if (is_nav_menu_item($menu_item_id)) {
                 wp_delete_post($menu_item_id);
             }
         }
     }
     wp_defer_term_counting(false);
 }
开发者ID:BenjaminCool,项目名称:client-dash,代码行数:46,代码来源:menus.php

示例7: wp_nav_menu_update_menu_items

/**
 * Saves nav menu items
 *
 * @since 3.6.0
 *
 * @param int|string $nav_menu_selected_id (id, slug, or name ) of the currently-selected menu
 * @param string $nav_menu_selected_title Title of the currently-selected menu
 * @return array $messages The menu updated message
 */
function wp_nav_menu_update_menu_items($nav_menu_selected_id, $nav_menu_selected_title)
{
    $unsorted_menu_items = wp_get_nav_menu_items($nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish'));
    $messages = array();
    $menu_items = array();
    // Index menu items by db ID
    foreach ($unsorted_menu_items as $_item) {
        $menu_items[$_item->db_id] = $_item;
    }
    $post_fields = array('menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 'menu-item-title', 'menu-item-url', 'menu-item-description', 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn');
    wp_defer_term_counting(true);
    // Loop through all the menu items' POST variables
    if (!empty($_POST['menu-item-db-id'])) {
        foreach ((array) $_POST['menu-item-db-id'] as $_key => $k) {
            // Menu item title can't be blank
            if (!isset($_POST['menu-item-title'][$_key]) || '' == $_POST['menu-item-title'][$_key]) {
                continue;
            }
            $args = array();
            foreach ($post_fields as $field) {
                $args[$field] = isset($_POST[$field][$_key]) ? $_POST[$field][$_key] : '';
            }
            $menu_item_db_id = wp_update_nav_menu_item($nav_menu_selected_id, $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key, $args);
            if (is_wp_error($menu_item_db_id)) {
                $messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>';
            } else {
                unset($menu_items[$menu_item_db_id]);
            }
        }
    }
    // Remove menu items from the menu that weren't in $_POST
    if (!empty($menu_items)) {
        foreach (array_keys($menu_items) as $menu_item_id) {
            if (is_nav_menu_item($menu_item_id)) {
                wp_delete_post($menu_item_id);
            }
        }
    }
    // Store 'auto-add' pages.
    $auto_add = !empty($_POST['auto-add-pages']);
    $nav_menu_option = (array) get_option('nav_menu_options');
    if (!isset($nav_menu_option['auto_add'])) {
        $nav_menu_option['auto_add'] = array();
    }
    if ($auto_add) {
        if (!in_array($nav_menu_selected_id, $nav_menu_option['auto_add'])) {
            $nav_menu_option['auto_add'][] = $nav_menu_selected_id;
        }
    } else {
        if (false !== ($key = array_search($nav_menu_selected_id, $nav_menu_option['auto_add']))) {
            unset($nav_menu_option['auto_add'][$key]);
        }
    }
    // Remove nonexistent/deleted menus
    $nav_menu_option['auto_add'] = array_intersect($nav_menu_option['auto_add'], wp_get_nav_menus(array('fields' => 'ids')));
    update_option('nav_menu_options', $nav_menu_option);
    wp_defer_term_counting(false);
    /** This action is documented in wp-includes/nav-menu.php */
    do_action('wp_update_nav_menu', $nav_menu_selected_id);
    $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(__('<strong>%1$s</strong> has been updated.'), $nav_menu_selected_title) . '</p></div>';
    unset($menu_items, $unsorted_menu_items);
    return $messages;
}
开发者ID:pmanterys,项目名称:wp-mw-newsletter,代码行数:72,代码来源:nav-menu.php

示例8: remove_visibility_meta

 /**
  * Remove the _menu_item_visibility meta when the menu item is removed
  *
  * @since 0.2.2
  */
 function remove_visibility_meta($post_id)
 {
     if (is_nav_menu_item($post_id)) {
         delete_post_meta($post_id, '_menu_item_visibility');
     }
 }
开发者ID:olechka1505,项目名称:hungrylemur,代码行数:11,代码来源:init.php

示例9: themify_remove_menu_icon_meta

/**
 * Clean up the icon meta field when a menu item is deleted
 *
 * @param int $post_id
 *
 * @since 1.6.8
 */
function themify_remove_menu_icon_meta($post_id)
{
    if (is_nav_menu_item($post_id)) {
        delete_post_meta($post_id, '_menu_item_icon');
    }
}
开发者ID:tchataigner,项目名称:palette,代码行数:13,代码来源:themify-utils.php

示例10: update_nav_menu

 function update_nav_menu($options, $clean)
 {
     $eo_options = get_option('eventorganiser_options');
     $menu = $clean['addtomenu'];
     $menu_item_db_id = isset($eo_options['menu_item_db_id']) ? (int) $eo_options['menu_item_db_id'] : 0;
     $current = isset($eo_options['addtomenu']) ? $eo_options['addtomenu'] : 0;
     if (!is_nav_menu_item($menu_item_db_id)) {
         $menu_item_db_id = 0;
         $current = '';
     }
     if ((empty($menu) || $menu == '1') && is_nav_menu_item($menu_item_db_id)) {
         wp_delete_post($menu_item_db_id, true);
         $menu_item_db_id = 0;
     }
     if (!empty($menu) && $menu != '1') {
         $menu_item_data = array();
         $menu_obj = wp_get_nav_menu_object($menu);
         $menu_id = $menu_obj ? $menu_obj->term_id : 0;
         $status = $menu_id == 0 ? '' : 'publish';
         $menu_item_data = array('menu-item-title' => $clean['navtitle'], 'menu-item-url' => get_post_type_archive_link('event'), 'menu-item-object' => 'event', 'menu-item-status' => $status, 'menu-item-type' => 'post_type_archive');
         $menu_item_db_id = wp_update_nav_menu_item($menu_id, $menu_item_db_id, $menu_item_data);
     }
     $clean['menu_item_db_id'] = $menu_item_db_id;
     return $clean;
 }
开发者ID:rashadrussell,项目名称:UIUC_WebMonkeys_Website,代码行数:25,代码来源:event-organiser-settings.php

示例11: mltlngg_the_title_filter

 function mltlngg_the_title_filter($title, $id)
 {
     global $mltlngg_options, $wpdb, $mltlngg_table_translate, $mltlngg_current_language, $mltlngg_active_language, $post;
     if (!is_nav_menu_item($id)) {
         /* Do not filter, if a navigation menu */
         $mltlngg_post_type = get_post_type($id);
         /* If current post type enabled to translation */
         if ($mltlngg_post_type == 'post' || $mltlngg_post_type == 'page') {
             if (is_admin()) {
                 $mltlngg_current_language = !empty($_SESSION['current_language']) ? $_SESSION['current_language'] : (isset($_GET['lang']) ? $_GET['lang'] : (!isset($_GET['message']) ? $mltlngg_options['default_language'] : $mltlngg_active_language['locale']));
             }
             $new_title = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$mltlngg_table_translate} WHERE `post_ID` = %d AND `language` = '%s'", $id, $mltlngg_current_language), ARRAY_A);
             /* If translation is exist and not empty, filter title */
             if (isset($new_title['post_title']) && "" != $new_title['post_title']) {
                 $title = $new_title['post_title'];
                 if (!is_admin()) {
                     if (!empty($post->post_password)) {
                         $protected_title_format = apply_filters('protected_title_format', __('Protected: %s', 'multilanguage'), $post);
                         $title = sprintf($protected_title_format, $title);
                     } else {
                         if (isset($post->post_status) && 'private' == $post->post_status) {
                             $private_title_format = apply_filters('private_title_format', __('Private: %s', 'multilanguage'), $post);
                             $title = sprintf($private_title_format, $title);
                         }
                     }
                 }
             }
         }
     }
     return $title;
 }
开发者ID:rochellecanale,项目名称:wordpress,代码行数:31,代码来源:multilanguage.php

示例12: get_page_auto_menu_item_id

 /**
  * Get the ID of a menu item from a post ID.
  *
  * @since     1.0.0
  *
  * @param     int    $post_id    Post ID.
  *
  * @return    int                Corresponding menu item ID.
  */
 public function get_page_auto_menu_item_id($page_id)
 {
     // Check if page already has assigned menu item.
     $menu_item_id = get_post_meta($page_id, '_amfp_menu_item_id', true);
     // Get object id (post it points to) of menu item.
     $menu_item_object_id = get_post_meta($menu_item_id, '_menu_item_object_id', true);
     /**
      * If we already have a valid menu item ID, and it's points to
      * this post, then return it.
      */
     if ($menu_item_id && is_nav_menu_item($menu_item_id) && $menu_item_object_id == $page_id) {
         return $menu_item_id;
     }
     /**
      * If no menu item is set or the value isn't good, generate a new menu item
      * ID by incrementing the highest post ID in the database by one.
      */
     // Make sure ID isn't already taken.
     while (FALSE !== get_post_status($this->highest_db_post_id)) {
         $this->highest_db_post_id++;
     }
     $menu_item_id = ++$this->highest_db_post_id;
     // Add post meta to hold ID of associated menu item.
     update_post_meta($page_id, '_amfp_menu_item_id', $menu_item_id);
     return $menu_item_id;
 }
开发者ID:jgonzo127,项目名称:auto-menu-from-pages,代码行数:35,代码来源:class-auto-menu-from-pages-admin.php

示例13: hocwp_get_top_parent_menu_item

function hocwp_get_top_parent_menu_item($menu_item)
{
    $item = hocwp_get_parent_menu_item($menu_item);
    if (is_nav_menu_item($item)) {
        while ($item->menu_item_parent && hocwp_id_number_valid($item->menu_item_parent)) {
            $item = hocwp_get_parent_menu_item($item);
        }
    }
    return $item;
}
开发者ID:skylarkcob,项目名称:hocwp-projects,代码行数:10,代码来源:functions.php

示例14: update_menu

 /**
  * Adds new menu item to specified menu or removes it
  */
 public function update_menu($menu_id = NULL, $menu_item_title = '')
 {
     $menu_item_id = $this->options['general']['event_nav_menu']['item_id'];
     if (is_nav_menu_item($menu_item_id)) {
         $nav_menu_item = true;
         if ($menu_id === NULL) {
             wp_delete_post($menu_item_id, true);
             $menu_item_id = 0;
         }
     } else {
         $nav_menu_item = false;
         $menu_item_id = 0;
     }
     if (is_int($menu_id) && !empty($menu_id)) {
         if (($menu = wp_get_nav_menu_object($menu_id)) === false) {
             return false;
         }
         $menu_id = $menu->term_id;
         $menu_item_data = array('menu-item-title' => $menu_item_title, 'menu-item-url' => em_get_event_date_link(), 'menu-item-object' => 'event', 'menu-item-status' => $menu_id == 0 ? '' : 'publish', 'menu-item-type' => 'custom');
         if ($nav_menu_item === true) {
             $menu_item = wp_setup_nav_menu_item(get_post($menu_item_id));
             $menu_item_data['menu-item-parent-id'] = $menu_item->menu_item_parent;
             $menu_item_data['menu-item-position'] = $menu_item->menu_order;
         }
         $menu_item_id = wp_update_nav_menu_item($menu_id, $menu_item_id, $menu_item_data);
     }
     return $menu_item_id;
 }
开发者ID:DarussalamTech,项目名称:aims_prj,代码行数:31,代码来源:class-settings.php

示例15: delete_menu_item

 public function delete_menu_item()
 {
     $menu_item_id = isset($_POST['menu_item_id']) ? intval($_POST['menu_item_id']) : false;
     $menu_items = isset($_POST['new_menu_order']) ? $_POST['new_menu_order'] : false;
     if ($menu_item_id) {
         if (is_nav_menu_item($menu_item_id) && wp_delete_post($menu_item_id, true)) {
             $messages[] = Upfront_UnewnavigationView::_get_l10n('delete_success');
         }
         //			update_post_meta($child['menu-item-db-id'], '_menu_item_menu_item_parent', 0);
         //echo $menu_items;
         //die(0);
         if ($menu_items) {
             $this->update_menu_order($menu_items);
             /*
             				foreach($menu_items as $menu_item) {
             	if(isset($menu_item['refresh-parent']) && $menu_item['refresh-parent'] == 1) {
             						echo "yes this happend";
             						return;
             	//				     $current_menu_item = get_post( $menu_item['menu-item-db-id'], 'ARRAY_A' );
             //						$current_menu_item['menu_order'] = $count;
             						delete_post_meta($menu_item['menu-item-db-id'], '_menu_item_menu_item_parent');
             		//				wp_update_post($current_menu_item);
             					}
             					$count++;
             				}
             */
         } else {
             $this->_out(new Upfront_JsonResponse_Success($messages));
         }
     }
     $this->_out(new Upfront_JsonResponse_Error(Upfront_UnewnavigationView::_get_l10n('cant_delete')));
 }
开发者ID:sedici,项目名称:wpmu-istec,代码行数:32,代码来源:unewnavigation.php


注:本文中的is_nav_menu_item函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。