Advertisement
Guest User

show

a guest
Nov 21st, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. ?>
  2.  
  3. <?php
  4. function callAdmin() {
  5.    include('form.php');
  6. }
  7.  
  8. function AddToOptionPage() {
  9.    add_options_page('One Crazy Plugin', 'One Crazy Plugin', 'manage_options', 'OSCommerceProductDisplay', 'callAdmin');
  10. }
  11. add_action('admin_menu', 'AddToOptionPage');
  12.  
  13. function addHeaderCode() {
  14.    echo '<link type="text/css" rel="stylesheet" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/twitter-rss-social-stats/css/style.css" />' . "\n";
  15. }
  16.  
  17. // Create table in database
  18. function my_plugin_create_table()
  19. {
  20.    global $wpdb;
  21.    if($wpdb->get_var("show tables like TRR_Stats") != 'TRR_Stats')
  22.    {
  23.       $sql = "CREATE TABLE TestTable (
  24.      id mediumint(9) NOT NULL,
  25.      Ime varchar(50) NOT NULL,
  26.      prezime varchar(50) NOT NULL,
  27.      datum datetime NOT NULL,
  28.      UNIQUE KEY id (id)
  29.      );";
  30.       require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
  31.       dbDelta($sql);
  32.    }
  33. }
  34.  
  35.  
  36. // Delete table when deactivate
  37. function my_plugin_remove_database() {
  38.      global $wpdb;
  39.      $table_name = "NestoNovo";
  40.      $sql = "DROP TABLE IF EXISTS $table_name;";
  41.      $wpdb->query($sql);
  42.      delete_option("my_plugin_db_version");
  43. }
  44.  
  45.  
  46. register_activation_hook( __FILE__, 'my_plugin_create_table' );
  47. register_uninstall_hook( __FILE__, 'my_plugin_remove_database' );
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement