Wordpress Plugin Development tutorial from scratch (Part 28) 'My Book' Plugin Create/Drop Table #5

preview_player
Показать описание
In this video session we will discuss about "My Book" Plugin tables script,
1. How can we create table when plugin activates?
2.How can we drop table when plugin deactivates or uninstalls?

#WordpressTutorialsPoint
#WordpressLearnersHub
#WordpressCustomizations
#LearnWordpressStepbyStep
#WordpressBySanjay

function my_book_table() {
global $wpdb;
return $wpdb-prefix . "my_books"; //wp_my_books
}

function my_book_generates_table_script() {

global $wpdb;

$sql = " CREATE TABLE `" . my_book_table() . "` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`author` varchar(255) DEFAULT NULL,
`about` text,
`book_image` text,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1";

dbDelta($sql);
}

register_activation_hook(__FILE__, "my_book_generates_table_script");

function drop_table_plugin_books() {
global $wpdb;
$wpdb-query("DROP TABLE IF EXISTS " . my_book_table());
}

register_deactivation_hook(__FILE__, "drop_table_plugin_books");
// register_uninstall_hook(__FILE__,"drop_table_plugin_books");

To add an administration menu
===============
Please Watch for help:

To add an administration submenus:
===============
Please Watch for help:

Important Videos from Plugin Development Series
===============

SOCIAL :
===============

RECOMMENDATION:
===============
1. Some knowledge of PHP, HTML for this video series

Also you can learn Wordpress Custom
===============

Tags
===============
online web tutor,
profotech solutions,
wordpress plugin development from scratch in hindi,
wordpress plugin development from scratch in easy steps,
wordpress plugin development,
wordpress plugin development in easy steps,
plugin development in wordpress from scratch in hindi,
plugin development in wordpress by online web tutor,
plugin development in wordpress tutorials from scratch in hindi,
plugin theme development tutorials in hindi,
plugin development tutorials in hindi,
owt tuts,
online web tutorials,

Thanks
Online Web Tutor
Keep learning and Sharing :)

-~-~~-~~~-~~-~-
-~-~~-~~~-~~-~-
Рекомендации по теме
Комментарии
Автор

Can I insert username (created by: ) into the database table?

SabbirAhmed-cmhk
Автор

drop table doesnt work then try :$wpdb->query("DROP TABLE IF EXISTS `" . your_table() . "`") ;

SagarSagar-rofj
visit shbcf.ru