无需按钮即可添加:
register_activation_hook( __FILE__, \'my_plugin_install_function\');
function my_plugin_install_function()
{
//post status and options
$post = array(
\'comment_status\' => \'closed\',
\'ping_status\' => \'closed\' ,
\'post_author\' => 1,
\'post_date\' => date(\'Y-m-d H:i:s\'),
\'post_name\' => \'Checklists\',
\'post_status\' => \'publish\' ,
\'post_title\' => \'Checklists\',
\'post_type\' => \'page\',
);
//insert page and save the id
$newvalue = wp_insert_post( $post, false );
//save the id in the database
update_option( \'hclpage\', $newvalue );
}
此功能将在用户安装插件时运行。对于超级智能控制,您应该检查该选项是否已经存在,以及id是否不是0(这意味着失败)