-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
83 lines (63 loc) · 2.25 KB
/
uninstall.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
*
* Description: uninstall script - Fotorama Multi Slider -automatically run by WP
* Author: Martin von Berg
* Author URI: https://www.berg-reise-foto.de/software-wordpress-lightroom-plugins/wordpress-plugins-fotos-und-gpx/
* License: GPL-2.0
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
// delete options in wp_options in the database at uninstall of the plugin
// if uninstall.php is not called by WordPress, die
if ( ! defined('WP_UNINSTALL_PLUGIN') ) {
die;
}
$option_name = 'fotorama_option2';
delete_option($option_name);
$option_name = 'fotorama_elevation_option_name';
delete_option($option_name);
$option_name = 'gpx-file';
delete_option($option_name);
$option_name = 'fm_plugins_checker';
delete_option($option_name);
$option_name = 'fm_swiper_options';
delete_option($option_name);
$option_name = 'fm_leaflet_options';
delete_option($option_name);
$option_name = 'fm_common_options';
delete_option($option_name);
$option_name = 'fm_fotorama_options';
delete_option($option_name);
$option_name = 'fm_gpx_options';
delete_option($option_name);
$option_name = 'fm_impexp_options';
delete_option($option_name);
$option_name = 'fm_masonry_options';
delete_option($option_name);
delete_custom_field( 'lat' );
delete_custom_field( 'lon' );
delete_custom_field( 'geoadress' );
delete_custom_field( 'fm_header_link' );
// Note: 'postimg' is deleted at deactivation, so no need to delete it here.
/**
* On Uninstall of the Plugin: Delete the custom-fields lat, lon, geoadress, fm_header_link for all pages and posts as this option is no longer required.
*
* @param string $key the custom-field to delete
* @return void none
*/
function delete_custom_field( string $key) {
$args = array(
'post_type' => array( 'post', 'page' ),
'posts_per_page' => -1,
'post_status' => array( 'publish', 'draft' ),
'meta_key' => $key
);
$the_query = new \WP_Query( $args );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
delete_post_meta( \get_the_ID(), $key);
}
}
wp_reset_postdata();
}