Я создал страницу, когда мой плагин активирован. Его работа прекрасна. Теперь я хочу удалить страницу, когда мой плагин отключен.Как удалить страницу после деактивации плагина
Мой код приведен ниже:
register_activation_hook(__FILE__, 'my_plugin_install_function');
function my_plugin_install_function() {
$post = array('page_template' => '', '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); }
register_deactivation_hook(__FILE__, 'my_plugin_remove');
function my_plugin_remove() {// the id of our page...
$the_page_id = get_option($newvalue);
if($the_page_id) {
wp_delete_post($the_page_id); // this will trash, not delete
}
Как я могу получить идентификатор сообщения, чтобы удалить эту страницу?
где получить PAGE_ID ??? могу ли я использовать $ newvalue ??? –
вы должны использовать имя опции, чтобы получить ее из БД. –
получил. Tomas Cot Большое спасибо –