Documentation
Documentation
Graphic_Data_Deactivation_Cleanup
in package
Asks, on deactivation, whether all Graphic Data plugin data should be permanently deleted if the plugin is later deleted, and performs that wipe from uninstall.php if the answer was yes.
The question is asked on the Plugins screen, before the deactivate link is followed, because a deactivated plugin's PHP is no longer loaded on subsequent requests — including the request where the "Delete" link is clicked, since WordPress only shows that link once a plugin is inactive. That means this plugin cannot interactively ask anything at the actual moment of deletion, so deactivation is used as a stand-in: the answer is stored in the graphic_data_delete_on_uninstall option and read back by uninstall.php when the plugin is eventually removed. Answering the question again on a later deactivation overwrites the stored answer.
Tags
Table of Contents
Constants
- NONCE_ACTION : mixed = 'graphic_data_set_uninstall_preference'
- Nonce action used to authorize the preference-saving AJAX request.
- PREFERENCE_OPTION : mixed = 'graphic_data_delete_on_uninstall'
- Option storing whether uninstall.php should wipe all plugin data.
Methods
- ajax_set_uninstall_preference() : void
- AJAX handler that stores whether the plugin's data should be wiped the next time it is deleted.
- delete_all_data() : void
- Delete all data and images associated with the plugin.
- enqueue_deactivation_script() : void
- Enqueue the deactivation confirmation script on the Plugins screen.
- delete_custom_post_type_posts() : void
- Delete every post of the about, instance, scene, modal, and figure post types.
- delete_data_directory() : void
- Recursively delete the wp-content/data directory.
- delete_instance_associated_images() : void
- Delete every attachment that has a graphic_data_instance_id postmeta value.
- delete_instance_type_taxonomy() : void
- Delete every instance_type taxonomy term, along with its term meta and term relationships. Taxonomy registration itself is code-based and has nothing persisted in the database beyond its terms.
Constants
NONCE_ACTION
Nonce action used to authorize the preference-saving AJAX request.
public
mixed
NONCE_ACTION
= 'graphic_data_set_uninstall_preference'
PREFERENCE_OPTION
Option storing whether uninstall.php should wipe all plugin data.
public
mixed
PREFERENCE_OPTION
= 'graphic_data_delete_on_uninstall'
Absent (falsy) by default, so deleting the plugin leaves its data in place unless the admin opted in on a prior deactivation.
Methods
ajax_set_uninstall_preference()
AJAX handler that stores whether the plugin's data should be wiped the next time it is deleted.
public
ajax_set_uninstall_preference() : void
Runs while the plugin is still active (triggered before the deactivate link is followed), so it must be safe to call independently of deactivation actually completing afterward.
delete_all_data()
Delete all data and images associated with the plugin.
public
delete_all_data() : void
Called from uninstall.php once it has confirmed the admin opted in via the PREFERENCE_OPTION; performs no capability or nonce checks of its own.
enqueue_deactivation_script()
Enqueue the deactivation confirmation script on the Plugins screen.
public
enqueue_deactivation_script(string $hook_suffix) : void
Parameters
- $hook_suffix : string
-
Current admin page hook.
delete_custom_post_type_posts()
Delete every post of the about, instance, scene, modal, and figure post types.
private
delete_custom_post_type_posts() : void
delete_data_directory()
Recursively delete the wp-content/data directory.
private
delete_data_directory() : void
delete_instance_associated_images()
Delete every attachment that has a graphic_data_instance_id postmeta value.
private
delete_instance_associated_images() : void
delete_instance_type_taxonomy()
Delete every instance_type taxonomy term, along with its term meta and term relationships. Taxonomy registration itself is code-based and has nothing persisted in the database beyond its terms.
private
delete_instance_type_taxonomy() : void