public function uninstall() { $uninstall = new Uninstall($this->m_db); if ($uninstall->init()) { echo '<h2>Uninstallation succeeded.</h2>'; } else { echo '<h2>Uninstallation failed.</h2>'; } }
/** * Singleton. */ protected function init() { $install = apply_filters(VA_SOCIALBUZZ_PREFIX . 'module_install', Install::get_called_class()); $uninstall = apply_filters(VA_SOCIALBUZZ_PREFIX . 'module_uninstall', Uninstall::get_called_class()); $update = apply_filters(VA_SOCIALBUZZ_PREFIX . 'module_update', Update::get_called_class()); $admin = apply_filters(VA_SOCIALBUZZ_PREFIX . 'module_admin', Admin::get_called_class()); $shortcode = apply_filters(VA_SOCIALBUZZ_PREFIX . 'module_shortcode', ShortCode::get_called_class()); $view = apply_filters(VA_SOCIALBUZZ_PREFIX . 'module_view', View::get_called_class()); $install::get_instance(); $uninstall::get_instance(); $update::get_instance(); $admin::get_instance(); $shortcode::get_instance(); $view::get_instance(); add_image_size(VA_SOCIALBUZZ_PREFIX . 'thumbnail', '980', '9999', false); // Recommend you don't use this short code registering your own post data. add_shortcode('socialbuzz', array(&$this, 'add_shortcode')); if (!is_admin()) { add_action('wp_enqueue_scripts', array(&$this, 'wp_enqueue_scripts'), 15); add_filter('the_content', array(&$this, 'the_content')); } }
<?php namespace WPES; if (!defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN')) { exit; } else { Uninstall::plugin_uninstall(); } class Uninstall { /** * プラグインアンインストール時の処理 */ public static function plugin_uninstall() { global $wpdb; delete_option('wpes_version'); $posts = get_posts(array('numberposts' => -1, 'post_type' => 'wpes', 'post_status' => 'any')); foreach ($posts as $post) { wp_delete_post($post->ID, true); } } }