/** * Uninstalling WPL * @author Howard <*****@*****.**> * @return boolean */ public function uninstall_wpl() { $tables = wpl_db::select('SHOW TABLES'); $database = wpl_db::get_DBO(); foreach ($tables as $table_name => $table) { if (strpos($table_name, $database->prefix . 'wpl_') !== false) { /** drop table **/ wpl_db::q("DROP TABLE `{$table_name}`"); } } /** delete options **/ wpl_db::q("DELETE FROM `#__options` WHERE `option_name` LIKE 'wpl_%' AND `option_name` NOT LIKE 'wpl_theme%'", 'delete'); /** remove WPL upload directory **/ if (function_exists('is_multisite') and is_multisite() and wpl_global::check_addon('multisite')) { $original_blog_id = wpl_global::get_current_blog_id(); // Get all blogs $blogs = wpl_db::select("SELECT `blog_id` FROM `#__blogs`", 'loadColumn'); foreach ($blogs as $blog) { if (!isset($blog->blog_id)) { continue; } switch_to_blog($blog->blog_id); $upload_path = wpl_global::get_upload_base_path($blog->blog_id); if (wpl_folder::exists($upload_path)) { wpl_folder::delete($upload_path); } } switch_to_blog($original_blog_id); } else { $upload_path = wpl_global::get_upload_base_path(); if (wpl_file::exists($upload_path)) { wpl_file::delete($upload_path); } } return true; }
/** * This functions will take care of multisite usage * @author Howard <*****@*****.**> * @param type $blog_id * @return string WPL base url for uploaded files */ public static function get_upload_base_url($blog_id = NULL) { if (!$blog_id) { $blog_id = wpl_global::get_current_blog_id(); } $ABSPATH = WPL_UP_ABSPATH; if (!$blog_id or $blog_id == 1) { return wpl_global::get_wp_site_url() . 'wp-content/uploads/WPL/'; } else { $path = rtrim($ABSPATH, DS) . $blog_id . DS; if (!wpl_folder::exists($path)) { wpl_folder::create($path); } return wpl_global::get_wp_site_url() . 'wp-content/uploads/WPL' . $blog_id . '/'; } }