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


PHP wp_delete_nav_menu函数代码示例

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


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


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