register_deactivation_hook() is launched when a plugin is deactivated. For plugin uninstall, there is register_uninstall_hook().
WordPress plugins can also have a file called uninstall.php that is ran whenever the plugin is uninstalled. To prevent the uninstall.php file from being triggered directly, the state of a constant called WP_UNINSTALL_PLUGIN should be checked before launching the codes for uninstall.
Your uninstall.php could be:
<?php
//if uninstall not called from WordPress exit
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
exit ();
global $wpdb;
$sortsearchtitle_db_version = '1.0';
$table = $wpdb->prefix."sortsearchresult";
$wpdb->query("DROP TABLE IF EXISTS $table");
delete_option('sortsearchtitle_db_version');
Related Posts:
- Which hook should be used to add an action containing a redirect?
- add_action hook for completely new post?
- WordPress Hook for user register
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- What’s the earliest point I can get the queried object ID?
- How do I Make a Theme “plugin-ready”?
- WordPress scheduled task is called but not executed
- How to modify post content before writing to database?
- How do I handle multiple Submit buttons in plugin’s option page?
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- How to check if certain plugin exists and in expected version
- Plugin development, hooks, generate content
- Is it possible to create an action hook using do_action() within add_action()?
- Dynamically Override Fancy Title
- Hook event for upload image in the menu
- Help with callback using do_action_ref_array
- Adding Automatically To In WordPress Using Filter Referencing?
- Best Practices for Creating and Handling Forms with Plugins?
- Is there a better way to implement responsive images than what WordPress uses by default?
- Modifying values with add_action to be sent to db
- Woocommerce – Hide a Column in Cart Table
- Add tab to profile.php wordpress plugin development
- How do I change the initial quantity of a product in woocommerce?
- How to delete an user including data from custom database tables
- Which are the hooks run before/after when a category’s deletion?
- Should action callbacks start with a verb?
- Why is my javascript not invoked in my hooks except wp_head?
- Namespaced action and filter tags
- What filter should I use to insert a button inside on Media>Add New
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- How to use a hook to override an update_post_meta call in a plugin?
- External Authentication, session_tokens not destroyed on logout
- Trying to understand order and frequency of action hooks firing
- correct way to call javascript into hook function
- do_action and add_action on two different installed plugins won’t work
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- template_redirect or admin-ajax.php?
- WordPress custom taxonomy check box to dropdown
- Force HTTPS 301 redirect with hook
- Add a new confirmation page before saving
- use of do_action() without any functions attached
- How dynamic action login_form_{action} is working
- What happens when two or more plugins use the same hook?
- How to get all queries’s results after they have executed?
- flush rewrite rules after plugin update?
- When does save_post hook fire on post save/update
- Plugin does not add action
- Add child pages to submenu automatically
- After plugin activation hook
- How to replace default comments with custom HTML?
- Odd map_meta_cap $args on post edit — sometimes integer, sometimes string
- How can I create a custom plugin that allows anonymous users to signup without registering?
- hook filter after the_content on a specific page
- Is there an admin hook that will let me read GET variable before it’s too late to set the header Location
- Call to undefined function is_home() or any conditional tags
- Associate multiple email addresses with the same user account, so they can log in with either
- Run command “composer install” when activating wordpress plugin
- Add a check box in Menu Settings
- Custom filter not working
- Configure WordPress to Generate Scheme-less Relative URLs
- Using init hook for register_taxonomy is causing invalid_taxonomy in wp_insert_term()
- Ajax +wordpress onClick link redirect to new page and create html content
- How to replace settings in WordPress plugin from a theme
- Creating posts with links from a txt file
- Set the payment processor callbacks to a plugin
- Action / Hook when a new plugin is added
- apply_filters() and call_user_func() to define and call a function outside a class
- Getting Post ID at “stylesheet” and “template” hooks
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- Woocommerce get_term_by() in transition_post_status hook doesn’t works
- Add two button to page and post admin to redirect to : add new & list of (posts – pages) just after saving post or page
- Limit get_next_post to posts from the same author
- Any way, hook to add content right before the “read more” link?
- Is there any way to get post meta from publish_post hook?
- How do I ensure I can loop through every enqueued script and CSS?
- Problem in plugin debuging in wordpress
- OOP development and hooks
- Plugin Development – Call to undefined function comment_exists()
- Add_action not calling callback function
- Prevent plugin activation and add admin notice
- Unable to show a message after plugin activation
- Function not working on any file other than the main plugin file
- Does WordPress have something like timer hook?
- Multi hook deploiement
- Can I use a hook other than ‘init’ to handle form submissions?
- Template file structure , wordpress hook for altering the template
- woocommerce single product page hook not working
- How can I set a dynamic value for post_updated_messages based on return value of post_updated?
- What is the use of wp_schedule_event hook?
- How do I replace title with my plugin?
- Looking for Hook that is fired after a plugin or wp upgrade is installed/updated
- Woocommerce: block user removing cart item
- how to insert content into wp_head after loop_end
- How can I get a plugin to hook ‘dbdelta_queries’ — a filter used during version update?
- Send retrieve password notification email with custom HTML email template
- wp_head is not fired from the hook I have used in my plugin
- Execute callback after REST API request completes + Response is sent
- How to customize password reset message page on success if no error in password reset
- how to execute a function only when i send an order to trash [closed]