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

返回介绍

sanitize_key()

发布于 2017-09-11 字数5364 浏览 887 评论 0

sanitize_key( string $key )

Sanitizes a string key.


描述

Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes and underscores are allowed.


参数

$key

(string)
(Required)
String key


返回值

(string) Sanitized key


源代码

File: wp-includes/formatting.php

function sanitize_key( $key ) {
	$raw_key = $key;
	$key = strtolower( $key );
	$key = preg_replace( '/[^a-z0-9_\-]/', '', $key );

	/**
	 * Filters a sanitized key string.
	 *
	 * @since 3.0.0
	 *
	 * @param string $key     Sanitized key.
	 * @param string $raw_key The key prior to sanitization.
	 */
	return apply_filters( 'sanitize_key', $key, $raw_key );
}

更新日志

Version 描述
3.0.0 Introduced.

相关函数

Uses

  • wp-includes/formatting.php:
    sanitize_key
  • wp-includes/plugin.php:
    apply_filters()

Used By

  • wp-includes/class-wp-theme.php:
    WP_Theme::get_post_templates()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_search_install_plugins()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_delete_plugin()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_search_plugins()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_install_theme()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_install_plugin()
  • wp-includes/customize/class-wp-customize-nav-menu-item-setting.php:
    WP_Customize_Nav_Menu_Item_Setting::sanitize()
  • wp-includes/class-wp-customize-nav-menus.php:
    WP_Customize_Nav_Menus::ajax_load_available_items()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_update_plugin()
  • wp-includes/class-wp-query.php:
    WP_Query::parse_orderby()
  • wp-admin/includes/class-wp-screen.php:
    WP_Screen::get()
  • wp-admin/includes/export.php:
    export_wp()
  • wp-admin/includes/class-wp-list-table.php:
    WP_List_Table::__construct()
  • wp-admin/includes/ms.php:
    update_user_status()
  • wp-admin/includes/misc.php:
    set_screen_options()
  • wp-admin/includes/post.php:
    post_preview()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_heartbeat()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_save_user_color_scheme()
  • wp-admin/includes/post.php:
    _wp_translate_postdata()
  • wp-admin/includes/post.php:
    edit_post()
  • wp-admin/includes/post.php:
    bulk_edit_posts()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_dismiss_wp_pointer()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_closed_postboxes()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_hidden_columns()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_meta_box_order()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_inline_save_tax()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_get_tagcloud()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_nopriv_heartbeat()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_ajax_tag_search()
  • wp-admin/includes/class-wp-comments-list-table.php:
    WP_Comments_List_Table::prepare_items()
  • wp-includes/class-wp-customize-manager.php:
    WP_Customize_Manager::__construct()
  • wp-includes/theme.php:
    _wp_customize_include()
  • wp-includes/class-wp-query.php:
    WP_Query::parse_query()
  • wp-includes/class-wp-tax-query.php:
    WP_Tax_Query::transform_query()
  • wp-includes/class-wp-user-query.php:
    WP_User_Query::prepare_query()
  • wp-includes/post.php:
    _get_last_post_time()
  • wp-includes/post.php:
    register_post_status()
  • wp-includes/post.php:
    register_post_type()
  • wp-includes/revision.php:
    _wp_preview_terms_filter()
  • wp-includes/post-formats.php:
    has_post_format()
  • wp-includes/post-formats.php:
    set_post_format()
  • wp-includes/nav-menu.php:
    wp_update_nav_menu_item()
  • wp-includes/class-wp-xmlrpc-server.php:
    wp_xmlrpc_server::mw_editPost()
  • wp-includes/class-wp-xmlrpc-server.php:
    wp_xmlrpc_server::mw_newPost()
  • wp-includes/class-wp-meta-query.php:
    WP_Meta_Query::get_sql()
  • wp-includes/meta.php:
    delete_metadata()
  • wp-includes/meta.php:
    update_metadata_by_mid()
  • wp-includes/meta.php:
    delete_metadata_by_mid()
  • wp-includes/meta.php:
    update_meta_cache()
  • wp-includes/meta.php:
    add_metadata()
  • wp-includes/meta.php:
    update_metadata()
  • Show 46 more used by
    Hide more used by


User Contributed Notes

上一篇:sanitize_html_class()

下一篇:sanitize_meta()

发布评论

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

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