/** * Handles output of tools. */ public static function status_tools() { global $wpdb; $tools = self::get_tools(); if (!empty($_GET['action']) && !empty($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'debug_action')) { switch ($_GET['action']) { case 'clear_expired_transients': /* * Deletes all expired transients. The multi-table delete syntax is used * to delete the transient record from table a, and the corresponding * transient_timeout record from table b. * * Based on code inside core's upgrade_network() function. */ $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\t\t\t\t\tWHERE a.option_name LIKE %s\n\t\t\t\t\t\tAND a.option_name NOT LIKE %s\n\t\t\t\t\t\tAND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )\n\t\t\t\t\t\tAND b.option_value < %d"; $rows = $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_transient_') . '%', $wpdb->esc_like('_transient_timeout_') . '%', time())); $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\t\t\t\t\tWHERE a.option_name LIKE %s\n\t\t\t\t\t\tAND a.option_name NOT LIKE %s\n\t\t\t\t\t\tAND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )\n\t\t\t\t\t\tAND b.option_value < %d"; $rows2 = $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_') . '%', $wpdb->esc_like('_site_transient_timeout_') . '%', time())); echo '<div class="updated inline"><p>' . sprintf(__('%d Transients Rows Cleared', 'axiscomposer'), $rows + $rows2) . '</p></div>'; break; case 'reset_roles': // Remove then re-add caps and roles AC_Install::remove_roles(); AC_Install::create_roles(); echo '<div class="updated inline"><p>' . __('Roles successfully reset', 'axiscomposer') . '</p></div>'; break; default: $action = esc_attr($_GET['action']); if (isset($tools[$action]['callback'])) { $callback = $tools[$action]['callback']; $return = call_user_func($callback); if ($return === false) { if (is_array($callback)) { echo '<div class="error inline"><p>' . sprintf(__('There was an error calling %s::%s', 'axiscomposer'), get_class($callback[0]), $callback[1]) . '</p></div>'; } else { echo '<div class="error inline"><p>' . sprintf(__('There was an error calling %s', 'axiscomposer'), $callback) . '</p></div>'; } } } break; } } // Display message if settings settings have been saved if (isset($_REQUEST['settings-updated'])) { echo '<div class="updated inline"><p>' . __('Your changes have been saved.', 'axiscomposer') . '</p></div>'; } include_once dirname(__FILE__) . '/views/html-admin-page-status-tools.php'; }
/** * Test - remove roles */ public function test_remove_roles() { AC_Install::remove_roles(); }
* @package AxisComposer/Uninstaller * @version 1.0.0 */ if (!defined('WP_UNINSTALL_PLUGIN')) { exit; } global $wpdb, $wp_version; /* * Only remove ALL pagebuilder data if AC_REMOVE_ALL_DATA constant is set to true in user's * wp-config.php. This is to prevent data loss when deleting the plugin from the backend * and to ensure only the site owner can perform this action. */ if (defined('AC_REMOVE_ALL_DATA') && true === AC_REMOVE_ALL_DATA) { // Roles + caps. include_once dirname(__FILE__) . '/includes/class-ac-install.php'; AC_Install::remove_roles(); // Delete options. $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'axiscomposer\\_%';"); // Delete posts + data. $wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'portfolio' );"); $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE meta_key IN ( '_pagebuilder_status', '_pagebuilder_canvas' );"); $wpdb->query("DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;"); // Delete terms if > WP 4.2 (term splitting was added in 4.2) if (version_compare($wp_version, '4.2', '>=')) { // Delete term taxonomies foreach (array('portfolio_cat', 'portfolio_tag', 'portfolio_type') as $taxonomy) { $wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy)); } // Delete orphan relationships $wpdb->query("DELETE tr FROM {$wpdb->term_relationships} tr LEFT JOIN {$wpdb->posts} posts ON posts.ID = tr.object_id WHERE posts.ID IS NULL;"); // Delete orphan terms