Plugin Important code

<?php
/*
Plugin Name:
Plugin URI:
Description: This plugin used for add edit delete and listing module at admin side.Also user can search and sort records.
Version: 2.0
Author:
Author URI:
*/

require_once(“bookingclass.php”);
$objmem = new Booking();
$table_seat = $wpdb->prefix . “seat”;
$table_event_date = $wpdb->prefix . “event”;
$table_order = $wpdb->prefix . “order”;
$table_seat_order = $wpdb->prefix . “seat_order”;

function addmyplug() {

global $wpdb;

$table_seat = $wpdb->prefix . “seat”;
$table_event_date = $wpdb->prefix . “event”;
$table_order = $wpdb->prefix . “order”;
$table_seat_order = $wpdb->prefix . “seat_order”;

$seat = “show tables like ‘$table_seat'”;
$event_date = “show tables like ‘$table_event_date'”;
$order = “show tables like ‘$table_order'”;
$seat_order = “show tables like ‘$table_seat_order'”;
if($wpdb->get_var($seat) != $table_seat)
{

$sql = “CREATE TABLE IF NOT EXISTS $table_seat (
id mediumint(9) NOT NULL AUTO_INCREMENT,
seat_name varchar(255) NULL,
datetime datetime DEFAULT ‘0000-00-00 00:00:00’ NOT NULL,
PRIMARY KEY id (id)
) “;

require_once(ABSPATH . “wp-admin/includes/upgrade.php”);
dbDelta($sql);
}

if($wpdb->get_var($event_date) != $table_event_date)
{

$sqls = “CREATE TABLE IF NOT EXISTS $table_event_date (
id mediumint(9) NOT NULL AUTO_INCREMENT,
date varchar(255) NULL,
event_name varchar(255) NULL,
event_palace varchar(255) NULL,
detail text NULL,
status varchar(255) NULL,
datetime datetime DEFAULT ‘0000-00-00 00:00:00’ NOT NULL,
PRIMARY KEY id (id)
) “;

require_once(ABSPATH . “wp-admin/includes/upgrade.php”);
dbDelta($sqls);
}

if($wpdb->get_var($order) != $table_order)
{

$ordsql = “CREATE TABLE IF NOT EXISTS $table_order (
id mediumint(9) NOT NULL AUTO_INCREMENT,
uid mediumint(9) NULL,
total varchar(255) NULL,
datetime datetime DEFAULT ‘0000-00-00 00:00:00’ NOT NULL,
PRIMARY KEY id (id)
) “;

require_once(ABSPATH . “wp-admin/includes/upgrade.php”);
dbDelta($ordsql);
}
if($wpdb->get_var($seat_order) != $table_seat_order)
{

$seatsql = “CREATE TABLE IF NOT EXISTS $table_seat_order (
id mediumint(9) NOT NULL AUTO_INCREMENT,
seat_id varchar(255) NULL,
event_id mediumint(9) NULL,
uid mediumint(9) NULL,
price varchar(255) NULL,
event_date varchar(255) NULL,
status mediumint(9) NULL,
datetime datetime DEFAULT ‘0000-00-00 00:00:00′ NOT NULL,
PRIMARY KEY id (id)
) “;

require_once(ABSPATH . “wp-admin/includes/upgrade.php”);
dbDelta($seatsql);
}

}
/* Hook Plugin */
register_activation_hook(__FILE__,’addmyplug’);

/* Creating Menus */
function booking_Menu()
{

/* Adding menus */
add_menu_page(__(‘Event List’),’Event List’, 8,’booking/muyplg.php’, ‘event_list’);
/* Adding Sub menus */
add_submenu_page(‘booking/muyplg.php’, ‘Add Event’, ‘Add Event’, 8, ‘event_add’, ‘event_add’);
add_submenu_page(‘booking/muyplg.php’, ‘&nbsp;’, ‘&nbsp;’, 8, ‘booking_list’, ‘booking_list’);
add_submenu_page(‘booking/single-event.php’, ‘&nbsp;’, ‘&nbsp;’, 8, ‘single_event’, ‘single_event’);

wp_register_style(‘demo_table.css’, plugin_dir_url(__FILE__) . ‘css/demo_table.css’);
wp_enqueue_style(‘demo_table.css’);
wp_register_style(‘jquery.ui.all.css’, plugin_dir_url(__FILE__) . ‘css/base/jquery.ui.all.css’);
wp_enqueue_style(‘jquery.ui.all.css’);
wp_register_style(‘demos.css’, plugin_dir_url(__FILE__) . ‘css/demos.css’);
wp_enqueue_style(‘demos.css’);

wp_register_script(‘jquery.dataTables.js’, plugin_dir_url(__FILE__) . ‘js/jquery.dataTables.js’, array(‘jquery’));
wp_enqueue_script(‘jquery.dataTables.js’);
wp_register_script(‘jquery-1.8.3.js’, plugin_dir_url(__FILE__) . ‘js/jquery-1.8.3.js’, array(‘jquery’));
wp_enqueue_script(‘jquery-1.8.3.js’);
wp_register_script(‘jquery.ui.core.js’, plugin_dir_url(__FILE__) . ‘js/ui/jquery.ui.core.js’, array(‘jquery’));
wp_enqueue_script(‘jquery.ui.core.js’);
wp_register_script(‘jquery.ui.datepicker.js’, plugin_dir_url(__FILE__) . ‘js/ui/jquery.ui.datepicker.js’, array(‘jquery’));
wp_enqueue_script(‘jquery.ui.datepicker.js’);
wp_register_script(‘jquery-ui-timepicker-addon.js’, plugin_dir_url(__FILE__) . ‘js/jquery-ui-timepicker-addon.js’, array(‘jquery’));
wp_enqueue_script(‘jquery-ui-timepicker-addon.js’);
}

add_action(‘admin_menu’, ‘booking_Menu’);

function event_list() {
include “event-list.php”;
}

function event_add() {
include “event-new.php”;
}

function booking_list() {
include “bookinglist.php”;
}
function single_event() {
include “single-event.php”;
}

if(isset($_POST[“submit”]))
{
$addme=$_POST[‘addme’];
if($addme==1)
{
$data=array();
$data[‘table’][‘name’]= $wpdb->prefix.’event’;
$data[‘data’][‘date’]=$_POST[‘date’];
$data[‘data’][‘event_name’]=$_POST[‘event_name’];
$data[‘data’][‘event_palace’]=$_POST[‘event_palace’];
$data[‘data’][‘status’]=$_POST[‘status’];
$data[‘data’][‘detail’]=$_POST[‘detail’];

$objmem->insert($data);
header(“Location:admin.php?page=booking/muyplg.php&info=saved”);
exit;
}
else if($addme==2)
{
$data=array();
$data[‘table’][‘name’]= $wpdb->prefix.’event’;
$data[‘data’][‘date’]=$_POST[‘date’];
$data[‘data’][‘event_name’]=$_POST[‘event_name’];
$data[‘data’][‘event_palace’]=$_POST[‘event_palace’];
$data[‘data’][‘status’]=$_POST[‘status’];
$data[‘data’][‘detail’]=$_POST[‘detail’];
$data[‘where’][‘id’]=$_POST[‘id’];
$objmem->upd($data);
header(“Location:admin.php?page=booking/muyplg.php&info=upd”);
exit;
}
}

function viewgallery_list()
{
global $wpdb, $table_name ;
include(‘single-event.php’);

}
add_shortcode(‘vgallery_List’, ‘viewgallery_list’);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s