Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // main plugin file, frequentVisitorCoupons.php
- require 'vendor/autoload.php';
- // the first argument points to this file because I think
- // autoload automatically loads the Utilities class here
- register_activation_hook(plugin_dir_url(__FILE__) . 'frequentVisitorCoupons.php',
- 'Utilities::createTablesIfNotExists');
- // classes/utilities.php
- <?php
- class Utilities {
- public static function createTablesIfNotExists() {
- global $wpdb;
- $createCouponTableQuery = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}frequentVisitorCoupons_coupons (
- couponId MEDIUMINT NOT NULL AUTO_INCREMENT UNIQUE,
- PRIMARY KEY (couponId),
- totalHits MEDIUMINT NOT NULL,
- isText BOOLEAN NOT NULL,
- imageUrl TEXT(1000)
- )";
- <2 more table create queries removed>
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
- dbDelta($createCouponTableQuery);
- var_dump($wpdb->queries);
- echo <<<'EOD'
- =====$wpdb->queries=====
- EOD;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement