我是php和wp插件开发新手,我刚刚为我的测试插件创建了一个简单的选项页面,选项页面只有一个复选框,我不知道如何在选中该复选框时执行一些功能,
我的插件选项页面如下
<?php
add_action( \'admin_menu\', \'chec_add_admin_menu\' );
add_action( \'admin_init\', \'chec_settings_init\' );
function chec_add_admin_menu( ) {
add_options_page( \'Checking\', \'Checking\', \'manage_options\', \'checking\', \'checking_options_page\' );
}
function chec_settings_init( ) {
register_setting( \'my_option\', \'chec_settings\' );
add_settings_section(
\'chec_checking_section\',
__( \'Your section description\', \'wp\' ),
\'chec_settings_section_callback\',
\'checking\'
);
add_settings_field(
\'chec_checkbox_field_0\',
__( \'Settings field description\', \'wp\' ),
\'chec_checkbox_field_0_render\',
\'checking\',
\'chec_checking_section\'
);
}
function chec_checkbox_field_0_render( ) {
$options = get_option( \'chec_settings\' );
?>
<input type=\'checkbox\' name=\'chec_settings[chec_checkbox_field_0]\' <?php checked( $options[\'chec_checkbox_field_0\'], 1 ); ?> value=\'1\'>
<?php
}
function chec_settings_section_callback( ) {
echo __( \'This section description\', \'wp\' );
}
function checking_options_page( ) {
?>
<form action=\'options.php\' method=\'post\'>
<h2>Checking</h2>
<?php
settings_fields( \'my_option\' );
do_settings_sections( \'checking\' );
submit_button();
?>
</form>
<?php
}
?>
现在,我想删除管理栏中的wp徽标,当使用以下代码选中该复选框时
add_action( \'admin_bar_menu\', \'remove_wp_logo\', 999 );
function remove_wp_logo( $wp_admin_bar ) {
$wp_admin_bar->remove_node( \'wp-logo\' );
}
如何做到这一点?