Я хочу, чтобы мой плагин автоматически создавал пользовательский тип записи при активации.
вот мой код
register_activation_hook(__FILE__, 'activate_myplugin');
function activate_myplugin() {
add_action('init', 'create_custom_type_post');
function create_custom_type_post() {
register_post_type('customposttype', array(
'label' => 'my custom type post',
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array(
'slug' => 'mycustomposttype',
'with_front' => false
),
'query_var' => true,
'supports' => array(
'title',
'editor',
'excerpt',
'trackbacks',
'custom-fields',
'revisions',
'thumbnail',
'author',
'page-attributes'
)
)
);
}
}
, а также как удалить его при деактивации?