-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
uninstall.php
53 lines (44 loc) · 972 Bytes
/
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
<?php
/**
* Class Uninstall.
*
* @package mihdan-lite-youtube-embed
*/
namespace Mihdan\LiteYouTubeEmbed;
/**
* Class Uninstall.
*
* @package mihdan-lite-youtube-embed
*/
class Uninstall {
/**
* Uninstall constructor.
*/
public function __construct() {
$this->clear_oembed_cache();
$tools = get_option( 'mlye_tools' );
// Delete plugin data upon uninstall.
if ( isset( $tools['delete_plugin_data'] ) && $tools['delete_plugin_data'] === 'on' ) {
$this->delete_plugin_data();
}
}
/**
* Clear oembed cache.
*/
public function clear_oembed_cache(): void {
global $wpdb;
$sql = "DELETE FROM {$wpdb->postmeta} WHERE LEFT(meta_key, 8) = '_oembed_'";
$wpdb->query( $sql );
}
/**
* Delete plugin data upon uninstall.
*
* @return void
*/
public function delete_plugin_data(): void {
global $wpdb;
$sql = "DELETE FROM {$wpdb->options} WHERE LEFT(option_name, 5) = 'mlye_'";
$wpdb->query( $sql );
}
}
new Uninstall();