| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Lightbox slider - Responsive Lightbox Gallery. |
| 4 |
* Version: 1.9.3 |
| 5 |
* Description: Lightbox slider plugin is allow users to view larger versions of images, simple slide shows and Gallery view with grid layout. |
| 6 |
* Author: Weblizar |
| 7 |
* Author URI: https://www.weblizar.com |
| 8 |
* Plugin URI: https://wordpress.org/plugins/simple-lightbox-gallery/ |
| 9 |
*/ |
| 10 |
|
| 11 |
/** |
| 12 |
* Constant Variable |
| 13 |
*/ |
| 14 |
defined( 'ABSPATH' ) or die(); |
| 15 |
define( 'WEBLIZAR_SLGF_TEXT_DOMAIN', 'weblizar_image_gallery' ); |
| 16 |
define( 'WEBLIZAR_SLGF_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 17 |
|
| 18 |
// Image Crop Size Function |
| 19 |
add_image_size( 'slgf_12_thumb', 500, 9999, array( 'center', 'top' ) ); |
| 20 |
add_image_size( 'slgf_346_thumb', 400, 9999, array( 'center', 'top' ) ); |
| 21 |
add_image_size( 'slgf_12_same_size_thumb', 500, 500, array( 'center', 'top' ) ); |
| 22 |
add_image_size( 'slgf_346_same_size_thumb', 400, 400, array( 'center', 'top' ) ); |
| 23 |
|
| 24 |
add_filter( 'image_size_names_choose', 'WEBLIZAR_SLGF_IMAGES_SIZES_FILTER' ); |
| 25 |
|
| 26 |
function WEBLIZAR_SLGF_IMAGES_SIZES_FILTER( $sizes ) { |
| 27 |
return array_merge( |
| 28 |
$sizes, |
| 29 |
array( |
| 30 |
'slgf_346_thumb' => __( 'Size 400 X AUTO' ), |
| 31 |
'slgf_12_thumb' => __( 'Size 500 X AUTO' ), |
| 32 |
'slgf_12_same_size_thumb' => __( 'Same Size 500 X 500' ), |
| 33 |
'slgf_346_same_size_thumb' => __( 'Same Size 400 X 400' ), |
| 34 |
) |
| 35 |
); |
| 36 |
} |
| 37 |
/** |
| 38 |
* Support and Our Products Page |
| 39 |
*/ |
| 40 |
add_action( 'admin_menu', 'slgf_SettingsPage' ); |
| 41 |
function slgf_SettingsPage() { |
| 42 |
add_submenu_page( 'edit.php?post_type=slgf_slider', esc_html__( 'Help and Support', WEBLIZAR_SLGF_TEXT_DOMAIN ), esc_html__( 'Help and Support', WEBLIZAR_SLGF_TEXT_DOMAIN ), 'administrator', 'SLGF-help-page', 'SLGF_Help_and_Support_page' ); |
| 43 |
} |
| 44 |
|
| 45 |
function SLGF_Help_and_Support_page() { |
| 46 |
wp_enqueue_style( 'wrgf-help_and_support-custom-css', WEBLIZAR_SLGF_PLUGIN_URL . 'css/help_and_support.css' ); |
| 47 |
require_once 'help_and_support.php'; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Get Responsive Gallery Pro Plugin Page |
| 52 |
*/ |
| 53 |
function SLGF_Pro_page_Function() { |
| 54 |
// css |
| 55 |
wp_enqueue_style( 'font-awesome', WEBLIZAR_SLGF_PLUGIN_URL . 'css/all.min.css' ); |
| 56 |
wp_enqueue_style( 'wrgf-pricing-table-css', WEBLIZAR_SLGF_PLUGIN_URL . 'css/pricing-table.css' ); |
| 57 |
wp_enqueue_style( 'bootstrap', WEBLIZAR_SLGF_PLUGIN_URL . 'css/bootstrap.min.css' ); |
| 58 |
} |
| 59 |
|
| 60 |
function SLGF_Recommendation_Page() { |
| 61 |
wp_enqueue_style( 'recom2', WEBLIZAR_SLGF_PLUGIN_URL . 'css/recom.css' ); |
| 62 |
require_once 'recommendations.php'; |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Weblizar Lightbox Slider Pro Shortcode Detect Function |
| 67 |
*/ |
| 68 |
function slgf_js_css_load_function() { |
| 69 |
global $wp_query; |
| 70 |
$Posts = $wp_query->posts; |
| 71 |
$Pattern = get_shortcode_regex(); |
| 72 |
foreach ( $Posts as $Post ) { |
| 73 |
if ( isset( $Post->post_content ) && strpos( $Post->post_content, 'SLGF' ) ) { |
| 74 |
/** |
| 75 |
* js scripts |
| 76 |
*/ |
| 77 |
/* |
| 78 |
wp_enqueue_style('wp-color-picker'); |
| 79 |
wp_enqueue_script('wp-color-picker'); |
| 80 |
*/ |
| 81 |
|
| 82 |
wp_enqueue_script( 'jquery' ); |
| 83 |
wp_enqueue_script( 'wl-slgf-hover-pack-js', WEBLIZAR_SLGF_PLUGIN_URL . 'js/hover-pack.js', array( 'jquery' ) ); |
| 84 |
wp_enqueue_script( 'wl-slgf-rpg-script', WEBLIZAR_SLGF_PLUGIN_URL . 'js/reponsive_photo_gallery_script.js', array( 'jquery' ) ); |
| 85 |
|
| 86 |
/** |
| 87 |
* css scripts |
| 88 |
*/ |
| 89 |
wp_register_style( 'wl-slgf-hover-pack-css', WEBLIZAR_SLGF_PLUGIN_URL . 'css/hover-pack.css' ); |
| 90 |
wp_enqueue_style( 'wl-slgf-hover-pack-css' ); |
| 91 |
|
| 92 |
wp_register_style( 'wl-slgf-img-gallery-css', WEBLIZAR_SLGF_PLUGIN_URL . 'css/img-gallery.css' ); |
| 93 |
wp_enqueue_style( 'wl-slgf-img-gallery-css' ); |
| 94 |
|
| 95 |
/** |
| 96 |
* font awesome css |
| 97 |
*/ |
| 98 |
wp_register_style( 'font-awesome-5', WEBLIZAR_SLGF_PLUGIN_URL . 'css/all.min.css' ); |
| 99 |
wp_enqueue_style( 'font-awesome-5' ); |
| 100 |
|
| 101 |
/*** envira & isotope js */ |
| 102 |
wp_register_script( 'slgf_envira-js', WEBLIZAR_SLGF_PLUGIN_URL . 'js/masonry.pkgd.min.js', array( 'jquery' ), '', true ); |
| 103 |
wp_enqueue_script( 'slgf_envira-js' ); |
| 104 |
|
| 105 |
wp_register_script( 'slgf_imagesloaded', WEBLIZAR_SLGF_PLUGIN_URL . 'js/imagesloaded.pkgd.min.js', array( 'jquery' ), '', true ); |
| 106 |
wp_enqueue_script( 'slgf_imagesloaded' ); |
| 107 |
|
| 108 |
break; |
| 109 |
} //end of if |
| 110 |
} //end of foreach |
| 111 |
} |
| 112 |
/** For the_title function */ |
| 113 |
// add_action('wp', 'slgf_js_css_load_function'); |
| 114 |
|
| 115 |
add_filter( 'the_title', 'slgf_convac_lite_untitled' ); |
| 116 |
function slgf_convac_lite_untitled( $title ) { |
| 117 |
if ( $title == '' ) { |
| 118 |
return esc_html__( 'No Title', WEBLIZAR_SLGF_TEXT_DOMAIN ); |
| 119 |
} else { |
| 120 |
return $title; |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
function slgf_remove_image_box() { |
| 125 |
remove_meta_box( 'postimagediv', 'slgf_slider', 'side' ); |
| 126 |
} |
| 127 |
|
| 128 |
add_action( 'do_meta_boxes', 'slgf_remove_image_box' ); |
| 129 |
|
| 130 |
/** |
| 131 |
* Class Defination For Lightbox Slider Pro |
| 132 |
*/ |
| 133 |
class SLGF { |
| 134 |
private $admin_thumbnail_size = 150; |
| 135 |
private $thumbnail_size_w = 150; |
| 136 |
private $thumbnail_size_h = 150; |
| 137 |
|
| 138 |
public function __construct() { |
| 139 |
add_action( 'admin_enqueue_scripts', array( &$this, 'slgf_admin_print_scripts' ) ); |
| 140 |
add_image_size( 'rpg_gallery_admin_thumb', $this->admin_thumbnail_size, $this->admin_thumbnail_size, true ); |
| 141 |
add_image_size( 'rpg_gallery_thumb', $this->thumbnail_size_w, $this->thumbnail_size_h, true ); |
| 142 |
add_shortcode( 'lightboxslider', array( &$this, 'shortcode' ) ); |
| 143 |
|
| 144 |
if ( is_admin() ) { |
| 145 |
add_action( 'init', array( &$this, 'SLGF_CPT' ), 1 ); |
| 146 |
add_action( 'add_meta_boxes', array( &$this, 'add_all_slgf_meta_boxes' ) ); |
| 147 |
add_action( 'admin_init', array( &$this, 'add_all_slgf_meta_boxes' ), 1 ); |
| 148 |
add_action( 'save_post', array( &$this, 'slgf_add_image_meta_box_save' ), 9, 1 ); |
| 149 |
add_action( 'save_post', array( &$this, 'slgf_settings_meta_save' ), 9, 1 ); |
| 150 |
add_action( 'wp_ajax_slgf_get_thumbnail', array( &$this, 'ajax_get_thumbnail_slgf' ) ); |
| 151 |
} |
| 152 |
} |
| 153 |
|
| 154 |
// Required JS & CSS |
| 155 |
public function slgf_admin_print_scripts( $hook_suffix ) { |
| 156 |
if ( in_array( $hook_suffix, array( 'post.php', 'post-new.php' ) ) ) { |
| 157 |
$screen = get_current_screen(); |
| 158 |
if ( is_object( $screen ) && 'slgf_slider' === $screen->post_type ) { |
| 159 |
wp_enqueue_script( 'media-upload' ); |
| 160 |
wp_enqueue_script( 'slgf-media-uploader-js', WEBLIZAR_SLGF_PLUGIN_URL . 'js/slgf-multiple-media-uploader.js', array( 'jquery' ) ); |
| 161 |
wp_enqueue_media(); |
| 162 |
// custom add image box css |
| 163 |
wp_enqueue_style( 'slgf-meta-css', WEBLIZAR_SLGF_PLUGIN_URL . 'css/rpg-meta.css' ); |
| 164 |
|
| 165 |
// font awesome css |
| 166 |
wp_enqueue_style( 'font-awesome-5', WEBLIZAR_SLGF_PLUGIN_URL . 'css/all.min.css' ); |
| 167 |
|
| 168 |
// single media uploader js |
| 169 |
wp_enqueue_script( |
| 170 |
'slgf-media-uploads', |
| 171 |
WEBLIZAR_SLGF_PLUGIN_URL . 'js/slgf-media-upload-script.js', |
| 172 |
array( |
| 173 |
'media-upload', |
| 174 |
'thickbox', |
| 175 |
'jquery', |
| 176 |
) |
| 177 |
); |
| 178 |
wp_enqueue_script( 'wp-color-picker' ); |
| 179 |
wp_enqueue_style( 'wp-color-picker' ); |
| 180 |
|
| 181 |
// code-mirror css & js for custom css section |
| 182 |
wp_enqueue_style( 'slgf_codemirror-css', WEBLIZAR_SLGF_PLUGIN_URL . 'css/codemirror/codemirror.css' ); |
| 183 |
wp_enqueue_style( 'slgf_blackboard', WEBLIZAR_SLGF_PLUGIN_URL . 'css/codemirror/blackboard.css' ); |
| 184 |
wp_enqueue_style( 'slgf_show-hint-css', WEBLIZAR_SLGF_PLUGIN_URL . 'css/codemirror/show-hint.css' ); |
| 185 |
|
| 186 |
wp_enqueue_script( 'slgf_codemirror-js', WEBLIZAR_SLGF_PLUGIN_URL . 'css/codemirror/codemirror.js', array( 'jquery' ) ); |
| 187 |
wp_enqueue_script( 'slgf_css-js', WEBLIZAR_SLGF_PLUGIN_URL . 'css/codemirror/slgf-css.js', array( 'jquery' ) ); |
| 188 |
wp_enqueue_script( 'slgf_css-hint-js', WEBLIZAR_SLGF_PLUGIN_URL . 'css/codemirror/css-hint.js', array( 'jquery' ) ); |
| 189 |
} |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
// Register Custom Post Type |
| 194 |
public function SLGF_CPT() { |
| 195 |
$labels = array( |
| 196 |
'name' => esc_html__( 'Lightbox Gallery', 'Lightbox Slider Pro', 'slgf_slider' ), |
| 197 |
'singular_name' => esc_html__( 'Lightbox Gallery', 'Lightbox Slider Pro', 'slgf_slider' ), |
| 198 |
'menu_name' => esc_html__( 'S. Lightbox Gallery', 'slgf_slider' ), |
| 199 |
'parent_item_colon' => esc_html__( 'Parent Item:', 'slgf_slider' ), |
| 200 |
'all_items' => esc_html__( 'All Galleries', 'slgf_slider' ), |
| 201 |
'view_item' => esc_html__( 'View Gallery', 'slgf_slider' ), |
| 202 |
'add_new_item' => esc_html__( 'Add New Lightbox Gallery', 'slgf_slider' ), |
| 203 |
'add_new' => esc_html__( 'Add Lightbox Gallery', 'slgf_slider' ), |
| 204 |
'edit_item' => esc_html__( 'Edit Lightbox Gallery', 'slgf_slider' ), |
| 205 |
'new_item' => esc_html__( 'New Gallery', 'slgf_slider' ), |
| 206 |
'update_item' => esc_html__( 'Update Lightbox Gallery', 'slgf_slider' ), |
| 207 |
'search_items' => esc_html__( 'Search Gallery', 'slgf_slider' ), |
| 208 |
'not_found' => esc_html__( 'No Lightbox Gallery Found', 'slgf_slider' ), |
| 209 |
'not_found_in_trash' => esc_html__( 'No Lightbox Gallery found in Trash', 'slgf_slider' ), |
| 210 |
); |
| 211 |
|
| 212 |
$args = array( |
| 213 |
'label' => esc_html__( 'slgf_slider', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 214 |
'description' => esc_html__( 'Free Lightbox Gallery', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 215 |
'labels' => $labels, |
| 216 |
'supports' => array( 'title', 'thumbnail', '', '', '', '', '', '', '', '', '' ), |
| 217 |
'hierarchical' => false, |
| 218 |
'public' => false, |
| 219 |
'show_ui' => true, |
| 220 |
'show_in_menu' => true, |
| 221 |
'show_in_nav_menus' => true, |
| 222 |
'show_in_admin_bar' => true, |
| 223 |
'menu_position' => 10, |
| 224 |
'menu_icon' => 'dashicons-format-gallery', |
| 225 |
'can_export' => true, |
| 226 |
'has_archive' => true, |
| 227 |
'exclude_from_search' => false, |
| 228 |
'publicly_queryable' => false, |
| 229 |
'capability_type' => 'post', |
| 230 |
); |
| 231 |
register_post_type( 'slgf_slider', $args ); |
| 232 |
add_filter( 'manage_edit-slgf_slider_columns', array( &$this, 'slgf_gallery_columns' ) ); |
| 233 |
add_action( 'manage_slgf_slider_posts_custom_column', array( &$this, 'slgf_gallery_manage_columns' ), 10, 2 ); |
| 234 |
} |
| 235 |
|
| 236 |
// column fields on all galleries page |
| 237 |
function slgf_gallery_columns( $columns ) { |
| 238 |
$columns = array( |
| 239 |
'cb' => '<input type="checkbox" />', |
| 240 |
'title' => esc_html__( 'Gallery', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 241 |
'shortcode' => esc_html__( 'Gallery Shortcode', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 242 |
'author' => esc_html__( 'Author', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 243 |
'date' => esc_html__( 'Date', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 244 |
); |
| 245 |
|
| 246 |
return $columns; |
| 247 |
} |
| 248 |
|
| 249 |
// column action fields on all galleries page |
| 250 |
function slgf_gallery_manage_columns( $column, $post_id ) { |
| 251 |
global $post; |
| 252 |
switch ( $column ) { |
| 253 |
case 'shortcode': |
| 254 |
echo '<input type="text" value="[SLGF id=' . $post_id . ']" readonly="readonly" />'; |
| 255 |
break; |
| 256 |
default: |
| 257 |
break; |
| 258 |
} |
| 259 |
} |
| 260 |
|
| 261 |
// all metabox generator function |
| 262 |
public function add_all_slgf_meta_boxes() { |
| 263 |
add_meta_box( |
| 264 |
esc_html__( 'Add Images', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 265 |
esc_html__( 'Add Images', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 266 |
array( |
| 267 |
&$this, |
| 268 |
'slgf_generate_add_image_meta_box_function', |
| 269 |
), |
| 270 |
'slgf_slider', |
| 271 |
'normal', |
| 272 |
'low' |
| 273 |
); |
| 274 |
add_meta_box( |
| 275 |
esc_html__( 'Apply Setting On Lightbox Gallery', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 276 |
esc_html__( 'Apply Setting On Lightbox Gallery', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 277 |
array( |
| 278 |
&$this, |
| 279 |
'slgf_settings_meta_box_function', |
| 280 |
), |
| 281 |
'slgf_slider', |
| 282 |
'normal', |
| 283 |
'low' |
| 284 |
); |
| 285 |
add_meta_box( |
| 286 |
esc_html__( 'Lightbox Gallery Shortcode', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 287 |
esc_html__( 'Lightbox Gallery Shortcode', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 288 |
array( |
| 289 |
&$this, |
| 290 |
'slgf_shotcode_meta_box_function', |
| 291 |
), |
| 292 |
'slgf_slider', |
| 293 |
'side', |
| 294 |
'low' |
| 295 |
); |
| 296 |
|
| 297 |
add_meta_box( |
| 298 |
esc_html__( 'Rate us on WordPress', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 299 |
esc_html__( 'Rate us on WordPress', WEBLIZAR_SLGF_TEXT_DOMAIN ), |
| 300 |
array( |
| 301 |
&$this, |
| 302 |
'slgf_rate_us_function', |
| 303 |
), |
| 304 |
'slgf_slider', |
| 305 |
'side', |
| 306 |
'low' |
| 307 |
); |
| 308 |
|
| 309 |
wp_enqueue_style( 'font-awesome-5', WEBLIZAR_SLGF_PLUGIN_URL . 'css/all.min.css' ); |
| 310 |
} |
| 311 |
|
| 312 |
/** Rate us **/ |
| 313 |
function slgf_rate_us_function() { ?> |
| 314 |
<div style="text-align:center"> |
| 315 |
<h3><?php esc_html_e( 'If you like our plugin then please show us some love', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?></h3> |
| 316 |
<a class="wrg-rate-us" style="text-align:center; text-decoration: none;font:normal 30px;" href="http://wordpress.org/plugins/simple-lightbox-gallery/#reviews" target="_blank"> |
| 317 |
<span class="dashicons dashicons-star-filled"></span> |
| 318 |
<span class="dashicons dashicons-star-filled"></span> |
| 319 |
<span class="dashicons dashicons-star-filled"></span> |
| 320 |
<span class="dashicons dashicons-star-filled"></span> |
| 321 |
<span class="dashicons dashicons-star-filled"></span> |
| 322 |
</a> |
| 323 |
<div class="upgrade-to-pro-demo" style="text-align:center;margin-bottom:10px;margin-top:10px;"> |
| 324 |
<a href="https://wordpress.org/plugins/simple-lightbox-gallery/#reviews" target="_new" class="button button-primary button-hero"><?php esc_html_e( 'Click Here', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?></a> |
| 325 |
</div> |
| 326 |
</div> |
| 327 |
<?php |
| 328 |
} |
| 329 |
|
| 330 |
/** |
| 331 |
* This function display Add New Image interface |
| 332 |
* Also loads all saved gallery photos into photo gallery |
| 333 |
*/ |
| 334 |
public function slgf_generate_add_image_meta_box_function( $post ) { |
| 335 |
?> |
| 336 |
|
| 337 |
<div id="rpggallery_container"> |
| 338 |
|
| 339 |
<input type="hidden" id="slgf_wl_action" name="slgf_wl_action" value="wl-save-settings"> |
| 340 |
<ul id="slgf_gallery_thumbs" class="clearfix"> |
| 341 |
<?php |
| 342 |
/* Load saved photos into gallery */ |
| 343 |
$SLGF_AllPhotosDetails = unserialize( get_post_meta( $post->ID, 'slgf_all_photos_details', true ) ); |
| 344 |
$TotalImages = get_post_meta( $post->ID, 'slgf_total_images_count', true ); |
| 345 |
$i = 0; |
| 346 |
if ( $TotalImages ) { |
| 347 |
foreach ( $SLGF_AllPhotosDetails as $SLGF_SinglePhotoDetails ) { |
| 348 |
$name = $SLGF_SinglePhotoDetails['slgf_image_label']; |
| 349 |
$UniqueString = substr( str_shuffle( 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ), 0, 5 ); |
| 350 |
$url = $SLGF_SinglePhotoDetails['slgf_image_url']; |
| 351 |
$slgf_image_id = $SLGF_SinglePhotoDetails['slgf_image_id']; |
| 352 |
$url1 = $SLGF_SinglePhotoDetails['slgf_12_thumb']; |
| 353 |
$url2 = $SLGF_SinglePhotoDetails['slgf_346_thumb']; |
| 354 |
$url3 = $SLGF_SinglePhotoDetails['slgf_12_same_size_thumb']; |
| 355 |
$url4 = $SLGF_SinglePhotoDetails['slgf_346_same_size_thumb']; |
| 356 |
$img_desc = $SLGF_SinglePhotoDetails['img_desc']; |
| 357 |
?> |
| 358 |
<li class="rpg-image-entry" id="rpg_img"> |
| 359 |
<a class="gallery_remove lbsremove_bt" href="#gallery_remove" id="lbs_remove_bt"><img src="<?php echo WEBLIZAR_SLGF_PLUGIN_URL . 'images/Close-icon-new.png'; ?>" /></a> |
| 360 |
<img src="<?php echo esc_url( $url ); ?>" class="rpg-meta-image" alt=""> |
| 361 |
<input type="button" id="upload-background-<?php echo esc_attr( $UniqueString ); ?>" name="upload-background-<?php echo esc_attr( $UniqueString ); ?>" value="Upload Image" class="button-primary " onClick="weblizar_image('<?php echo esc_attr( $UniqueString ); ?>')" /> |
| 362 |
<input type="text" id="slgf_image_label[]" name="slgf_image_label[]" value="<?php echo html_entity_decode( $name, ENT_QUOTES, 'UTF-8' ); ?>" placeholder="Enter Image Label" class="rpg_label_text"> |
| 363 |
<input type="hidden" id="slgf_image_id[]" name="slgf_image_id[]" value="<?php echo esc_attr( $slgf_image_id ); ?>"> |
| 364 |
|
| 365 |
<input type="text" id="slgf_image_url[]" name="slgf_image_url[]" class="rpg_label_text" value="<?php echo esc_url( $url ); ?>" readonly="readonly" style="display:none;" /> |
| 366 |
<input type="text" id="slgf_image_url1[]" name="slgf_image_url1[]" class="rpg_label_text" value="<?php echo esc_url( $url1 ); ?>" readonly="readonly" style="display:none;" /> |
| 367 |
<input type="text" id="slgf_image_url2[]" name="slgf_image_url2[]" class="rpg_label_text" value="<?php echo esc_url( $url2 ); ?>" readonly="readonly" style="display:none;" /> |
| 368 |
<input type="text" id="slgf_image_url3[]" name="slgf_image_url3[]" class="rpg_label_text" value="<?php echo esc_url( $url3 ); ?>" readonly="readonly" style="display:none;" /> |
| 369 |
<input type="text" id="slgf_image_url4[]" name="slgf_image_url4[]" class="rpg_label_text" value="<?php echo esc_url( $url4 ); ?>" readonly="readonly" style="display:none;" /> |
| 370 |
|
| 371 |
|
| 372 |
<label><?php esc_html_e( 'Description', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?></label> |
| 373 |
<textarea name="img_desc[]" id="img_desc[]" placeholder="<?php esc_html_e( 'Description', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?>" class="gal_richeditbox_<?php echo esc_attr( $i ); ?>"><?php echo htmlentities( $img_desc ); ?></textarea> |
| 374 |
</li> |
| 375 |
<?php |
| 376 |
|
| 377 |
} // end of foreach |
| 378 |
} else { |
| 379 |
$TotalImages = 0; |
| 380 |
} |
| 381 |
?> |
| 382 |
</ul> |
| 383 |
</div> |
| 384 |
|
| 385 |
<!--Add New Image Button--> |
| 386 |
<div class="add_del_buttons"> |
| 387 |
<div class="rpg-image-entry add_rpg_new_image" id="slgf_gallery_upload_button" data-uploader_title="Upload Image" data-uploader_button_text="Select"> |
| 388 |
<div class="dashicons dashicons-plus"></div> |
| 389 |
<p> |
| 390 |
<?php esc_html_e( 'Add New Images', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?> |
| 391 |
</p> |
| 392 |
</div> |
| 393 |
|
| 394 |
<div class="rpg-image-entry del_rpg_image" id="slgf_delete_all_button"> |
| 395 |
<div class="dashicons dashicons-trash"></div> |
| 396 |
<p> |
| 397 |
<?php esc_html_e( 'Delete All', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?> |
| 398 |
</p> |
| 399 |
</div> |
| 400 |
|
| 401 |
</div> |
| 402 |
|
| 403 |
<div style="clear:left;"></div> |
| 404 |
|
| 405 |
<p><strong><?php esc_html_e( 'Tips', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?> |
| 406 |
:</strong> <?php esc_html_e( 'Plugin crop images with same size thumbnails', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?> |
| 407 |
. <?php esc_html_e( 'So please upload all gallery images using Add New Image button', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?> |
| 408 |
. <?php esc_html_e( 'Do not use or add pre uploaded images which are uploaded previously using Media or Post or Page', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?> |
| 409 |
.</p><?php esc_html_e( 'Show Us Some Love', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?> |
| 410 |
(<?php esc_html_e( 'Rate Us', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?>) |
| 411 |
<a class="wrg-rate-us2" style="text-align:center; text-decoration: none;font:normal 30px;" href="<?php echo esc_url('http://wordpress.org/plugins/simple-lightbox-gallery/#reviews'); ?>" target="_blank"> |
| 412 |
<span class="dashicons dashicons-star-filled"></span> |
| 413 |
<span class="dashicons dashicons-star-filled"></span> |
| 414 |
<span class="dashicons dashicons-star-filled"></span> |
| 415 |
<span class="dashicons dashicons-star-filled"></span> |
| 416 |
<span class="dashicons dashicons-star-filled"></span> |
| 417 |
</a> |
| 418 |
|
| 419 |
<?php |
| 420 |
} |
| 421 |
|
| 422 |
/** |
| 423 |
* This function display Add New Image interface |
| 424 |
* Also loads all saved gallery photos into Lightbox gallery |
| 425 |
*/ |
| 426 |
public function slgf_settings_meta_box_function( $post ) { |
| 427 |
require_once 'simple-lightbox-slider-setting-metabox.php'; |
| 428 |
} |
| 429 |
|
| 430 |
public function slgf_shotcode_meta_box_function() { |
| 431 |
?> |
| 432 |
<p><?php esc_html_e( 'Use below shortcode in any Page/Post to publish your photo gallery', WEBLIZAR_SLGF_PLUGIN_URL ); ?></p> |
| 433 |
<input id="slgf_shortcode_field" readonly="readonly" type="text" value="<?php echo '[SLGF id=' . get_the_ID() . ']'; ?>"> |
| 434 |
<button id="slgf_btn_copy" type="button" class="wp-core-ui button-primary"><?php esc_html_e( 'Copy', WEBLIZAR_SLGF_PLUGIN_URL ); ?></button> |
| 435 |
|
| 436 |
<?php |
| 437 |
} |
| 438 |
|
| 439 |
public function admin_thumb( $id ) { |
| 440 |
// echo $id; |
| 441 |
$image = wp_get_attachment_image_src( $id, 'lightboxslider_admin_medium', true ); |
| 442 |
$image1 = wp_get_attachment_image_src( $id, 'slgf_12_thumb', true ); |
| 443 |
$image2 = wp_get_attachment_image_src( $id, 'slgf_346_thumb', true ); |
| 444 |
$image3 = wp_get_attachment_image_src( $id, 'slgf_12_same_size_thumb', true ); |
| 445 |
$image4 = wp_get_attachment_image_src( $id, 'slgf_346_same_size_thumb', true ); |
| 446 |
$UniqueString = substr( str_shuffle( 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ), 0, 5 ); |
| 447 |
?> |
| 448 |
<li class="rpg-image-entry" id="rpg_img"> |
| 449 |
<a class="gallery_remove lbsremove_bt" href="#gallery_remove" id="lbs_remove_bt"> |
| 450 |
<img src="<?php echo WEBLIZAR_SLGF_PLUGIN_URL . 'images/Close-icon-new.png'; ?>" /></a> |
| 451 |
<img src="<?php echo esc_url( $image[0] ); ?>" class="rpg-meta-image" alt=""> |
| 452 |
<input type="button" id="upload-background-<?php echo esc_attr( $UniqueString ); ?>" name="upload-background-<?php echo esc_attr( $UniqueString ); ?>" value="Upload Image" class="button-primary " onClick="weblizar_image('<?php echo esc_attr( $UniqueString ); ?>')" /> |
| 453 |
<input type="text" id="slgf_image_label[]" name="slgf_image_label[]" placeholder="Enter Image Label" class="rpg_label_text"> |
| 454 |
<input type="hidden" id="slgf_image_id[]" name="slgf_image_id[]" value="<?php echo esc_attr( $id ); ?>"> |
| 455 |
<input type="text" id="slgf_image_url[]" name="slgf_image_url[]" class="rpg_label_text" value="<?php echo esc_url( $image[0] ); ?>" readonly="readonly" style="display:none;" /> |
| 456 |
<input type="text" id="slgf_image_url1[]" name="slgf_image_url1[]" class="rpg_label_text" value="<?php echo esc_url( $image1[0] ); ?>" readonly="readonly" style="display:none;" /> |
| 457 |
<input type="text" id="slgf_image_url2[]" name="slgf_image_url2[]" class="rpg_label_text" value="<?php echo esc_url( $image2[0] ); ?>" readonly="readonly" style="display:none;" /> |
| 458 |
<input type="text" id="slgf_image_url3[]" name="slgf_image_url3[]" class="rpg_label_text" value="<?php echo esc_url( $image3[0] ); ?>" readonly="readonly" style="display:none;" /> |
| 459 |
<input type="text" id="slgf_image_url4[]" name="slgf_image_url4[]" class="rpg_label_text" value="<?php echo esc_url( $image4[0] ); ?>" readonly="readonly" style="display:none;" /> |
| 460 |
<label><?php esc_html_e( 'Description', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?></label> |
| 461 |
<textarea name="img_desc[]" id="img_desc[]" placeholder="<?php esc_html_e( 'Description', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?>" class="gal_richeditbox_<?php echo esc_attr( $id ); ?>"></textarea> |
| 462 |
|
| 463 |
</li> |
| 464 |
<?php |
| 465 |
} |
| 466 |
|
| 467 |
public function ajax_get_thumbnail_slgf() { |
| 468 |
echo esc_html( $this->admin_thumb( $_POST['imageid'] ) ); |
| 469 |
die; |
| 470 |
} |
| 471 |
|
| 472 |
public function slgf_add_image_meta_box_save( $PostID ) { |
| 473 |
if ( isset( $PostID ) && isset( $_POST['slgf_wl_action'] ) ) { |
| 474 |
$TotalImages = isset( $_POST['slgf_image_url'] ) ? count($_POST['slgf_image_url']) : ''; |
| 475 |
$ImagesArray = array(); |
| 476 |
// echo "<pre>"; |
| 477 |
// print_r($_POST); |
| 478 |
// die; |
| 479 |
if ( $TotalImages ) { |
| 480 |
for ( $i = 0; $i < $TotalImages; $i++ ) { |
| 481 |
$url = esc_url_raw( $_POST['slgf_image_url'][ $i ] ); |
| 482 |
$url1 = esc_url_raw( $_POST['slgf_image_url1'][ $i ] ); |
| 483 |
$url2 = esc_url_raw( $_POST['slgf_image_url2'][ $i ] ); |
| 484 |
$url3 = esc_url_raw( $_POST['slgf_image_url3'][ $i ] ); |
| 485 |
$url4 = esc_url_raw( $_POST['slgf_image_url4'][ $i ] ); |
| 486 |
$img_desc = sanitize_text_field( $_POST['img_desc'][ $i ] ); |
| 487 |
$image_id = sanitize_text_field( $_POST['slgf_image_id'][ $i ] ); |
| 488 |
$image_label = sanitize_text_field( $_POST['slgf_image_label'][ $i ] ); |
| 489 |
|
| 490 |
$ImagesArray[] = array( |
| 491 |
'slgf_image_label' => $image_label, |
| 492 |
'slgf_image_id' => $image_id, |
| 493 |
'slgf_image_url' => $url, |
| 494 |
'slgf_12_thumb' => $url1, |
| 495 |
'slgf_346_thumb' => $url2, |
| 496 |
'slgf_12_same_size_thumb' => $url3, |
| 497 |
'slgf_346_same_size_thumb' => $url4, |
| 498 |
'img_desc' => $img_desc, |
| 499 |
); |
| 500 |
} |
| 501 |
// print_r($ImagesArray); |
| 502 |
// die; |
| 503 |
update_post_meta( $PostID, 'slgf_all_photos_details', serialize( $ImagesArray ) ); |
| 504 |
update_post_meta( $PostID, 'slgf_total_images_count', $TotalImages ); |
| 505 |
} else { |
| 506 |
$TotalImages = 0; |
| 507 |
update_post_meta( $PostID, 'slgf_total_images_count', $TotalImages ); |
| 508 |
$ImagesArray = array(); |
| 509 |
update_post_meta( $PostID, 'slgf_all_photos_details', serialize( $ImagesArray ) ); |
| 510 |
} |
| 511 |
} |
| 512 |
// die; |
| 513 |
} |
| 514 |
// save settings meta box values |
| 515 |
public function slgf_settings_meta_save( $PostID ) { |
| 516 |
if ( isset( $PostID ) && isset( $_POST['slgf_save_action'] ) && isset( $_POST['security'] ) ) { |
| 517 |
if ( ! wp_verify_nonce( $_POST['security'], 'nonce_save_settings_option' ) ) { |
| 518 |
die(); |
| 519 |
} |
| 520 |
$SLGF_Show_Gallery_Title = sanitize_text_field( $_POST['wl-show-gallery-title'] ); |
| 521 |
$SLGF_Show_Image_Label = sanitize_text_field( $_POST['wl-show-image-label'] ); |
| 522 |
$SLGF_Hover_Animation = sanitize_text_field( $_POST['wl-hover-animation'] ); |
| 523 |
$SLGF_Gallery_Layout = sanitize_text_field( $_POST['wl-gallery-layout'] ); |
| 524 |
$SLGF_Thumbnail_Layout = sanitize_text_field( $_POST['wl-thumbnail-layout'] ); |
| 525 |
$SLGF_Hover_Color = sanitize_hex_color( $_POST['wl-hover-color'] ); |
| 526 |
$SLGF_Text_BG_Color = sanitize_hex_color( $_POST['wl-text-bg-color'] ); |
| 527 |
$SLGF_Text_Color = isset( $_POST['wl-text-color'] ) ? sanitize_hex_color( $_POST['wl-text-color'] ) : ''; |
| 528 |
$lk_show_img_desc = sanitize_text_field( $_POST['lk_show_img_desc'] ); |
| 529 |
$SLGF_Hover_Color_Opacity = sanitize_text_field( $_POST['wl-hover-color-opacity'] ); |
| 530 |
$SLGF_Font_Style = sanitize_text_field( $_POST['wl-font-style'] ); |
| 531 |
$SLGF_Box_Shadow = sanitize_text_field( $_POST['wl-box-Shadow'] ); |
| 532 |
$SLGF_Custom_CSS = wp_strip_all_tags( $_POST['wl-custom-css'] ); |
| 533 |
$SLGF_open_link = sanitize_text_field( $_POST['SLGF_open_link'] ); |
| 534 |
$SLGF_label_Color = sanitize_hex_color( $_POST['SLGF_label_Color'] ); |
| 535 |
$SLGF_desc_font_Color = sanitize_hex_color( $_POST['SLGF_desc_font_Color'] ); |
| 536 |
$SLGF_btn_Color = sanitize_hex_color( $_POST['SLGF_btn_Color'] ); |
| 537 |
$SLGF_btn_font_Color = sanitize_hex_color( $_POST['SLGF_btn_font_Color'] ); |
| 538 |
$SLGF_button_title = sanitize_text_field( $_POST['SLGF_button_title'] ); |
| 539 |
$SLGF_Light_Box = sanitize_text_field( $_POST['SLGF_Light_Box'] ); |
| 540 |
$SLGF_title_Color = sanitize_hex_color( $_POST['SLGF_title_Color'] ); |
| 541 |
|
| 542 |
$SLGF_DefaultSettingsArray = serialize( |
| 543 |
array( |
| 544 |
'SLGF_Show_Gallery_Title' => $SLGF_Show_Gallery_Title, |
| 545 |
'SLGF_Show_Image_Label' => $SLGF_Show_Image_Label, |
| 546 |
'SLGF_Hover_Animation' => $SLGF_Hover_Animation, |
| 547 |
'SLGF_Gallery_Layout' => $SLGF_Gallery_Layout, |
| 548 |
'SLGF_Thumbnail_Layout' => $SLGF_Thumbnail_Layout, |
| 549 |
'SLGF_Hover_Color' => $SLGF_Hover_Color, |
| 550 |
'SLGF_Text_BG_Color' => $SLGF_Text_BG_Color, |
| 551 |
'SLGF_Text_Color' => $SLGF_Text_Color, |
| 552 |
'SLGF_Hover_Color_Opacity' => $SLGF_Hover_Color_Opacity, |
| 553 |
'SLGF_Font_Style' => $SLGF_Font_Style, |
| 554 |
'lk_show_img_desc' => $lk_show_img_desc, |
| 555 |
'SLGF_Box_Shadow' => $SLGF_Box_Shadow, |
| 556 |
'SLGF_Custom_CSS' => $SLGF_Custom_CSS, |
| 557 |
'SLGF_open_link' => $SLGF_open_link, |
| 558 |
'SLGF_label_Color' => $SLGF_label_Color, |
| 559 |
'SLGF_desc_font_Color' => $SLGF_desc_font_Color, |
| 560 |
'SLGF_btn_Color' => $SLGF_btn_Color, |
| 561 |
'SLGF_btn_font_Color' => $SLGF_btn_font_Color, |
| 562 |
'SLGF_button_title' => $SLGF_button_title, |
| 563 |
'SLGF_Light_Box' => $SLGF_Light_Box, |
| 564 |
'SLGF_title_Color' => $SLGF_title_Color, |
| 565 |
) |
| 566 |
); |
| 567 |
|
| 568 |
$SLGF_Gallery_Settings = 'SLGF_Gallery_Settings_' . $PostID; |
| 569 |
update_post_meta( $PostID, $SLGF_Gallery_Settings, $SLGF_DefaultSettingsArray ); |
| 570 |
} |
| 571 |
} |
| 572 |
} |
| 573 |
|
| 574 |
/** |
| 575 |
* Initialize Class with Object |
| 576 |
*/ |
| 577 |
$SLGF = new SLGF(); |
| 578 |
|
| 579 |
/** |
| 580 |
* Lightbox Slider Pro Short Code [SLGF] |
| 581 |
*/ |
| 582 |
require_once 'simple-lightbox-slider-shortcode.php'; |
| 583 |
|
| 584 |
/** |
| 585 |
* Hex Color code to RGB Color Code converter function |
| 586 |
*/ |
| 587 |
if ( ! function_exists( 'SLGF_RPGhex2rgb' ) ) { |
| 588 |
function SLGF_RPGhex2rgb( $hex ) { |
| 589 |
$hex = str_replace( '#', '', $hex ); |
| 590 |
|
| 591 |
if ( strlen( $hex ) == 3 ) { |
| 592 |
$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
| 593 |
$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
| 594 |
$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
| 595 |
} else { |
| 596 |
$r = hexdec( substr( $hex, 0, 2 ) ); |
| 597 |
$g = hexdec( substr( $hex, 2, 2 ) ); |
| 598 |
$b = hexdec( substr( $hex, 4, 2 ) ); |
| 599 |
} |
| 600 |
$rgb = array( $r, $g, $b ); |
| 601 |
|
| 602 |
return $rgb; // returns an array with the rgb values |
| 603 |
} |
| 604 |
} |
| 605 |
|
| 606 |
add_action( 'media_buttons', 'add_slgf_custom_button' ); |
| 607 |
function add_slgf_custom_button() { |
| 608 |
$context = null; |
| 609 |
$img = plugins_url( '/images/Photos-icon.png', __FILE__ ); |
| 610 |
$container_id = 'SLGF'; |
| 611 |
$title = 'Select Lightbox Gallery to insert into post'; |
| 612 |
$context .= '<a class="button button-primary thickbox" title="Select Lightbox Gallery to insert into post" href="#TB_inline?width=400&inlineId=' . $container_id . '"> |
| 613 |
<span class="wp-media-buttons-icon" style="background: url(' . $img . '); background-repeat: no-repeat; background-position: left bottom;"></span> |
| 614 |
Simple Lightbox Gallery Shortcode</a>'; |
| 615 |
|
| 616 |
printf( $context ); |
| 617 |
} |
| 618 |
|
| 619 |
add_action( 'admin_footer', 'add_slgf_inline_popup_content' ); |
| 620 |
function add_slgf_inline_popup_content() { |
| 621 |
?> |
| 622 |
|
| 623 |
<?php |
| 624 |
wp_register_script( 'slg_script', false ); |
| 625 |
wp_enqueue_script( 'slg_script' ); |
| 626 |
$js = ' '; |
| 627 |
ob_start(); |
| 628 |
?> |
| 629 |
$(document).ready(function () { |
| 630 |
$('#slgfgalleryinsert').on('click', function () { |
| 631 |
var id = $('#slgf-gallery-select option:selected').val(); |
| 632 |
window.send_to_editor('<p>[SLGF id=' + id + ']</p>'); |
| 633 |
tb_remove(); |
| 634 |
}) |
| 635 |
}); |
| 636 |
<?php |
| 637 |
$js .= ob_get_clean(); |
| 638 |
wp_add_inline_script( 'slg_script', $js ); |
| 639 |
?> |
| 640 |
|
| 641 |
<div id="SLGF" style="display:none;"> |
| 642 |
<h3> |
| 643 |
<?php esc_html_e( 'Select Lightbox Gallery To Insert Into Post', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?> |
| 644 |
</h3> |
| 645 |
<?php |
| 646 |
$all_posts = wp_count_posts( 'slgf_slider' )->publish; |
| 647 |
$args = array( |
| 648 |
'post_type' => 'slgf_slider', |
| 649 |
'posts_per_page' => $all_posts, |
| 650 |
); |
| 651 |
global $rpg_galleries; |
| 652 |
$rpg_galleries = new WP_Query( $args ); |
| 653 |
if ( $rpg_galleries->have_posts() ) { |
| 654 |
?> |
| 655 |
<select id="slgf-gallery-select"> |
| 656 |
<?php |
| 657 |
while ( $rpg_galleries->have_posts() ) : |
| 658 |
$rpg_galleries->the_post(); |
| 659 |
?> |
| 660 |
<option value="<?php echo get_the_ID(); ?>"><?php the_title(); ?></option> |
| 661 |
<?php endwhile; ?> |
| 662 |
</select> |
| 663 |
<button class='button primary' id='slgfgalleryinsert'> |
| 664 |
<?php esc_html_e( 'Insert Gallery Shortcode', WEBLIZAR_SLGF_TEXT_DOMAIN ); ?> |
| 665 |
</button> |
| 666 |
</button> |
| 667 |
<?php |
| 668 |
} else { |
| 669 |
esc_html_e( 'No Gallery Found', WEBLIZAR_SLGF_TEXT_DOMAIN ); |
| 670 |
} |
| 671 |
?> |
| 672 |
</div> |
| 673 |
<?php |
| 674 |
} |
| 675 |
|
| 676 |
// Add settings link on plugin page |
| 677 |
$slgf_plugin_name = plugin_basename( __FILE__ ); |
| 678 |
add_filter( "plugin_action_links_$slgf_plugin_name", 'as_settings_link_slgf' ); |
| 679 |
function as_settings_link_slgf( $links ) { |
| 680 |
$as_settings_link1 = '<a href="https://weblizar.com/lightbox-slider-pro/" style="font-weight:700; color:#e35400" target="_blank">' . esc_html__( 'Get Premium', WEBLIZAR_SLGF_TEXT_DOMAIN ) . '</a>'; |
| 681 |
$as_settings_link2 = '<a href="edit.php?post_type=slgf_slider">' . esc_html__( 'Settings', WEBLIZAR_SLGF_TEXT_DOMAIN ) . '</a>'; |
| 682 |
array_unshift( $links, $as_settings_link1, $as_settings_link2 ); |
| 683 |
|
| 684 |
return $links; |
| 685 |
} |
| 686 |
?> |
| 687 |
|