unregister_widget() - WordPress 函数参考中文文档

返回介绍

unregister_widget()

发布于 2017-09-11 字数2635 浏览 870 评论 0

unregister_widget( string $widget_class )

Unregisters a widget.


描述

Unregisters a WP_Widget widget. Useful for un-registering default widgets. Run within a function hooked to the ‘widgets_init’ action.


参数

$widget_class

(string)
(Required)
The name of a class that extends WP_Widget.


源代码

File: wp-includes/widgets.php

function unregister_widget($widget_class) {
	global $wp_widget_factory;

	$wp_widget_factory->unregister($widget_class);
}

更新日志

Version 描述
2.8.0 Introduced.

相关函数

Uses

  • wp-includes/class-wp-widget-factory.php:
    WP_Widget_Factory::unregister()

User Contributed Notes

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

    Contributed by Codex

    Example

    This will un-register the built-in WP_Widget_Calendar widget (useful if you wish to replace the built-in version).

    
    function wpdocs_remove_calendar_widget() {
    	unregister_widget( 'WP_Widget_Calendar' );
    }
    add_action( 'widgets_init', 'wpdocs_remove_calendar_widget' );
    
  2. Available parameters (from the Codex):

    WP_Widget_Pages = Pages Widget
    WP_Widget_Calendar = Calendar Widget
    WP_Widget_Archives = Archives Widget
    WP_Widget_Links = Links Widget
    WP_Widget_Meta = Meta Widget
    WP_Widget_Search = Search Widget
    WP_Widget_Text = Text Widget
    WP_Widget_Categories = Categories Widget
    WP_Widget_Recent_Posts = Recent Posts Widget
    WP_Widget_Recent_Comments = Recent Comments Widget
    WP_Widget_RSS = RSS Widget
    WP_Widget_Tag_Cloud = Tag Cloud Widget
    WP_Nav_Menu_Widget = Menus Widget

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!