Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.06 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: OneAwesomePlugin
  4. Description: VeryAwesomePlugin ;)
  5. Version: 1.0
  6. Author:
  7. Author URI:
  8. */
  9. ?>
  10.  
  11. <?php
  12. function callAdmin() {
  13.    include('addme.php');
  14.   /* include_once 'uninstall.php';*/
  15. }
  16.  
  17. function AddToOptionPage() {
  18.    add_options_page('One Crazy Plugin', 'One Crazy Plugin', 'manage_options', 'OSCommerceProductDisplay', 'callAdmin');
  19. }
  20. add_action('admin_menu', 'AddToOptionPage');
  21.  
  22. global $wpdb;
  23. // Create table in database
  24. function my_plugin_create_table()
  25. {
  26.    global $wpdb;
  27.    if($wpdb->get_var("show tables like TRR_Stats") != 'TRR_Stats')
  28.    {
  29.       $sql = "CREATE TABLE TestTable (
  30.      id mediumint(9) NOT NULL,
  31.      Ime varchar(50) NOT NULL,
  32.      prezime varchar(50) NOT NULL,
  33.      datum datetime NOT NULL,
  34.      UNIQUE KEY id (id)
  35.      );";
  36.       require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
  37.       dbDelta($sql);
  38.    }
  39. }
  40.  
  41.  
  42. // Delete table when deactivate
  43. function my_plugin_remove_database() {
  44.      global $wpdb;
  45.      $table_name = "TestTable";
  46.      $sql = "DROP TABLE IF EXISTS $table_name;";
  47.      $wpdb->query($sql);
  48.      delete_option("my_plugin_db_version");
  49. }
  50.  
  51. //show results
  52. function showresult(){
  53.   ?>
  54.   <table border="1">
  55.   <tr>
  56.     <th>ID</th>
  57.    <th>Ime</th>
  58.    <th>Prezime</th>
  59.    <th>Datum Rodjenja</th>
  60.    <th>Obrisi</th>
  61.   </tr>
  62.     <?php
  63.  
  64.       global $wpdb;
  65.       $result = $wpdb->get_results ( "SELECT * FROM TestTable" );
  66.       foreach ( $result as $print )   {
  67.       ?>
  68.       <form  name="deleteForm" method="post"  action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']);?>">
  69.       <tr>
  70.       <td><?php echo $print->id;?></td>
  71.       <td><?php echo $print->Ime;?></td>
  72.       <td><?php echo $print->prezime;?></td>
  73.       <td><?php echo $print->datum;?></td>
  74.       <td><input type='checkbox' name="check_list[]"  value=<?php  var_dump( $print->id);?>></td>
  75.       </tr>
  76.  
  77.     </form>
  78. <?php
  79.            }
  80.    }
  81.  
  82. register_activation_hook( __FILE__, 'my_plugin_create_table' );
  83. register_uninstall_hook( __FILE__, 'my_plugin_remove_database' );
  84.  
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement