wp_protect_special_option

函式
wp_protect_special_option ( $option )
引數
  • (string) $option Option name.
    Required:
定義位置
相關方法
wp_widget_descriptionget_site_optionwp_load_alloptionswp_load_core_site_optionsupdate_user_option
引入
2.2.0
棄用
-

wp_protect_special_option: 這個函式用來保護某些WordPress選項不被未經授權的使用者刪除或修改。它在允許使用者對選項進行修改之前檢查使用者的許可權。

保護WordPress的特殊選項不被修改。

如果$option在受保護的列表中,將會死亡。受保護的選項是”alloptions”和”notoptions”選項。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_protect_special_option( $option ) {
if ( 'alloptions' === $option || 'notoptions' === $option ) {
wp_die(
sprintf(
/* translators: %s: Option name. */
__( '%s is a protected WP option and may not be modified' ),
esc_html( $option )
)
);
}
}
function wp_protect_special_option( $option ) { if ( 'alloptions' === $option || 'notoptions' === $option ) { wp_die( sprintf( /* translators: %s: Option name. */ __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) ); } }
function wp_protect_special_option( $option ) {
	if ( 'alloptions' === $option || 'notoptions' === $option ) {
		wp_die(
			sprintf(
				/* translators: %s: Option name. */
				__( '%s is a protected WP option and may not be modified' ),
				esc_html( $option )
			)
		);
	}
}

常見問題

FAQs
檢視更多 >