Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. // main plugin file, frequentVisitorCoupons.php
  2. require 'vendor/autoload.php';
  3.  
  4. // the first argument points to this file because I think
  5. // autoload automatically loads the Utilities class here
  6. register_activation_hook(plugin_dir_url(__FILE__) . 'frequentVisitorCoupons.php',
  7. 'Utilities::createTablesIfNotExists');
  8.  
  9.  
  10. // classes/utilities.php
  11. <?php
  12. class Utilities {
  13. public static function createTablesIfNotExists() {
  14. global $wpdb;
  15.  
  16. $createCouponTableQuery = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}frequentVisitorCoupons_coupons (
  17. couponId MEDIUMINT NOT NULL AUTO_INCREMENT UNIQUE,
  18. PRIMARY KEY (couponId),
  19. totalHits MEDIUMINT NOT NULL,
  20. isText BOOLEAN NOT NULL,
  21. imageUrl TEXT(1000)
  22. )";
  23.  
  24. <2 more table create queries removed>
  25.  
  26. require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
  27. dbDelta($createCouponTableQuery);
  28.  
  29. var_dump($wpdb->queries);
  30. echo <<<'EOD'
  31. =====$wpdb->queries=====
  32. EOD;
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement