-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.php
67 lines (54 loc) · 2.57 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
<?php
/**
* a3 Portfolio Uninstall
*
* Uninstalling deletes options, tables, and pages.
*
*/
if( ! defined( 'WP_UNINSTALL_PLUGIN' ) )
exit();
$plugin_key = 'a3_portfolios';
// Delete Google Font
delete_option( $plugin_key . '_google_api_key' . '_enable' );
delete_transient( $plugin_key . '_google_api_key' . '_status' );
delete_option( $plugin_key . '_google_font_list' );
if ( get_option( $plugin_key . '_clean_on_deletion' ) == 1 ) {
delete_option( $plugin_key . '_google_api_key' );
delete_option( $plugin_key . '_toggle_box_open' );
delete_option( $plugin_key . '-custom-boxes' );
delete_metadata( 'user', 0, $plugin_key . '-' . 'plugin_framework_global_box' . '-' . 'opened', '', true );
global $wpdb;
// Delete Pages
wp_trash_post( get_option( 'portfolio_page_id' ) );
// Delete Plugin Settings
delete_option( 'a3_portfolio_global_settings' );
delete_option( 'a3_portfolio_item_cards_settings' );
delete_option( 'a3_portfolio_global_item_expander_settings' );
delete_option( 'a3_portfolio_item_posts_settings' );
delete_option( 'a3_portfolio_shortcodes_setting' );
delete_option( $plugin_key . '_clean_on_deletion' );
// Delete Tables
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "a3_portfolio_feature" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "a3_portfolio_categorymeta" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "a3_portfolio_attributes" );
// Delete postmeta
delete_post_meta_by_key( '_a3_portfolio_meta_layout_column' );
delete_post_meta_by_key( '_a3_portfolio_meta_gallery_wide' );
delete_post_meta_by_key( '_a3_portfolio_meta_thumb_position' );
delete_post_meta_by_key( '_a3_portfolio_launch_site_url' );
delete_post_meta_by_key( '_a3_portfolio_launch_button_text' );
delete_post_meta_by_key( '_a3_portfolio_viewmore_button_text' );
delete_post_meta_by_key( '_a3_portfolio_image_gallery' );
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE '_a3_portfolio_meta_feature_%';" );
// Delete posts
$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'a3-portfolio' );" );
// Delete wpml data
$string_ids = $wpdb->get_col( "SELECT id FROM {$wpdb->prefix}icl_strings WHERE context='a3 Portfolios' " );
if ( is_array( $string_ids ) && count( $string_ids ) > 0 ) {
$str = join( ',', array_map( 'intval', $string_ids ) );
$wpdb->query( "
DELETE s.*, t.* FROM {$wpdb->prefix}icl_strings s LEFT JOIN {$wpdb->prefix}icl_string_translations t ON s.id = t.string_id
WHERE s.id IN ({$str})" );
$wpdb->query( "DELETE FROM {$wpdb->prefix}icl_string_positions WHERE string_id IN ({$str})" );
}
}