本文整理汇总了PHP中wp_delete_nav_menu函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_delete_nav_menu函数的具体用法?PHP wp_delete_nav_menu怎么用?PHP wp_delete_nav_menu使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_delete_nav_menu函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Delete one or more menus
*
* <menu>...
* : The name, slug, or term ID for the menu(s)
*
* ## EXAMPLES
*
* wp menu delete "My Menu"
*/
public function delete($args, $_)
{
foreach ($args as $arg) {
$ret = wp_delete_nav_menu($arg);
if (!$ret || is_wp_error($ret)) {
WP_CLI::warning("Error deleting menu.");
}
}
WP_CLI::success("Menu(s) deleted.");
}
开发者ID:ryanshoover,项目名称:wp-cli,代码行数:20,代码来源:menu.php
示例2: delete
/**
* Delete one or more menus.
*
* ## OPTIONS
*
* <menu>...
* : The name, slug, or term ID for the menu(s).
*
* ## EXAMPLES
*
* $ wp menu delete "My Menu"
* Success: 1 menu deleted.
*/
public function delete($args, $_)
{
$count = $errors = 0;
foreach ($args as $arg) {
$ret = wp_delete_nav_menu($arg);
if (!$ret || is_wp_error($ret)) {
WP_CLI::warning("Couldn't delete menu '{$arg}'.");
$errors++;
} else {
WP_CLI::log("Deleted menu '{$arg}'.");
$count++;
}
}
Utils\report_batch_operation_results('menu', 'delete', count($args), $count, $errors);
}
开发者ID:wp-cli,项目名称:wp-cli,代码行数:28,代码来源:menu.php
示例3: menu_customizer_delete_menu_ajax
/**
* Ajax handler for deleting a menu.
*
* @since Menu Customizer 0.0.
*/
function menu_customizer_delete_menu_ajax()
{
check_ajax_referer('customize-menus', 'customize-nav-menu-nonce');
if (!current_user_can('edit_theme_options')) {
wp_die(-1);
}
$menu_id = absint($_POST['menu_id']);
if (is_nav_menu($menu_id)) {
$deletion = wp_delete_nav_menu($menu_id);
if (is_wp_error($deletion)) {
echo $deletion->message();
}
} else {
echo __('Error: invalid menu to delete.');
}
wp_die();
}
开发者ID:dauidus,项目名称:woof,代码行数:22,代码来源:menu-customize-ajax.php
示例4: create_menu
/**
* creates the menu
* @param $menu_name
*/
function create_menu($menu_name)
{
$current_menu = wp_get_nav_menu_object($menu_name);
if (!$current_menu) {
$this->last_menu_id = wp_create_nav_menu($menu_name);
$this->log("create_menu({$menu_name})", 'ID:' . $this->last_menu_id);
} else {
wp_delete_nav_menu($menu_name);
$this->last_menu_id = wp_create_nav_menu($menu_name);
$this->log("create_menu({$menu_name})", 'Menu recreated ID:' . $this->last_menu_id);
/*
if (!empty($current_menu->term_id)) {
$this->last_menu_id = $current_menu->term_id;
$this->log("create_menu($menu_name)", 'menu already exists ID: ' . $this->last_menu_id);
}
*/
}
}
开发者ID:Vatia13,项目名称:wordpress,代码行数:22,代码来源:td_demo_site.php
示例5: reset_all_settings
/**
* Resets ALL Client Dash settings by deleting them.
*
* @since Client Dash 1.6
*/
public function reset_all_settings()
{
global $ClientDash, $ClientDash_Core_Page_Settings_Tab_Widgets;
// Cycle through all option defaults and delete them
foreach ($ClientDash->option_defaults as $name => $value) {
delete_option("cd_{$name}");
}
// Remove all modified admin menus
foreach (get_editable_roles() as $role_ID => $role) {
// Get the menu object
$menu_object = wp_get_nav_menu_object("cd_admin_menu_{$role_ID}");
// If it doesn't exist, it returns false. So skip
if (!$menu_object) {
continue;
}
wp_delete_nav_menu("cd_admin_menu_{$role_ID}");
// Delete the nav menu
delete_transient("cd_adminmenu_output_{$menu_object->term_id}");
// Cached menu info
delete_option("{$menu_object->name}_modified");
// Menu output
delete_option("cd_adminmenu_disabled_{$menu_object->term_id}");
// Menu disable option
}
// Remove all of the widgets
// Prevent widget syncing
add_filter('cd_sync_widgets', '__return_false');
// This forces the widgets to be reset
delete_option('cd_populate_dashboard_widgets');
// Remove each CD sidebar settings
$sidebars = get_option('sidebars_widgets');
foreach ($ClientDash_Core_Page_Settings_Tab_Widgets->sidebars as $sidebar) {
unset($sidebars[$sidebar['id']]);
}
update_option('sidebars_widgets', $sidebars);
// Remove individual widget settings
foreach (ClientDash::$_cd_widgets as $widget_ID => $widget) {
delete_option("widget_{$widget_ID}");
}
echo 'Settings successfully reset!';
die;
}
开发者ID:BenjaminCool,项目名称:client-dash,代码行数:47,代码来源:ajax.php
示例6: callback
function callback($path = '', $site = 0, $menu_id = 0)
{
$site_id = $this->switch_to_blog_and_validate_user($this->api->get_blog_id($site));
if (is_wp_error($site_id)) {
return $site_id;
}
if ($menu_id <= 0) {
return new WP_Error('menu-id', 'Menu ID must be greater than 0.', 400);
}
$result = wp_delete_nav_menu($menu_id);
if (!is_wp_error($result)) {
$result = array('deleted' => $result);
}
return $result;
}
开发者ID:kanei,项目名称:vantuch.cz,代码行数:15,代码来源:class.wpcom-json-api-menus-v1-1-endpoint.php
示例7: update
/**
* Create/update the nav_menu term for this setting.
*
* Any created menus will have their assigned term IDs exported to the client
* via the customize_save_response filter. Likewise, any errors will be exported
* to the client via the customize_save_response() filter.
*
* To delete a menu, the client can send false as the value.
*
* @since 4.3.0
*
* @see wp_update_nav_menu_object()
*
* @param array|false $value {
* The value to update. Note that slug cannot be updated via wp_update_nav_menu_object().
* If false, then the menu will be deleted entirely.
*
* @type string $name The name of the menu to save.
* @type string $description The term description. Default empty string.
* @type int $parent The id of the parent term. Default 0.
* @type bool $auto_add Whether pages will auto_add to this menu. Default false.
* }
* @return void
*/
protected function update( $value ) {
if ( $this->is_updated ) {
return;
}
$this->is_updated = true;
$is_placeholder = ( $this->term_id < 0 );
$is_delete = ( false === $value );
add_filter( 'customize_save_response', array( $this, 'amend_customize_save_response' ) );
$auto_add = null;
if ( $is_delete ) {
// If the current setting term is a placeholder, a delete request is a no-op.
if ( $is_placeholder ) {
$this->update_status = 'deleted';
} else {
$r = wp_delete_nav_menu( $this->term_id );
if ( is_wp_error( $r ) ) {
$this->update_status = 'error';
$this->update_error = $r;
} else {
$this->update_status = 'deleted';
$auto_add = false;
}
}
} else {
// Insert or update menu.
$menu_data = wp_array_slice_assoc( $value, array( 'description', 'parent' ) );
if ( isset( $value['name'] ) ) {
$menu_data['menu-name'] = $value['name'];
}
$r = wp_update_nav_menu_object( $is_placeholder ? 0 : $this->term_id, $menu_data );
if ( is_wp_error( $r ) ) {
$this->update_status = 'error';
$this->update_error = $r;
} else {
if ( $is_placeholder ) {
$this->previous_term_id = $this->term_id;
$this->term_id = $r;
$this->update_status = 'inserted';
} else {
$this->update_status = 'updated';
}
$auto_add = $value['auto_add'];
}
}
if ( null !== $auto_add ) {
$nav_menu_options = $this->filter_nav_menu_options_value(
(array) get_option( 'nav_menu_options', array() ),
$this->term_id,
$auto_add
);
update_option( 'nav_menu_options', $nav_menu_options );
}
// Make sure that new menus assigned to nav menu locations use their new IDs.
if ( 'inserted' === $this->update_status ) {
foreach ( $this->manager->settings() as $setting ) {
if ( ! preg_match( '/^nav_menu_locations\[/', $setting->id ) ) {
continue;
}
$post_value = $setting->post_value( null );
if ( ! is_null( $post_value ) && $this->previous_term_id === intval( $post_value ) ) {
$this->manager->set_post_value( $setting->id, $this->term_id );
$setting->save();
}
}
}
}
开发者ID:nasrulhazim,项目名称:WordPress,代码行数:99,代码来源:class-wp-customize-setting.php
示例8: remove_item
public function remove_item($item)
{
$remove_success = false;
switch ($item->type) {
case 'nav_menu':
$remove_success = !is_wp_error(wp_delete_nav_menu($item->id));
break;
case 'nav_menu_item':
// should be picked up by remove nav menu ^
$remove_success = true;
break;
case 'attachment':
$remove_success = wp_delete_attachment($item->id, true) !== false;
break;
case 'revslider':
if (class_exists('RevSlider')) {
$revslider = new RevSlider();
$data = array('sliderid' => $item->id);
try {
$remove_success = $revslider->deleteSliderFromData($data);
} catch (Exception $e) {
$remove_success = false;
}
}
break;
case 'widget':
// remove widget from sidebar
$sidebars_widgets = get_option('sidebars_widgets');
if (isset($sidebars_widgets[$item->id['widget_area']])) {
foreach ($sidebars_widgets[$item->id['widget_area']] as $count => $widget_id) {
if ($widget_id === $item->id['widget_id']) {
unset($sidebars_widgets[$item->id['widget_area']][$count]);
}
}
}
update_option('sidebars_widgets', $sidebars_widgets);
// remove widget
$widget_options = get_option('widget_' . $item->id['type']);
unset($widget_options[$item->id['count']]);
update_option('widget_' . $item->id['type'], $widget_options);
$remove_success = true;
break;
default:
$remove_success = wp_delete_post($item->id, true) !== false;
break;
}
return $remove_success;
}
开发者ID:ntngiri,项目名称:Wordpress-dhaba,代码行数:48,代码来源:OxygennaPackageInstall.php
示例9: destroy_auto_menu
/**
* Destroy auto menu object (currently not used).
*
* @since 1.0.0
*/
public function destroy_auto_menu()
{
// Generate menu title.
$menu_name = $this->plugin->get('menu_name');
// Create new menu if it doesn't already exist.
$menu_exists = wp_get_nav_menu_object($menu_name);
if ($menu_exists) {
wp_delete_nav_menu($menu_name);
}
}
开发者ID:avimedia,项目名称:auto-menu-from-pages,代码行数:15,代码来源:class-auto-menu-from-pages-admin.php
示例10: check_admin_referer
}
}
}
break;
case 'delete-menu-item':
$menu_item_id = (int) $_REQUEST['menu-item'];
check_admin_referer('delete-menu_item_' . $menu_item_id);
if (is_nav_menu_item($menu_item_id) && wp_delete_post($menu_item_id, true)) {
$messages[] = '<div id="message" class="updated"><p>' . __('The menu item has been successfully deleted.') . '</p></div>';
}
break;
case 'delete':
check_admin_referer('delete-nav_menu-' . $nav_menu_selected_id);
if (is_nav_menu($nav_menu_selected_id)) {
$deleted_nav_menu = wp_get_nav_menu_object($nav_menu_selected_id);
$delete_nav_menu = wp_delete_nav_menu($nav_menu_selected_id);
if (is_wp_error($delete_nav_menu)) {
$messages[] = '<div id="message" class="error"><p>' . $delete_nav_menu->get_error_message() . '</p></div>';
} else {
// Remove this menu from any locations.
$locations = get_theme_mod('nav_menu_locations');
foreach ((array) $locations as $location => $menu_id) {
if ($menu_id == $nav_menu_selected_id) {
$locations[$location] = 0;
}
}
set_theme_mod('nav_menu_locations', $locations);
$messages[] = '<div id="message" class="updated"><p>' . __('The menu has been successfully deleted.') . '</p></div>';
// Select the next available menu
$nav_menu_selected_id = 0;
$_nav_menus = wp_get_nav_menus(array('orderby' => 'name'));
开发者ID:Esleelkartea,项目名称:asociacion-tecnicos-artes-escenicas-ATAE-,代码行数:31,代码来源:nav-menus.php
示例11: theme_content_start_import
function theme_content_start_import()
{
check_ajax_referer('theme_content_importer');
if ($sample_data = get_option('theme_sample_data')) {
foreach ($sample_data['posts'] as $post_id) {
wp_delete_post($post_id, true);
}
foreach ($sample_data['pages'] as $page_id) {
wp_delete_post($page_id, true);
}
foreach ($sample_data['widgets'] as $widget_id) {
theme_delete_widget($widget_id, true);
}
foreach ($sample_data['menu'] as $menu_id) {
wp_delete_nav_menu($menu_id);
}
}
$theme_content_importer = new Theme_Content_Import();
$theme_content_importer->go();
update_option('theme_content_import', true);
die;
}
开发者ID:epiii,项目名称:Clean-Wordpress-theme,代码行数:22,代码来源:content-importer.php
示例12: update_option
if (x_demo_content_blog_page()) {
update_option('page_for_posts', x_demo_content_blog_page());
}
}
x_demo_content_set_stage_completed('set-page-options');
}
// Create Menu
// =============================================================================
if (x_demo_content_stage_not_completed('create-menu')) {
//
// Check if the menu exists and delete it if it does.
//
$menu_name = 'X Demo Menu';
$menu_exists = wp_get_nav_menu_object($menu_name);
if ($menu_exists) {
wp_delete_nav_menu($menu_name);
}
//
// Create a new demo menu.
//
$new_menu_id = wp_create_nav_menu($menu_name);
x_demo_content_create_nav_menu($new_menu_id, $front_page_is_page, $front_page_is_blog, $front_page_is_portfolio, $include_posts, $include_portfolio_items);
//
// Assign new menu to all available locations.
//
$menu_locations = get_theme_mod('nav_menu_locations');
$menu_locations['primary'] = $new_menu_id;
$menu_locations['footer'] = $new_menu_id;
set_theme_mod('nav_menu_locations', $menu_locations);
x_demo_content_set_stage_completed('create-menu');
}
开发者ID:bitflipper1,项目名称:ghcontracting,代码行数:31,代码来源:setup.php
示例13: kt_remove_menu
function kt_remove_menu()
{
global $menus_id;
if (is_array($menus_id) && count($menus_id) > 0) {
foreach ($menus_id as $menu) {
wp_delete_nav_menu($menu);
}
delete_option('kt_demo_menus');
$menus_id = array();
}
}
开发者ID:acamboy,项目名称:kutetheme-wp,代码行数:11,代码来源:utility.php
示例14: jeg_prepare_import
function jeg_prepare_import()
{
// prevent double menu
$termarray = array();
$termarray[0] = get_term_by('name', 'Bottom Menu', 'nav_menu');
$termarray[1] = get_term_by('name', 'Main Menu', 'nav_menu');
foreach ($termarray as $term) {
if (is_object($term)) {
wp_delete_nav_menu($term->term_id);
}
}
}
开发者ID:ntnvu,项目名称:tcb_online,代码行数:12,代码来源:import-content.php
示例15: update
/**
* Create/update the nav_menu term for this setting.
*
* Any created menus will have their assigned term IDs exported to the client
* via the customize_save_response filter. Likewise, any errors will be exported
* to the client via the customize_save_response() filter.
*
* To delete a menu, the client can send false as the value.
*
* @since 4.3.0
* @access protected
*
* @see wp_update_nav_menu_object()
*
* @param array|false $value {
* The value to update. Note that slug cannot be updated via wp_update_nav_menu_object().
* If false, then the menu will be deleted entirely.
*
* @type string $name The name of the menu to save.
* @type string $description The term description. Default empty string.
* @type int $parent The id of the parent term. Default 0.
* @type bool $auto_add Whether pages will auto_add to this menu. Default false.
* }
* @return null|void
*/
protected function update($value)
{
if ($this->is_updated) {
return;
}
$this->is_updated = true;
$is_placeholder = $this->term_id < 0;
$is_delete = false === $value;
add_filter('customize_save_response', array($this, 'amend_customize_save_response'));
$auto_add = null;
if ($is_delete) {
// If the current setting term is a placeholder, a delete request is a no-op.
if ($is_placeholder) {
$this->update_status = 'deleted';
} else {
$r = wp_delete_nav_menu($this->term_id);
if (is_wp_error($r)) {
$this->update_status = 'error';
$this->update_error = $r;
} else {
$this->update_status = 'deleted';
$auto_add = false;
}
}
} else {
// Insert or update menu.
$menu_data = wp_array_slice_assoc($value, array('description', 'parent'));
$menu_data['menu-name'] = $value['name'];
$menu_id = $is_placeholder ? 0 : $this->term_id;
$r = wp_update_nav_menu_object($menu_id, wp_slash($menu_data));
$original_name = $menu_data['menu-name'];
$name_conflict_suffix = 1;
while (is_wp_error($r) && 'menu_exists' === $r->get_error_code()) {
$name_conflict_suffix += 1;
/* translators: 1: original menu name, 2: duplicate count */
$menu_data['menu-name'] = sprintf(__('%1$s (%2$d)'), $original_name, $name_conflict_suffix);
$r = wp_update_nav_menu_object($menu_id, wp_slash($menu_data));
}
if (is_wp_error($r)) {
$this->update_status = 'error';
$this->update_error = $r;
} else {
if ($is_placeholder) {
$this->previous_term_id = $this->term_id;
$this->term_id = $r;
$this->update_status = 'inserted';
} else {
$this->update_status = 'updated';
}
$auto_add = $value['auto_add'];
}
}
if (null !== $auto_add) {
$nav_menu_options = $this->filter_nav_menu_options_value((array) get_option('nav_menu_options', array()), $this->term_id, $auto_add);
update_option('nav_menu_options', $nav_menu_options);
}
if ('inserted' === $this->update_status) {
// Make sure that new menus assigned to nav menu locations use their new IDs.
foreach ($this->manager->settings() as $setting) {
if (!preg_match('/^nav_menu_locations\\[/', $setting->id)) {
continue;
}
$post_value = $setting->post_value(null);
if (!is_null($post_value) && $this->previous_term_id === intval($post_value)) {
$this->manager->set_post_value($setting->id, $this->term_id);
$setting->save();
}
}
// Make sure that any nav_menu widgets referencing the placeholder nav menu get updated and sent back to client.
foreach (array_keys($this->manager->unsanitized_post_values()) as $setting_id) {
$nav_menu_widget_setting = $this->manager->get_setting($setting_id);
if (!$nav_menu_widget_setting || !preg_match('/^widget_nav_menu\\[/', $nav_menu_widget_setting->id)) {
continue;
}
$widget_instance = $nav_menu_widget_setting->post_value();
//.........这里部分代码省略.........
开发者ID:idies,项目名称:escience-2016-wp,代码行数:101,代码来源:class-wp-customize-nav-menu-setting.php
示例16: create_nav_menu
protected function create_nav_menu()
{
if (!function_exists('wp_create_nav_menu')) {
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
}
$nav_menu_locations = array();
foreach (wpsw_get_config('register.nav_menus') as $menu_key => $menu_name) {
wp_delete_nav_menu($menu_name);
$items = array_get($this->menus, $menu_key, array());
$menu_items = array();
foreach ($items as $key => $item) {
$data = array();
$data['menu-item-title'] = $item['title'];
$data['menu-item-position'] = $key + 1;
if (isset($item['class'])) {
$data['menu-item-classes'] = explode(' ', $item['class']);
}
if (isset($item['link'])) {
$src = preg_replace('/\\.html$/i', '.md', $item['link']);
$id = wpsw_get_alias_id($src);
$post = get_post($id);
if ($post) {
$data['menu-item-type'] = 'post_type';
$data['menu-item-object'] = $post->post_type;
$data['menu-item-object-id'] = $id;
} else {
$data['menu-item-url'] = $item['link'];
}
}
$menu_item = $this->perpare_nav_item_data($data);
$menu_item_db_id = $this->add_nav_menu_item($menu_name, $menu_item);
pc($menu_item_db_id, 'menu_item_db_id');
foreach (array_get($item, 'sub_menu', array()) as $index => $sub_item) {
$data = array();
$data['menu-item-title'] = $sub_item['title'];
$data['menu-item-position'] = $index + 1;
$data['menu-item-parent-id'] = $menu_item_db_id;
if (isset($sub_item['class'])) {
$data['menu-item-classes'] = explode(' ', $sub_item['class']);
}
if (isset($sub_item['link'])) {
$src = preg_replace('/\\.html$/i', '.md', $sub_item['link']);
$id = wpsw_get_alias_id($src);
$post = get_post($id);
if ($post) {
$data['menu-item-type'] = 'post_type';
$data['menu-item-object'] = $post->post_type;
$data['menu-item-object-id'] = $id;
} else {
$data['menu-item-url'] = $sub_item['link'];
}
}
$sub_menu_item = $this->perpare_nav_item_data($data);
$sub_menu_item_db_id = $this->add_nav_menu_item($menu_name, $sub_menu_item);
}
}
// items loop
$menu = wp_get_nav_menu_object($menu_name);
$nav_menu_locations[$menu_key] = $menu->term_id;
}
// register.nav_menus loop
$theme_mods = array(false, 'nav_menu_locations' => $nav_menu_locations);
$theme = get_option('stylesheet');
if (get_option("theme_mods_{$theme}")) {
update_option("theme_mods_{$theme}", $theme_mods);
} else {
add_option("theme_mods_{$theme}", $theme_mods);
}
}
开发者ID:solutionworks,项目名称:theme-setup,代码行数:69,代码来源:Migration.php
示例17: recreate_default_navigation_menu
public function recreate_default_navigation_menu()
{
$menu_name = 'cuar_main_menu';
$menu = null;
$locations = get_nav_menu_locations();
if (isset($locations[$menu_name]) && $locations[$menu_name] > 0) {
$menu = wp_get_nav_menu_object($locations[$menu_name]);
if ($menu != false) {
$menu_items = wp_get_nav_menu_items($menu->term_id);
// Delete existing menu items
foreach ($menu_items as $item) {
wp_delete_post($item->ID, true);
}
}
}
// Create new menu if not existing already
if ($menu == null) {
wp_delete_nav_menu(_x('wp-customer-area-menu', 'Localised slug for the main navigation menu (small caps version of the "WP Customer Area Menu" translation)', 'cuar'));
$menu = wp_create_nav_menu(__('WP Customer Area Menu', 'cuar'));
}
if (is_wp_error($menu)) {
$this->plugin->add_admin_notice(sprintf(__('Could not create the menu. %s', 'cuar'), $menu->get_error_message()));
return;
} else {
$menu = wp_get_nav_menu_object($menu);
}
// Place the menu at the right location
$locations[$menu_name] = $menu->term_id;
set_theme_mod('nav_menu_locations', $locations);
// Now add all default menu items
$pages = $this->get_customer_area_pages();
$menu_items = array();
foreach ($pages as $slug => $page) {
// Ignore home on purpose
if ($slug == 'customer-home') {
continue;
}
// Exclude pages that are made to be seen when not logged-in
$exclude = false;
if ($page->hide_if_logged_in() || $page->hide_in_menu()) {
$exclude = true;
}
if ($page->always_include_in_menu()) {
$exclude = false;
}
if ($exclude) {
continue;
}
$args = array('menu-item-object-id' => $page->get_page_id(), 'menu-item-object' => 'page', 'menu-item-type' => 'post_type', 'menu-item-status' => 'publish');
// Find parent if any
$parent_slug = $page->get_parent_slug();
if (!empty($parent_slug) && isset($menu_items[$parent_slug])) {
$args['menu-item-parent-id'] = $menu_items[$parent_slug];
}
$item_id = wp_update_nav_menu_item($menu->term_id, 0, $args);
if (!is_wp_error($item_id)) {
// Remember the slug for parent ownership
$menu_items[$slug] = $item_id;
}
}
$this->plugin->clear_attention_needed('nav-menu-needs-sync');
$this->plugin->add_admin_notice(sprintf(__('The menu has been created: <a href="%s">view menu</a>', 'cuar'), admin_url('nav-menus.php?menu=') . $menu->term_id), 'updated');
}
开发者ID:Rohit-Infobeans,项目名称:wordpress,代码行数:63,代码来源:customer-pages-addon.class.php
示例18: importMenu
public function importMenu($menu)
{
wp_delete_nav_menu($menu['menu-name']);
$newMenu = wp_update_nav_menu_object(0, $menu);
if (is_wp_error($newTerm)) {
return $newTerm;
}
$this->registry->set('term', $menu['id'], (int) $newMenu);
foreach ($menu['items'] as $menuItem) {
$existing = $this->registry->get('post', $menuItem['id']);
if (is_nav_menu_item($existing)) {
wp_delete_post($existing, true);
}
if ('taxonomy' == $menuItem['menu-item-type']) {
$menuItem['menu-item-object-id'] = $this->registry->get('term', $menuItem['menu-item-object-id']);
} elseif ('post_type' == $menuItem['menu-item-type']) {
$menuItem['menu-item-object-id'] = $this->registry->get('post', $menuItem['menu-item-object-id']);
}
if (0 != (int) $menuItem['menu-item-parent-id']) {
$menuItem['menu-item-parent-id'] = $this->registry->get('post', $menuItem['menu-item-parent-id']);
if (is_null($menuItem['menu-item-parent-id'])) {
continue;
}
}
$newMenuItem = wp_update_nav_menu_item($newMenu, 0, $menuItem);
if (is_wp_error($newMenuItem)) {
return $newMenuItem;
}
$this->registry->set('post', $menuItem['id'], (int) $newMenuItem);
}
$this->message = sprintf(__('Creating menus...', '__x__'), $menu['menu-name']);
return true;
}
开发者ID:datracka,项目名称:datalook.io,代码行数:33,代码来源:class-x-demo-import-processor.php
示例19: clean_all_alternative_menus
/**
* This function removes all alternative menus. Useful when cleaning and
* deactivating the plugin.
*/
public static function clean_all_alternative_menus()
{
$aux = self::get_instance();
$aux->begin();
$alt_menus = array();
foreach ($aux->menus_in_exps as $menu => $exp) {
wp_delete_nav_menu($menu);
}
$aux->rollback();
}
开发者ID:jeremygeltman,项目名称:ThinkThinly,代码行数:14,代码来源:menu-experiment-controller.php
示例20: delete_agency_menu
/**
* Delete menu when agency is deleted.
*/
public function delete_agency_menu($post_id)
{
$menu = get_post_meta($post_id, 'post_menu');
wp_delete_nav_menu($menu);
}
开发者ID:proudcity,项目名称:wp-proud-agency,代码行数:8,代码来源:wp-proud-agency.php
注:本文中的wp_delete_nav_menu函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论