/** * Test - create roles */ public function test_create_roles() { // Clean existing install first if (!defined('WP_UNINSTALL_PLUGIN')) { define('WP_UNINSTALL_PLUGIN', true); define('AC_REMOVE_ALL_DATA', true); } include dirname(dirname(dirname(dirname(__FILE__)))) . '/uninstall.php'; AC_Install::create_roles(); }
/** * 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'; }