this is th plugin for gallery first create a file --
/*
Plugin Name:Side Gallery
Plugin URI:
Description:
Author: Vikas Gautam
*/
include("side_function.php");
add_action('admin_menu', 'add_admin_panel');
function add_admin_panel(){
$icon_path = get_option('siteurl').'/wp-content/plugins/'.basename(dirname(__FILE__)).'/icon';
add_menu_page('Side Gallery', 'Side Gallery','read','my-plug','',$icon_path.'/icon.png');
add_submenu_page('my-plug', 'Side Gallery', '1st Submenu', 'read', 'my-plug','my_menu_default');
}
function my_menu_default(){?>
$sql=mysql_query("CREATE TABLE `td_sidebar_image` (
`id` int(100) NOT NULL AUTO_INCREMENT,
`image_name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`path` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
)");
Manage Side Bar Slider
/* Inserting Image*/
$image=new side_gallery;
$image1=$image->inser_image();
/* Inserting image End */
$image_data1=$image->Show_data();
?>
$count=1;
$i=0;
$j=0;
foreach($image_data1 as $image12)
{ $id=$image12['id'];
?>
echo "
".$count."
";?>
echo "
";
?>
if(isset($_POST[$i]))
{
if($_REQUEST['b'.$j])
{
$id12=$_REQUEST['b'.$j];
//echo $_REQUEST['b'.$j];
$image_delete=$image->delete_image($id12);
}
}
$i++;
$j++;
$count++;
}
?>
}
?>
After to handele function add this fiie side_function.php
class side_gallery
{
function inser_image()
{
if(isset($_POST['submit']))
{
$image=$_FILES["file"]["name"];
$path1="../wp-content/Sidebar_image/" . $_FILES["file"]["name"];
$upload_image=mysql_query("insert into td_sidebar_image (id,image_name,path) values('',' $image','$path1')");
echo "$sql";
echo " Record Inserted";
move_uploaded_file($_FILES["file"]["tmp_name"],
"../wp-content/Sidebar_image/" . $_FILES["file"]["name"]);
$path1="../wp-content/Sidebar_image/" . $_FILES["file"]["name"];
}
}
function Show_data()
{
$data=mysql_query("select * from td_sidebar_image");
while($data1=mysql_fetch_assoc($data))
{
$image_data[]=$data1;
//echo $data1['image_name'];
}
return $image_data;
}
function delete_image($id12)
{
$unlik_image=mysql_query("select * from td_sidebar_image where id=$id12");
$data12=mysql_fetch_assoc($unlik_image);
$rt=$data12['path'];
unlink($rt);
$delete=mysql_query("delete from td_sidebar_image where id=$id12");
if($delete)
{
echo "Record Deleted Successfully";
}
}
}
function plugin_side_gallery()
{
$sql=mysql_query("select * from td_sidebar_image");
while($data=mysql_fetch_assoc($sql))
{
$image_da[]=$data;
}
return $image_da;
}
?>
/*
Plugin Name:Side Gallery
Plugin URI:
Description:
Author: Vikas Gautam
*/
include("side_function.php");
add_action('admin_menu', 'add_admin_panel');
function add_admin_panel(){
$icon_path = get_option('siteurl').'/wp-content/plugins/'.basename(dirname(__FILE__)).'/icon';
add_menu_page('Side Gallery', 'Side Gallery','read','my-plug','',$icon_path.'/icon.png');
add_submenu_page('my-plug', 'Side Gallery', '1st Submenu', 'read', 'my-plug','my_menu_default');
}
function my_menu_default(){?>
$sql=mysql_query("CREATE TABLE `td_sidebar_image` (
`id` int(100) NOT NULL AUTO_INCREMENT,
`image_name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`path` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
)");
Manage Side Bar Slider
/* Inserting Image*/
$image=new side_gallery;
$image1=$image->inser_image();
/* Inserting image End */
$image_data1=$image->Show_data();
?>
$count=1;
$i=0;
$j=0;
foreach($image_data1 as $image12)
{ $id=$image12['id'];
?>
echo "
".$count."
";?>
echo "
";
?>
if(isset($_POST[$i]))
{
if($_REQUEST['b'.$j])
{
$id12=$_REQUEST['b'.$j];
//echo $_REQUEST['b'.$j];
$image_delete=$image->delete_image($id12);
}
}
$i++;
$j++;
$count++;
}
?>
}
?>
After to handele function add this fiie side_function.php
class side_gallery
{
function inser_image()
{
if(isset($_POST['submit']))
{
$image=$_FILES["file"]["name"];
$path1="../wp-content/Sidebar_image/" . $_FILES["file"]["name"];
$upload_image=mysql_query("insert into td_sidebar_image (id,image_name,path) values('',' $image','$path1')");
echo "$sql";
echo " Record Inserted";
move_uploaded_file($_FILES["file"]["tmp_name"],
"../wp-content/Sidebar_image/" . $_FILES["file"]["name"]);
$path1="../wp-content/Sidebar_image/" . $_FILES["file"]["name"];
}
}
function Show_data()
{
$data=mysql_query("select * from td_sidebar_image");
while($data1=mysql_fetch_assoc($data))
{
$image_data[]=$data1;
//echo $data1['image_name'];
}
return $image_data;
}
function delete_image($id12)
{
$unlik_image=mysql_query("select * from td_sidebar_image where id=$id12");
$data12=mysql_fetch_assoc($unlik_image);
$rt=$data12['path'];
unlink($rt);
$delete=mysql_query("delete from td_sidebar_image where id=$id12");
if($delete)
{
echo "Record Deleted Successfully";
}
}
}
function plugin_side_gallery()
{
$sql=mysql_query("select * from td_sidebar_image");
while($data=mysql_fetch_assoc($sql))
{
$image_da[]=$data;
}
return $image_da;
}
?>
No comments:
Post a Comment