本文整理汇总了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;未经允许,请勿转载。 |
请发表评论