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

返回介绍

add_option_whitelist()

发布于 2017-09-10 字数2039 浏览 1239 评论 0

add_option_whitelist( array $new_options,  string|array $options = '' )

Adds an array of options to the options whitelist.


描述


参数

$new_options

(array)
(Required)

$options

(string|array)
(Optional)

Default value: ”


返回值

(array)


源代码

File: wp-admin/includes/plugin.php

function add_option_whitelist( $new_options, $options = '' ) {
	if ( $options == '' )
		global $whitelist_options;
	else
		$whitelist_options = $options;

	foreach ( $new_options as $page => $keys ) {
		foreach ( $keys as $key ) {
			if ( !isset($whitelist_options[ $page ]) || !is_array($whitelist_options[ $page ]) ) {
				$whitelist_options[ $page ] = array();
				$whitelist_options[ $page ][] = $key;
			} else {
				$pos = array_search( $key, $whitelist_options[ $page ] );
				if ( $pos === false )
					$whitelist_options[ $page ][] = $key;
			}
		}
	}

	return $whitelist_options;
}

更新日志

Version 描述
2.7.0 Introduced.

相关函数

Used By

  • wp-admin/includes/plugin.php:
    option_update_filter()

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 David Brumbaugh

    Here’s a nice little tutorial that uses add_option_wp_whitelist: http://wpmututorials.com/how-to/writing-plugins/

发布评论

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

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