-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbooks-plugin.php
40 lines (33 loc) · 1.01 KB
/
books-plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/*
Plugin Name: Books Plugin
Description: A plugin that manages books, including a custom post type, taxonomies, and a meta box for ISBN.
Version: 1.0
Author: Alireza Abedi
Text Domain: books-plugin
Domain Path: /languages
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once plugin_dir_path( __FILE__ ) . 'includes/class-books-plugin.php';
function run_books_plugin() {
$plugin = new BooksPlugin\Books_Plugin();
$plugin->run();
}
run_books_plugin();
register_activation_hook( __FILE__, 'books_plugin_activate' );
function books_plugin_activate() {
global $wpdb;
$table_name = $wpdb->prefix . 'books_info';
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name (
ID bigint(20) NOT NULL AUTO_INCREMENT,
post_id bigint(20) NOT NULL,
isbn varchar(255) DEFAULT '' NOT NULL,
PRIMARY KEY (ID),
UNIQUE KEY post_id (post_id)
) $charset_collate;";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $sql );
}