Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: OneAwesomePlugin
- Description: VeryAwesomePlugin ;)
- Version: 1.0
- Author:
- Author URI:
- */
- ?>
- <?php
- function callAdmin() {
- include('addme.php');
- /* include_once 'uninstall.php';*/
- }
- function AddToOptionPage() {
- add_options_page('One Crazy Plugin', 'One Crazy Plugin', 'manage_options', 'OSCommerceProductDisplay', 'callAdmin');
- }
- add_action('admin_menu', 'AddToOptionPage');
- global $wpdb;
- // Create table in database
- function my_plugin_create_table()
- {
- global $wpdb;
- if($wpdb->get_var("show tables like TRR_Stats") != 'TRR_Stats')
- {
- $sql = "CREATE TABLE TestTable (
- id mediumint(9) NOT NULL,
- Ime varchar(50) NOT NULL,
- prezime varchar(50) NOT NULL,
- datum datetime NOT NULL,
- UNIQUE KEY id (id)
- );";
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql);
- }
- }
- // Delete table when deactivate
- function my_plugin_remove_database() {
- global $wpdb;
- $table_name = "TestTable";
- $sql = "DROP TABLE IF EXISTS $table_name;";
- $wpdb->query($sql);
- delete_option("my_plugin_db_version");
- }
- //show results
- function showresult(){
- ?>
- <table border="1">
- <tr>
- <th>ID</th>
- <th>Ime</th>
- <th>Prezime</th>
- <th>Datum Rodjenja</th>
- <th>Obrisi</th>
- </tr>
- <?php
- global $wpdb;
- $result = $wpdb->get_results ( "SELECT * FROM TestTable" );
- foreach ( $result as $print ) {
- ?>
- <form name="deleteForm" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']);?>">
- <tr>
- <td><?php echo $print->id;?></td>
- <td><?php echo $print->Ime;?></td>
- <td><?php echo $print->prezime;?></td>
- <td><?php echo $print->datum;?></td>
- <td><input type='checkbox' name="check_list[]" value=<?php var_dump( $print->id);?>></td>
- </tr>
- </form>
- <?php
- }
- }
- register_activation_hook( __FILE__, 'my_plugin_create_table' );
- register_uninstall_hook( __FILE__, 'my_plugin_remove_database' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement