Вот что я пробовал.
Код: Выделить всё
function bohio_table() {
global $wpdb;
$wpdb->hide_errors();
// Require upgrade
// Set charset
$collate = '';
if ( $wpdb->has_cap( 'collation' ) ) {
$collate = $wpdb->get_charset_collate();
}
$bohio = $wpdb->prefix . 'bohio';
$cadence = $wpdb->prefix . 'cadence';
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
$queries = array();
// bohio table
array_push($queries, "CREATE TABLE `{$bohio}` (
primary_key mediumint(11) NOT NULL AUTO_INCREMENT,
square_feet varchar(80) NOT NULL,
bed varchar(80) NOT NULL,
bath varchar(80) NOT NULL,
bh_service varchar(80) NOT NULL,
price varchar(80) NOT NULL,
PRIMARY KEY (primary_key)
) {$collate}");
// cadence table
array_push($queries, "CREATE TABLE `{$cadence}` (
id int(11) NOT NULL AUTO_INCREMENT,
fk varchar(80) NOT NULL,
cadence varchar(80) NOT NULL,
price varchar(80) NOT NULL,
PRIMARY KEY (id)
) {$collate}");
foreach ($queries as $key => $sql) {
dbDelta( $sql );
}
}
register_activation_hook( __FILE__, 'bohio_table' );
Называю это в основном файле моего плагина как
Код: Выделить всё
if( !defined('ABSPATH') ) {
die('You cannot be here');
}
if( !class_exists('BohioClean') ) {
class BohioClean{
public function __construct() {
define('MY_PLUGIN_PATH', plugin_dir_path( __FILE__ ));
define('MY_PLUGIN_URL', plugin_dir_url( __FILE__ ));
}
public function initialize() {
// Load tables on the fly
include_once MY_PLUGIN_PATH . 'tables/bohio_table.php';
}
}
$BohioClean = new BohioClean;
$BohioClean->initialize();
}
Пожалуйста, помогите. спасибо и с уважением
Подробнее здесь: https://stackoverflow.com/questions/741 ... activation
Мобильная версия