| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
Plugin Name: Slideshow Gallery |
| 5 |
Plugin URI: https://tribulant.com/plugins/view/13/ |
| 6 |
Author: Tribulant |
| 7 |
Author URI: https://tribulant.com |
| 8 |
Description: Feature content in a JavaScript powered slideshow gallery showcase on your WordPress website. The slideshow is flexible and all aspects can easily be configured. Embedding or hardcoding the slideshow gallery is a breeze. See the <a href="https://tribulant.com/docs/wordpress-slideshow-gallery/1758/" target="_blank">online documentation</a> for instructions on using and embedding slideshow galleries. Upgrade to the premium version to remove all limitations. |
| 9 |
Version: 1.8.1 |
| 10 |
License: GNU General Public License v2 or later |
| 11 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 12 |
Tags: slideshow gallery, slideshow, gallery, slider, jquery, bfithumb, galleries, photos, images |
| 13 |
Text Domain: slideshow-gallery |
| 14 |
Domain Path: /languages |
| 15 |
*/ |
| 16 |
|
| 17 |
if (!defined('ABSPATH')) exit; // Exit if accessed directly |
| 18 |
|
| 19 |
if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } |
| 20 |
|
| 21 |
$path = dirname(__FILE__) . DS . 'slideshow-gallery-plugin.php'; |
| 22 |
if (file_exists($path)) { |
| 23 |
require_once(dirname(__FILE__) . DS . 'includes' . DS . 'checkinit.php'); |
| 24 |
require_once(dirname(__FILE__) . DS . 'includes' . DS . 'constants.php'); |
| 25 |
require_once($path); |
| 26 |
require_once(dirname(__FILE__) . DS . 'includes' . DS . 'errorhandler.php'); |
| 27 |
require_once(dirname(__FILE__) . DS . 'vendors' . DS . 'otf_regen_thumbs.php'); |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
if (!class_exists('SlideshowGallery')) { |
| 33 |
class SlideshowGallery extends GalleryPlugin { |
| 34 |
|
| 35 |
|
| 36 |
function __construct() { |
| 37 |
$url = explode("&", $_SERVER['REQUEST_URI']); |
| 38 |
$this -> url = $url[0]; |
| 39 |
$this -> referer = (empty($_SERVER['HTTP_REFERER'])) ? $this -> url : $_SERVER['HTTP_REFERER']; |
| 40 |
$this -> plugin_name = basename(dirname(__FILE__)); |
| 41 |
$this -> plugin_file = plugin_basename(__FILE__); |
| 42 |
$this -> register_plugin($this -> plugin_name, __FILE__); |
| 43 |
$this -> errorhandler = new SlideshowErrorHandler(); |
| 44 |
|
| 45 |
|
| 46 |
//WordPress action hooks |
| 47 |
$this -> add_action('plugins_loaded'); |
| 48 |
$this -> add_action('wp_head'); |
| 49 |
$this -> add_action('wp_footer'); |
| 50 |
$this -> add_action('admin_menu'); |
| 51 |
$this -> add_action('admin_head'); |
| 52 |
$this -> add_action('admin_notices'); |
| 53 |
$this -> add_action('wp_print_styles', 'print_styles'); |
| 54 |
$this -> add_action('admin_print_styles', 'print_styles'); |
| 55 |
$this -> add_action('wp_print_scripts', 'print_scripts'); |
| 56 |
$this -> add_action('admin_print_scripts', 'print_scripts'); |
| 57 |
$this -> add_action('init', 'init_textdomain', 10, 1); |
| 58 |
$this -> add_action('admin_init', 'custom_redirect', 1, 1); |
| 59 |
|
| 60 |
//WordPress Ajax hooks |
| 61 |
$this -> add_action('wp_ajax_slideshow_slides_order', 'ajax_slides_order', 10, 1); |
| 62 |
$this -> add_action('wp_ajax_slideshow_tinymce', 'ajax_tinymce', 10, 1); |
| 63 |
|
| 64 |
//WordPress filter hooks |
| 65 |
$this -> add_filter('mce_buttons'); |
| 66 |
$this -> add_filter('mce_external_plugins'); |
| 67 |
$this -> add_filter("plugin_action_links_" . $this -> plugin_file, 'plugin_action_links', 10, 4); |
| 68 |
|
| 69 |
$this -> add_action('slideshow_ratereviewhook', 'ratereview_hook'); |
| 70 |
|
| 71 |
if (!is_admin() || wp_doing_ajax()) { |
| 72 |
add_shortcode('slideshow', array($this, 'embed')); |
| 73 |
add_shortcode('tribulant_slideshow', array($this, 'embed')); |
| 74 |
} |
| 75 |
|
| 76 |
$this -> updating_plugin(); |
| 77 |
} |
| 78 |
|
| 79 |
function excerpt_more($more = null) { |
| 80 |
global $slideshow_post; |
| 81 |
$excerptsettings = $this -> get_option('excerptsettings'); |
| 82 |
if (!empty($excerptsettings)) { |
| 83 |
$excerpt_readmore = $this -> get_option('excerpt_readmore'); |
| 84 |
if (!empty($excerpt_readmore)) { |
| 85 |
$more = ' <a href="' . get_permalink($slideshow_post -> ID) . '">' . esc_html($excerpt_readmore) . '</a>'; |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
return $more; |
| 90 |
} |
| 91 |
|
| 92 |
function excerpt_length($length = null) { |
| 93 |
$excerptsettings = $this -> get_option('excerptsettings'); |
| 94 |
if (!empty($excerptsettings)) { |
| 95 |
$excerpt_length = $this -> get_option('excerpt_length'); |
| 96 |
if (!empty($excerpt_length)) { |
| 97 |
$length = $excerpt_length; |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
return $length; |
| 102 |
} |
| 103 |
|
| 104 |
function plugin_action_links($actions = null, $plugin_file = null, $plugin_data = null, $context = null) { |
| 105 |
$this_plugin = plugin_basename(__FILE__); |
| 106 |
|
| 107 |
if (!empty($plugin_file) && $plugin_file == $this_plugin) { |
| 108 |
$actions[] = '<a href="" onclick="jQuery.colorbox({href:ajaxurl + \'?action=slideshow_serialkey&security=' . wp_create_nonce('serialkey') . '\'}); return false;" id="slideshow_submitseriallink"><i class="fa fa-key fa-fw"></i> ' . __('Serial Key', 'slideshow-gallery') . '</a>'; |
| 109 |
$actions[] = '<a href="' . admin_url('admin.php?page=' . $this -> sections -> settings) . '"><i class="fa fa-cog fa-fw"></i> ' . __('Settings', 'slideshow-gallery') . '</a>'; |
| 110 |
|
| 111 |
/*if ($update = $this -> vendor('update')) { |
| 112 |
$version_info = $update -> get_version_info(); |
| 113 |
if (!empty($version_info['dtype']) && $version_info['dtype'] == "single") { |
| 114 |
$actions[] = '<a href="https://tribulant.com/items/upgrade/' . $version_info['item_id'] . '" target="_blank"><i class="fa fa-level-up fa-fw"></i> ' . __('Upgrade', 'slideshow-gallery') . '</a>'; |
| 115 |
} |
| 116 |
}*/ |
| 117 |
} |
| 118 |
|
| 119 |
return $actions; |
| 120 |
} |
| 121 |
|
| 122 |
function init() { |
| 123 |
} |
| 124 |
|
| 125 |
function init_textdomain() { |
| 126 |
$locale = get_locale(); |
| 127 |
|
| 128 |
if (!empty($locale)) { |
| 129 |
if ($locale == "ja" || $locale == "ja_JP") { setlocale(LC_ALL, "ja_JP.UTF8"); } |
| 130 |
} else { |
| 131 |
setlocale(LC_ALL, apply_filters('slideshow_setlocale', $locale)); |
| 132 |
} |
| 133 |
|
| 134 |
$mo_file = $this -> plugin_name . '-' . $locale . '.mo'; |
| 135 |
$language_external = $this -> get_option('language_external'); |
| 136 |
|
| 137 |
if (!empty($language_external)) { |
| 138 |
if (function_exists('load_textdomain')) { |
| 139 |
load_textdomain($this -> plugin_name, WP_LANG_DIR . DS . $this -> plugin_name . DS . $mo_file); |
| 140 |
} |
| 141 |
} else { |
| 142 |
if (function_exists('load_plugin_textdomain')) { |
| 143 |
load_plugin_textdomain($this -> plugin_name, false, dirname(plugin_basename(__FILE__)) . DS . 'languages' . DS); |
| 144 |
} |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
function plugins_loaded() { |
| 149 |
$this -> ci_initialize(); |
| 150 |
|
| 151 |
if ($this -> language_do()) { |
| 152 |
add_filter('gettext', array($this, 'language_useordefault'), 0); |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
function wp_head() { |
| 157 |
global $slideshow_javascript, $slideshow_css; |
| 158 |
$slideshow_javascript = array(); |
| 159 |
$slideshow_css = array(); |
| 160 |
|
| 161 |
$this -> render('head', false, true, 'default'); |
| 162 |
} |
| 163 |
|
| 164 |
function wp_footer() { |
| 165 |
global $slideshow_javascript, $slideshow_css; |
| 166 |
$jsoutput = $this -> get_option('jsoutput'); |
| 167 |
|
| 168 |
if (!empty($slideshow_javascript)) { |
| 169 |
if (!empty($jsoutput) && $jsoutput == "footerglobal") { |
| 170 |
?><!-- Slideshow Gallery Javascript BEG --><?php |
| 171 |
|
| 172 |
foreach ($slideshow_javascript as $javascript) { |
| 173 |
//echo wp_unslash($javascript); |
| 174 |
echo html_entity_decode(str_replace("\'", "'", str_replace('\n', '', esc_js($javascript)))); |
| 175 |
} |
| 176 |
|
| 177 |
?><!-- Slideshow Gallery Javascript END --><?php |
| 178 |
} |
| 179 |
} |
| 180 |
|
| 181 |
if (!empty($slideshow_css)) { |
| 182 |
if (!empty($jsoutput) && $jsoutput == "footerglobal") { |
| 183 |
?><!-- Slideshow Gallery CSS BEG --><?php |
| 184 |
|
| 185 |
foreach ($slideshow_css as $css) { |
| 186 |
//echo wp_unslash($css); |
| 187 |
echo html_entity_decode(esc_html($css)); |
| 188 |
} |
| 189 |
|
| 190 |
?><!-- Slideshow Gallery CSS END --><?php |
| 191 |
} |
| 192 |
} |
| 193 |
} |
| 194 |
|
| 195 |
function admin_menu() { |
| 196 |
//$update_icon = ($this -> has_update()) ? ' <span class="update-plugins count-1"><span class="update-count">1</span></span>' : ''; |
| 197 |
$update_icon = ''; |
| 198 |
$this -> check_roles(); |
| 199 |
|
| 200 |
add_menu_page(__('Slideshow', 'slideshow-gallery'), __('Slideshow', 'slideshow-gallery') . $update_icon, 'slideshow_slides', $this -> sections -> slides, array($this, 'admin_slides'), false, "26.113"); |
| 201 |
$this -> menus['slideshow-slides'] = add_submenu_page($this -> sections -> slides, __('Manage Slides', 'slideshow-gallery'), __('Manage Slides', 'slideshow-gallery'), 'slideshow_slides', $this -> sections -> slides, array($this, 'admin_slides')); |
| 202 |
$this -> menus['slideshow-galleries'] = add_submenu_page($this -> sections -> slides, __('Manage Galleries', 'slideshow-gallery'), __('Manage Galleries', 'slideshow-gallery'), 'slideshow_galleries', $this -> sections -> galleries, array($this, 'admin_galleries')); |
| 203 |
$this -> menus['slideshow-settings'] = add_submenu_page($this -> sections -> slides, __('Settings', 'slideshow-gallery'), __('Settings', 'slideshow-gallery'), 'slideshow_settings', $this -> sections -> settings, array($this, 'admin_settings')); |
| 204 |
//$this -> menus['slideshow-settings-updates'] = add_submenu_page($this -> sections -> slides, __('Updates', 'slideshow-gallery'), __('Updates', 'slideshow-gallery') . $update_icon, 'slideshow_settings_updates', $this -> sections -> settings_updates, array($this, 'admin_settings_updates')); |
| 205 |
|
| 206 |
if (!$this -> ci_serial_valid()) { |
| 207 |
//$this -> menus['slideshow-submitserial'] = add_submenu_page($this -> sections -> slides, __('Submit Serial Key', 'slideshow-gallery'), __('Submit Serial Key', 'slideshow-gallery'), 'slideshow_submitserial', $this -> sections -> submitserial, array($this, 'admin_submitserial')); |
| 208 |
} |
| 209 |
|
| 210 |
add_action("load-" . $this -> menus['slideshow-slides'], array($this, 'screen_options_slides')); |
| 211 |
add_action("load-" . $this -> menus['slideshow-galleries'], array($this, 'screen_options_galleries')); |
| 212 |
|
| 213 |
do_action('slideshow_admin_menu', $this -> menus); |
| 214 |
|
| 215 |
add_action('admin_head-' . $this -> menus['slideshow-settings'], array($this, 'admin_head_gallery_settings')); |
| 216 |
|
| 217 |
add_dashboard_page(sprintf('Slideshow Gallery %s', $this -> version), sprintf('Slideshow Gallery %s', $this -> version), 'read', $this -> sections -> about, array($this, 'slideshow_gallery_about')); |
| 218 |
remove_submenu_page('index.php', $this -> sections -> about); |
| 219 |
} |
| 220 |
|
| 221 |
function set_screen_option($status = null, $option = null, $value = null) { |
| 222 |
return $value; |
| 223 |
} |
| 224 |
|
| 225 |
function removable_query_args($removable_query_args = array()) { |
| 226 |
|
| 227 |
$removable_query_args[] = 'Galleryupdated'; |
| 228 |
$removable_query_args[] = 'Gallerymessage'; |
| 229 |
|
| 230 |
return $removable_query_args; |
| 231 |
} |
| 232 |
|
| 233 |
function screen_options_slides() { |
| 234 |
$screen = get_current_screen(); |
| 235 |
|
| 236 |
// get out of here if we are not on our settings page |
| 237 |
if (!is_object($screen) || $screen -> id != $this -> menus['slideshow-slides']) { |
| 238 |
return; |
| 239 |
} |
| 240 |
|
| 241 |
$args = array( |
| 242 |
'label' => __('Slides per page', 'slideshow-gallery'), |
| 243 |
'default' => 15, |
| 244 |
'option' => 'slideshow_slides_perpage' |
| 245 |
); |
| 246 |
|
| 247 |
add_screen_option('per_page', $args); |
| 248 |
|
| 249 |
require_once $this -> plugin_base() . DS . 'includes' . DS . 'class.slide-list-table.php'; |
| 250 |
$Slide_List_Table = new Slide_List_Table; |
| 251 |
} |
| 252 |
|
| 253 |
function screen_options_galleries() { |
| 254 |
$screen = get_current_screen(); |
| 255 |
|
| 256 |
// get out of here if we are not on our settings page |
| 257 |
if (!is_object($screen) || $screen -> id != $this -> menus['slideshow-galleries']) { |
| 258 |
return; |
| 259 |
} |
| 260 |
|
| 261 |
$args = array( |
| 262 |
'label' => __('Galleries per page', 'slideshow-gallery'), |
| 263 |
'default' => 15, |
| 264 |
'option' => 'slideshow_galleries_perpage' |
| 265 |
); |
| 266 |
|
| 267 |
add_screen_option('per_page', $args); |
| 268 |
|
| 269 |
require_once $this -> plugin_base() . DS . 'includes' . DS . 'class.gallery-list-table.php'; |
| 270 |
$Gallery_List_Table = new Gallery_List_Table; |
| 271 |
} |
| 272 |
|
| 273 |
function default_hidden_columns($hidden = null, $screen = null) { |
| 274 |
if ($current_screen = get_current_screen()) { |
| 275 |
if (($current_screen -> id == $this -> menus['slideshow-slides']) || ($current_screen -> id == $this -> menus['slideshow-galleries'])) { |
| 276 |
switch ($screen -> id) { |
| 277 |
case $this -> menus['slideshow-slides'] : |
| 278 |
$hidden = array( |
| 279 |
'id', |
| 280 |
'link', |
| 281 |
'expiry', |
| 282 |
'order', |
| 283 |
); |
| 284 |
break; |
| 285 |
case $this -> menus['slideshow-galleries'] : |
| 286 |
$hidden = array( |
| 287 |
'id', |
| 288 |
); |
| 289 |
break; |
| 290 |
} |
| 291 |
} |
| 292 |
} |
| 293 |
|
| 294 |
return $hidden; |
| 295 |
} |
| 296 |
|
| 297 |
function slideshow_gallery_about() { |
| 298 |
$this -> render('about', false, true, 'admin'); |
| 299 |
} |
| 300 |
|
| 301 |
function admin_head() { |
| 302 |
$this -> render('head', false, true, 'admin'); |
| 303 |
} |
| 304 |
|
| 305 |
function admin_head_gallery_settings() { |
| 306 |
add_meta_box('submitdiv', __('Save Settings', 'slideshow-gallery'), array($this -> Metabox, "settings_submit"), $this -> menus['slideshow-settings'], 'side', 'core'); |
| 307 |
add_meta_box('pluginsdiv', __('Recommended Plugin', 'slideshow-gallery'), array($this -> Metabox, "settings_plugins"), $this -> menus['slideshow-settings'], 'side', 'core'); |
| 308 |
add_meta_box('aboutdiv', __('About This Plugin', 'slideshow-gallery') . $this -> Html -> help(__('More about this plugin and the creators of it', 'slideshow-gallery')), array($this -> Metabox, "settings_about"), $this -> menus['slideshow-settings'], 'side', 'core'); |
| 309 |
add_meta_box('generaldiv', __('General Settings', 'slideshow-gallery') . $this -> Html -> help(__('General settings for the inner workings and some default behaviours', 'slideshow-gallery')), array($this -> Metabox, "settings_general"), $this -> menus['slideshow-settings'], 'normal', 'core'); |
| 310 |
add_meta_box('postsdiv', __('Posts/Pages Settings', 'slideshow-gallery'), array($this -> Metabox, "settings_postspages"), $this -> menus['slideshow-settings'], 'normal', 'core'); |
| 311 |
add_meta_box('linksimagesdiv', __('Links & Images Overlay', 'slideshow-gallery') . $this -> Html -> help(__('Configure the way that slides with links are opened', 'slideshow-gallery')), array($this -> Metabox, "settings_linksimages"), $this -> menus['slideshow-settings'], 'normal', 'core'); |
| 312 |
add_meta_box('stylesdiv', __('Appearance & Styles', 'slideshow-gallery') . $this -> Html -> help(__('Change the way the slideshows look so that it suits your needs', 'slideshow-gallery')), array($this -> Metabox, "settings_styles"), $this -> menus['slideshow-settings'], 'normal', 'core'); |
| 313 |
add_meta_box('techdiv', __('Technical Settings', 'slideshow-gallery'), array($this -> Metabox, "settings_tech"), $this -> menus['slideshow-settings'], 'normal', 'core'); |
| 314 |
add_meta_box('wprelateddiv', __('WordPress Related', 'slideshow-gallery') . $this -> Html -> help(__('Settings specifically related to WordPress', 'slideshow-gallery')), array($this -> Metabox, "settings_wprelated"), $this -> menus['slideshow-settings'], 'normal', 'core'); |
| 315 |
|
| 316 |
global $post; |
| 317 |
do_action('do_meta_boxes', $this -> menus['slideshow-settings'], 'normal', $post); |
| 318 |
do_action('do_meta_boxes', $this -> menus['slideshow-settings'], 'side', $post); |
| 319 |
} |
| 320 |
|
| 321 |
function admin_submitserial() { |
| 322 |
$success = false; |
| 323 |
|
| 324 |
if (!empty($_POST)) { |
| 325 |
check_admin_referer($this -> sections -> submitserial); |
| 326 |
|
| 327 |
$serial = sanitize_text_field($_REQUEST['serial']); |
| 328 |
|
| 329 |
if (empty($serial)) { $errors[] = __('Please fill in a serial key.', 'slideshow-gallery'); } |
| 330 |
else { |
| 331 |
$this -> update_option('serialkey', $serial); //update the DB option |
| 332 |
$this -> delete_all_cache('all'); |
| 333 |
|
| 334 |
if (!$this -> ci_serial_valid()) { $errors[] = __('Serial key is invalid, please try again.', 'slideshow-gallery'); } |
| 335 |
else { |
| 336 |
delete_transient($this -> pre . 'update_info'); |
| 337 |
$success = true; |
| 338 |
$this -> redirect(admin_url('admin.php?page=' . $this -> sections -> welcome)); |
| 339 |
} |
| 340 |
} |
| 341 |
} |
| 342 |
|
| 343 |
$this -> render('settings-submitserial', array('success' => $success, 'errors' => $errors), true, 'admin'); |
| 344 |
} |
| 345 |
|
| 346 |
function admin_notices() { |
| 347 |
|
| 348 |
if (is_admin()) { |
| 349 |
$this -> check_uploaddir(); |
| 350 |
|
| 351 |
$message = (!empty($_GET[$this -> pre . 'message'])) ? wp_kses_html_error($_GET[$this -> pre . 'message']) : false; |
| 352 |
if (!empty($message)) { |
| 353 |
$msg_type = (!empty($_GET[$this -> pre . 'updated'])) ? 'msg' : 'err'; |
| 354 |
call_user_func(array($this, 'render_' . $msg_type), $message); |
| 355 |
} |
| 356 |
|
| 357 |
$showmessage_ratereview = $this -> get_option('showmessage_ratereview'); |
| 358 |
if (!empty($showmessage_ratereview)) { |
| 359 |
$message = sprintf(esc_html__('You have been using the %s for %s days or more. Please consider to %s it or say it %s on %s.', 'slideshow-gallery'), |
| 360 |
'<a href="https://wordpress.org/plugins/slideshow-gallery/" target="_blank">Tribulant Slideshow Gallery plugin</a>', |
| 361 |
$showmessage_ratereview, |
| 362 |
'<a class="button" href="https://wordpress.org/support/plugin/slideshow-gallery/reviews/?rate=5#new-post" target="_blank"><i class="fa fa-star"></i> Rate</a>', |
| 363 |
'<a class="button" href="https://wordpress.org/plugins/slideshow-gallery/?compatibility[version]=' . get_bloginfo('version') . '&compatibility[topic_version]=' . $this -> version . '&compatibility[compatible]=1" target="_blank"><i class="fa fa-check"></i> Works</a>', |
| 364 |
'<a href="https://wordpress.org/plugins/slideshow-gallery/" target="_blank">WordPress.org</a>'); |
| 365 |
|
| 366 |
$dismissable = admin_url('admin.php?page=' . $this -> sections -> settings . '&slideshow_method=hidemessage&message=ratereview'); |
| 367 |
$this -> render_msg($message, $dismissable, false); |
| 368 |
} |
| 369 |
|
| 370 |
/* Serial key submission message */ |
| 371 |
if (isset($_GET['page'])) { |
| 372 |
$page = sanitize_text_field($_GET['page']); |
| 373 |
} else { |
| 374 |
$page = ""; |
| 375 |
} |
| 376 |
|
| 377 |
if (!$this -> ci_serial_valid() && (empty($page) || $page != $this -> sections -> submitserial)) { |
| 378 |
$hidemessage_upgradetopro = $this -> get_option('hidemessage_upgradetopro'); |
| 379 |
|
| 380 |
if (empty($hidemessage_upgradetopro)) { |
| 381 |
$message = sprintf(esc_html__('You are using Slideshow Gallery LITE. Take your slideshows to the next level with %s. Already purchased? %s.', 'slideshow-gallery'), '<a href="' . admin_url('admin.php?page=' . $this -> sections -> lite_upgrade) . '">Slideshow Gallery PRO</a>', '<a href="https://tribulant.com/docs/wordpress-slideshow-gallery/1758" target="_blank">See instructions to install PRO</a>'); |
| 382 |
$message .= ' <a class="button button-primary" href="' . admin_url('admin.php?page=' . $this -> sections -> lite_upgrade) . '"><i class="fa fa-check"></i> ' . __('Upgrade to PRO', 'slideshow-gallery') . '</a>'; |
| 383 |
$message .= ' <a class="button button-secondary" href="' . admin_url('admin.php?page=' . $this -> sections -> welcome . '&slideshow_method=hidemessage&message=upgradetopro') . '"><i class="fa fa-times"></i> ' . __('Hide this message', 'slideshow-gallery') . '</a>'; |
| 384 |
$dismissable = admin_url('admin.php?page=' . $this -> sections -> welcome . '&slideshow_method=hidemessage&message=upgradetopro'); |
| 385 |
$this -> render_msg($message, $dismissable, false); |
| 386 |
|
| 387 |
?> |
| 388 |
|
| 389 |
<script type="text/javascript"> |
| 390 |
jQuery(document).ready(function(e) { |
| 391 |
jQuery('#<?php echo esc_attr($this -> pre); ?>submitseriallink').click(function() { |
| 392 |
jQuery.colorbox({href:ajaxurl + "?action=slideshow_serialkey&security=<?php echo wp_create_nonce('serialkey'); ?>"}); |
| 393 |
return false; |
| 394 |
}); |
| 395 |
}); |
| 396 |
</script> |
| 397 |
|
| 398 |
<?php |
| 399 |
} |
| 400 |
} |
| 401 |
|
| 402 |
// Is an Update Available? |
| 403 |
/*if (!empty($page) && in_array($page, (array) $this -> sections)) { |
| 404 |
if (apply_filters('slideshow_updates', true)) { |
| 405 |
if (current_user_can('edit_plugins') && $this -> has_update() && (empty($page) || (!empty($page) && $page != $this -> sections -> settings_updates))) { |
| 406 |
$hideupdate = $this -> get_option('hideupdate'); |
| 407 |
if (empty($hideupdate) || (!empty($hideupdate) && version_compare($this -> version, $hideupdate, '>'))) { |
| 408 |
$update = $this -> vendor('update'); |
| 409 |
$update_info = $update -> get_version_info(); |
| 410 |
$this -> render('update', array('update_info' => $update_info), true, 'admin'); |
| 411 |
} |
| 412 |
} |
| 413 |
} |
| 414 |
}*/ |
| 415 |
} |
| 416 |
|
| 417 |
} |
| 418 |
|
| 419 |
function mce_buttons($buttons) { |
| 420 |
array_push($buttons, "separator", "gallery"); |
| 421 |
return $buttons; |
| 422 |
} |
| 423 |
|
| 424 |
function mce_external_plugins($plugins) { |
| 425 |
$plugins['gallery'] = $this -> url() . '/js/tinymce/editor_plugin.js'; |
| 426 |
return $plugins; |
| 427 |
} |
| 428 |
|
| 429 |
function slideshow($output = true, $post_id = null, $exclude = null) { |
| 430 |
$params['post_id'] = $post_id; |
| 431 |
$params['exclude'] = $exclude; |
| 432 |
|
| 433 |
$content = $this -> embed($params, false); |
| 434 |
|
| 435 |
if ($output == true) { |
| 436 |
echo wp_kses_post($content); |
| 437 |
} else { |
| 438 |
return $content; |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
function embed($atts = array(), $content = null) { |
| 443 |
//global variables |
| 444 |
global $wpdb; |
| 445 |
$styles = $this -> get_option('styles'); |
| 446 |
|
| 447 |
$effect = $this -> get_option('effect'); |
| 448 |
$slide_direction = $this -> get_option('slide_direction'); |
| 449 |
$easing = $this -> get_option('easing'); |
| 450 |
$autoheight = $this -> get_option('autoheight'); |
| 451 |
|
| 452 |
$this -> add_filter('excerpt_more', 'excerpt_more', 999, 1); |
| 453 |
$this -> add_filter('excerpt_length', 'excerpt_length', 999, 1); |
| 454 |
|
| 455 |
// default shortcode parameters |
| 456 |
$defaults = array( |
| 457 |
'source' => "slides", |
| 458 |
'products' => false, |
| 459 |
'productsnumber' => 10, |
| 460 |
'featured' => false, |
| 461 |
'featurednumber' => 10, |
| 462 |
'featuredtype' => "post", |
| 463 |
'gallery_id' => false, |
| 464 |
'orderby' => array('order', "ASC"), |
| 465 |
'orderf' => false, // order field |
| 466 |
'orderd' => false, // order direction (ASC/DESC) |
| 467 |
'resizeimages' => (($styles['resizeimages'] == "Y") ? "true" : "false"), |
| 468 |
'imagesoverlay' => (($this -> get_option('imagesthickbox') == "Y") ? "true" : "false"), |
| 469 |
'layout' => ($styles['layout']), |
| 470 |
'width' => ($styles['width']), |
| 471 |
'height' => ((empty($autoheight)) ? $styles['height'] : false), |
| 472 |
'autoheight' => ((!empty($autoheight)) ? "true" : "false"), |
| 473 |
'autoheight_max' => ($this -> get_option('autoheight_max')), |
| 474 |
'resheight' => ($styles['resheight']), |
| 475 |
'resheighttype' => ($styles['resheighttype']), |
| 476 |
'auto' => (($this -> get_option('autoslide') == "Y") ? "true" : "false"), |
| 477 |
'effect' => ((empty($effect) || (!empty($effect) && $effect == "fade")) ? 'fade' : $effect), |
| 478 |
'slide_direction' => ((empty($slide_direction) || (!empty($slide_direction) && $slide_direction == "lr")) ? 'lr' : 'tb'), |
| 479 |
'easing' => ((empty($easing)) ? 'swing' : $easing), |
| 480 |
'autospeed' => ($this -> get_option('autospeed')), |
| 481 |
'alwaysauto' => ($this -> get_option('alwaysauto')), |
| 482 |
'fadespeed' => ($this -> get_option('fadespeed')), |
| 483 |
'shownav' => (($this -> get_option('shownav') == "Y") ? "true" : "false"), |
| 484 |
'navopacity' => ($this -> get_option('navopacity')), |
| 485 |
'navhoveropacity' => ($this -> get_option('navhover')), |
| 486 |
'showinfo' => (($this -> get_option('information') == "Y") ? "true" : "false"), |
| 487 |
'infoheadingcontent' => "title", |
| 488 |
'infoposition' => ($this -> get_option('infoposition')), |
| 489 |
'infoonhover' => ($this -> get_option('infoonhover')), |
| 490 |
'infospeed' => ($this -> get_option('infospeed')), |
| 491 |
'infodelay' => ($this -> get_option('infodelay')), |
| 492 |
'infofade' => ($this -> get_option ('infofade')), |
| 493 |
'infofadedelay' => ($this -> get_option ('infofadedelay')), |
| 494 |
'showthumbs' => (($this -> get_option('thumbnails') == "Y") ? "true" : "false"), |
| 495 |
'thumbsposition' => ($this -> get_option('thumbposition')), |
| 496 |
'thumbsborder' => (isset($styles['thumbactive']) ? (empty($styles['thumbactive'] ) ? "#ffffff" : $styles['thumbactive'] ) : "#ffffff" ), |
| 497 |
'thumbsspeed' => ($this -> get_option('thumbscrollspeed')), |
| 498 |
'thumbsspacing' => ($this -> get_option('thumbspacing')), |
| 499 |
'post_id' => null, |
| 500 |
'numberposts' => "-1", |
| 501 |
'exclude' => null, |
| 502 |
'custom' => null, |
| 503 |
); |
| 504 |
|
| 505 |
$s = shortcode_atts($defaults, $atts); |
| 506 |
extract($s); |
| 507 |
|
| 508 |
$slideshowtype = false; |
| 509 |
|
| 510 |
if (!empty($products)) { |
| 511 |
include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
| 512 |
if (is_plugin_active('wp-checkout' . DS . 'wp-checkout.php')) { |
| 513 |
$slides = array(); |
| 514 |
|
| 515 |
if (empty($orderf) && empty($orderd)) { |
| 516 |
$orderf = "created"; |
| 517 |
$orderd = "DESC"; |
| 518 |
} |
| 519 |
|
| 520 |
if (class_exists('wpCheckout')) { |
| 521 |
if ($wpCheckout = new wpCheckout()) { |
| 522 |
global $wpcoDb, $Product; |
| 523 |
$wpcoDb -> model = $Product -> model; |
| 524 |
$productstype = $products; |
| 525 |
|
| 526 |
switch ($productstype) { |
| 527 |
case 'latest' : |
| 528 |
$products = $wpcoDb -> find_all(false, false, array($orderf, $orderd), $productsnumber); |
| 529 |
break; |
| 530 |
case 'featured' : |
| 531 |
$products = $wpcoDb -> find_all(array('featured' => "1"), false, array($orderf, $orderd), $productsnumber); |
| 532 |
break; |
| 533 |
} |
| 534 |
} |
| 535 |
} |
| 536 |
|
| 537 |
if (!empty($products)) { |
| 538 |
$slides = $products; |
| 539 |
$slideshowtype = "products"; |
| 540 |
$content = $this -> render('gallery', array('slides' => $slides, 'unique' => 'products' . $productstype . $productsnumber, 'products' => true, 'options' => $s, 'frompost' => false), false, 'default'); |
| 541 |
} else { |
| 542 |
$error = __('No products are available', 'slideshow-gallery'); |
| 543 |
} |
| 544 |
} else { |
| 545 |
$error = sprintf(__('You need the %sShopping Cart plugin%s to display products slides.', 'slideshow-gallery'), '<a href="https://tribulant.com/plugins/view/10/wordpress-shopping-cart-plugin" target="_blank">', '</a>'); |
| 546 |
} |
| 547 |
// Featured images |
| 548 |
} elseif (!empty($featured)) { |
| 549 |
global $post; |
| 550 |
|
| 551 |
if (empty($orderf) && empty($orderd)) { |
| 552 |
$orderf = "date"; |
| 553 |
$orderd = "DESC"; |
| 554 |
} |
| 555 |
|
| 556 |
$args = array( |
| 557 |
'numberposts' => $featurednumber, // should show 5 but only shows 3 |
| 558 |
'post_type' => $featuredtype, // posts only |
| 559 |
'meta_key' => '_thumbnail_id', // with thumbnail |
| 560 |
'exclude' => $post -> ID, // exclude current post |
| 561 |
'orderby' => $orderf, |
| 562 |
'order' => $orderd, |
| 563 |
); |
| 564 |
|
| 565 |
if ($posts = get_posts($args)) { |
| 566 |
$slides = $posts; |
| 567 |
$slideshowtype = "featured"; |
| 568 |
$content = $this -> render('gallery', array('slides' => $slides, 'unique' => 'featured' . $featuredtype . $featurednumber, 'featured' => true, 'options' => $s, 'frompost' => false), false, 'default'); |
| 569 |
} else { |
| 570 |
$error = sprintf(__('No posts with featured images are available. Ensure your theme includes %s support.', 'slideshow-gallery'), '<code>add_theme_support("post-thumbnails");</code>'); |
| 571 |
} |
| 572 |
// Slides of a gallery |
| 573 |
} elseif (!empty($gallery_id)) { |
| 574 |
if (!is_array($orderby) || $orderby == "random") { |
| 575 |
$orderbystring = "ORDER BY RAND()"; |
| 576 |
} else { |
| 577 |
if (empty($orderf) && empty($orderd)) { |
| 578 |
list($orderf, $orderd) = $orderby; |
| 579 |
} |
| 580 |
|
| 581 |
if ($orderf == "order") { |
| 582 |
$orderbystring = "ORDER BY " . $this -> GallerySlides() -> table . ".order " . esc_sql($orderd) . ""; |
| 583 |
} else { |
| 584 |
$orderbystring = "ORDER BY " . $this -> Slide() -> table . "." . esc_sql($orderf) . " " . esc_sql($orderd) . ""; |
| 585 |
} |
| 586 |
} |
| 587 |
|
| 588 |
$slidesquery = "SELECT * FROM " . $this -> Slide() -> table . " LEFT JOIN " . $this -> GallerySlides() -> table . |
| 589 |
" ON " . $this -> Slide() -> table . ".id = " . $this -> GallerySlides() -> table . ".slide_id WHERE " . |
| 590 |
$this -> GallerySlides() -> table . ".gallery_id = '" . esc_sql($gallery_id) . "' AND (" . $this -> Slide() -> table . ".expiry = NULL OR " . $this -> Slide() -> table . ".expiry > CURDATE() OR " . $this -> Slide() -> table . ".expiry = '0000-00-00') " . $orderbystring; |
| 591 |
|
| 592 |
$query_hash = md5($slidesquery); |
| 593 |
if ($oc_slides = wp_cache_get($query_hash, 'slideshowgallery')) { |
| 594 |
$slides = $oc_slides; |
| 595 |
} else { |
| 596 |
$slides = $wpdb -> get_results($slidesquery); |
| 597 |
wp_cache_set($query_hash, $slides, 'slideshowgallery', 0); |
| 598 |
} |
| 599 |
|
| 600 |
if (!empty($slides)) { |
| 601 |
$imagespath = $this -> get_option('imagespath'); |
| 602 |
|
| 603 |
foreach ($slides as $skey => $slide) { |
| 604 |
$slides[$skey] = $this -> init_class($this -> Slide() -> model, $slide); |
| 605 |
//$slides[$skey] -> image_path = $this -> Html -> image_path($slide); |
| 606 |
} |
| 607 |
|
| 608 |
if ($orderby == "random") { shuffle($slides); } |
| 609 |
$slideshowtype = "gallery"; |
| 610 |
$content = $this -> render('gallery', array('slides' => $slides, 'unique' => 'gallery' . $gallery_id . rand(1, 999), 'options' => $s, 'frompost' => false), false, 'default'); |
| 611 |
} else { |
| 612 |
$error = __('No slides are available in this gallery', 'slideshow-gallery'); |
| 613 |
} |
| 614 |
// All slides |
| 615 |
} elseif (!empty($custom) || empty($post_id)) { |
| 616 |
if (!empty($orderf) && !empty($orderd)) { |
| 617 |
$orderby = array($orderf, $orderd); |
| 618 |
} |
| 619 |
|
| 620 |
$slides = $this -> Slide() -> find_all(null, null, $orderby); |
| 621 |
|
| 622 |
if (!empty($slides)) { |
| 623 |
foreach ($slides as $slide_key => $slide) { |
| 624 |
|
| 625 |
// Check exclude |
| 626 |
if (!empty($exclude)) { |
| 627 |
$exclude = array_map('trim', explode(',', $exclude)); |
| 628 |
if (in_array($slide -> id, $exclude)) { |
| 629 |
unset($slides[$slide_key]); |
| 630 |
} |
| 631 |
} |
| 632 |
|
| 633 |
// Check slide expiration |
| 634 |
if (!empty($slide -> expiry)) { |
| 635 |
if (strtotime($slide -> expiry) <= time()) { |
| 636 |
unset($slides[$slide_key]); |
| 637 |
} |
| 638 |
} |
| 639 |
} |
| 640 |
} |
| 641 |
|
| 642 |
if ($orderby == "random") { shuffle($slides); } |
| 643 |
$slideshowtype = "slides"; |
| 644 |
|
| 645 |
if (!empty($slides)) { |
| 646 |
$content = $this -> render('gallery', array('slides' => $slides, 'unique' => "custom" . rand(1, 999), 'options' => $s, 'frompost' => false), false, 'default'); |
| 647 |
} else { |
| 648 |
$error = __('No slides are available', 'slideshow-gallery'); |
| 649 |
} |
| 650 |
// Images of a post/page |
| 651 |
} else { |
| 652 |
global $post; |
| 653 |
$pid = (empty($post_id)) ? $post -> ID : $post_id; |
| 654 |
|
| 655 |
if (!is_numeric($post_id)) { |
| 656 |
$pid = $post -> ID; |
| 657 |
} |
| 658 |
|
| 659 |
if (!empty($pid) && $post = get_post($pid)) { |
| 660 |
$children_attributes = array( |
| 661 |
'numberposts' => $numberposts, |
| 662 |
'post_parent' => $post -> ID, |
| 663 |
'post_type' => "attachment", |
| 664 |
'post_status' => "any", |
| 665 |
'post_mime_type' => "image", |
| 666 |
'orderby' => ((!empty($orderf)) ? $orderf : "menu_order"), |
| 667 |
'order' => ((!empty($orderd)) ? $orderd : "ASC"), |
| 668 |
); |
| 669 |
|
| 670 |
if ($attachments = get_children($children_attributes)) { |
| 671 |
if (!empty($exclude)) { |
| 672 |
$exclude = array_map('trim', explode(',', $exclude)); |
| 673 |
|
| 674 |
$a = 0; |
| 675 |
foreach ($attachments as $id => $attachment) { |
| 676 |
//$attachments[$id] = (object) array_map('esc_attr', (array) $attachment); |
| 677 |
|
| 678 |
$a++; |
| 679 |
if (in_array($a, $exclude)) { |
| 680 |
unset($attachments[$id]); |
| 681 |
} |
| 682 |
} |
| 683 |
} |
| 684 |
|
| 685 |
if ($orderby == "random") { shuffle($attachments); } |
| 686 |
$slides = $attachments; |
| 687 |
|
| 688 |
$slideshowtype = "post"; |
| 689 |
$content = $this -> render('gallery', array('slides' => $slides, 'unique' => $pid, 'options' => $s, 'frompost' => true), false, 'default'); |
| 690 |
} else { |
| 691 |
$error = __('No attachments on this post/page', 'slideshow-gallery'); |
| 692 |
} |
| 693 |
} else { |
| 694 |
$error = __('No post/page ID was specified', 'slideshow-gallery'); |
| 695 |
} |
| 696 |
} |
| 697 |
|
| 698 |
// Check if this is an RSS Feed? |
| 699 |
if (is_feed()) { |
| 700 |
$content = ''; |
| 701 |
ob_start(); |
| 702 |
|
| 703 |
$width = $this -> get_option('thumbwidth'); |
| 704 |
$height = $this -> get_option('thumbheight'); |
| 705 |
|
| 706 |
if (!empty($slides)) { |
| 707 |
switch ($slideshowtype) { |
| 708 |
case 'products' : |
| 709 |
foreach ($slides as $slide) { |
| 710 |
?> |
| 711 |
|
| 712 |
<a href="<?php echo get_permalink($slide -> post_id); ?>" title="<?php echo esc_attr($slide -> title); ?>"> |
| 713 |
<img align="left" hspace="15" src="<?php echo esc_url($this -> Html() -> otf_image_src($slide, $this -> get_option('thumbwidth'), $this -> get_option('thumbheight'), 100)); ?>" /> |
| 714 |
</a> |
| 715 |
|
| 716 |
<?php |
| 717 |
} |
| 718 |
break; |
| 719 |
case 'gallery' : |
| 720 |
foreach ($slides as $slide) { |
| 721 |
?> |
| 722 |
|
| 723 |
<a href="<?php echo esc_url($slide -> image_path); ?>" title="<?php echo esc_attr($slide -> title); ?>"> |
| 724 |
<img align="left" hspace="15" src="<?php echo esc_url($this -> Html() -> otf_image_src($slide, $this -> get_option('thumbwidth'), $this -> get_option('thumbheight'), 100)); ?>" alt="<?php echo esc_attr($this -> Html -> sanitize($slide -> title)); ?>" /> |
| 725 |
</a> |
| 726 |
|
| 727 |
<?php |
| 728 |
} |
| 729 |
break; |
| 730 |
case 'featured' : |
| 731 |
foreach ($slides as $slide) { |
| 732 |
?> |
| 733 |
|
| 734 |
<a href="<?php echo esc_url($slide -> guid); ?>" title="<?php echo esc_attr($slide -> post_title); ?>"> |
| 735 |
<img align="left" hspace="15" src="<?php echo esc_url($this -> Html() -> otf_image_src($slide, $this -> get_option('thumbwidth'), $this -> get_option('thumbheight'), 100)); ?>" alt="<?php echo esc_attr($this -> Html -> sanitize($slide -> post_title)); ?>" /> |
| 736 |
</a> |
| 737 |
|
| 738 |
<?php |
| 739 |
} |
| 740 |
break; |
| 741 |
case 'post' : |
| 742 |
default : |
| 743 |
foreach ($slides as $slide) { |
| 744 |
$full_image_href = wp_get_attachment_image_src($slide -> ID, 'full', false); |
| 745 |
$full_image_url = wp_get_attachment_url($slide -> ID); |
| 746 |
|
| 747 |
?> |
| 748 |
|
| 749 |
<a href="<?php echo esc_url($full_image_url); ?>" title="<?php echo esc_attr($slide -> post_title); ?>"> |
| 750 |
<img align="left" hspace="15" src="<?php echo esc_url($this -> Html() -> otf_image_src($slide, $this -> get_option('thumbwidth'), $this -> get_option('thumbheight'), 100)); ?>" alt="<?php echo $this -> Html -> sanitize($slide -> post_title); ?>" /> |
| 751 |
</a> |
| 752 |
|
| 753 |
<?php |
| 754 |
} |
| 755 |
break; |
| 756 |
} |
| 757 |
|
| 758 |
?><hr style="visibility:hidden; height:1px; width:100%; display:block;" /><?php |
| 759 |
} |
| 760 |
|
| 761 |
$content = ob_get_clean(); |
| 762 |
} |
| 763 |
|
| 764 |
// Check for error messages |
| 765 |
if (!empty($error)) { |
| 766 |
$content = ''; |
| 767 |
$content .= '<p class="slideshow_error slideshow-gallery-error">'; |
| 768 |
$content .= wp_unslash($error); |
| 769 |
$content .= '</p>'; |
| 770 |
} |
| 771 |
|
| 772 |
remove_filter('excerpt_more', array($this, 'excerpt_more')); |
| 773 |
remove_filter('excerpt_length', array($this, 'excerpt_length')); |
| 774 |
|
| 775 |
return $content; |
| 776 |
} |
| 777 |
|
| 778 |
function admin_slides() { |
| 779 |
global $wpdb; |
| 780 |
$method = (!empty($_GET['method'])) ? sanitize_text_field($_GET['method']) : false; |
| 781 |
$errors = array(); |
| 782 |
switch ($method) { |
| 783 |
case 'delete' : |
| 784 |
check_admin_referer($this -> sections -> slides . '_delete'); |
| 785 |
$id = sanitize_text_field($_GET['id']); |
| 786 |
if (!empty($id)) { |
| 787 |
if ($this -> Slide() -> delete($id)) { |
| 788 |
$msg_type = 'message'; |
| 789 |
$message = __('Slide has been removed', 'slideshow-gallery'); |
| 790 |
} else { |
| 791 |
$msg_type = 'error'; |
| 792 |
$message = __('Slide cannot be removed', 'slideshow-gallery'); |
| 793 |
} |
| 794 |
} else { |
| 795 |
$msg_type = 'error'; |
| 796 |
$message = __('No slide was specified', 'slideshow-gallery'); |
| 797 |
} |
| 798 |
|
| 799 |
$this -> redirect($this -> referer, $msg_type, $message); |
| 800 |
break; |
| 801 |
case 'save' : |
| 802 |
if (!empty($_POST)) { |
| 803 |
check_admin_referer($this -> sections -> slides . '_save'); |
| 804 |
|
| 805 |
if ($this -> Slide() -> save($_POST, true)) { |
| 806 |
$message = __('Slide item has been saved', 'slideshow-gallery'); |
| 807 |
|
| 808 |
if (!empty($_POST['continueediting'])) { |
| 809 |
$this -> redirect(admin_url('admin.php?page=' . $this -> sections -> slides . '&method=save&id=' . $this -> Slide() -> insertid . '&continueediting=1'), 'message', $message); |
| 810 |
} else { |
| 811 |
$this -> redirect($this -> url, "message", $message); |
| 812 |
} |
| 813 |
} else { |
| 814 |
$this -> render_err(__('Slide could not be saved', 'slideshow-gallery')); |
| 815 |
$this -> render('slides' . DS . 'save', false, true, 'admin'); |
| 816 |
} |
| 817 |
} else { |
| 818 |
$this -> Db -> model = $this -> Slide() -> model; |
| 819 |
$slideId = (isset($_GET['id'])) ? sanitize_text_field($_GET['id']) : 0; |
| 820 |
$this -> Slide() -> find(array('id' => $slideId)); |
| 821 |
$this -> render('slides' . DS . 'save', false, true, 'admin'); |
| 822 |
} |
| 823 |
break; |
| 824 |
case 'save-multiple' : |
| 825 |
if (!empty($_POST)) { |
| 826 |
check_admin_referer($this -> sections -> slides . '_save-multiple'); |
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
if (!empty($_POST['Slide']['slides'])) { |
| 831 |
$slides = map_deep($_POST['Slide']['slides'], 'sanitize_text_field'); |
| 832 |
$galleries = map_deep((empty($_POST['Slide']['galleries']) ? array() : $_POST['Slide']['galleries']) , 'sanitize_text_field'); |
| 833 |
|
| 834 |
$s = 0; |
| 835 |
|
| 836 |
foreach ($slides as $attachment_id => $slide) { |
| 837 |
$slide_data = array( |
| 838 |
'Slide' => array( |
| 839 |
'title' => $slide['title'], |
| 840 |
'description' => $slide['description'], |
| 841 |
'image' => basename($slide['url']), |
| 842 |
'attachment_id' => $attachment_id, |
| 843 |
'type' => 'media', |
| 844 |
'image_url' => $slide['url'], |
| 845 |
'media_file' => $slide['url'], |
| 846 |
'galleries' => $galleries, |
| 847 |
) |
| 848 |
); |
| 849 |
|
| 850 |
if (!$this -> Slide() -> save($slide_data)) { |
| 851 |
//$errors = array_merge($errors, $this -> Slide() -> errors); |
| 852 |
$errors[$s] = $this -> Slide() -> errors; |
| 853 |
} |
| 854 |
|
| 855 |
$s++; |
| 856 |
} |
| 857 |
|
| 858 |
if (empty($errors)) { |
| 859 |
$message = __('Slides have been saved', 'slideshow-gallery'); |
| 860 |
$this -> redirect(admin_url('admin.php?page=' . $this -> sections -> slides), 'message', $message); |
| 861 |
} |
| 862 |
} else { |
| 863 |
$errors[] = __('No slides were selected', 'slideshow-gallery'); |
| 864 |
} |
| 865 |
} |
| 866 |
|
| 867 |
$this -> render('slides' . DS . 'save-multiple', array('errors' => $errors), true, 'admin'); |
| 868 |
break; |
| 869 |
case 'order' : |
| 870 |
if (isset($_GET['gallery_id'])) { |
| 871 |
$gallery_id = sanitize_text_field($_GET['gallery_id']); |
| 872 |
} else { |
| 873 |
$gallery_id = ""; |
| 874 |
} |
| 875 |
|
| 876 |
if (!empty($gallery_id)) { |
| 877 |
$gallery = $this -> Gallery() -> find(array('id' => $gallery_id)); |
| 878 |
|
| 879 |
$slides = array(); |
| 880 |
$gsquery = "SELECT gs.slide_id FROM `" . $this -> GallerySlides() -> table . "` gs WHERE `gallery_id` = '" . esc_sql($gallery -> id) . "' ORDER BY gs.order ASC"; |
| 881 |
|
| 882 |
$query_hash = md5($gsquery); |
| 883 |
if ($oc_gs = wp_cache_get($query_hash, 'slideshowgallery')) { |
| 884 |
$gs = $oc_gs; |
| 885 |
} else { |
| 886 |
$gs = $wpdb -> get_results($gsquery); |
| 887 |
wp_cache_set($query_hash, $gs, 'slideshowgallery', 0); |
| 888 |
} |
| 889 |
|
| 890 |
if (!empty($gs)) { |
| 891 |
foreach ($gs as $galleryslide) { |
| 892 |
$slides[] = $this -> Slide() -> find(array('id' => $galleryslide -> slide_id)); |
| 893 |
} |
| 894 |
} |
| 895 |
|
| 896 |
$this -> render('slides' . DS . 'order-gallery', array('gallery' => $gallery, 'slides' => $slides), true, 'admin'); |
| 897 |
} else { |
| 898 |
$slides = $this -> Slide() -> find_all(null, null, array('order', "ASC")); |
| 899 |
$this -> render('slides' . DS . 'order', array('slides' => $slides), true, 'admin'); |
| 900 |
} |
| 901 |
break; |
| 902 |
default : |
| 903 |
$this -> render('slides' . DS . 'index', false, true, 'admin'); |
| 904 |
break; |
| 905 |
} |
| 906 |
} |
| 907 |
|
| 908 |
function admin_galleries() { |
| 909 |
|
| 910 |
$method = (!empty($_GET['method'])) ? sanitize_text_field($_GET['method']) : false; |
| 911 |
switch ($method) { |
| 912 |
case 'save' : |
| 913 |
if (!empty($_POST)) { |
| 914 |
check_admin_referer($this -> sections -> galleries . '_save'); |
| 915 |
|
| 916 |
if ($this -> Gallery() -> save($_POST, true)) { |
| 917 |
$message = __('Gallery item has been saved', 'slideshow-gallery'); |
| 918 |
|
| 919 |
if (!empty($_POST['continueediting'])) { |
| 920 |
$this -> redirect(admin_url('admin.php?page=' . $this -> sections -> galleries . '&method=save&id=' . $this -> Gallery() -> insertid . '&continueediting=1'), 'message', $message); |
| 921 |
} else { |
| 922 |
$this -> redirect($this -> url, "message", $message); |
| 923 |
} |
| 924 |
} else { |
| 925 |
$this -> render('galleries' . DS . 'save', false, true, 'admin'); |
| 926 |
} |
| 927 |
} else { |
| 928 |
$this -> Db -> model = $this -> Gallery() -> model; |
| 929 |
$galleryId = (isset($_GET['id'])) ? sanitize_text_field($_GET['id']) : 0; |
| 930 |
$this -> Gallery() -> find(array('id' => $galleryId)); |
| 931 |
$this -> render('galleries' . DS . 'save', false, true, 'admin'); |
| 932 |
} |
| 933 |
break; |
| 934 |
case 'view' : |
| 935 |
$this -> Db -> model = $this -> Gallery() -> model; |
| 936 |
$gallery = $this -> Gallery() -> find(array('id' => sanitize_text_field($_GET['id']))); |
| 937 |
$perpage = (isset($_COOKIE[$this -> pre . 'slidesperpage'])) ? sanitize_text_field($_COOKIE[$this -> pre . 'slidesperpage']) : 25; |
| 938 |
$orderfield = (empty($_GET['orderby'])) ? 'modified' : sanitize_text_field($_GET['orderby']); |
| 939 |
$orderdirection = (empty($_GET['order'])) ? 'DESC' : strtoupper(sanitize_text_field($_GET['order'])); |
| 940 |
$order = array($orderfield, $orderdirection); |
| 941 |
$data = $this -> paginate('GallerySlides', "*", $this -> sections -> galleries . '&method=view&id=' . $gallery -> id, array('gallery_id' => $gallery -> id), false, $perpage, $order); |
| 942 |
|
| 943 |
$data['Slide'] = array(); |
| 944 |
if (!empty($data[$this -> GallerySlides() -> model])) { |
| 945 |
foreach ($data[$this -> GallerySlides() -> model] as $galleryslide) { |
| 946 |
$this -> Db -> model = $this -> Slide() -> model; |
| 947 |
$data['Slide'][] = $this -> Slide() -> find(array('id' => $galleryslide -> slide_id)); |
| 948 |
} |
| 949 |
} |
| 950 |
|
| 951 |
$this -> render('galleries' . DS . 'view', array('gallery' => $gallery, 'slides' => $data[$this -> Slide() -> model], 'paginate' => $data['Paginate']), true, 'admin'); |
| 952 |
break; |
| 953 |
case 'hardcode' : |
| 954 |
$this -> Db -> model = $this -> Gallery() -> model; |
| 955 |
$gallery = $this -> Gallery() -> find(array('id' => sanitize_text_field($_GET['id']))); |
| 956 |
$this -> render('galleries' . DS . 'hardcode', array('gallery' => $gallery), true, 'admin'); |
| 957 |
break; |
| 958 |
case 'delete' : |
| 959 |
check_admin_referer($this -> sections -> galleries . '_delete'); |
| 960 |
|
| 961 |
$id = sanitize_text_field($_GET['id']); |
| 962 |
if (!empty($id)) { |
| 963 |
if ($this -> Gallery() -> delete($id)) { |
| 964 |
$msg_type = 'message'; |
| 965 |
$message = __('Gallery has been removed', 'slideshow-gallery'); |
| 966 |
} else { |
| 967 |
$msg_type = 'error'; |
| 968 |
$message = __('Gallery cannot be removed', 'slideshow-gallery'); |
| 969 |
} |
| 970 |
} else { |
| 971 |
$msg_type = 'error'; |
| 972 |
$message = __('No gallery was specified', 'slideshow-gallery'); |
| 973 |
} |
| 974 |
|
| 975 |
$this -> redirect($this -> referer, $msg_type, $message); |
| 976 |
break; |
| 977 |
default : |
| 978 |
$this -> render('galleries' . DS . 'index', false, true, 'admin'); |
| 979 |
break; |
| 980 |
} |
| 981 |
} |
| 982 |
|
| 983 |
function admin_settings() { |
| 984 |
global $wpdb; |
| 985 |
$method = (!empty($_GET['method'])) ? sanitize_text_field($_GET['method']) : false; |
| 986 |
|
| 987 |
switch ($method) { |
| 988 |
case 'clearlog' : |
| 989 |
|
| 990 |
check_admin_referer($this -> sections -> settings . '_clearlog'); |
| 991 |
|
| 992 |
@unlink(SLIDESHOW_LOG_FILE); |
| 993 |
|
| 994 |
$fh = fopen(SLIDESHOW_LOG_FILE, "w"); |
| 995 |
fwrite($fh, "*** Slideshow Log File *** \r\n\r\n"); |
| 996 |
fclose($fh); |
| 997 |
chmod(SLIDESHOW_LOG_FILE, 0777); |
| 998 |
|
| 999 |
$msgtype = 'message'; |
| 1000 |
$message = __('Log file has been cleared', 'slideshow-gallery'); |
| 1001 |
$this -> redirect($this -> referer, $msgtype, $message); |
| 1002 |
|
| 1003 |
break; |
| 1004 |
case 'dismiss' : |
| 1005 |
if (!empty($_GET['dismiss'])) { |
| 1006 |
$this -> update_option('dismiss_' . sanitize_text_field($_GET['dismiss']), 1); |
| 1007 |
} |
| 1008 |
|
| 1009 |
$this -> redirect($this -> referer); |
| 1010 |
break; |
| 1011 |
case 'checkdb' : |
| 1012 |
check_admin_referer($this -> sections -> settings . '_checkdb'); |
| 1013 |
$this -> check_tables(); |
| 1014 |
|
| 1015 |
if (!empty($this -> models)) { |
| 1016 |
foreach ($this -> models as $model) { |
| 1017 |
$query = "OPTIMIZE TABLE `" . $this -> {$model}() -> table . "`"; |
| 1018 |
$wpdb -> query($query); |
| 1019 |
} |
| 1020 |
} |
| 1021 |
|
| 1022 |
$this -> redirect($this -> referer, 'message', __('Database tables have been checked and optimized', 'slideshow-gallery')); |
| 1023 |
break; |
| 1024 |
case 'reset' : |
| 1025 |
check_admin_referer($this -> sections -> settings . '_reset'); |
| 1026 |
global $wpdb; |
| 1027 |
$query = "DELETE FROM `" . $wpdb -> prefix . "options` WHERE `option_name` LIKE '" . esc_sql($this -> pre) . "%';"; |
| 1028 |
|
| 1029 |
if ($wpdb -> query($query)) { |
| 1030 |
$this -> initialize_options(); |
| 1031 |
|
| 1032 |
$message = __('All settings have been reset to their defaults', 'slideshow-gallery'); |
| 1033 |
$msg_type = 'message'; |
| 1034 |
$this -> render_msg($message); |
| 1035 |
} else { |
| 1036 |
$message = __('Settings could not be reset', 'slideshow-gallery'); |
| 1037 |
$msg_type = 'error'; |
| 1038 |
$this -> render_err($message); |
| 1039 |
} |
| 1040 |
|
| 1041 |
$this -> redirect($this -> url, $msg_type, $message); |
| 1042 |
break; |
| 1043 |
default : |
| 1044 |
if (!empty($_POST)) { |
| 1045 |
check_admin_referer($this -> sections -> settings); |
| 1046 |
|
| 1047 |
delete_option('tridebugging'); |
| 1048 |
$this -> delete_option('infohideonmobile'); |
| 1049 |
$this -> delete_option('autoheight'); |
| 1050 |
$this -> delete_option('language_external'); |
| 1051 |
$this -> delete_option('excerptsettings'); |
| 1052 |
$this -> delete_option('infofade'); |
| 1053 |
$this -> delete_option('fadedelay'); |
| 1054 |
$this -> delete_option('infoonhover'); |
| 1055 |
$this -> delete_option('thumbhideonmobile'); |
| 1056 |
|
| 1057 |
foreach ($_POST as $pkey => $pval) { |
| 1058 |
switch ($pkey) { |
| 1059 |
case 'styles' : |
| 1060 |
$styles = array(); |
| 1061 |
foreach ($pval as $pvalkey => $pvalval) { |
| 1062 |
switch ($pvalkey) { |
| 1063 |
case 'layout' : |
| 1064 |
if (!$this -> ci_serial_valid()) { |
| 1065 |
$styles[$pvalkey] = "specific"; |
| 1066 |
} else { |
| 1067 |
$styles[$pvalkey] = $pvalval; |
| 1068 |
} |
| 1069 |
break; |
| 1070 |
default : |
| 1071 |
$styles[$pvalkey] = $pvalval; |
| 1072 |
break; |
| 1073 |
} |
| 1074 |
} |
| 1075 |
|
| 1076 |
$this -> update_option('styles', $styles); |
| 1077 |
break; |
| 1078 |
case 'debugging' : |
| 1079 |
if (!empty($pval)) { |
| 1080 |
update_option('tridebugging', 1); |
| 1081 |
} |
| 1082 |
break; |
| 1083 |
case 'excerpt_readmore' : |
| 1084 |
if ($this -> language_do()) { |
| 1085 |
$this -> update_option($pkey, $this -> language_join($pval)); |
| 1086 |
} else { |
| 1087 |
$this -> update_option($pkey, $pval); |
| 1088 |
} |
| 1089 |
break; |
| 1090 |
case 'permissions' : |
| 1091 |
global $wp_roles; |
| 1092 |
$role_names = $wp_roles -> get_names(); |
| 1093 |
|
| 1094 |
if (!empty($_POST['permissions'])) { |
| 1095 |
$permissions = map_deep($_POST['permissions'], 'sanitize_text_field'); |
| 1096 |
|
| 1097 |
foreach ($role_names as $role_key => $role_name) { |
| 1098 |
foreach ($this -> sections as $section_key => $section_name) { |
| 1099 |
$wp_roles -> remove_cap($role_key, 'slideshow_' . $section_key); |
| 1100 |
|
| 1101 |
if (!empty($permissions[$role_key]) && in_array($section_key, $permissions[$role_key])) { |
| 1102 |
$wp_roles -> add_cap($role_key, 'slideshow_' . $section_key); |
| 1103 |
} |
| 1104 |
|
| 1105 |
if ($role_key == "administrator") { |
| 1106 |
$wp_roles -> add_cap("administrator", 'slideshow_' . $section_key); |
| 1107 |
$permissions[$role_key][] = $section_key; |
| 1108 |
} |
| 1109 |
} |
| 1110 |
} |
| 1111 |
} |
| 1112 |
|
| 1113 |
$this -> update_option('permissions', $permissions); |
| 1114 |
break; |
| 1115 |
default : |
| 1116 |
$this -> update_option($pkey, $pval); |
| 1117 |
break; |
| 1118 |
} |
| 1119 |
} |
| 1120 |
|
| 1121 |
if (!$this -> ci_serial_valid()) { |
| 1122 |
$this -> update_option('effect', "slide"); |
| 1123 |
$this -> update_option('easing', "swing"); |
| 1124 |
$this -> update_option('infodelay', "0"); |
| 1125 |
$this -> delete_option('infohideonmobile'); |
| 1126 |
$this -> delete_option('excerptsettings'); |
| 1127 |
$this -> update_option('imagesthickbox', "N"); |
| 1128 |
$this -> delete_option('thumbhideonmobile'); |
| 1129 |
} |
| 1130 |
|
| 1131 |
$message = __('Settings has been saved', 'slideshow-gallery'); |
| 1132 |
$this -> render_msg($message); |
| 1133 |
} |
| 1134 |
|
| 1135 |
$this -> render('settings', false, true, 'admin'); |
| 1136 |
break; |
| 1137 |
} |
| 1138 |
} |
| 1139 |
|
| 1140 |
function admin_settings_updates() { |
| 1141 |
$method = (!empty($_GET['method'])) ? sanitize_text_field($_GET['method']) : false; |
| 1142 |
switch ($method) { |
| 1143 |
case 'check' : |
| 1144 |
delete_transient('slideshow_update_info'); |
| 1145 |
$this -> redirect($this -> referer); |
| 1146 |
break; |
| 1147 |
} |
| 1148 |
|
| 1149 |
$this -> render('settings-updates', false, true, 'admin'); |
| 1150 |
} |
| 1151 |
|
| 1152 |
public function secureSlideshowGalleryLiteLog() { |
| 1153 |
// Define the path to the .htaccess file |
| 1154 |
$htaccessPath = ABSPATH . '.htaccess'; // ABSPATH is the WordPress root directory |
| 1155 |
// Directive to add for restricting access to newsletters.log |
| 1156 |
$restrictionDirective = "\n<FilesMatch \"^slideshow\\.log$\">\nOrder Allow,Deny\nDeny from all\n</FilesMatch>\n"; |
| 1157 |
// Check if the .htaccess file exists |
| 1158 |
if (file_exists($htaccessPath)) { |
| 1159 |
$contents = file_get_contents($htaccessPath); |
| 1160 |
|
| 1161 |
// Check if the directive is already present |
| 1162 |
if (strpos($contents, trim($restrictionDirective)) === false) { |
| 1163 |
// Directive not found, append it |
| 1164 |
file_put_contents($htaccessPath, $restrictionDirective, FILE_APPEND); |
| 1165 |
echo "Directive added to existing .htaccess file."; |
| 1166 |
} else { |
| 1167 |
// Directive already exists |
| 1168 |
echo "Directive already exists in .htaccess file."; |
| 1169 |
} |
| 1170 |
} else { |
| 1171 |
// .htaccess file does not exist, create it and add the directive |
| 1172 |
file_put_contents($htaccessPath, $restrictionDirective); |
| 1173 |
echo "No .htaccess file found. New file created with directive."; |
| 1174 |
} |
| 1175 |
} |
| 1176 |
|
| 1177 |
|
| 1178 |
function activation_hook() { |
| 1179 |
$this->secureSlideshowGalleryLiteLog(); |
| 1180 |
$this -> add_option('activation_redirect', true); |
| 1181 |
} |
| 1182 |
|
| 1183 |
function custom_redirect() { |
| 1184 |
|
| 1185 |
$method = (!empty($_GET['slideshow_method'])) ? sanitize_text_field($_GET['slideshow_method']) : false; |
| 1186 |
if (!empty($method)) { |
| 1187 |
switch ($method) { |
| 1188 |
case 'hidemessage' : |
| 1189 |
if (!empty($_GET['message'])) { |
| 1190 |
switch ($_GET['message']) { |
| 1191 |
case 'upgradetopro' : |
| 1192 |
$this -> update_option('hidemessage_upgradetopro', true); |
| 1193 |
break; |
| 1194 |
case 'ratereview' : |
| 1195 |
$this -> delete_option('showmessage_ratereview'); |
| 1196 |
$this -> redirect($this -> referer); |
| 1197 |
break; |
| 1198 |
} |
| 1199 |
} |
| 1200 |
break; |
| 1201 |
case 'hideupdate' : |
| 1202 |
if (!empty($_GET['version'])) { |
| 1203 |
$this -> update_option('hideupdate', sanitize_text_field($_GET['version'])); |
| 1204 |
$this -> redirect($this -> referer); |
| 1205 |
} |
| 1206 |
break; |
| 1207 |
} |
| 1208 |
} |
| 1209 |
|
| 1210 |
$activation_redirect = $this -> get_option('activation_redirect'); |
| 1211 |
if (is_admin() && !empty($activation_redirect)) { |
| 1212 |
$this -> delete_option('activation_redirect'); |
| 1213 |
wp_cache_flush(); |
| 1214 |
wp_redirect(admin_url('index.php?page=' . $this -> sections -> about)); |
| 1215 |
} |
| 1216 |
} |
| 1217 |
} |
| 1218 |
} |
| 1219 |
|
| 1220 |
if (!function_exists('SG')) { |
| 1221 |
function SG($param = null) { |
| 1222 |
return new SlideshowGallery($param); |
| 1223 |
} |
| 1224 |
} |
| 1225 |
|
| 1226 |
//initialize a Gallery object |
| 1227 |
global $Gallery; |
| 1228 |
$Gallery = new SlideshowGallery(); |
| 1229 |
register_activation_hook(plugin_basename(__FILE__), array($Gallery, 'initialize_options')); |
| 1230 |
register_activation_hook(plugin_basename(__FILE__), array($Gallery, 'activation_hook')); |
| 1231 |
|
| 1232 |
if (!function_exists('slideshow')) { |
| 1233 |
function slideshow($output = true, $gallery_id = null, $post_id = null, $params = array()) { |
| 1234 |
$params['gallery_id'] = $gallery_id; |
| 1235 |
$params['post_id'] = $post_id; |
| 1236 |
|
| 1237 |
$Gallery = new SlideshowGallery(); |
| 1238 |
$content = $Gallery -> embed($params, false); |
| 1239 |
|
| 1240 |
if ($output == true) { |
| 1241 |
echo wp_kses_post($content); |
| 1242 |
} else { |
| 1243 |
return $content; |
| 1244 |
} |
| 1245 |
} |
| 1246 |
} |
| 1247 |
|
| 1248 |
?> |
| 1249 |
|