• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_get_associated_nav_menu_items函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_wp_get_associated_nav_menu_items

 function test_wp_get_associated_nav_menu_items()
 {
     $tag_id = $this->factory->tag->create();
     $cat_id = $this->factory->category->create();
     $post_id = $this->factory->post->create();
     $post_2_id = $this->factory->post->create();
     $page_id = $this->factory->post->create(array('post_type' => 'page'));
     $tag_insert = wp_update_nav_menu_item($this->menu_id, 0, array('menu-item-type' => 'taxonomy', 'menu-item-object' => 'post_tag', 'menu-item-object-id' => $tag_id, 'menu-item-status' => 'publish'));
     $cat_insert = wp_update_nav_menu_item($this->menu_id, 0, array('menu-item-type' => 'taxonomy', 'menu-item-object' => 'category', 'menu-item-object-id' => $cat_id, 'menu-item-status' => 'publish'));
     $post_insert = wp_update_nav_menu_item($this->menu_id, 0, array('menu-item-type' => 'post_type', 'menu-item-object' => 'post', 'menu-item-object-id' => $post_id, 'menu-item-status' => 'publish'));
     // Item without menu-item-object arg
     $post_2_insert = wp_update_nav_menu_item($this->menu_id, 0, array('menu-item-type' => 'post_type', 'menu-item-object-id' => $post_2_id, 'menu-item-status' => 'publish'));
     $page_insert = wp_update_nav_menu_item($this->menu_id, 0, array('menu-item-type' => 'post_type', 'menu-item-object' => 'page', 'menu-item-object-id' => $page_id, 'menu-item-status' => 'publish'));
     $tag_items = wp_get_associated_nav_menu_items($tag_id, 'taxonomy', 'post_tag');
     $this->assertEqualSets(array($tag_insert), $tag_items);
     $cat_items = wp_get_associated_nav_menu_items($cat_id, 'taxonomy', 'category');
     $this->assertEqualSets(array($cat_insert), $cat_items);
     $post_items = wp_get_associated_nav_menu_items($post_id);
     $this->assertEqualSets(array($post_insert), $post_items);
     $post_2_items = wp_get_associated_nav_menu_items($post_2_id);
     $this->assertEqualSets(array($post_2_insert), $post_2_items);
     $page_items = wp_get_associated_nav_menu_items($page_id);
     $this->assertEqualSets(array($page_insert), $page_items);
     wp_delete_term($tag_id, 'post_tag');
     $tag_items = wp_get_associated_nav_menu_items($tag_id, 'taxonomy', 'post_tag');
     $this->assertEqualSets(array(), $tag_items);
     wp_delete_term($cat_id, 'category');
     $cat_items = wp_get_associated_nav_menu_items($cat_id, 'taxonomy', 'category');
     $this->assertEqualSets(array(), $cat_items);
     wp_delete_post($post_id, true);
     $post_items = wp_get_associated_nav_menu_items($post_id);
     $this->assertEqualSets(array(), $post_items);
     wp_delete_post($post_2_id, true);
     $post_2_items = wp_get_associated_nav_menu_items($post_2_id);
     $this->assertEqualSets(array(), $post_2_items);
     wp_delete_post($page_id, true);
     $page_items = wp_get_associated_nav_menu_items($page_id);
     $this->assertEqualSets(array(), $page_items);
 }
开发者ID:Benrajalu,项目名称:philRaj,代码行数:39,代码来源:nav-menu.php


示例2: test_wp_get_associated_nav_menu_items

	function test_wp_get_associated_nav_menu_items() {
		$tag_id = $this->factory->tag->create();
		$cat_id = $this->factory->category->create();

		$tag_insert = wp_update_nav_menu_item( $this->menu_id, 0, array(
			'menu-item-type' => 'taxonomy',
			'menu-item-object' => 'post_tag',
			'menu-item-object-id' => $tag_id,
			'menu-item-status' => 'publish'
		) );

		$cat_insert = wp_update_nav_menu_item( $this->menu_id, 0, array(
			'menu-item-type' => 'taxonomy',
			'menu-item-object' => 'category',
			'menu-item-object-id' => $cat_id,
			'menu-item-status' => 'publish'
		) );

		$tag_items = wp_get_associated_nav_menu_items( $tag_id, 'taxonomy', 'post_tag' );
		$this->assertEqualSets( array( $tag_insert ), $tag_items );
		$cat_items = wp_get_associated_nav_menu_items( $cat_id, 'taxonomy', 'category' );
		$this->assertEqualSets( array( $cat_insert ), $cat_items );
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:23,代码来源:nav-menu.php


示例3: _wp_delete_tax_menu_item

/**
 * Callback for handling a menu item when its original object is deleted.
 *
 * @since 3.0.0
 * @access private
 *
 * @param int $object_id The ID of the original object being trashed.
 *
 */
function _wp_delete_tax_menu_item($object_id = 0, $tt_id, $taxonomy)
{
    $object_id = (int) $object_id;
    $menu_item_ids = wp_get_associated_nav_menu_items($object_id, 'taxonomy', $taxonomy);
    foreach ((array) $menu_item_ids as $menu_item_id) {
        wp_delete_post($menu_item_id, true);
    }
}
开发者ID:valiror,项目名称:sharingdais_demo1,代码行数:17,代码来源:nav-menu.php


示例4: ajax_delete_page

 /**
  * Called via WP Ajax action 'wp_ajax_spm_delete_page' if can_edit_pages
  *
  * Ajax function to delete a page
  */
 public function ajax_delete_page()
 {
     if (!current_user_can('delete_pages')) {
         wp_die(__('You do not have sufficient permissions to access this page. #708'));
     }
     $post_id = intval($_POST['post_ID']);
     if (isset($post_id) && !empty($post_id)) {
         $menu_items = wp_get_associated_nav_menu_items($post_id, 'post_type', 'page');
         foreach ($menu_items as $menu_item_id) {
             wp_delete_post($menu_item_id, true);
         }
         $post_data = wp_delete_post($post_id, false);
         if (is_object($post_data)) {
             echo '1';
         } else {
             echo '0';
             // fail, tell js
         }
     } else {
         echo '0';
         // fail, tell js
     }
     exit;
 }
开发者ID:interfisch,项目名称:lm,代码行数:29,代码来源:swifty-page-manager.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_get_attachment_id3_keys函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_get_archives函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap