prefix .'ald_gallery';
$ald_image_table = $wpdb->prefix .'ald_images';
$ald_gallery_path = admin_url('admin.php?page=ald-gallery', 'http' );
$ald_gallery_db_version = '1.3';
function install_ald_gallery(){
global $ald_gallery_db_version;
global $wpdb;
global $ald_gallery_table;
global $ald_image_table;
$charset_collate1 = $wpdb->get_charset_collate();
$charset_collate2 = $wpdb->get_charset_collate();
$gallery_table = "CREATE TABLE IF NOT EXISTS $ald_gallery_table(
gallery_id mediumint(9) NOT NULL AUTO_INCREMENT,
gallery_name tinytext NOT NULL,
gallery_text text NOT NULL,
PRIMARY KEY (gallery_id)
)$charset_collate1;";
$img_table = "CREATE TABLE IF NOT EXISTS $ald_image_table(
img_id mediumint(9) NOT NULL AUTO_INCREMENT,
img_name tinytext NOT NULL,
img_text text NOT NULL,
img_url varchar(100) DEFAULT '' NOT NULL,
gallery_id mediumint(9) NOT NULL,
PRIMARY KEY (img_id)
)$charset_collate2;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $gallery_table );
dbDelta( $img_table );
add_option( 'ald_gallery_db_version', $ald_gallery_db_version );
}
if (isset($_GET['activate']) && $_GET['activate'] == 'true') add_action('init', 'install_ald_gallery');
add_action('admin_menu', 'ald_gallry_plugin_menu');
function ald_gallry_plugin_menu() {
add_menu_page(
__( 'ALD Gallery', 'ald-gallery' ),
'ALD Gallery',
'manage_options',
'ald-gallery',
'ald_gallery_index',
plugins_url( 'ald-image-gallery/img/image-gallery.svg' ),
6
);
}
add_action('admin_menu', 'ald_register_add_new_ald_gallery_page');
function ald_register_add_new_ald_gallery_page() {
add_submenu_page(
'ald-gallery',
'Add New Gallery',
'Add New Gallery',
'manage_options',
'add-new-ald-gallery',
'add_new_ald_gallery' );
}
function add_new_ald_gallery() {
?>
Add New Gallery
Gallery added successfully.
Sorry. gallery didn't added. Please try again later.
Welcome, display_name; ?>
Gallery Informations
Gallery deleted successfully.
Sorry. gallery didn't deleted. Please try again later.
get_results( "SELECT * FROM $ald_gallery_table order by gallery_id desc");
?>
| Gallery Name |
Shortcode |
Gallery Description |
Gallery Images |
Delete |
| gallery_name);?> |
[aldgallery gallery="gallery_id); ?>"] |
gallery_text);?> |
Gallery Images |
Delete |
0)
{
global $wpdb;
global $ald_gallery_table;
$wpdb->insert(
$ald_gallery_table,
array(
'gallery_name' => $gallery_name,
'gallery_text' => $gallery_text,
)
);
$msg = 'true';
}
else{
$msg = 'false';
}
$path = add_query_arg('message', $msg, $_SERVER['HTTP_REFERER']);
wp_redirect( $path, $status = 302 );
exit();
}
// Delete Gallery
add_action( 'admin_action_delete_gallery', 'delete_gallery_admin_action' );
function delete_gallery_admin_action()
{
global $wpdb;
global $ald_gallery_table;
global $ald_image_table;
$gallery = intval( trim($_GET['data']) );
if(strlen( $gallery ) > 0)
{
$wpdb->delete( $ald_gallery_table, array( 'gallery_id' => $gallery ) );
$wpdb->delete( $ald_image_table, array( 'gallery_id' => $gallery ) );
$msg = 'true';
}
$path = add_query_arg('message', $msg, $_SERVER['HTTP_REFERER']);
wp_redirect( $path, $status = 302 );
exit();
}
add_action('admin_menu', 'register_ald_gallery_images_page');
function register_ald_gallery_images_page(){
add_submenu_page( null, 'Gallery Images', null, 'manage_options', 'ald-gallery-images', 'gallery_images' );
}
function gallery_images()
{
global $wpdb;
global $ald_image_table;
$gallery = intval( trim($_GET['gallery']) );
if(strlen( $gallery ) > 0)
{
?>
Gallery Images
Image added successfully.
Sorry. image didn't added. Please try again later.
Image deleted successfully.
get_results( "SELECT * FROM $ald_image_table where gallery_id=$gallery order by img_id desc");
?>
| ID |
Image Name |
Image Caption |
Images |
Images Url |
Delete |
| img_id); ?> |
img_name);?> |
img_text);?> |
;?>) |
img_url);?> |
Delete |
0) && (strlen( $image_url) > 0) )
{
global $wpdb;
global $ald_image_table;
$wpdb->insert(
$ald_image_table,
array(
'img_name' => $image_name,
'img_url' => $image_url,
'img_text' => $image_text,
'gallery_id' => $gallery_id,
)
);
$msg = 'true';
}
else{
$msg = 'false';
}
$path = add_query_arg('message', $msg, $_SERVER['HTTP_REFERER']);
wp_redirect( $path, $status = 302 );
exit();
}
// Delete Image
add_action( 'admin_action_delete_image', 'delete_image_admin_action' );
function delete_image_admin_action()
{
global $wpdb;
global $ald_image_table;
$image = intval( trim($_GET['data'] ));
if(isset($image))
{
$wpdb->delete( $ald_image_table, array( 'img_id' => $image ) );
$msg = 'deleted';
}
$path = add_query_arg('message', $msg, $_SERVER['HTTP_REFERER']);
wp_redirect( $path, $status = 302 );
exit();
}
function external_css() {
wp_enqueue_style( 'ald-style', plugins_url('css/ald-style.css', __FILE__) );
wp_enqueue_style( 'lightcase-style', plugins_url('lightcase/src/css/lightcase.css', __FILE__) );
}
function external_js() {
wp_enqueue_script( 'ald-script', plugins_url('js/ald-script.js', __FILE__), array('jquery'), null, true );
wp_enqueue_script( 'lightcase-script', plugins_url('lightcase/src/js/lightcase.js', __FILE__), array('jquery'), null, true );
wp_enqueue_script( 'lightcase-touch-script', plugins_url('lightcase/vendor/jQuery/jquery.events.touch.js', __FILE__), array('jquery'), null, true );
}
add_action( 'wp_enqueue_scripts', 'external_css' );
add_action( 'wp_enqueue_scripts', 'external_js' );
// Shortcode
function aldgallery_func( $atts ){
$a = shortcode_atts( array(
'limit' => '0,18446744073709551615',
'width' => '150px',
'height' => '120px',
'gallery' => '1',
'slideshow' => '0',
), $atts );
$limit = $a['limit'];
$width = $a['width'];
$height = $a['height'];
$gallery = $a['gallery'];
$slideshow = $a['slideshow'];
global $wpdb;
global $ald_image_table;
$results = $wpdb->get_results( "SELECT * FROM $ald_image_table where gallery_id = $gallery order by img_id desc limit $limit ");
?>
img_name;
$img_text = $data->img_text;
$img_url = $data->img_url;
?>
-