Bạn đang xem: Uninstall
I have found this on the WordPress codex, but I don"t understand what to vị with it.. Shame
if ( !defined( "WP_UNINSTALL_PLUGIN" ) ) exit();$option_name = "plugin_option_name";delete_option( $option_name );// For site options in multisitedelete_site_option( $option_name ); //drop a custom db tableglobal $wpdb;$wpdb->query( "DROP TABLE IF EXISTS $wpdb->prefixmytable" );Can anyone help?
Thanks in advance
Would this be correct?
if ( !defined( "WP_UNINSTALL_PLUGIN" ) ) exit(); global $wpdb; $posts_table = $wpdb->posts; $query = " DELETE FROM wp_posts WHERE post_type = "messages" ";$wpdb->query($query);
chia sẻ
Improve this question
Follow
edited Aug 8, năm trước at 11:15
antonio83
asked Aug 8, 2014 at 8:04

antonio83antonio83
42433 silver badges99 bronze badges
2
showroom a comment |
1 Answer 1
Sorted by: Reset to default
Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first)
1
The WP codex page http://codex.wordpress.org/Function_Reference/register_uninstall_hook has 2 important pieces of information, only 1 of which you menu in your question. You bởi need lớn make sure that you register the hook.
That aside, if you want to lớn remove all custom post data (regardless if it is upon uninstallation or as another person commented having a seperate button khổng lồ remove data as many plugins do) you need to be sure khổng lồ remove the postmeta records as well.
Xem thêm: Bệnh Phụ Nữ Băng Huyết Là Gì?Tìm Hiểu Nguyên Nhân Tìm Hiểu Nguyên Nhân
global $wpdb;$cptName = "messages";$tablePostMeta = $wpdb->prefix . "postmeta";$tablePosts = $wpdb->prefix . "posts";$postMetaDeleteQuery = "DELETE FROM $tablePostMeta". " WHERE post_id IN". " (SELECT id FROM $tablePosts WHERE post_type="$cptName"";$postDeleteQuery = "DELETE FROM $tablePosts WHERE post_type="$cptName"";$wpdb->query($postMetaDeleteQuery);$wpdb->query($postDeleteQuery);
cốt truyện
Improve this answer
Follow
answered Aug 9, 2014 at 3:29

Adam ErstelleAdam Erstelle
2,41433 gold badges2121 silver badges3535 bronze badges
1
add a phản hồi |
Your Answer
Thanks for contributing an answer khổng lồ Stack Overflow!Please be sure lớn answer the question. Provide details & share your research!
But avoid …
Asking for help, clarification, or responding khổng lồ other answers.Making statements based on opinion; back them up with references or personal experience.To learn more, see our tips on writing great answers.
Draft saved
Draft discarded
Sign up or log in
Sign up using Google
Sign up using Facebook
Sign up using e-mail and Password
Submit
Post as a guest
Name
e-mail Required, but never shown
Post as a guest
Name
thư điện tử
Required, but never shown
Post Your Answer Discard
By clicking “Post Your Answer”, you agree khổng lồ our terms of service, privacy policy and cookie policy
Not the answer you're looking for? Browse other questions tagged or ask your own question.
The Overflow Blog Featured on Meta
Related
635
Can I install/update WordPress plugins without providing FTP access?
3
wordpress mysql - delete all custom post type
4
Order by custom field (numeric) in WP_Query
0
Wordpress custom metabox, load on posts, pages, & all custom post types?
0
Mysql Left OUTER JOIN with Subquery (wordpress)
1
wordpress kiến thiết pattern name
Hot Network Questions more hot questions
Question feed
Subscribe to lớn RSS
Question feed khổng lồ subscribe to this RSS feed, copy and paste this URL into your RSS reader.

lang-php
Stack Overflow
Products
Company
Stack Exchange Network
Site design / logo sản phẩm © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. Rev2023.1.5.43140
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device & disclose information in accordance with our Cookie Policy.