I made my first Wordpress plugin and I would get that crease a datatable in worpress databases. I tried the next code buy I get nothing:
register_activation_hook(__FILE__, 'rating_install');
register_deactivation_hook(__FILE__, 'rating_uninstall');
function rating_install(){
//Funcion que genera la instalacion del plugin
global $wpdb;
$table_name = $wpdb->prefix."rating";
$create = "CRETA TABLE ".$table_name." "
. "(id int(11) NOT NULL AUTO_INCREMENT, "
. "url tinytext NOT NULL, "
. "descripcion tinytext NOT NULL)"
. "PRIMARY KEY ('id')";
require_once(ABSPATH."wp-admin/includes/upgrade.php");
dbDelta($create);
}
function rating_uninstall(){
//Funcion que genera la desinstalacion del plugin
global $wpdb;
$table_name = $wpbd->prefix."rating";
$drop = "DROP TABLE IF EXISTS ".$table_name;
require_once(ABSPATH."wp-admin/includes/upgrade.php");
dbDelta($drop);
}
This functions will be do something when we enable/disabled the plugin...buy isn't works.
And other question...how I made the same event when I install the plugin?
Thanks!