Use this code
register_activation_hook(__FILE__, 'rating_install');
register_deactivation_hook(__FILE__, 'rating_uninstall');
function rating_install(){
global $wpdb;
$table_name = $wpdb->prefix."rating";
$create = "CRETA TABLE ".$table_name." ( "
. "id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, "
. "url TINYTEXT NOT NULL, "
. "descripcion TINYTEXT NOT NULL ) ";
$wpdb->query($create);
}
function rating_uninstall(){
global $wpdb;
$table_name = $wpdb->prefix."rating";
$drop = "DROP TABLE IF EXISTS ".$table_name;
$wpdb->query($drop);
}
Related Posts:
- How to redirect to settings page once the plugin is activated?
- How to output message during plugin activation
- Prevent network activation of plugin
- Inserting Taxonomy Terms During a Plugin Activation?
- Using wp_cron with custom time interval and the register activation hook
- Call activation hook multiple times
- Only allow plugin to be activated on root site of multisite
- Install widget on plugin activation
- why creating tables using $wpdb is not being executed while installing plugins?
- Override pluggable functions in a plugin?
- Plugin activation error due to unexpected output
- Settings not set after calling register_setting()
- Is there any way to allow a plugin to write over a previous version?
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- How to stop activation addon if the main plugin is not activated
- Add Link Category on Activation?
- WordPress Plugin Activate / Deactive Failing
- Multiple array for post_content on plugin activation
- Class cannot be found, but it’s available in the file, I get: Fatal Error: Uncaught Error: Class ‘Blocks\Base\Activation’ not found
- Plugin can’t be activated [closed]
- Clean way to initialize plugin in newly-added site when plugin has been network activated?
- Activate / Deactivate plugin
- Plugin Install Issue “-1” Appended to end of plugin name
- Error Connecting to Database WHEN Installing WordPress on XAMPP [Tried All the Usual Stuff] (Pics Included)
- WordPress Fatal error: Uncaught Error: Call to undefined function dbDelta()
- Custom Plugin activation error in Multisite
- How to store in the database directly the translation?
- Unable to show a message after plugin activation
- Refresh or redirect page after activate my plugin
- How to make auto installer Plugin?
- WordPress plugin tables become corrupt
- Deactivate plugin on registration
- how can a plugin return an error message on activation?
- Is there a canonical way for a plugin to install a mu-plugin or drop-in?
- My activator class isn’t running the code inside
- What process do you use for WordPress development? [closed]
- How do I create a custom role capability?
- Where to put third party PHP library?
- Add a new tab to WordPress Plugin install Listing
- Export data as CSV in back end with proper HTTP headers
- Scheduled events disappear from events queue
- How to integrate a PHP webmail script into the backend of WordPress?
- Custom Post Type Link from Plugin
- How to Get a List of Sub Blogs without Using get_blog_list()?
- Conditional check to see if a bootstrap.css is included in a theme
- Create Element From Dynamic HTML String [closed]
- Can I add pages to my custom menu via script?
- what is the best practice for including ‘wp-includes’ classes
- Programmatically Selecting Theme Based on URL
- Custom Plugin Database relations
- Save user-specific options in WordPress admin
- Why is print_r returning $classObj->userObj in several places on site
- How can i get the title i specified in add_options_page for my header
- use __($str) to translate strings (symfony/twig)
- Plugin development: is adding empty index.php files necessary?
- Plugin base URL
- Is there a way to list tags order by post_meta field
- Customize multisite site creation with user data
- Adding plugin settings link upon activation
- Proper way to run wp_query from inside a plugin
- Buddypress function and global $bp question
- Custom plugin: Loop through taxonomy types and update columns for all types?
- How to create a table with filters for my plugin
- Maximum lifetime for nonce
- How to Display my HTML form in my Custom Plugin?
- How to setAttributes in Gutenberg block?
- Adding rewrite rule dynamically
- Incorporate small angular feature in my wordpress site
- Use just a shortcode from another page
- Using a multiple element in widget form
- How can I avoid conflicts between plugin and theme?
- How to control an elements classes from multiple Gutenberg sidebar controls?
- $wpdb->prepare with LIKE and sprintf
- Why in this archive page that call query_posts() function show only the last 10 posts?
- Quasi-custom API Call Plugin
- How can I show posts for a single category?
- Show content without a post
- WP ajax requests not stacking?
- In wordpress plugin wp_signon shows error
- Is it possible to load the css just on my plugin admin page?
- Problem with autoloader and namespaces
- How to create taxonomy without using register_taxonomy () function
- AJAX call returns ‘testtest0’ instead of ‘test’ – why?
- Get audio metadata on file upload
- Loading Images from Javascript on the Front End
- Custom payment method after payment user is logged out on thank you page
- The URL of images on my website changed after being set as featured image
- extraprops override existing props
- converting a node.js project into a wp plugin
- how to handle premium features in a wordpress plugin?
- Unexpected issue when using attachment_fields_to_edit filter
- How Can I Update wp_enqueue_scripts () From WordPress Option Page Radio Buttons
- Load textdomain from global languages directory
- WP Cron as Fast as WordPress AJAX?
- Tie specific functions to options-update for limiting API requests
- How to set custom homepage via a plugin
- the correct way to use options from settings page [closed]
- On one of my sites a file is shown as 404 but the file IS there
- How to synchronize an e-commerce site and a pharmacy management software?
- Extend WP_List_Table class – Edit wp_usermeta – WPPB.me Boilerplate – Action error