public function install(Table $table = null)
{
$table = $table ?: $this->table;
if (!$table) {
throw InvalidTableException::for_action('install');
}
$table_name = $table->name();
$schema = $table->schema();
$columns = $this->get_columns($schema);
$keys = $this->get_keys($table);
$options = $this->get_options();
/**
* WordPress file with the dbDelta() function.
*/
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta("CREATE TABLE {$table_name} ({$columns}{$keys}) {$options}");
if (!$this->table_exists($table_name)) {
return false;
}
$this->insert_default_content($table);
return true;
}
/** * @return void */ public function reset_table() { \Inpsyde\MultilingualPress\check_admin_referer($this->nonce); $table_prefix = $this->wpdb->base_prefix; $table = new LanguagesTable($table_prefix); $installer = new WPDBTableInstaller($table); $installer->uninstall(); $installer->install(); /** * Runs after having reset the database table. * * @param Table $table Languages table object. */ do_action('mlp_reset_table_done', $table); $url = add_query_arg('msg', 'resettable', $_REQUEST['_wp_http_referer']); wp_safe_redirect($url); \Inpsyde\MultilingualPress\call_exit(); }