Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Project and support maintained on github at [pfefferle/wordpress-webmention](htt
* Fix `array_merge()` error when `_embedded` key is missing in WordPress API response.
* Fix fatal error when parsing invalid date strings in webmentions.
* Fix span tags inside anchor tags confusing WordPress auto-linking.
* Add uninstall method to clean up plugin options on deletion.
* Add `webmention_form_submit_text` filter to customize the "Ping me!" button text.
* Fix distorted emoji display when avatars are disabled in Discussion settings.
* Add basic styling for webmention form input and button elements.
Expand Down
64 changes: 64 additions & 0 deletions uninstall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Webmention Uninstall
*
* Fired when the plugin is uninstalled to clean up plugin options and cached files.
*
* @package Webmention
*/

// If uninstall not called from WordPress, exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}

/**
* Delete all plugin options.
*/
$options = array(
// Settings registered in class-admin.php.
'webmention_disable_selfpings_same_url',
'webmention_disable_selfpings_same_domain',
'webmention_disable_media_mentions',
'webmention_support_post_types',
'webmention_show_comment_form',
'webmention_comment_form_text',
'webmention_home_mentions',
'webmention_approve_domains',
'webmention_avatars',
'webmention_avatar_store_enable',
'webmention_separate_comment',
'webmention_show_facepile',
'webmention_facepile_fold_limit',
// Legacy option for media mentions.
'webmention_send_media_mentions',
// Database version tracking.
'webmention_db_version',
// Migration lock.
'webmention_migration_lock',
);

foreach ( $options as $option ) {
delete_option( $option );
}

/**
* Delete cached avatar files using WP_Filesystem.
*/
global $wp_filesystem;

if ( ! function_exists( 'WP_Filesystem' ) ) {
require_once ABSPATH . 'wp-admin/includes/file.php';
}

WP_Filesystem();

if ( $wp_filesystem ) {
$upload_dir = wp_get_upload_dir();
$webmention_dir = $upload_dir['basedir'] . '/webmention';

// Delete the entire webmention directory recursively.
if ( $wp_filesystem->is_dir( $webmention_dir ) ) {
$wp_filesystem->delete( $webmention_dir, true );
}
}
Loading