Version Description
- 07/03/2022 =
- Fixed: security issue
Download this release
Release Info
Developer | giucu91 |
Plugin | Image Photo Gallery Final Tiles Grid |
Version | 3.5.5 |
Comparing to | |
See all releases |
Code changes from version 3.5.4 to 3.5.5
- FinalTilesGalleryLite.php +1586 -1586
- admin/add-gallery.php +287 -287
- admin/bundle.css +2032 -2032
- admin/css/gutenberg_block.css +3 -3
- admin/css/materialize.css +8706 -8706
- admin/css/style.css +1165 -1165
- admin/facebook.php +11 -11
- admin/header.php +9 -9
- admin/images/everlightbox-reviews.png +0 -0
- admin/images/everlightbox.png +0 -0
- admin/images/photoblocks.png +0 -0
- admin/include/fields.php +1109 -1109
- admin/include/tinymce-galleries.php +87 -87
- admin/overview.php +238 -238
- admin/scripts/admin.js +20 -20
- admin/scripts/editor-plugin.js +31 -31
- admin/scripts/final-tiles-gallery-admin.js +0 -0
- admin/scripts/materialize.min.js +0 -6263
FinalTilesGalleryLite.php
CHANGED
@@ -1,1587 +1,1587 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Plugin Name: Final Tiles Grid Gallery - Image Gallery
|
5 |
-
* Description: Wordpress Plugin for creating responsive image galleries.
|
6 |
-
* Version: 3.5.
|
7 |
-
* Author: WPChill
|
8 |
-
* Author URI: https://wpchill.com
|
9 |
-
* Tested up to: 5.
|
10 |
-
* Requires: 5.2 or higher
|
11 |
-
* License: GPLv3 or later
|
12 |
-
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
13 |
-
* Requires PHP: 5.6
|
14 |
-
* Text Domain: final-tiles-grid-gallery-lite
|
15 |
-
* Domain Path: /languages
|
16 |
-
*
|
17 |
-
* Copyright 2015-2019 GreenTreeLabs diego@greentreelabs.net
|
18 |
-
* Copyright 2019-2020 MachoThemes office@machothemes.com
|
19 |
-
* SVN commit with proof of ownership transfer: https://plugins.trac.wordpress.org/changeset/2163481/
|
20 |
-
* NOTE: MachoThemes took ownership of this plugin on: 09/26/2019 08:49:37 AM as can be seen from the above SVN commit.
|
21 |
-
* Copyright 2020 WPChill heyyy@wpchill.com
|
22 |
-
*
|
23 |
-
* Original Plugin URI: https://greentreelabs.net/final-tiles-gallery-lite/
|
24 |
-
* Original Author URI: https://greentreelabs.net
|
25 |
-
* Original Author: https://profiles.wordpress.org/greentreealbs/
|
26 |
-
*
|
27 |
-
*/
|
28 |
-
define( "FTGVERSION", "3.5.
|
29 |
-
// Create a helper function for easy SDK access.
|
30 |
-
|
31 |
-
if ( !function_exists( 'ftg_fs' ) ) {
|
32 |
-
// Create a helper function for easy SDK access.
|
33 |
-
function ftg_fs()
|
34 |
-
{
|
35 |
-
global $ftg_fs ;
|
36 |
-
|
37 |
-
if ( !isset( $ftg_fs ) ) {
|
38 |
-
// Activate multisite network integration.
|
39 |
-
if ( !defined( 'WP_FS__PRODUCT_1002_MULTISITE' ) ) {
|
40 |
-
define( 'WP_FS__PRODUCT_1002_MULTISITE', true );
|
41 |
-
}
|
42 |
-
// Include Freemius SDK.
|
43 |
-
require_once dirname( __FILE__ ) . '/freemius/start.php';
|
44 |
-
$ftg_fs = fs_dynamic_init( array(
|
45 |
-
'id' => '1002',
|
46 |
-
'slug' => 'final-tiles-grid-gallery-lite',
|
47 |
-
'type' => 'plugin',
|
48 |
-
'public_key' => 'pk_d0e075b84d491d510a1d0a21087af',
|
49 |
-
'is_premium' => false,
|
50 |
-
'has_addons' => false,
|
51 |
-
'has_paid_plans' => true,
|
52 |
-
'trial' => array(
|
53 |
-
'days' => 14,
|
54 |
-
'is_require_payment' => true,
|
55 |
-
),
|
56 |
-
'has_affiliation' => 'all',
|
57 |
-
'menu' => array(
|
58 |
-
'slug' => 'ftg-lite-gallery-admin',
|
59 |
-
),
|
60 |
-
'is_live' => true,
|
61 |
-
) );
|
62 |
-
}
|
63 |
-
|
64 |
-
return $ftg_fs;
|
65 |
-
}
|
66 |
-
|
67 |
-
// Init Freemius.
|
68 |
-
ftg_fs();
|
69 |
-
// Signal that SDK was initiated.
|
70 |
-
do_action( 'ftg_fs_loaded' );
|
71 |
-
}
|
72 |
-
|
73 |
-
function activate_finaltilesgallery()
|
74 |
-
{
|
75 |
-
global $wpdb ;
|
76 |
-
include_once 'lib/install-db.php';
|
77 |
-
FinalTiles_Gallery::define_db_tables();
|
78 |
-
FinalTilesdb::updateConfiguration();
|
79 |
-
|
80 |
-
if ( is_multisite() ) {
|
81 |
-
foreach ( $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" ) as $blog_id ) {
|
82 |
-
switch_to_blog( $blog_id );
|
83 |
-
install_db();
|
84 |
-
restore_current_blog();
|
85 |
-
}
|
86 |
-
} else {
|
87 |
-
install_db();
|
88 |
-
}
|
89 |
-
|
90 |
-
}
|
91 |
-
|
92 |
-
define( "FTG_PLAN", "free" );
|
93 |
-
if ( !class_exists( 'FinalTiles_Gallery' ) ) {
|
94 |
-
class FinalTiles_Gallery
|
95 |
-
{
|
96 |
-
private $defaultValues = array(
|
97 |
-
'aClass' => '',
|
98 |
-
'afterGalleryText' => '',
|
99 |
-
'allFilterLabel' => 'All',
|
100 |
-
'ajaxLoading' => 'F',
|
101 |
-
'backgroundColor' => 'transparent',
|
102 |
-
'beforeGalleryText' => '',
|
103 |
-
'blank' => 'F',
|
104 |
-
'borderColor' => 'transparent',
|
105 |
-
'borderRadius' => 0,
|
106 |
-
'borderSize' => 0,
|
107 |
-
'captionBackgroundColor' => '#000000',
|
108 |
-
'captionBehavior' => 'none',
|
109 |
-
'captionColor' => '#ffffff',
|
110 |
-
'captionCustomFields' => '',
|
111 |
-
'captionEasing' => 'linear',
|
112 |
-
'captionEffect' => 'slide-from-bottom',
|
113 |
-
'captionEffectDuration' => 250,
|
114 |
-
'captionEmpty' => 'hide',
|
115 |
-
'captionFontSize' => 12,
|
116 |
-
'captionFrame' => 'F',
|
117 |
-
'captionFrameColor' => '#ffffff',
|
118 |
-
'captionHorizontalAlignment' => 'center',
|
119 |
-
'captionIcon' => 'zoom',
|
120 |
-
'captionIconColor' => '#ffffff',
|
121 |
-
'captionIconSize' => 12,
|
122 |
-
'captionMobileBehavior' => "desktop",
|
123 |
-
'captionOpacity' => 80,
|
124 |
-
'captionPosition' => 'inside',
|
125 |
-
'captionVerticalAlignment' => 'middle',
|
126 |
-
'categoriesAsFilters' => 'F',
|
127 |
-
'columns' => 4,
|
128 |
-
'columnsPhoneLandscape' => 3,
|
129 |
-
'columnsPhonePortrait' => 2,
|
130 |
-
'columnsTabletLandscape' => 4,
|
131 |
-
'columnsTabletPortrait' => 3,
|
132 |
-
'compressHTML' => 'T',
|
133 |
-
'customCaptionIcon' => '',
|
134 |
-
'defaultFilter' => '',
|
135 |
-
'defaultSize' => 'medium',
|
136 |
-
'delay' => 0,
|
137 |
-
'disableLightboxGroups' => 'F',
|
138 |
-
'enableFacebook' => 'F',
|
139 |
-
'enablePinterest' => 'F',
|
140 |
-
'enableTwitter' => 'F',
|
141 |
-
'enlargeImages' => 'T',
|
142 |
-
'filterClick' => 'F',
|
143 |
-
'filters' => '',
|
144 |
-
'gridCellSize' => 25,
|
145 |
-
'gridCellSizeDisabledBelow' => 800,
|
146 |
-
'hoverDuration' => 250,
|
147 |
-
'hoverIconRotation' => 'F',
|
148 |
-
'hoverRotation' => 0,
|
149 |
-
'hoverZoom' => 100,
|
150 |
-
'imageSizeFactor' => 30,
|
151 |
-
'imageSizeFactorCustom' => '',
|
152 |
-
'imageSizeFactorPhoneLandscape' => 30,
|
153 |
-
'imageSizeFactorPhonePortrait' => 20,
|
154 |
-
'imageSizeFactorTabletLandscape' => 30,
|
155 |
-
'imageSizeFactorTabletPortrait' => 20,
|
156 |
-
'imagesOrder' => 'user',
|
157 |
-
'layout' => 'final',
|
158 |
-
'lazyLoad' => false,
|
159 |
-
'lightbox' => 'lightbox2',
|
160 |
-
'lightboxImageSize' => 'large',
|
161 |
-
'lightboxOptions' => '',
|
162 |
-
'lightboxOptionsMobile' => '',
|
163 |
-
'loadedDuration' => 500,
|
164 |
-
'loadedEasing' => 'ease-out',
|
165 |
-
'loadedHSlide' => 0,
|
166 |
-
'loadedRotateY' => 0,
|
167 |
-
'loadedRotateX' => 0,
|
168 |
-
'loadedScaleY' => 100,
|
169 |
-
'loadedScaleX' => 100,
|
170 |
-
'loadedVSlide' => 0,
|
171 |
-
'loadingBarBackgroundColor' => "#fff",
|
172 |
-
'loadingBarColor' => "#666",
|
173 |
-
'loadMethod' => 'sequential',
|
174 |
-
'margin' => 10,
|
175 |
-
'max_posts' => 0,
|
176 |
-
'minTileWidth' => '250',
|
177 |
-
'mobileLightbox' => 'lightbox2',
|
178 |
-
'post_types' => '',
|
179 |
-
'post_taxonomies' => '',
|
180 |
-
'recentPostsCaption' => 'title',
|
181 |
-
'recentPostsCaptionAutoExcerptLength' => 20,
|
182 |
-
'rel' => '',
|
183 |
-
'reverseOrder' => false,
|
184 |
-
'script' => '',
|
185 |
-
'shadowColor' => '#cccccc',
|
186 |
-
'shadowSize' => 0,
|
187 |
-
'socialIconColor' => '#ffffff',
|
188 |
-
'socialIconPosition' => 'bottom',
|
189 |
-
'socialIconStyle' => 'none',
|
190 |
-
'source' => 'images',
|
191 |
-
'style' => '',
|
192 |
-
'support' => 'F',
|
193 |
-
'supportText' => 'Powered by Final Tiles Grid Gallery',
|
194 |
-
'taxonomyOperator' => 'OR',
|
195 |
-
'tilesPerPage' => 0,
|
196 |
-
'titleFontSize' => 14,
|
197 |
-
'width' => '100%',
|
198 |
-
'wp_field_caption' => 'description',
|
199 |
-
'wp_field_title' => 'title',
|
200 |
-
) ;
|
201 |
-
//Constructor
|
202 |
-
public function __construct()
|
203 |
-
{
|
204 |
-
$this->plugin_name = plugin_basename( __FILE__ );
|
205 |
-
$this->define_constants();
|
206 |
-
$this->setupFields();
|
207 |
-
$this->define_db_tables();
|
208 |
-
$this->FinalTilesdb = $this->create_db_conn();
|
209 |
-
add_filter( 'widget_text', 'do_shortcode' );
|
210 |
-
add_action( 'init', array( $this, 'create_textdomain' ) );
|
211 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'add_gallery_scripts' ) );
|
212 |
-
//add_action( 'admin_init', array($this,'gallery_admin_init') );
|
213 |
-
add_action( 'admin_menu', array( $this, 'add_gallery_admin_menu' ) );
|
214 |
-
add_action( 'init', array( $this, 'register_gutenberg_block' ) );
|
215 |
-
add_shortcode( 'FinalTilesGallery', array( $this, 'gallery_shortcode_handler' ) );
|
216 |
-
add_action( 'wp_ajax_save_gallery', array( $this, 'save_gallery' ) );
|
217 |
-
add_action( 'wp_ajax_add_new_gallery', array( $this, 'add_new_gallery' ) );
|
218 |
-
add_action( 'wp_ajax_delete_gallery', array( $this, 'delete_gallery' ) );
|
219 |
-
add_action( 'wp_ajax_clone_gallery', array( $this, 'clone_gallery' ) );
|
220 |
-
add_action( 'wp_ajax_save_image', array( $this, 'save_image' ) );
|
221 |
-
add_action( 'wp_ajax_add_image', array( $this, 'add_image' ) );
|
222 |
-
add_action( 'wp_ajax_save_video', array( $this, 'save_video' ) );
|
223 |
-
add_action( 'wp_ajax_sort_images', array( $this, 'sort_images' ) );
|
224 |
-
add_action( 'wp_ajax_delete_image', array( $this, 'delete_image' ) );
|
225 |
-
add_action( 'wp_ajax_assign_filters', array( $this, 'assign_filters' ) );
|
226 |
-
add_action( 'wp_ajax_assign_group', array( $this, 'assign_group' ) );
|
227 |
-
add_action( 'wp_ajax_toggle_visibility', array( $this, 'toggle_visibility' ) );
|
228 |
-
add_action( 'wp_ajax_refresh_gallery', array( $this, 'refresh_gallery' ) );
|
229 |
-
add_action( 'wp_ajax_get_gallery_configuration', array( $this, 'get_configuration' ) );
|
230 |
-
add_action( 'wp_ajax_update_gallery_configuration', array( $this, 'update_configuration' ) );
|
231 |
-
add_action( 'wp_ajax_get_image_size_url', array( $this, 'get_image_size_url' ) );
|
232 |
-
add_filter( 'mce_buttons', array( $this, 'editor_button' ) );
|
233 |
-
add_filter( 'mce_external_plugins', array( $this, 'register_editor_plugin' ) );
|
234 |
-
add_action( 'wp_ajax_ftg_shortcode_editor', array( $this, 'ftg_shortcode_editor' ) );
|
235 |
-
add_filter(
|
236 |
-
'plugin_row_meta',
|
237 |
-
array( $this, 'register_links' ),
|
238 |
-
10,
|
239 |
-
2
|
240 |
-
);
|
241 |
-
add_action( 'wp_ajax_load_chunk', array( $this, 'load_chunk' ) );
|
242 |
-
add_action( 'wp_ajax_nopriv_load_chunk', array( $this, 'load_chunk' ) );
|
243 |
-
|
244 |
-
if ( ftg_fs()->is_not_paying() ) {
|
245 |
-
add_action( 'admin_notices', array( $this, 'review' ) );
|
246 |
-
add_action( 'wp_ajax_ftg_dismiss_review', array( $this, 'dismiss_review' ) );
|
247 |
-
add_filter(
|
248 |
-
'admin_footer_text',
|
249 |
-
array( $this, 'admin_footer' ),
|
250 |
-
1,
|
251 |
-
2
|
252 |
-
);
|
253 |
-
}
|
254 |
-
|
255 |
-
$this->resetFields();
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Register Gutenberg Block
|
260 |
-
*/
|
261 |
-
public function register_gutenberg_block()
|
262 |
-
{
|
263 |
-
if ( !function_exists( 'register_block_type' ) ) {
|
264 |
-
// Gutenberg is not active.
|
265 |
-
return;
|
266 |
-
}
|
267 |
-
// Register block js script
|
268 |
-
wp_register_script( 'ftg-gallery-block', plugins_url( 'scripts/gutenberg_block.js', __FILE__ ), array(
|
269 |
-
'wp-blocks',
|
270 |
-
'wp-i18n',
|
271 |
-
'wp-element',
|
272 |
-
'wp-editor',
|
273 |
-
'wp-components'
|
274 |
-
) );
|
275 |
-
// Editor CSS
|
276 |
-
wp_register_style( 'ftg-gallery-block-editor', plugins_url( 'admin/css/gutenberg_block.css', __FILE__ ), array( 'wp-edit-blocks' ) );
|
277 |
-
// Register block
|
278 |
-
register_block_type( 'ftg/gallery', array(
|
279 |
-
'editor_style' => 'ftg-gallery-block-editor',
|
280 |
-
'editor_script' => 'ftg-gallery-block',
|
281 |
-
) );
|
282 |
-
// Set block translation
|
283 |
-
wp_set_script_translations( 'FinalTiles-gallery', 'final-tiles-gallery', dirname( plugin_basename( __FILE__ ) ) . '/lib/languages/' );
|
284 |
-
$galls = [ [
|
285 |
-
'value' => 0,
|
286 |
-
'label' => esc_html__( 'Select gallery', 'final-tiles-grid-gallery-lite' ),
|
287 |
-
] ];
|
288 |
-
$galleries = $this->FinalTilesdb->getGalleries();
|
289 |
-
if ( $galleries ) {
|
290 |
-
foreach ( $galleries as $g ) {
|
291 |
-
$galls[] = [
|
292 |
-
'value' => $g->Id,
|
293 |
-
'label' => $g->name,
|
294 |
-
];
|
295 |
-
}
|
296 |
-
}
|
297 |
-
// send list of galleries to block
|
298 |
-
wp_localize_script( 'ftg-gallery-block', 'ftg_galleries', array(
|
299 |
-
'items' => $galls,
|
300 |
-
'add_new_galler_url' => admin_url( 'admin.php?page=ftg-add-gallery' ),
|
301 |
-
) );
|
302 |
-
}
|
303 |
-
|
304 |
-
public function review()
|
305 |
-
{
|
306 |
-
// Verify that we can do a check for reviews.
|
307 |
-
$review = get_option( 'ftg_review' );
|
308 |
-
$time = time();
|
309 |
-
$load = false;
|
310 |
-
$there_was_review = false;
|
311 |
-
|
312 |
-
if ( !$review ) {
|
313 |
-
$review = array(
|
314 |
-
'time' => $time,
|
315 |
-
'dismissed' => false,
|
316 |
-
);
|
317 |
-
$load = true;
|
318 |
-
$there_was_review = false;
|
319 |
-
} else {
|
320 |
-
// Check if it has been dismissed or not.
|
321 |
-
if ( isset( $review['dismissed'] ) && !$review['dismissed'] && (isset( $review['time'] ) && $review['time'] + DAY_IN_SECONDS <= $time) ) {
|
322 |
-
$load = true;
|
323 |
-
}
|
324 |
-
}
|
325 |
-
|
326 |
-
// If we cannot load, return early.
|
327 |
-
if ( !$load ) {
|
328 |
-
return;
|
329 |
-
}
|
330 |
-
// Update the review option now.
|
331 |
-
update_option( 'ftg_review', $review );
|
332 |
-
// Run through optins on the site to see if any have been loaded for more than a week.
|
333 |
-
$valid = false;
|
334 |
-
$galleries = $this->FinalTilesdb->getGalleries();
|
335 |
-
if ( !$galleries ) {
|
336 |
-
return;
|
337 |
-
}
|
338 |
-
$with_date = false;
|
339 |
-
foreach ( $galleries as $gallery ) {
|
340 |
-
if ( !isset( $gallery->date ) ) {
|
341 |
-
continue;
|
342 |
-
}
|
343 |
-
$with_date = true;
|
344 |
-
$data = $gallery->date;
|
345 |
-
// Check the creation date of the local optin. It must be at least one week after.
|
346 |
-
$created = ( isset( $data ) ? strtotime( $data ) + 7 * DAY_IN_SECONDS : false );
|
347 |
-
if ( !$created ) {
|
348 |
-
continue;
|
349 |
-
}
|
350 |
-
|
351 |
-
if ( $created <= $time ) {
|
352 |
-
$valid = true;
|
353 |
-
break;
|
354 |
-
}
|
355 |
-
|
356 |
-
}
|
357 |
-
if ( !$with_date && count( $galleries ) > 0 && !$there_was_review ) {
|
358 |
-
$valid = true;
|
359 |
-
}
|
360 |
-
// If we don't have a valid option yet, return.
|
361 |
-
if ( !$valid ) {
|
362 |
-
return;
|
363 |
-
}
|
364 |
-
// We have a candidate! Output a review message.
|
365 |
-
?>
|
366 |
-
<div class="notice notice-info is-dismissible ftg-review-notice">
|
367 |
-
<p><?php
|
368 |
-
esc_html_e( 'Hey, I noticed you created a photo gallery with Final Tiles - that’s awesome! Would you mind give it a 5-star rating on WordPress to help us spread the word and boost our motivation for new featrues?', 'final-tiles-grid-gallery-lite' );
|
369 |
-
?></p>
|
370 |
-
<p><strong><?php
|
371 |
-
esc_html_e( 'MachoThemes', 'final-tiles-grid-gallery-lite' );
|
372 |
-
?></strong></p>
|
373 |
-
<p>
|
374 |
-
<a href="https://wordpress.org/support/plugin/final-tiles-grid-gallery-lite/reviews/?filter=5#new-post" class="ftg-dismiss-review-notice ftg-review-out" target="_blank" rel="noopener"><?php
|
375 |
-
esc_html_e( 'Ok, you deserve it', 'final-tiles-grid-gallery-lite' );
|
376 |
-
?></a><br>
|
377 |
-
<a href="#" class="ftg-dismiss-review-notice" rel="noopener"><?php
|
378 |
-
esc_html_e( 'Nope, maybe later', 'final-tiles-grid-gallery-lite' );
|
379 |
-
?></a><br>
|
380 |
-
<a href="#" class="ftg-dismiss-review-notice" rel="noopener"><?php
|
381 |
-
esc_html_e( 'I already did', 'final-tiles-grid-gallery-lite' );
|
382 |
-
?></a><br>
|
383 |
-
</p>
|
384 |
-
</div>
|
385 |
-
<script type="text/javascript">
|
386 |
-
jQuery(document).ready( function($) {
|
387 |
-
$(document).on('click', '.ftg-dismiss-review-notice, .ftg-review-notice button', function( event ) {
|
388 |
-
if ( ! $(this).hasClass('ftg-review-out') ) {
|
389 |
-
event.preventDefault();
|
390 |
-
}
|
391 |
-
|
392 |
-
$.post( ajaxurl, {
|
393 |
-
action: 'ftg_dismiss_review'
|
394 |
-
});
|
395 |
-
|
396 |
-
$('.ftg-review-notice').remove();
|
397 |
-
});
|
398 |
-
});
|
399 |
-
</script>
|
400 |
-
<?php
|
401 |
-
}
|
402 |
-
|
403 |
-
public function dismiss_review()
|
404 |
-
{
|
405 |
-
$review = get_option( 'ftg_review' );
|
406 |
-
if ( !$review ) {
|
407 |
-
$review = array();
|
408 |
-
}
|
409 |
-
$review['time'] = time();
|
410 |
-
$review['dismissed'] = true;
|
411 |
-
update_option( 'ftg_review', $review );
|
412 |
-
die;
|
413 |
-
}
|
414 |
-
|
415 |
-
public function admin_footer( $text )
|
416 |
-
{
|
417 |
-
global $current_screen ;
|
418 |
-
|
419 |
-
if ( !empty($current_screen->id) && strpos( $current_screen->id, 'ftg' ) !== false ) {
|
420 |
-
$url = esc_url( 'https://wordpress.org/support/plugin/final-tiles-grid-gallery-lite/reviews/?filter=5#new-post' );
|
421 |
-
$text = sprintf( __( 'Please rate <strong>Final Tiles Gallery</strong> <a href="%s" target="_blank">★★★★★</a> on <a href="%s" target="_blank">WordPress.org</a> to help us spread the word. Thank you from the Final Tiles Gallery team!', 'final-tiles-grid-gallery-lite' ), $url, $url );
|
422 |
-
}
|
423 |
-
|
424 |
-
return $text;
|
425 |
-
}
|
426 |
-
|
427 |
-
private function resetFields()
|
428 |
-
{
|
429 |
-
$keys = array(
|
430 |
-
'name',
|
431 |
-
'hiddenFor',
|
432 |
-
'type',
|
433 |
-
'description',
|
434 |
-
'default',
|
435 |
-
'min',
|
436 |
-
'max',
|
437 |
-
'mu',
|
438 |
-
'excludeFrom'
|
439 |
-
);
|
440 |
-
foreach ( $this->fields as $tab_name => $tab ) {
|
441 |
-
foreach ( $tab["fields"] as $key => $field ) {
|
442 |
-
//print_r($field);
|
443 |
-
foreach ( $keys as $kk ) {
|
444 |
-
if ( !array_key_exists( $kk, $field ) ) {
|
445 |
-
$this->fields[$tab_name]["fields"][$key][$kk] = "";
|
446 |
-
}
|
447 |
-
}
|
448 |
-
}
|
449 |
-
}
|
450 |
-
//print_r($this->fields);
|
451 |
-
}
|
452 |
-
|
453 |
-
public function register_links( $links, $file )
|
454 |
-
{
|
455 |
-
$base = plugin_basename( __FILE__ );
|
456 |
-
|
457 |
-
if ( $file == $base ) {
|
458 |
-
$links[] = '<a href="admin.php?page=ftg-lite-gallery-admin" title="Final Tiles Grid Gallery Dashboard">Dashboard</a>';
|
459 |
-
$links[] = '<a href="https://www.machothemes.com/" title="MachoThemes website">MachoThemes</a>';
|
460 |
-
$links[] = '<a href="https://twitter.com/machothemes" title="@MachoThemes on Twitter">Twitter</a>';
|
461 |
-
$links[] = '<a href="https://www.facebook.com/machothemes" title="MachoThemes on Facebook">Facebook</a>';
|
462 |
-
}
|
463 |
-
|
464 |
-
return $links;
|
465 |
-
}
|
466 |
-
|
467 |
-
/*public function create_db_tables()
|
468 |
-
{
|
469 |
-
include_once 'lib/install-db.php';
|
470 |
-
install_db();
|
471 |
-
}
|
472 |
-
|
473 |
-
public function activation()
|
474 |
-
{
|
475 |
-
|
476 |
-
}*/
|
477 |
-
//Define textdomain
|
478 |
-
public function create_textdomain()
|
479 |
-
{
|
480 |
-
$plugin_dir = basename( dirname( __FILE__ ) );
|
481 |
-
load_plugin_textdomain( 'final-tiles-grid-gallery-lite', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
482 |
-
foreach ( $this->fields as $s => $section ) {
|
483 |
-
foreach ( $section["fields"] as $f => $field ) {
|
484 |
-
$this->fields[$s]["fields"][$f]["description"] = esc_html__( $this->fields[$s]["fields"][$f]["description"], 'final-tiles-grid-gallery-lite' );
|
485 |
-
}
|
486 |
-
}
|
487 |
-
}
|
488 |
-
|
489 |
-
//Define constants
|
490 |
-
public function define_constants()
|
491 |
-
{
|
492 |
-
if ( !defined( 'FINALTILESGALLERY_PLUGIN_BASENAME' ) ) {
|
493 |
-
define( 'FINALTILESGALLERY_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
494 |
-
}
|
495 |
-
if ( !defined( 'FINALTILESGALLERY_PLUGIN_NAME' ) ) {
|
496 |
-
define( 'FINALTILESGALLERY_PLUGIN_NAME', trim( dirname( FINALTILESGALLERY_PLUGIN_BASENAME ), '/' ) );
|
497 |
-
}
|
498 |
-
if ( !defined( 'FINALTILESGALLERY_PLUGIN_DIR' ) ) {
|
499 |
-
define( 'FINALTILESGALLERY_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . FINALTILESGALLERY_PLUGIN_NAME );
|
500 |
-
}
|
501 |
-
}
|
502 |
-
|
503 |
-
//Define DB tables
|
504 |
-
public static function define_db_tables()
|
505 |
-
{
|
506 |
-
global $wpdb ;
|
507 |
-
$wpdb->FinalTilesGalleries = $wpdb->prefix . 'FinalTiles_gallery';
|
508 |
-
$wpdb->FinalTilesImages = $wpdb->prefix . 'FinalTiles_gallery_images';
|
509 |
-
}
|
510 |
-
|
511 |
-
public function create_db_conn()
|
512 |
-
{
|
513 |
-
require 'lib/db-class.php';
|
514 |
-
$FinalTilesdb = FinalTilesDB::getInstance();
|
515 |
-
return $FinalTilesdb;
|
516 |
-
}
|
517 |
-
|
518 |
-
public function editor_button( $buttons )
|
519 |
-
{
|
520 |
-
array_push( $buttons, 'separator', 'ftg_shortcode_editor' );
|
521 |
-
return $buttons;
|
522 |
-
}
|
523 |
-
|
524 |
-
public function register_editor_plugin( $plugin_array )
|
525 |
-
{
|
526 |
-
$plugin_array['ftg_shortcode_editor'] = plugins_url( '/admin/scripts/editor-plugin.js', __FILE__ );
|
527 |
-
return $plugin_array;
|
528 |
-
}
|
529 |
-
|
530 |
-
public function ftg_shortcode_editor()
|
531 |
-
{
|
532 |
-
$css_path = plugins_url( 'assets/css/admin.css', __FILE__ );
|
533 |
-
$admin_url = admin_url();
|
534 |
-
$galleries = $this->FinalTilesdb->getGalleries();
|
535 |
-
//load all galleries
|
536 |
-
include 'admin/include/tinymce-galleries.php';
|
537 |
-
wp_die();
|
538 |
-
}
|
539 |
-
|
540 |
-
public function attachment_fields_to_edit( $form, $post )
|
541 |
-
{
|
542 |
-
$form["ftg_link"] = array(
|
543 |
-
"label" => "Link <small>FTG</small>",
|
544 |
-
"input" => "text",
|
545 |
-
"value" => get_post_meta( $post->ID, "_ftg_link", true ),
|
546 |
-
"helps" => "",
|
547 |
-
);
|
548 |
-
$form["ftg_target"] = array(
|
549 |
-
"label" => "_blank <small>FTG</small>",
|
550 |
-
"input" => "html",
|
551 |
-
"html" => "<input type='checkbox' name='attachments[{$post->ID}][ftg_target]' id='attachments[{$post->ID}][ftg_target]' value='_mblank' " . (( get_post_meta( $post->ID, "_ftg_target", true ) == "_mblank" ? "checked" : "" )) . " />",
|
552 |
-
);
|
553 |
-
return $form;
|
554 |
-
}
|
555 |
-
|
556 |
-
public function attachment_fields_to_save( $post, $attachment )
|
557 |
-
{
|
558 |
-
if ( isset( $attachment['ftg_link'] ) ) {
|
559 |
-
update_post_meta( $post['ID'], '_ftg_link', esc_url_raw( $attachment['ftg_link'] ) );
|
560 |
-
}
|
561 |
-
if ( isset( $attachment['ftg_target'] ) ) {
|
562 |
-
update_post_meta( $post['ID'], '_ftg_target', sanitize_text_field( $attachment['ftg_target'] ) );
|
563 |
-
}
|
564 |
-
return $post;
|
565 |
-
}
|
566 |
-
|
567 |
-
//Delete gallery
|
568 |
-
public function delete_gallery()
|
569 |
-
{
|
570 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) && isset( $_POST['id'] ) ) {
|
571 |
-
$this->FinalTilesdb->deleteGallery( intval( $_POST['id'] ) );
|
572 |
-
}
|
573 |
-
return array();
|
574 |
-
}
|
575 |
-
|
576 |
-
public function update_configuration()
|
577 |
-
{
|
578 |
-
|
579 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
580 |
-
$id = ( isset( $_POST['galleryId'] ) ? absint( $_POST['galleryId'] ) : 0 );
|
581 |
-
$config = ( isset( $_POST['config'] ) ? wp_unslash( $_POST['config'] ) : '' );
|
582 |
-
// phpcs:ignore
|
583 |
-
$this->FinalTilesdb->update_config( $id, $config );
|
584 |
-
}
|
585 |
-
|
586 |
-
exit;
|
587 |
-
}
|
588 |
-
|
589 |
-
public function get_configuration()
|
590 |
-
{
|
591 |
-
|
592 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
593 |
-
$id = ( isset( $_POST['galleryId'] ) ? absint( $_POST['galleryId'] ) : 0 );
|
594 |
-
$gallery = $this->FinalTilesdb->getGalleryConfig( $id );
|
595 |
-
echo stripslashes( $gallery ) ;
|
596 |
-
// phpcs:ignore
|
597 |
-
}
|
598 |
-
|
599 |
-
exit;
|
600 |
-
}
|
601 |
-
|
602 |
-
public function get_image_size_url()
|
603 |
-
{
|
604 |
-
|
605 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
606 |
-
$id = ( isset( $_POST['id'] ) ? absint( $_POST['id'] ) : 0 );
|
607 |
-
$size = ( isset( $_POST['size'] ) ? sanitize_text_field( wp_unslash( $_POST['size'] ) ) : 'thumbnail' );
|
608 |
-
echo esc_url( wp_get_attachment_image_url( $id, $size, false ) ) ;
|
609 |
-
}
|
610 |
-
|
611 |
-
exit;
|
612 |
-
}
|
613 |
-
|
614 |
-
//Clone gallery
|
615 |
-
public function clone_gallery()
|
616 |
-
{
|
617 |
-
|
618 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
619 |
-
$sourceId = ( isset( $_POST['id'] ) ? intval( $_POST['id'] ) : 0 );
|
620 |
-
$g = $this->FinalTilesdb->getGalleryById( $sourceId, true );
|
621 |
-
$g['name'] .= " (copy)";
|
622 |
-
$this->FinalTilesdb->addGallery( $g );
|
623 |
-
$id = $this->FinalTilesdb->getNewGalleryId();
|
624 |
-
$images = $this->FinalTilesdb->getImagesByGalleryId( $sourceId, 0, 0 );
|
625 |
-
foreach ( $images as &$image ) {
|
626 |
-
$image->Id = null;
|
627 |
-
$image->gid = $id;
|
628 |
-
}
|
629 |
-
$this->FinalTilesdb->addImages( $id, $images );
|
630 |
-
}
|
631 |
-
|
632 |
-
return array();
|
633 |
-
}
|
634 |
-
|
635 |
-
//Add gallery scripts
|
636 |
-
public function add_gallery_scripts()
|
637 |
-
{
|
638 |
-
wp_enqueue_script( 'jquery' );
|
639 |
-
wp_register_script(
|
640 |
-
'finalTilesGallery',
|
641 |
-
plugins_url( 'scripts/jquery.finalTilesGallery.js', __FILE__ ),
|
642 |
-
array( 'jquery' ),
|
643 |
-
FTGVERSION,
|
644 |
-
true
|
645 |
-
);
|
646 |
-
wp_enqueue_script( 'finalTilesGallery' );
|
647 |
-
wp_register_style(
|
648 |
-
'finalTilesGallery_stylesheet',
|
649 |
-
plugins_url( 'scripts/ftg.css', __FILE__ ),
|
650 |
-
array(),
|
651 |
-
FTGVERSION
|
652 |
-
);
|
653 |
-
wp_enqueue_style( 'finalTilesGallery_stylesheet' );
|
654 |
-
wp_register_script( 'lightbox2_script', plugins_url( 'lightbox/lightbox2/js/script.js', __FILE__ ), array( 'jquery' ) );
|
655 |
-
wp_register_style( 'lightbox2_stylesheet', plugins_url( 'lightbox/lightbox2/css/style.css', __FILE__ ) );
|
656 |
-
wp_register_style( 'fontawesome_stylesheet', '//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css' );
|
657 |
-
wp_enqueue_style( 'fontawesome_stylesheet' );
|
658 |
-
}
|
659 |
-
|
660 |
-
//Admin Section - register scripts and styles
|
661 |
-
public function gallery_admin_init()
|
662 |
-
{
|
663 |
-
if ( function_exists( 'wp_enqueue_media' ) ) {
|
664 |
-
wp_enqueue_media();
|
665 |
-
}
|
666 |
-
$ftg_db_version = '20190518';
|
667 |
-
$installed_ver = get_option( "FinalTiles_gallery_db_version" );
|
668 |
-
if ( !$installed_ver || empty($installed_ver) ) {
|
669 |
-
update_option( "FinalTiles_gallery_db_version", $ftg_db_version );
|
670 |
-
}
|
671 |
-
|
672 |
-
if ( $installed_ver != $ftg_db_version ) {
|
673 |
-
activate_finaltilesgallery();
|
674 |
-
update_option( "FinalTiles_gallery_db_version", $ftg_db_version );
|
675 |
-
}
|
676 |
-
|
677 |
-
function ftg_get_image_sizes()
|
678 |
-
{
|
679 |
-
global $_wp_additional_image_sizes ;
|
680 |
-
$sizes = array();
|
681 |
-
foreach ( get_intermediate_image_sizes() as $_size ) {
|
682 |
-
|
683 |
-
if ( in_array( $_size, array(
|
684 |
-
'thumbnail',
|
685 |
-
'medium',
|
686 |
-
'medium_large',
|
687 |
-
'large'
|
688 |
-
) ) ) {
|
689 |
-
$sizes[$_size]['width'] = get_option( "{$_size}_size_w" );
|
690 |
-
$sizes[$_size]['height'] = get_option( "{$_size}_size_h" );
|
691 |
-
$sizes[$_size]['crop'] = (bool) get_option( "{$_size}_crop" );
|
692 |
-
} elseif ( isset( $_wp_additional_image_sizes[$_size] ) ) {
|
693 |
-
$sizes[$_size] = array(
|
694 |
-
'width' => $_wp_additional_image_sizes[$_size]['width'],
|
695 |
-
'height' => $_wp_additional_image_sizes[$_size]['height'],
|
696 |
-
'crop' => $_wp_additional_image_sizes[$_size]['crop'],
|
697 |
-
);
|
698 |
-
}
|
699 |
-
|
700 |
-
}
|
701 |
-
return $sizes;
|
702 |
-
}
|
703 |
-
|
704 |
-
foreach ( ftg_get_image_sizes() as $name => $size ) {
|
705 |
-
$this->fields["Links & Lightbox"]["fields"]["lightboxImageSize"]["values"]["Size"][] = $name . "|" . $name . " (" . $size['width'] . 'x' . $size['height'] . (( $size['crop'] ? ' cropped)' : ')' ));
|
706 |
-
}
|
707 |
-
$this->fields["Links & Lightbox"]["fields"]["lightboxImageSize"]["values"]["Size"][] = "full|Original (full)";
|
708 |
-
wp_enqueue_script( 'jquery' );
|
709 |
-
wp_enqueue_script( 'jquery-ui-dialog' );
|
710 |
-
wp_enqueue_script( 'jquery-ui-sortable' );
|
711 |
-
wp_enqueue_script( 'wp-color-picker' );
|
712 |
-
wp_enqueue_style( 'wp-color-picker' );
|
713 |
-
wp_enqueue_script( 'media-upload' );
|
714 |
-
wp_enqueue_script( 'thickbox' );
|
715 |
-
wp_register_style( 'google-fonts', '//fonts.googleapis.com/css?family=Roboto:400,700,500,300,900' );
|
716 |
-
wp_enqueue_style( 'google-fonts' );
|
717 |
-
wp_register_style( 'google-icons', '//cdn.materialdesignicons.com/1.9.32/css/materialdesignicons.min.css', array() );
|
718 |
-
wp_enqueue_style( 'google-icons' );
|
719 |
-
wp_register_style( 'final-tiles-gallery-admin', plugins_url( 'admin/css/style.css', __FILE__ ), array( 'colors' ) );
|
720 |
-
wp_enqueue_style( 'final-tiles-gallery-admin' );
|
721 |
-
wp_register_script( 'materialize', plugins_url( 'admin/scripts/materialize.min.js', __FILE__ ), array( 'jquery' ) );
|
722 |
-
wp_enqueue_script( 'materialize' );
|
723 |
-
wp_register_script( 'final-tiles-gallery', plugins_url( 'admin/scripts/final-tiles-gallery-admin.js', __FILE__ ), array(
|
724 |
-
'jquery',
|
725 |
-
'media-upload',
|
726 |
-
'thickbox',
|
727 |
-
'materialize'
|
728 |
-
) );
|
729 |
-
wp_enqueue_script( 'final-tiles-gallery' );
|
730 |
-
wp_enqueue_style( 'thickbox' );
|
731 |
-
wp_register_style( 'fontawesome_stylesheet', '//netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.css' );
|
732 |
-
wp_enqueue_style( 'fontawesome_stylesheet' );
|
733 |
-
}
|
734 |
-
|
735 |
-
//Create Admin Menu
|
736 |
-
public function add_gallery_admin_menu()
|
737 |
-
{
|
738 |
-
$overview = add_menu_page(
|
739 |
-
'Final Tiles Gallery',
|
740 |
-
'Final Tiles Gallery',
|
741 |
-
'edit_posts',
|
742 |
-
'ftg-lite-gallery-admin',
|
743 |
-
array( $this, 'add_overview' ),
|
744 |
-
plugins_url( 'admin/icon.png', __FILE__ )
|
745 |
-
);
|
746 |
-
$add_gallery = add_submenu_page(
|
747 |
-
'ftg-lite-gallery-admin',
|
748 |
-
esc_html__( 'FinalTiles Gallery >> Add Gallery', 'final-tiles-grid-gallery-lite' ),
|
749 |
-
esc_html__( 'Add Gallery', 'final-tiles-grid-gallery-lite' ),
|
750 |
-
'edit_posts',
|
751 |
-
'ftg-add-gallery',
|
752 |
-
array( $this, 'add_gallery' )
|
753 |
-
);
|
754 |
-
add_action( 'load-' . $overview, array( $this, 'gallery_admin_init' ) );
|
755 |
-
add_action( 'load-' . $add_gallery, array( $this, 'gallery_admin_init' ) );
|
756 |
-
/*if(! class_exists("PhotoBlocks"))
|
757 |
-
{
|
758 |
-
$photoblocks = add_submenu_page('ftg-lite-gallery-admin', __('FinalTiles Gallery >> PhotoBlocks', 'FinalTiles-gallery'), __('PhotoBlocks', 'FinalTiles-gallery'), 'edit_posts', 'ftg-photoblocks', array($this, 'photoblocks'));
|
759 |
-
add_action('load-' . $photoblocks, array($this, 'gallery_admin_init'));
|
760 |
-
}
|
761 |
-
|
762 |
-
if(! class_exists("EverlightBox"))
|
763 |
-
{
|
764 |
-
$everlightbox = add_submenu_page('ftg-lite-gallery-admin', __('FinalTiles Gallery >> EverlightBox', 'FinalTiles-gallery'), __('EverlightBox', 'FinalTiles-gallery'), 'edit_posts', 'ftg-everlightbox', array($this, 'everlightbox'));
|
765 |
-
add_action('load-' . $everlightbox, array($this, 'gallery_admin_init'));
|
766 |
-
}*/
|
767 |
-
}
|
768 |
-
|
769 |
-
//Create Admin Pages
|
770 |
-
public function add_overview()
|
771 |
-
{
|
772 |
-
global $ftg_fields ;
|
773 |
-
$ftg_fields = $this->fields;
|
774 |
-
global $ftg_parent_page ;
|
775 |
-
$ftg_parent_page = "dashboard";
|
776 |
-
|
777 |
-
if ( array_key_exists( "id", $_GET ) ) {
|
778 |
-
$woocommerce_post_types = array(
|
779 |
-
"product",
|
780 |
-
"product_variation",
|
781 |
-
"shop_order",
|
782 |
-
"shop_order_refund",
|
783 |
-
"shop_coupon",
|
784 |
-
"shop_webhook"
|
785 |
-
);
|
786 |
-
$wp_post_types = array( "revision", "nav_menu_item" );
|
787 |
-
$excluded_post_types = array_merge( $wp_post_types, $woocommerce_post_types );
|
788 |
-
$woo_categories = $this->getWooCategories();
|
789 |
-
include "admin/edit-gallery.php";
|
790 |
-
} else {
|
791 |
-
include "admin/overview.php";
|
792 |
-
}
|
793 |
-
|
794 |
-
}
|
795 |
-
|
796 |
-
public function tutorial()
|
797 |
-
{
|
798 |
-
include "admin/tutorial.php";
|
799 |
-
}
|
800 |
-
|
801 |
-
public function support()
|
802 |
-
{
|
803 |
-
include "admin/support.php";
|
804 |
-
}
|
805 |
-
|
806 |
-
public function photoblocks()
|
807 |
-
{
|
808 |
-
include "admin/photoblocks.php";
|
809 |
-
}
|
810 |
-
|
811 |
-
public function everlightbox()
|
812 |
-
{
|
813 |
-
include "admin/everlightbox.php";
|
814 |
-
}
|
815 |
-
|
816 |
-
private function getWooCategories()
|
817 |
-
{
|
818 |
-
|
819 |
-
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
|
820 |
-
$taxonomy = 'product_cat';
|
821 |
-
$orderby = 'name';
|
822 |
-
$show_count = 0;
|
823 |
-
// 1 for yes, 0 for no
|
824 |
-
$pad_counts = 0;
|
825 |
-
// 1 for yes, 0 for no
|
826 |
-
$hierarchical = 1;
|
827 |
-
// 1 for yes, 0 for no
|
828 |
-
$title = '';
|
829 |
-
$empty = 0;
|
830 |
-
$args = array(
|
831 |
-
'taxonomy' => $taxonomy,
|
832 |
-
'orderby' => $orderby,
|
833 |
-
'show_count' => $show_count,
|
834 |
-
'pad_counts' => $pad_counts,
|
835 |
-
'hierarchical' => $hierarchical,
|
836 |
-
'title_li' => $title,
|
837 |
-
'hide_empty' => $empty,
|
838 |
-
);
|
839 |
-
return get_categories( $args );
|
840 |
-
} else {
|
841 |
-
return array();
|
842 |
-
}
|
843 |
-
|
844 |
-
}
|
845 |
-
|
846 |
-
public function add_gallery()
|
847 |
-
{
|
848 |
-
global $ftg_fields ;
|
849 |
-
$ftg_fields = $this->fields;
|
850 |
-
$gallery = null;
|
851 |
-
$woocommerce_post_types = array(
|
852 |
-
"product",
|
853 |
-
"product_variation",
|
854 |
-
"shop_order",
|
855 |
-
"shop_order_refund",
|
856 |
-
"shop_coupon",
|
857 |
-
"shop_webhook"
|
858 |
-
);
|
859 |
-
$wp_post_types = array( "revision", "nav_menu_item" );
|
860 |
-
$excluded_post_types = array_merge( $wp_post_types, $woocommerce_post_types );
|
861 |
-
$woo_categories = $this->getWooCategories();
|
862 |
-
include "admin/add-gallery.php";
|
863 |
-
}
|
864 |
-
|
865 |
-
public function delete_image()
|
866 |
-
{
|
867 |
-
|
868 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
869 |
-
$ids = ( isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : 0 );
|
870 |
-
foreach ( explode( ",", $ids ) as $id ) {
|
871 |
-
$this->FinalTilesdb->deleteImage( absint( $id ) );
|
872 |
-
}
|
873 |
-
}
|
874 |
-
|
875 |
-
wp_die();
|
876 |
-
}
|
877 |
-
|
878 |
-
public function assign_filters()
|
879 |
-
{
|
880 |
-
|
881 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
882 |
-
$ids = ( isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : 0 );
|
883 |
-
$filters = ( isset( $_POST['filters'] ) ? sanitize_text_field( wp_unslash( $_POST['filters'] ) ) : '' );
|
884 |
-
|
885 |
-
if ( isset( $_POST['source'] ) && $_POST['source'] == 'posts' ) {
|
886 |
-
foreach ( explode( ",", $ids ) as $id ) {
|
887 |
-
update_post_meta( absint( $id ), 'ftg_filters', sanitize_text_field( $filters ) );
|
888 |
-
}
|
889 |
-
} else {
|
890 |
-
foreach ( explode( ",", $ids ) as $id ) {
|
891 |
-
$result = $this->FinalTilesdb->editImage( absint( $id ), array(
|
892 |
-
"filters" => sanitize_text_field( $filters ),
|
893 |
-
) );
|
894 |
-
}
|
895 |
-
}
|
896 |
-
|
897 |
-
}
|
898 |
-
|
899 |
-
wp_die();
|
900 |
-
}
|
901 |
-
|
902 |
-
public function toggle_visibility()
|
903 |
-
{
|
904 |
-
|
905 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
906 |
-
$ids = ( isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : 0 );
|
907 |
-
foreach ( explode( ",", $ids ) as $id ) {
|
908 |
-
$image = $this->FinalTilesdb->getImage( $id );
|
909 |
-
$this->FinalTilesdb->editImage( absint( $id ), array(
|
910 |
-
"hidden" => ( $image->hidden == 'T' ? 'F' : 'T' ),
|
911 |
-
) );
|
912 |
-
}
|
913 |
-
}
|
914 |
-
|
915 |
-
wp_die();
|
916 |
-
}
|
917 |
-
|
918 |
-
public function assign_group()
|
919 |
-
{
|
920 |
-
|
921 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
922 |
-
$ids = ( isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : 0 );
|
923 |
-
$group = ( isset( $_POST['group'] ) ? sanitize_text_field( wp_unslash( $_POST['group'] ) ) : '' );
|
924 |
-
|
925 |
-
if ( isset( $_POST['source'] ) && $_POST['source'] == 'posts' ) {
|
926 |
-
foreach ( explode( ",", $ids ) as $id ) {
|
927 |
-
update_post_meta( intval( $id ), 'ftg_group', sanitize_text_field( $group ) );
|
928 |
-
}
|
929 |
-
} else {
|
930 |
-
foreach ( explode( ",", $ids ) as $id ) {
|
931 |
-
$result = $this->FinalTilesdb->editImage( $id, array(
|
932 |
-
"group" => sanitize_text_field( $group ),
|
933 |
-
) );
|
934 |
-
}
|
935 |
-
}
|
936 |
-
|
937 |
-
}
|
938 |
-
|
939 |
-
wp_die();
|
940 |
-
}
|
941 |
-
|
942 |
-
public function add_image()
|
943 |
-
{
|
944 |
-
|
945 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
946 |
-
$gid = ( isset( $_POST['galleryId'] ) ? intval( $_POST['galleryId'] ) : 0 );
|
947 |
-
$enc_images = ( isset( $_POST['enc_images'] ) ? wp_unslash( $_POST['enc_images'] ) : '' );
|
948 |
-
// phpcs:ignore
|
949 |
-
$images = json_decode( $enc_images );
|
950 |
-
$result = $this->FinalTilesdb->addImages( $gid, $images );
|
951 |
-
header( "Content-type: application/json" );
|
952 |
-
|
953 |
-
if ( $result === false ) {
|
954 |
-
echo "{\"success\":false}" ;
|
955 |
-
} else {
|
956 |
-
echo "{\"success\":true}" ;
|
957 |
-
}
|
958 |
-
|
959 |
-
}
|
960 |
-
|
961 |
-
wp_die();
|
962 |
-
}
|
963 |
-
|
964 |
-
public function list_thumbnail_sizes()
|
965 |
-
{
|
966 |
-
global $_wp_additional_image_sizes ;
|
967 |
-
$sizes = array();
|
968 |
-
foreach ( get_intermediate_image_sizes() as $s ) {
|
969 |
-
|
970 |
-
if ( in_array( $s, array( 'thumbnail', 'medium', 'large' ) ) ) {
|
971 |
-
$sizes[$s][0] = get_option( $s . '_size_w' );
|
972 |
-
$sizes[$s][1] = get_option( $s . '_size_h' );
|
973 |
-
} else {
|
974 |
-
if ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[$s] ) && $_wp_additional_image_sizes[$s]['width'] > 0 && $_wp_additional_image_sizes[$s]['height'] > 0 ) {
|
975 |
-
$sizes[$s] = array( $_wp_additional_image_sizes[$s]['width'], $_wp_additional_image_sizes[$s]['height'] );
|
976 |
-
}
|
977 |
-
}
|
978 |
-
|
979 |
-
}
|
980 |
-
return $sizes;
|
981 |
-
}
|
982 |
-
|
983 |
-
public function sort_images()
|
984 |
-
{
|
985 |
-
|
986 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
987 |
-
$ids = ( isset( $_POST['ids'] ) ? sanitize_text_field( wp_unslash( $_POST['ids'] ) ) : 0 );
|
988 |
-
$result = $this->FinalTilesdb->sortImages( explode( ',', $ids ) );
|
989 |
-
header( "Content-type: application/json" );
|
990 |
-
|
991 |
-
if ( $result === false ) {
|
992 |
-
echo "{\"success\":false}" ;
|
993 |
-
} else {
|
994 |
-
echo "{\"success\":true}" ;
|
995 |
-
}
|
996 |
-
|
997 |
-
}
|
998 |
-
|
999 |
-
wp_die();
|
1000 |
-
}
|
1001 |
-
|
1002 |
-
public function load_chunk()
|
1003 |
-
{
|
1004 |
-
require_once 'lib/gallery-class.php';
|
1005 |
-
|
1006 |
-
if ( check_admin_referer( 'finaltilesgallery', 'finaltilesgallery' ) ) {
|
1007 |
-
$gid = ( isset( $_POST['gallery'] ) ? intval( $_POST['gallery'] ) : 0 );
|
1008 |
-
$images = $this->FinalTilesdb->getImagesByGalleryId( $gid, 0, 0 );
|
1009 |
-
$FinalTilesGallery = new FinalTilesGallery( $gid, $this->FinalTilesdb, $this->defaultValues );
|
1010 |
-
echo $FinalTilesGallery->images_markup() ;
|
1011 |
-
// phpcs:ignore
|
1012 |
-
}
|
1013 |
-
|
1014 |
-
wp_die();
|
1015 |
-
}
|
1016 |
-
|
1017 |
-
public function refresh_gallery()
|
1018 |
-
{
|
1019 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
1020 |
-
if ( isset( $_POST['source'] ) && sanitize_text_field( wp_unslash( $_POST['source'] ) ) == 'images' ) {
|
1021 |
-
$this->list_images();
|
1022 |
-
}
|
1023 |
-
}
|
1024 |
-
}
|
1025 |
-
|
1026 |
-
public function save_image()
|
1027 |
-
{
|
1028 |
-
|
1029 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
1030 |
-
$result = false;
|
1031 |
-
|
1032 |
-
if ( isset( $_POST['source'] ) && $_POST['source'] == 'posts' ) {
|
1033 |
-
$result = true;
|
1034 |
-
$postId = ( isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0 );
|
1035 |
-
$img_url = ( isset( $_POST['img_url'] ) ? esc_url_raw( $_POST['img_url'] ) : '' );
|
1036 |
-
update_post_meta( $postId, 'ftg_image_url', esc_url_raw( $img_url ) );
|
1037 |
-
if ( array_key_exists( "filters", $_POST ) && strlen( sanitize_text_field( wp_unslash( $_POST['filters'] ) ) ) ) {
|
1038 |
-
update_post_meta( $postId, 'ftg_filters', sanitize_text_field( wp_unslash( $_POST['filters'] ) ) );
|
1039 |
-
}
|
1040 |
-
} else {
|
1041 |
-
$type = ( isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '' );
|
1042 |
-
$imageUrl = ( isset( $_POST['img_url'] ) ? esc_url_raw( $_POST['img_url'] ) : '' );
|
1043 |
-
$imageCaption = ( isset( $_POST['description'] ) ? wp_kses_post( wp_unslash( $_POST['description'] ) ) : '' );
|
1044 |
-
$filters = ( isset( $_POST['filters'] ) ? sanitize_text_field( wp_unslash( $_POST['filters'] ) ) : '' );
|
1045 |
-
$title = ( isset( $_POST['imageTitle'] ) ? wp_kses_post( wp_unslash( $_POST['imageTitle'] ) ) : '' );
|
1046 |
-
$target = ( isset( $_POST['target'] ) ? sanitize_text_field( wp_unslash( $_POST['target'] ) ) : '' );
|
1047 |
-
$group = ( isset( $_POST['group'] ) ? sanitize_text_field( wp_unslash( $_POST['group'] ) ) : '' );
|
1048 |
-
$alt = ( isset( $_POST['alt'] ) ? sanitize_text_field( wp_unslash( $_POST['alt'] ) ) : '' );
|
1049 |
-
$hidden = $this->checkboxVal( 'hidden' );
|
1050 |
-
$link = ( isset( $_POST['link'] ) ? esc_url_raw( wp_unslash( $_POST['link'] ) ) : null );
|
1051 |
-
$imageId = ( isset( $_POST['img_id'] ) ? intval( wp_unslash( $_POST['img_id'] ) ) : 0 );
|
1052 |
-
$sortOrder = ( isset( $_POST['sortOrder'] ) ? intval( wp_unslash( $_POST['sortOrder'] ) ) : 0 );
|
1053 |
-
$data = array(
|
1054 |
-
"imagePath" => $imageUrl,
|
1055 |
-
"target" => $target,
|
1056 |
-
"link" => $link,
|
1057 |
-
"imageId" => $imageId,
|
1058 |
-
"description" => $imageCaption,
|
1059 |
-
"filters" => $filters,
|
1060 |
-
"title" => $title,
|
1061 |
-
"group" => $group,
|
1062 |
-
"alt" => $alt,
|
1063 |
-
"hidden" => $hidden,
|
1064 |
-
"sortOrder" => $sortOrder,
|
1065 |
-
);
|
1066 |
-
|
1067 |
-
if ( !empty($_POST["id"]) ) {
|
1068 |
-
$imageId = intval( $_POST['id'] );
|
1069 |
-
$result = $this->FinalTilesdb->editImage( $imageId, $data );
|
1070 |
-
} else {
|
1071 |
-
$data["gid"] = ( isset( $_POST['galleryId'] ) ? absint( $_POST['galleryId'] ) : 0 );
|
1072 |
-
$result = $this->FinalTilesdb->addFullImage( $data );
|
1073 |
-
}
|
1074 |
-
|
1075 |
-
}
|
1076 |
-
|
1077 |
-
header( "Content-type: application/json" );
|
1078 |
-
|
1079 |
-
if ( $result === false ) {
|
1080 |
-
echo "{\"success\":false}" ;
|
1081 |
-
} else {
|
1082 |
-
echo "{\"success\":true}" ;
|
1083 |
-
}
|
1084 |
-
|
1085 |
-
}
|
1086 |
-
|
1087 |
-
wp_die();
|
1088 |
-
}
|
1089 |
-
|
1090 |
-
public function save_video()
|
1091 |
-
{
|
1092 |
-
|
1093 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
1094 |
-
$result = false;
|
1095 |
-
$type = ( isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : "" );
|
1096 |
-
$data = array(
|
1097 |
-
"imagePath" => wp_unslash( $_POST["embed"] ),
|
1098 |
-
"filters" => ( isset( $_POST['filters'] ) ? sanitize_text_field( wp_unslash( $_POST['filters'] ) ) : '' ),
|
1099 |
-
"gid" => ( isset( $_POST['galleryId'] ) ? absint( $_POST['galleryId'] ) : 0 ),
|
1100 |
-
);
|
1101 |
-
$id = ( isset( $_POST['id'] ) ? absint( $_POST['id'] ) : "" );
|
1102 |
-
$step = ( isset( $_POST['step'] ) ? sanitize_text_field( wp_unslash( $_POST['step'] ) ) : "" );
|
1103 |
-
if ( !empty($step) ) {
|
1104 |
-
|
1105 |
-
if ( $step == "add" ) {
|
1106 |
-
$result = $this->FinalTilesdb->addVideo( $data );
|
1107 |
-
} else {
|
1108 |
-
if ( $step == "edit" ) {
|
1109 |
-
$result = $this->FinalTilesdb->editVideo( $id, $data );
|
1110 |
-
}
|
1111 |
-
}
|
1112 |
-
|
1113 |
-
}
|
1114 |
-
header( "Content-type: application/json" );
|
1115 |
-
|
1116 |
-
if ( $result === false ) {
|
1117 |
-
echo "{\"success\":false}" ;
|
1118 |
-
} else {
|
1119 |
-
echo "{\"success\":true}" ;
|
1120 |
-
}
|
1121 |
-
|
1122 |
-
}
|
1123 |
-
|
1124 |
-
wp_die();
|
1125 |
-
}
|
1126 |
-
|
1127 |
-
public function list_images()
|
1128 |
-
{
|
1129 |
-
|
1130 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
1131 |
-
$gid = ( isset( $_POST['gid'] ) ? absint( $_POST['gid'] ) : 0 );
|
1132 |
-
$imageResults = $this->FinalTilesdb->getImagesByGalleryId( $gid, 0, 0 );
|
1133 |
-
$gallery = $this->FinalTilesdb->getGalleryById( $gid );
|
1134 |
-
$list_size = "medium";
|
1135 |
-
$column_size = "s6 m3 l3";
|
1136 |
-
if ( isset( $_POST['list_size'] ) && !empty($_POST['list_size']) ) {
|
1137 |
-
$list_size = sanitize_text_field( wp_unslash( $_POST['list_size'] ) );
|
1138 |
-
}
|
1139 |
-
setcookie( 'ftg_imglist_size', $list_size );
|
1140 |
-
$_COOKIE['ftg_imglist_size'] = $list_size;
|
1141 |
-
if ( $list_size == 'small' ) {
|
1142 |
-
$column_size = 's4 m2 l2';
|
1143 |
-
}
|
1144 |
-
if ( $list_size == 'medium' ) {
|
1145 |
-
$column_size = 's6 m3 l3';
|
1146 |
-
}
|
1147 |
-
if ( $list_size == 'big' ) {
|
1148 |
-
$column_size = 's12 m4 l4';
|
1149 |
-
}
|
1150 |
-
include 'admin/include/image-list.php';
|
1151 |
-
}
|
1152 |
-
|
1153 |
-
wp_die();
|
1154 |
-
}
|
1155 |
-
|
1156 |
-
public function add_new_gallery()
|
1157 |
-
{
|
1158 |
-
|
1159 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
1160 |
-
$data = $this->defaultValues;
|
1161 |
-
// phpcs:ignore
|
1162 |
-
$data["name"] = ( isset( $_POST['ftg_name'] ) ? wp_kses_post( wp_unslash( $_POST['ftg_name'] ) ) : '' );
|
1163 |
-
// phpcs:ignore
|
1164 |
-
$data["description"] = ( isset( $_POST['ftg_description'] ) ? wp_kses_post( wp_unslash( $_POST['ftg_description'] ) ) : '' );
|
1165 |
-
$data["source"] = ( isset( $_POST['ftg_source'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_source'] ) ) : '' );
|
1166 |
-
$data["wp_field_caption"] = ( isset( $_POST['ftg_wp_field_caption'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_wp_field_caption'] ) ) : '' );
|
1167 |
-
$data["wp_field_title"] = ( isset( $_POST['ftg_wp_field_title'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_wp_field_title'] ) ) : '' );
|
1168 |
-
$data["captionEffect"] = ( isset( $_POST['ftg_captionEffect'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_captionEffect'] ) ) : '' );
|
1169 |
-
$data["post_types"] = ( isset( $_POST['post_types'] ) ? sanitize_text_field( wp_unslash( $_POST["post_types"] ) ) : '' );
|
1170 |
-
$data["layout"] = ( isset( $_POST['layout'] ) ? sanitize_text_field( wp_unslash( $_POST["layout"] ) ) : '' );
|
1171 |
-
$data["defaultWooImageSize"] = ( isset( $_POST['def_imgsize'] ) ? sanitize_text_field( wp_unslash( $_POST['def_imgsize'] ) ) : '' );
|
1172 |
-
$data["defaultPostImageSize"] = ( isset( $_POST['def_imgsize'] ) ? sanitize_text_field( wp_unslash( $_POST['def_imgsize'] ) ) : '' );
|
1173 |
-
$data["woo_categories"] = ( isset( $_POST['woo_categories'] ) ? sanitize_text_field( wp_unslash( $_POST["woo_categories"] ) ) : '' );
|
1174 |
-
$result = $this->FinalTilesdb->addGallery( $data );
|
1175 |
-
$id = $this->FinalTilesdb->getNewGalleryId();
|
1176 |
-
// phpcs:ignore
|
1177 |
-
|
1178 |
-
if ( $id > 0 && array_key_exists( 'enc_images', $_POST ) && strlen( wp_unslash( $_POST['enc_images'] ) ) ) {
|
1179 |
-
$images = json_decode( wp_unslash( $_POST["enc_images"] ) );
|
1180 |
-
$result = $this->FinalTilesdb->addImages( $id, $images );
|
1181 |
-
}
|
1182 |
-
|
1183 |
-
echo absint( $id ) ;
|
1184 |
-
} else {
|
1185 |
-
echo -1 ;
|
1186 |
-
}
|
1187 |
-
|
1188 |
-
wp_die();
|
1189 |
-
}
|
1190 |
-
|
1191 |
-
private function checkboxVal( $field )
|
1192 |
-
{
|
1193 |
-
|
1194 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
1195 |
-
if ( isset( $_POST[$field] ) ) {
|
1196 |
-
return 'T';
|
1197 |
-
}
|
1198 |
-
return 'F';
|
1199 |
-
}
|
1200 |
-
|
1201 |
-
wp_die();
|
1202 |
-
}
|
1203 |
-
|
1204 |
-
public function save_gallery()
|
1205 |
-
{
|
1206 |
-
|
1207 |
-
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
1208 |
-
$galleryName = ( isset( $_POST['ftg_name'] ) ? wp_kses_post( wp_unslash( $_POST['ftg_name'] ) ) : '' );
|
1209 |
-
$galleryDescription = ( isset( $_POST['ftg_description'] ) ? wp_kses_post( wp_unslash( $_POST['ftg_description'] ) ) : '' );
|
1210 |
-
$slug = strtolower( str_replace( " ", "", $galleryName ) );
|
1211 |
-
$margin = ( isset( $_POST['ftg_margin'] ) ? absint( $_POST['ftg_margin'] ) : '' );
|
1212 |
-
$minTileWidth = ( isset( $_POST['ftg_minTileWidth'] ) ? absint( $_POST['ftg_minTileWidth'] ) : '' );
|
1213 |
-
$gridCellSize = ( isset( $_POST['ftg_gridCellSize'] ) ? absint( $_POST['ftg_gridCellSize'] ) : '' );
|
1214 |
-
$imagesOrder = ( isset( $_POST['ftg_imagesOrder'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_imagesOrder'] ) ) : '' );
|
1215 |
-
$width = ( isset( $_POST['ftg_width'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_width'] ) ) : '' );
|
1216 |
-
$enableTwitter = $this->checkboxVal( 'ftg_enableTwitter' );
|
1217 |
-
$filterClick = $this->checkboxVal( 'ftg_filterClick' );
|
1218 |
-
$enableFacebook = $this->checkboxVal( 'ftg_enableFacebook' );
|
1219 |
-
$enablePinterest = $this->checkboxVal( 'ftg_enablePinterest' );
|
1220 |
-
$lightbox = ( isset( $_POST['ftg_lightbox'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_lightbox'] ) ) : '' );
|
1221 |
-
$mobileLightbox = ( isset( $_POST['ftg_mobileLightbox'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_mobileLightbox'] ) ) : '' );
|
1222 |
-
$blank = $this->checkboxVal( 'ftg_blank' );
|
1223 |
-
$filters = ( isset( $_POST['ftg_filters'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_filters'] ) ) : '' );
|
1224 |
-
$scrollEffect = ( isset( $_POST['ftg_scrollEffect'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_scrollEffect'] ) ) : '' );
|
1225 |
-
$captionBehavior = ( isset( $_POST['ftg_captionBehavior'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_captionBehavior'] ) ) : '' );
|
1226 |
-
$captionMobileBehavior = ( isset( $_POST['ftg_captionMobileBehavior'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_captionMobileBehavior'] ) ) : '' );
|
1227 |
-
$captionEffect = ( isset( $_POST['ftg_captionEffect'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_captionEffect'] ) ) : '' );
|
1228 |
-
$captionColor = ( isset( $_POST['ftg_captionColor'] ) ? sanitize_hex_color( wp_unslash( $_POST['ftg_captionColor'] ) ) : '' );
|
1229 |
-
$captionBackgroundColor = ( isset( $_POST['ftg_captionBackgroundColor'] ) ? sanitize_hex_color( wp_unslash( $_POST['ftg_captionBackgroundColor'] ) ) : '' );
|
1230 |
-
$captionEasing = ( isset( $_POST['ftg_captionEasing'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_captionEasing'] ) ) : '' );
|
1231 |
-
$captionHorizontalAlignment = ( isset( $_POST['ftg_captionHorizontalAlignment'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_captionHorizontalAlignment'] ) ) : '' );
|
1232 |
-
$captionVerticalAlignment = ( isset( $_POST['ftg_captionVerticalAlignment'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_captionVerticalAlignment'] ) ) : '' );
|
1233 |
-
$captionEmpty = ( isset( $_POST['ftg_captionEmpty'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_captionEmpty'] ) ) : '' );
|
1234 |
-
$captionOpacity = ( isset( $_POST['ftg_captionOpacity'] ) ? absint( $_POST['ftg_captionOpacity'] ) : '' );
|
1235 |
-
$borderSize = ( isset( $_POST['ftg_borderSize'] ) ? absint( $_POST['ftg_borderSize'] ) : '' );
|
1236 |
-
$borderColor = ( isset( $_POST['ftg_borderColor'] ) ? sanitize_hex_color( wp_unslash( $_POST['ftg_borderColor'] ) ) : '' );
|
1237 |
-
$titleFontSize = ( isset( $_POST['ftg_titleFontSize'] ) ? absint( $_POST['ftg_titleFontSize'] ) : '' );
|
1238 |
-
$loadingBarColor = ( isset( $_POST['ftg_loadingBarColor'] ) ? sanitize_hex_color( wp_unslash( $_POST['ftg_loadingBarColor'] ) ) : '' );
|
1239 |
-
$loadingBarBackgroundColor = ( isset( $_POST['ftg_loadingBarBackgroundColor'] ) ? sanitize_hex_color( wp_unslash( $_POST['ftg_loadingBarBackgroundColor'] ) ) : '' );
|
1240 |
-
$borderRadius = ( isset( $_POST['ftg_borderRadius'] ) ? absint( $_POST['ftg_borderRadius'] ) : '' );
|
1241 |
-
$allFilterLabel = ( isset( $_POST['ftg_allFilterLabel'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_allFilterLabel'] ) ) : '' );
|
1242 |
-
$shadowColor = ( isset( $_POST['ftg_shadowColor'] ) ? sanitize_hex_color( wp_unslash( $_POST['ftg_shadowColor'] ) ) : '' );
|
1243 |
-
$shadowSize = ( isset( $_POST['ftg_shadowSize'] ) ? absint( $_POST['ftg_shadowSize'] ) : '' );
|
1244 |
-
$enlargeImages = $this->checkboxVal( 'ftg_enlargeImages' );
|
1245 |
-
$wp_field_caption = ( isset( $_POST['ftg_wp_field_caption'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_wp_field_caption'] ) ) : '' );
|
1246 |
-
$wp_field_title = ( isset( $_POST['ftg_wp_field_title'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_wp_field_title'] ) ) : '' );
|
1247 |
-
$style = ( isset( $_POST['ftg_style'] ) ? sanitize_textarea_field( wp_unslash( $_POST['ftg_style'] ) ) : '' );
|
1248 |
-
$script = ( isset( $_POST['ftg_script'] ) ? sanitize_textarea_field( wp_unslash( $_POST['ftg_script'] ) ) : '' );
|
1249 |
-
$loadedHSlide = ( isset( $_POST['ftg_loadedHSlide'] ) ? intval( wp_unslash( $_POST['ftg_loadedHSlide'] ) ) : '' );
|
1250 |
-
$loadedVSlide = ( isset( $_POST['ftg_loadedVSlide'] ) ? intval( wp_unslash( $_POST['ftg_loadedVSlide'] ) ) : '' );
|
1251 |
-
$captionEffectDuration = ( isset( $_POST['ftg_captionEffectDuration'] ) ? absint( $_POST['ftg_captionEffectDuration'] ) : 250 );
|
1252 |
-
$id = ( isset( $_POST['ftg_gallery_edit'] ) ? absint( $_POST['ftg_gallery_edit'] ) : 0 );
|
1253 |
-
$data = array(
|
1254 |
-
'ajaxLoading' => ( isset( $_POST['ftg_ajaxLoading'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_ajaxLoading'] ) ) : '' ),
|
1255 |
-
'layout' => ( isset( $_POST['ftg_layout'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_layout'] ) ) : '' ),
|
1256 |
-
'name' => $galleryName,
|
1257 |
-
'slug' => $slug,
|
1258 |
-
'description' => $galleryDescription,
|
1259 |
-
'lightbox' => $lightbox,
|
1260 |
-
'lightboxOptions' => ( isset( $_POST['ftg_lightboxOptions'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_lightboxOptions'] ) ) : '' ),
|
1261 |
-
'lightboxOptionsMobile' => ( isset( $_POST['lightboxOptionsMobile'] ) ? sanitize_text_field( wp_unslash( $_POST['lightboxOptionsMobile'] ) ) : '' ),
|
1262 |
-
'mobileLightbox' => $mobileLightbox,
|
1263 |
-
'lightboxImageSize' => ( isset( $_POST['ftg_lightboxImageSize'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_lightboxImageSize'] ) ) : '' ),
|
1264 |
-
'blank' => $blank,
|
1265 |
-
'margin' => $margin,
|
1266 |
-
'allFilterLabel' => $allFilterLabel,
|
1267 |
-
'minTileWidth' => $minTileWidth,
|
1268 |
-
'gridCellSize' => $gridCellSize,
|
1269 |
-
'gridCellSizeDisabledBelow' => ( isset( $_POST['ftg_gridCellSizeDisabledBelow'] ) ? absint( $_POST['ftg_gridCellSizeDisabledBelow'] ) : '' ),
|
1270 |
-
'enableTwitter' => $enableTwitter,
|
1271 |
-
'backgroundColor' => ( isset( $_POST['ftg_backgroundColor'] ) ? sanitize_hex_color( wp_unslash( $_POST['ftg_backgroundColor'] ) ) : '' ),
|
1272 |
-
'filterClick' => $filterClick,
|
1273 |
-
'disableLightboxGroups' => $this->checkboxVal( 'ftg_disableLightboxGroups' ),
|
1274 |
-
'defaultFilter' => ( isset( $_POST['ftg_filterDef'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_filterDef'] ) ) : '' ),
|
1275 |
-
'enableFacebook' => $enableFacebook,
|
1276 |
-
'enablePinterest' => $enablePinterest,
|
1277 |
-
'imagesOrder' => $imagesOrder,
|
1278 |
-
'compressHTML' => $this->checkboxVal( 'ftg_compressHTML' ),
|
1279 |
-
'loadMethod' => ( isset( $_POST['ftg_loadMethod'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_loadMethod'] ) ) : '' ),
|
1280 |
-
'socialIconColor' => ( isset( $_POST['ftg_socialIconColor'] ) ? sanitize_hex_color( wp_unslash( $_POST['ftg_socialIconColor'] ) ) : '' ),
|
1281 |
-
'socialIconPosition' => ( isset( $_POST['ftg_socialIconPosition'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_socialIconPosition'] ) ) : '' ),
|
1282 |
-
'socialIconStyle' => ( isset( $_POST['ftg_socialIconStyle'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_socialIconStyle'] ) ) : '' ),
|
1283 |
-
'recentPostsCaption' => ( isset( $_POST['ftg_recentPostsCaption'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_recentPostsCaption'] ) ) : '' ),
|
1284 |
-
'recentPostsCaptionAutoExcerptLength' => ( isset( $_POST['ftg_recentPostsCaptionAutoExcerptLength'] ) ? intval( wp_unslash( $_POST['ftg_recentPostsCaptionAutoExcerptLength'] ) ) : '' ),
|
1285 |
-
'captionBehavior' => $captionBehavior,
|
1286 |
-
'captionEffect' => $captionEffect,
|
1287 |
-
'captionEmpty' => $captionEmpty,
|
1288 |
-
'captionBackgroundColor' => $captionBackgroundColor,
|
1289 |
-
'captionColor' => $captionColor,
|
1290 |
-
'captionCustomFields' => ( isset( $_POST['ftg_captionCustomFields'] ) ? wp_kses_post( wp_unslash( $_POST['ftg_captionCustomFields'] ) ) : '' ),
|
1291 |
-
'captionFrameColor' => ( isset( $_POST['ftg_captionFrameColor'] ) ? sanitize_hex_color( wp_unslash( $_POST['ftg_captionFrameColor'] ) ) : '' ),
|
1292 |
-
'captionEffectDuration' => $captionEffectDuration,
|
1293 |
-
'captionEasing' => $captionEasing,
|
1294 |
-
'captionVerticalAlignment' => $captionVerticalAlignment,
|
1295 |
-
'captionHorizontalAlignment' => $captionHorizontalAlignment,
|
1296 |
-
'captionMobileBehavior' => $captionMobileBehavior,
|
1297 |
-
'captionOpacity' => $captionOpacity,
|
1298 |
-
'captionIcon' => ( isset( $_POST['ftg_captionIcon'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_captionIcon'] ) ) : '' ),
|
1299 |
-
'captionFrame' => $this->checkboxVal( 'ftg_captionFrame' ),
|
1300 |
-
'customCaptionIcon' => ( isset( $_POST['ftg_customCaptionIcon'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_customCaptionIcon'] ) ) : '' ),
|
1301 |
-
'captionIconColor' => ( isset( $_POST['ftg_captionIconColor'] ) ? sanitize_hex_color( wp_unslash( $_POST['ftg_captionIconColor'] ) ) : '' ),
|
1302 |
-
'captionIconSize' => ( isset( $_POST['ftg_captionIconSize'] ) ? absint( $_POST['ftg_captionIconSize'] ) : '' ),
|
1303 |
-
'captionFontSize' => ( isset( $_POST['ftg_captionFontSize'] ) ? absint( $_POST['ftg_captionFontSize'] ) : '' ),
|
1304 |
-
'captionPosition' => ( isset( $_POST['ftg_captionPosition'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_captionPosition'] ) ) : '' ),
|
1305 |
-
'titleFontSize' => ( isset( $_POST['ftg_titleFontSize'] ) ? absint( $_POST['ftg_titleFontSize'] ) : '' ),
|
1306 |
-
'hoverZoom' => ( isset( $_POST['ftg_hoverZoom'] ) ? absint( $_POST['ftg_hoverZoom'] ) : '' ),
|
1307 |
-
'hoverRotation' => ( isset( $_POST['ftg_hoverRotation'] ) ? intval( wp_unslash( $_POST['ftg_hoverRotation'] ) ) : '' ),
|
1308 |
-
'hoverDuration' => ( isset( $_POST['ftg_hoverDuration'] ) ? intval( wp_unslash( $_POST['ftg_hoverDuration'] ) ) : '' ),
|
1309 |
-
'hoverIconRotation' => $this->checkboxVal( 'ftg_hoverIconRotation' ),
|
1310 |
-
'filters' => $filters,
|
1311 |
-
'wp_field_caption' => $wp_field_caption,
|
1312 |
-
'wp_field_title' => $wp_field_title,
|
1313 |
-
'borderSize' => $borderSize,
|
1314 |
-
'borderColor' => $borderColor,
|
1315 |
-
'loadingBarColor' => $loadingBarColor,
|
1316 |
-
'loadingBarBackgroundColor' => $loadingBarBackgroundColor,
|
1317 |
-
'enlargeImages' => $enlargeImages,
|
1318 |
-
'borderRadius' => $borderRadius,
|
1319 |
-
'imageSizeFactor' => ( isset( $_POST['ftg_imageSizeFactor'] ) ? absint( $_POST['ftg_imageSizeFactor'] ) : '' ),
|
1320 |
-
'imageSizeFactorTabletLandscape' => ( isset( $_POST['ftg_imageSizeFactorTabletLandscape'] ) ? absint( $_POST['ftg_imageSizeFactorTabletLandscape'] ) : '' ),
|
1321 |
-
'imageSizeFactorTabletPortrait' => ( isset( $_POST['ftg_imageSizeFactorTabletPortrait'] ) ? absint( $_POST['ftg_imageSizeFactorTabletPortrait'] ) : '' ),
|
1322 |
-
'imageSizeFactorPhoneLandscape' => ( isset( $_POST['ftg_imageSizeFactorPhoneLandscape'] ) ? absint( $_POST['ftg_imageSizeFactorPhoneLandscape'] ) : '' ),
|
1323 |
-
'imageSizeFactorPhonePortrait' => ( isset( $_POST['ftg_imageSizeFactorPhonePortrait'] ) ? absint( $_POST['ftg_imageSizeFactorPhonePortrait'] ) : '' ),
|
1324 |
-
'imageSizeFactorCustom' => ( isset( $_POST['ftg_imageSizeFactorCustom'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_imageSizeFactorCustom'] ) ) : '' ),
|
1325 |
-
'taxonomyAsFilter' => ( isset( $_POST['ftg_taxonomyAsFilter'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_taxonomyAsFilter'] ) ) : '' ),
|
1326 |
-
'columns' => ( isset( $_POST['ftg_columns'] ) ? intval( wp_unslash( $_POST['ftg_columns'] ) ) : '' ),
|
1327 |
-
'columnsTabletLandscape' => ( isset( $_POST['ftg_columnsTabletLandscape'] ) ? absint( $_POST['ftg_columnsTabletLandscape'] ) : '' ),
|
1328 |
-
'columnsTabletPortrait' => ( isset( $_POST['ftg_columnsTabletPortrait'] ) ? absint( $_POST['ftg_columnsTabletPortrait'] ) : '' ),
|
1329 |
-
'columnsPhoneLandscape' => ( isset( $_POST['ftg_columnsPhoneLandscape'] ) ? absint( $_POST['ftg_columnsPhoneLandscape'] ) : '' ),
|
1330 |
-
'columnsPhonePortrait' => ( isset( $_POST['ftg_columnsPhonePortrait'] ) ? absint( $_POST['ftg_columnsPhonePortrait'] ) : '' ),
|
1331 |
-
'max_posts' => ( isset( $_POST['ftg_max_posts'] ) ? absint( $_POST['ftg_max_posts'] ) : '' ),
|
1332 |
-
'shadowSize' => $shadowSize,
|
1333 |
-
'shadowColor' => $shadowColor,
|
1334 |
-
'source' => ( isset( $_POST['ftg_source'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_source'] ) ) : '' ),
|
1335 |
-
'post_types' => ( isset( $_POST['ftg_post_types'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_post_types'] ) ) : '' ),
|
1336 |
-
'post_taxonomies' => ( isset( $_POST['ftg_post_taxonomies'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_post_taxonomies'] ) ) : '' ),
|
1337 |
-
'taxonomyOperator' => ( isset( $_POST['ftg_taxonomyOperator'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_taxonomyOperator'] ) ) : '' ),
|
1338 |
-
'post_tags' => ( isset( $_POST['ftg_post_tags'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_post_tags'] ) ) : '' ),
|
1339 |
-
'tilesPerPage' => ( isset( $_POST['ftg_tilesPerPage'] ) ? absint( $_POST['ftg_tilesPerPage'] ) : '' ),
|
1340 |
-
'woo_categories' => ( isset( $_POST['ftg_woo_categories'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_woo_categories'] ) ) : '' ),
|
1341 |
-
'defaultPostImageSize' => ( isset( $_POST['ftg_defaultPostImageSize'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_defaultPostImageSize'] ) ) : '' ),
|
1342 |
-
'defaultWooImageSize' => ( isset( $_POST['ftg_defaultWooImageSize'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_defaultWooImageSize'] ) ) : '' ),
|
1343 |
-
'width' => $width,
|
1344 |
-
'beforeGalleryText' => ( isset( $_POST['ftg_beforeGalleryText'] ) ? wp_kses_post( wp_unslash( $_POST['ftg_beforeGalleryText'] ) ) : '' ),
|
1345 |
-
'afterGalleryText' => ( isset( $_POST['ftg_afterGalleryText'] ) ? wp_kses_post( wp_unslash( $_POST['ftg_afterGalleryText'] ) ) : '' ),
|
1346 |
-
'aClass' => ( isset( $_POST['ftg_aClass'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_aClass'] ) ) : '' ),
|
1347 |
-
'rel' => ( isset( $_POST['ftg_rel'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_rel'] ) ) : '' ),
|
1348 |
-
'style' => $style,
|
1349 |
-
'delay' => ( isset( $_POST['ftg_delay'] ) ? absint( $_POST['ftg_delay'] ) : '' ),
|
1350 |
-
'script' => $script,
|
1351 |
-
'support' => $this->checkboxVal( 'ftg_support' ),
|
1352 |
-
'supportText' => ( isset( $_POST['ftg_supportText'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_supportText'] ) ) : '' ),
|
1353 |
-
'scrollEffect' => $scrollEffect,
|
1354 |
-
'loadedScaleY' => ( isset( $_POST['ftg_loadedScaleY'] ) ? absint( $_POST['ftg_loadedScaleY'] ) : '' ),
|
1355 |
-
'loadedScaleX' => ( isset( $_POST['ftg_loadedScaleX'] ) ? absint( $_POST['ftg_loadedScaleX'] ) : '' ),
|
1356 |
-
'loadedHSlide' => $loadedHSlide,
|
1357 |
-
'loadedVSlide' => $loadedVSlide,
|
1358 |
-
'loadedEasing' => ( isset( $_POST['ftg_loadedEasing'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_loadedEasing'] ) ) : '' ),
|
1359 |
-
'loadedDuration' => ( isset( $_POST['ftg_loadedDuration'] ) ? absint( $_POST['ftg_loadedDuration'] ) : '' ),
|
1360 |
-
'loadedRotateY' => ( isset( $_POST['ftg_loadedRotateY'] ) ? intval( wp_unslash( $_POST['ftg_loadedRotateY'] ) ) : '' ),
|
1361 |
-
'loadedRotateX' => ( isset( $_POST['ftg_loadedRotateX'] ) ? intval( wp_unslash( $_POST['ftg_loadedRotateX'] ) ) : '' ),
|
1362 |
-
);
|
1363 |
-
header( "Content-type: application/json" );
|
1364 |
-
|
1365 |
-
if ( $id > 0 ) {
|
1366 |
-
$result = $this->FinalTilesdb->editGallery( $id, $data );
|
1367 |
-
} else {
|
1368 |
-
$result = $this->FinalTilesdb->addGallery( $data );
|
1369 |
-
$id = $this->FinalTilesdb->getNewGalleryId();
|
1370 |
-
}
|
1371 |
-
|
1372 |
-
|
1373 |
-
if ( $result ) {
|
1374 |
-
echo "{\"success\":true,\"id\":" . absint( $id ) . "}" ;
|
1375 |
-
} else {
|
1376 |
-
echo "{\"success\":false}" ;
|
1377 |
-
}
|
1378 |
-
|
1379 |
-
}
|
1380 |
-
|
1381 |
-
wp_die();
|
1382 |
-
}
|
1383 |
-
|
1384 |
-
public static function get_image_size_links( $id )
|
1385 |
-
{
|
1386 |
-
$result = array();
|
1387 |
-
$sizes = get_intermediate_image_sizes();
|
1388 |
-
$sizes[] = 'full';
|
1389 |
-
foreach ( $sizes as $size ) {
|
1390 |
-
$image = wp_get_attachment_image_src( $id, $size );
|
1391 |
-
if ( !empty($image) && (true == $image[3] || 'full' == $size) ) {
|
1392 |
-
$result["{$image[1]}x{$image[2]}"] = $image[0];
|
1393 |
-
}
|
1394 |
-
}
|
1395 |
-
ksort( $result );
|
1396 |
-
return $result;
|
1397 |
-
}
|
1398 |
-
|
1399 |
-
//Create gallery
|
1400 |
-
public function create_gallery( $attrs )
|
1401 |
-
{
|
1402 |
-
require_once 'lib/gallery-class.php';
|
1403 |
-
global $FinalTilesGallery ;
|
1404 |
-
$galleryId = $attrs['id'];
|
1405 |
-
|
1406 |
-
if ( class_exists( 'FinalTilesGallery' ) ) {
|
1407 |
-
$FinalTilesGallery = new FinalTilesGallery(
|
1408 |
-
$galleryId,
|
1409 |
-
$this->FinalTilesdb,
|
1410 |
-
$this->defaultValues,
|
1411 |
-
$attrs
|
1412 |
-
);
|
1413 |
-
$settings = $FinalTilesGallery->getGallery();
|
1414 |
-
|
1415 |
-
if ( $settings != null ) {
|
1416 |
-
switch ( $settings->lightbox ) {
|
1417 |
-
case "magnific":
|
1418 |
-
wp_enqueue_style( 'magnific_stylesheet' );
|
1419 |
-
wp_enqueue_script( 'magnific_script' );
|
1420 |
-
break;
|
1421 |
-
case "prettyphoto":
|
1422 |
-
wp_enqueue_style( 'prettyphoto_stylesheet' );
|
1423 |
-
wp_enqueue_script( 'prettyphoto_script' );
|
1424 |
-
break;
|
1425 |
-
case "fancybox":
|
1426 |
-
wp_enqueue_style( 'fancybox_stylesheet' );
|
1427 |
-
wp_enqueue_script( 'fancybox_script' );
|
1428 |
-
break;
|
1429 |
-
case "colorbox":
|
1430 |
-
wp_enqueue_style( 'colorbox_stylesheet' );
|
1431 |
-
wp_enqueue_script( 'colorbox_script' );
|
1432 |
-
break;
|
1433 |
-
case "swipebox":
|
1434 |
-
wp_enqueue_style( 'swipebox_stylesheet' );
|
1435 |
-
wp_enqueue_script( 'swipebox_script' );
|
1436 |
-
break;
|
1437 |
-
case "lightbox2":
|
1438 |
-
wp_enqueue_style( 'lightbox2_stylesheet' );
|
1439 |
-
wp_enqueue_script( 'lightbox2_script' );
|
1440 |
-
break;
|
1441 |
-
case "image-lightbox":
|
1442 |
-
wp_enqueue_script( 'image-lightbox_script' );
|
1443 |
-
break;
|
1444 |
-
case "lightgallery":
|
1445 |
-
wp_enqueue_style( 'lightgallery_stylesheet' );
|
1446 |
-
wp_enqueue_script( 'lightgallery_script' );
|
1447 |
-
break;
|
1448 |
-
}
|
1449 |
-
switch ( $settings->mobileLightbox ) {
|
1450 |
-
default:
|
1451 |
-
case "magnific":
|
1452 |
-
wp_enqueue_style( 'magnific_stylesheet' );
|
1453 |
-
wp_enqueue_script( 'magnific_script' );
|
1454 |
-
break;
|
1455 |
-
case "prettyphoto":
|
1456 |
-
wp_enqueue_style( 'prettyphoto_stylesheet' );
|
1457 |
-
wp_enqueue_script( 'prettyphoto_script' );
|
1458 |
-
break;
|
1459 |
-
case "fancybox":
|
1460 |
-
wp_enqueue_style( 'fancybox_stylesheet' );
|
1461 |
-
wp_enqueue_script( 'fancybox_script' );
|
1462 |
-
break;
|
1463 |
-
case "colorbox":
|
1464 |
-
wp_enqueue_style( 'colorbox_stylesheet' );
|
1465 |
-
wp_enqueue_script( 'colorbox_script' );
|
1466 |
-
break;
|
1467 |
-
case "swipebox":
|
1468 |
-
wp_enqueue_style( 'swipebox_stylesheet' );
|
1469 |
-
wp_enqueue_script( 'swipebox_script' );
|
1470 |
-
break;
|
1471 |
-
case "lightbox2":
|
1472 |
-
wp_enqueue_style( 'lightbox2_stylesheet' );
|
1473 |
-
wp_enqueue_script( 'lightbox2_script' );
|
1474 |
-
break;
|
1475 |
-
case "image-lightbox":
|
1476 |
-
wp_enqueue_script( 'image-lightbox_script' );
|
1477 |
-
case "lightgallery":
|
1478 |
-
wp_enqueue_style( 'lightgallery_stylesheet' );
|
1479 |
-
wp_enqueue_script( 'lightgallery_script' );
|
1480 |
-
break;
|
1481 |
-
}
|
1482 |
-
}
|
1483 |
-
|
1484 |
-
return $FinalTilesGallery->render();
|
1485 |
-
} else {
|
1486 |
-
return __( "Gallery not found.", 'final-tiles-grid-gallery-lite' );
|
1487 |
-
}
|
1488 |
-
|
1489 |
-
}
|
1490 |
-
|
1491 |
-
//Create Short Code
|
1492 |
-
private $photon_removed ;
|
1493 |
-
public function gallery_shortcode_handler( $atts )
|
1494 |
-
{
|
1495 |
-
$this->photon_removed = '';
|
1496 |
-
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
|
1497 |
-
$this->photon_removed = remove_filter( 'image_downsize', array( Jetpack_Photon::instance(), 'filter_image_downsize' ) );
|
1498 |
-
}
|
1499 |
-
return $this->create_gallery( $atts );
|
1500 |
-
//@todo: statement can't be reached. Investigate
|
1501 |
-
if ( $this->photon_removed ) {
|
1502 |
-
add_filter(
|
1503 |
-
'image_downsize',
|
1504 |
-
array( Jetpack_Photon::instance(), 'filter_image_downsize' ),
|
1505 |
-
10,
|
1506 |
-
3
|
1507 |
-
);
|
1508 |
-
}
|
1509 |
-
}
|
1510 |
-
|
1511 |
-
public static function slugify( $text )
|
1512 |
-
{
|
1513 |
-
$text = preg_replace( '~[^\\pL\\d]+~u', '-', $text );
|
1514 |
-
$text = trim( $text, '-' );
|
1515 |
-
if ( function_exists( "iconv" ) ) {
|
1516 |
-
$text = iconv( 'utf-8', 'us-ascii//TRANSLIT', $text );
|
1517 |
-
}
|
1518 |
-
$text = strtolower( $text );
|
1519 |
-
$text = preg_replace( '~[^-\\w]+~', '', $text );
|
1520 |
-
if ( empty($text) ) {
|
1521 |
-
return 'n-a';
|
1522 |
-
}
|
1523 |
-
return $text;
|
1524 |
-
}
|
1525 |
-
|
1526 |
-
public static function getFieldType( $field )
|
1527 |
-
{
|
1528 |
-
return "cta";
|
1529 |
-
}
|
1530 |
-
|
1531 |
-
var $fields = array() ;
|
1532 |
-
private function addField( $section, $field, $data )
|
1533 |
-
{
|
1534 |
-
$this->fields[$section]["fields"][$field] = $data;
|
1535 |
-
}
|
1536 |
-
|
1537 |
-
private function setupFields()
|
1538 |
-
{
|
1539 |
-
include 'admin/include/fields.php';
|
1540 |
-
}
|
1541 |
-
|
1542 |
-
}
|
1543 |
-
}
|
1544 |
-
if ( !class_exists( "FinalTilesGalleryUtils" ) ) {
|
1545 |
-
class FinalTilesGalleryUtils
|
1546 |
-
{
|
1547 |
-
public static function shortcodeToFieldName( $string, $capitalizeFirstCharacter = false )
|
1548 |
-
{
|
1549 |
-
$str = str_replace( '-', '\\t', $string );
|
1550 |
-
$str = str_replace( '_', '', ucwords( $str ) );
|
1551 |
-
$str = str_replace( '\\t', '_', $str );
|
1552 |
-
if ( !$capitalizeFirstCharacter ) {
|
1553 |
-
$str = lcfirst( $str );
|
1554 |
-
}
|
1555 |
-
return $str;
|
1556 |
-
}
|
1557 |
-
|
1558 |
-
public static function fieldNameToShortcode( $string )
|
1559 |
-
{
|
1560 |
-
preg_match_all( '!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $string, $matches );
|
1561 |
-
$ret = $matches[0];
|
1562 |
-
foreach ( $ret as &$match ) {
|
1563 |
-
$match = ( $match == strtoupper( $match ) ? strtolower( $match ) : lcfirst( $match ) );
|
1564 |
-
}
|
1565 |
-
return implode( '_', $ret );
|
1566 |
-
}
|
1567 |
-
|
1568 |
-
}
|
1569 |
-
}
|
1570 |
-
|
1571 |
-
if ( class_exists( "FinalTiles_Gallery" ) ) {
|
1572 |
-
global $ob_FinalTiles_Gallery ;
|
1573 |
-
$ob_FinalTiles_Gallery = new FinalTiles_Gallery();
|
1574 |
-
}
|
1575 |
-
|
1576 |
-
|
1577 |
-
if ( !function_exists( "ftg_admin_script" ) ) {
|
1578 |
-
function ftg_admin_script()
|
1579 |
-
{
|
1580 |
-
wp_register_script( 'admin-generic-ftg', plugins_url( 'admin/scripts/admin.js', __FILE__ ), array( 'jquery' ) );
|
1581 |
-
wp_enqueue_script( 'admin-generic-ftg' );
|
1582 |
-
}
|
1583 |
-
|
1584 |
-
add_action( 'admin_enqueue_scripts', 'ftg_admin_script' );
|
1585 |
-
}
|
1586 |
-
|
1587 |
Â
register_activation_hook( __FILE__, 'activate_finaltilesgallery' );
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Plugin Name: Final Tiles Grid Gallery - Image Gallery
|
5 |
+
* Description: Wordpress Plugin for creating responsive image galleries.
|
6 |
+
* Version: 3.5.5
|
7 |
+
* Author: WPChill
|
8 |
+
* Author URI: https://wpchill.com
|
9 |
+
* Tested up to: 5.8
|
10 |
+
* Requires: 5.2 or higher
|
11 |
+
* License: GPLv3 or later
|
12 |
+
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
13 |
+
* Requires PHP: 5.6
|
14 |
+
* Text Domain: final-tiles-grid-gallery-lite
|
15 |
+
* Domain Path: /languages
|
16 |
+
*
|
17 |
+
* Copyright 2015-2019 GreenTreeLabs diego@greentreelabs.net
|
18 |
+
* Copyright 2019-2020 MachoThemes office@machothemes.com
|
19 |
+
* SVN commit with proof of ownership transfer: https://plugins.trac.wordpress.org/changeset/2163481/
|
20 |
+
* NOTE: MachoThemes took ownership of this plugin on: 09/26/2019 08:49:37 AM as can be seen from the above SVN commit.
|
21 |
+
* Copyright 2020 WPChill heyyy@wpchill.com
|
22 |
+
*
|
23 |
+
* Original Plugin URI: https://greentreelabs.net/final-tiles-gallery-lite/
|
24 |
+
* Original Author URI: https://greentreelabs.net
|
25 |
+
* Original Author: https://profiles.wordpress.org/greentreealbs/
|
26 |
+
*
|
27 |
+
*/
|
28 |
+
define( "FTGVERSION", "3.5.5" );
|
29 |
+
// Create a helper function for easy SDK access.
|
30 |
+
|
31 |
+
if ( !function_exists( 'ftg_fs' ) ) {
|
32 |
+
// Create a helper function for easy SDK access.
|
33 |
+
function ftg_fs()
|
34 |
+
{
|
35 |
+
global $ftg_fs ;
|
36 |
+
|
37 |
+
if ( !isset( $ftg_fs ) ) {
|
38 |
+
// Activate multisite network integration.
|
39 |
+
if ( !defined( 'WP_FS__PRODUCT_1002_MULTISITE' ) ) {
|
40 |
+
define( 'WP_FS__PRODUCT_1002_MULTISITE', true );
|
41 |
+
}
|
42 |
+
// Include Freemius SDK.
|
43 |
+
require_once dirname( __FILE__ ) . '/freemius/start.php';
|
44 |
+
$ftg_fs = fs_dynamic_init( array(
|
45 |
+
'id' => '1002',
|
46 |
+
'slug' => 'final-tiles-grid-gallery-lite',
|
47 |
+
'type' => 'plugin',
|
48 |
+
'public_key' => 'pk_d0e075b84d491d510a1d0a21087af',
|
49 |
+
'is_premium' => false,
|
50 |
+
'has_addons' => false,
|
51 |
+
'has_paid_plans' => true,
|
52 |
+
'trial' => array(
|
53 |
+
'days' => 14,
|
54 |
+
'is_require_payment' => true,
|
55 |
+
),
|
56 |
+
'has_affiliation' => 'all',
|
57 |
+
'menu' => array(
|
58 |
+
'slug' => 'ftg-lite-gallery-admin',
|
59 |
+
),
|
60 |
+
'is_live' => true,
|
61 |
+
) );
|
62 |
+
}
|
63 |
+
|
64 |
+
return $ftg_fs;
|
65 |
+
}
|
66 |
+
|
67 |
+
// Init Freemius.
|
68 |
+
ftg_fs();
|
69 |
+
// Signal that SDK was initiated.
|
70 |
+
do_action( 'ftg_fs_loaded' );
|
71 |
+
}
|
72 |
+
|
73 |
+
function activate_finaltilesgallery()
|
74 |
+
{
|
75 |
+
global $wpdb ;
|
76 |
+
include_once 'lib/install-db.php';
|
77 |
+
FinalTiles_Gallery::define_db_tables();
|
78 |
+
FinalTilesdb::updateConfiguration();
|
79 |
+
|
80 |
+
if ( is_multisite() ) {
|
81 |
+
foreach ( $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" ) as $blog_id ) {
|
82 |
+
switch_to_blog( $blog_id );
|
83 |
+
install_db();
|
84 |
+
restore_current_blog();
|
85 |
+
}
|
86 |
+
} else {
|
87 |
+
install_db();
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
define( "FTG_PLAN", "free" );
|
93 |
+
if ( !class_exists( 'FinalTiles_Gallery' ) ) {
|
94 |
+
class FinalTiles_Gallery
|
95 |
+
{
|
96 |
+
private $defaultValues = array(
|
97 |
+
'aClass' => '',
|
98 |
+
'afterGalleryText' => '',
|
99 |
+
'allFilterLabel' => 'All',
|
100 |
+
'ajaxLoading' => 'F',
|
101 |
+
'backgroundColor' => 'transparent',
|
102 |
+
'beforeGalleryText' => '',
|
103 |
+
'blank' => 'F',
|
104 |
+
'borderColor' => 'transparent',
|
105 |
+
'borderRadius' => 0,
|
106 |
+
'borderSize' => 0,
|
107 |
+
'captionBackgroundColor' => '#000000',
|
108 |
+
'captionBehavior' => 'none',
|
109 |
+
'captionColor' => '#ffffff',
|
110 |
+
'captionCustomFields' => '',
|
111 |
+
'captionEasing' => 'linear',
|
112 |
+
'captionEffect' => 'slide-from-bottom',
|
113 |
+
'captionEffectDuration' => 250,
|
114 |
+
'captionEmpty' => 'hide',
|
115 |
+
'captionFontSize' => 12,
|
116 |
+
'captionFrame' => 'F',
|
117 |
+
'captionFrameColor' => '#ffffff',
|
118 |
+
'captionHorizontalAlignment' => 'center',
|
119 |
+
'captionIcon' => 'zoom',
|
120 |
+
'captionIconColor' => '#ffffff',
|
121 |
+
'captionIconSize' => 12,
|
122 |
+
'captionMobileBehavior' => "desktop",
|
123 |
+
'captionOpacity' => 80,
|
124 |
+
'captionPosition' => 'inside',
|
125 |
+
'captionVerticalAlignment' => 'middle',
|
126 |
+
'categoriesAsFilters' => 'F',
|
127 |
+
'columns' => 4,
|
128 |
+
'columnsPhoneLandscape' => 3,
|
129 |
+
'columnsPhonePortrait' => 2,
|
130 |
+
'columnsTabletLandscape' => 4,
|
131 |
+
'columnsTabletPortrait' => 3,
|
132 |
+
'compressHTML' => 'T',
|
133 |
+
'customCaptionIcon' => '',
|
134 |
+
'defaultFilter' => '',
|
135 |
+
'defaultSize' => 'medium',
|
136 |
+
'delay' => 0,
|
137 |
+
'disableLightboxGroups' => 'F',
|
138 |
+
'enableFacebook' => 'F',
|
139 |
+
'enablePinterest' => 'F',
|
140 |
+
'enableTwitter' => 'F',
|
141 |
+
'enlargeImages' => 'T',
|
142 |
+
'filterClick' => 'F',
|
143 |
+
'filters' => '',
|
144 |
+
'gridCellSize' => 25,
|
145 |
+
'gridCellSizeDisabledBelow' => 800,
|
146 |
+
'hoverDuration' => 250,
|
147 |
+
'hoverIconRotation' => 'F',
|
148 |
+
'hoverRotation' => 0,
|
149 |
+
'hoverZoom' => 100,
|
150 |
+
'imageSizeFactor' => 30,
|
151 |
+
'imageSizeFactorCustom' => '',
|
152 |
+
'imageSizeFactorPhoneLandscape' => 30,
|
153 |
+
'imageSizeFactorPhonePortrait' => 20,
|
154 |
+
'imageSizeFactorTabletLandscape' => 30,
|
155 |
+
'imageSizeFactorTabletPortrait' => 20,
|
156 |
+
'imagesOrder' => 'user',
|
157 |
+
'layout' => 'final',
|
158 |
+
'lazyLoad' => false,
|
159 |
+
'lightbox' => 'lightbox2',
|
160 |
+
'lightboxImageSize' => 'large',
|
161 |
+
'lightboxOptions' => '',
|
162 |
+
'lightboxOptionsMobile' => '',
|
163 |
+
'loadedDuration' => 500,
|
164 |
+
'loadedEasing' => 'ease-out',
|
165 |
+
'loadedHSlide' => 0,
|
166 |
+
'loadedRotateY' => 0,
|
167 |
+
'loadedRotateX' => 0,
|
168 |
+
'loadedScaleY' => 100,
|
169 |
+
'loadedScaleX' => 100,
|
170 |
+
'loadedVSlide' => 0,
|
171 |
+
'loadingBarBackgroundColor' => "#fff",
|
172 |
+
'loadingBarColor' => "#666",
|
173 |
+
'loadMethod' => 'sequential',
|
174 |
+
'margin' => 10,
|
175 |
+
'max_posts' => 0,
|
176 |
+
'minTileWidth' => '250',
|
177 |
+
'mobileLightbox' => 'lightbox2',
|
178 |
+
'post_types' => '',
|
179 |
+
'post_taxonomies' => '',
|
180 |
+
'recentPostsCaption' => 'title',
|
181 |
+
'recentPostsCaptionAutoExcerptLength' => 20,
|
182 |
+
'rel' => '',
|
183 |
+
'reverseOrder' => false,
|
184 |
+
'script' => '',
|
185 |
+
'shadowColor' => '#cccccc',
|
186 |
+
'shadowSize' => 0,
|
187 |
+
'socialIconColor' => '#ffffff',
|
188 |
+
'socialIconPosition' => 'bottom',
|
189 |
+
'socialIconStyle' => 'none',
|
190 |
+
'source' => 'images',
|
191 |
+
'style' => '',
|
192 |
+
'support' => 'F',
|
193 |
+
'supportText' => 'Powered by Final Tiles Grid Gallery',
|
194 |
+
'taxonomyOperator' => 'OR',
|
195 |
+
'tilesPerPage' => 0,
|
196 |
+
'titleFontSize' => 14,
|
197 |
+
'width' => '100%',
|
198 |
+
'wp_field_caption' => 'description',
|
199 |
+
'wp_field_title' => 'title',
|
200 |
+
) ;
|
201 |
+
//Constructor
|
202 |
+
public function __construct()
|
203 |
+
{
|
204 |
+
$this->plugin_name = plugin_basename( __FILE__ );
|
205 |
+
$this->define_constants();
|
206 |
+
$this->setupFields();
|
207 |
+
$this->define_db_tables();
|
208 |
+
$this->FinalTilesdb = $this->create_db_conn();
|
209 |
+
add_filter( 'widget_text', 'do_shortcode' );
|
210 |
+
add_action( 'init', array( $this, 'create_textdomain' ) );
|
211 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'add_gallery_scripts' ) );
|
212 |
+
//add_action( 'admin_init', array($this,'gallery_admin_init') );
|
213 |
+
add_action( 'admin_menu', array( $this, 'add_gallery_admin_menu' ) );
|
214 |
+
add_action( 'init', array( $this, 'register_gutenberg_block' ) );
|
215 |
+
add_shortcode( 'FinalTilesGallery', array( $this, 'gallery_shortcode_handler' ) );
|
216 |
+
add_action( 'wp_ajax_save_gallery', array( $this, 'save_gallery' ) );
|
217 |
+
add_action( 'wp_ajax_add_new_gallery', array( $this, 'add_new_gallery' ) );
|
218 |
+
add_action( 'wp_ajax_delete_gallery', array( $this, 'delete_gallery' ) );
|
219 |
+
add_action( 'wp_ajax_clone_gallery', array( $this, 'clone_gallery' ) );
|
220 |
+
add_action( 'wp_ajax_save_image', array( $this, 'save_image' ) );
|
221 |
+
add_action( 'wp_ajax_add_image', array( $this, 'add_image' ) );
|
222 |
+
add_action( 'wp_ajax_save_video', array( $this, 'save_video' ) );
|
223 |
+
add_action( 'wp_ajax_sort_images', array( $this, 'sort_images' ) );
|
224 |
+
add_action( 'wp_ajax_delete_image', array( $this, 'delete_image' ) );
|
225 |
+
add_action( 'wp_ajax_assign_filters', array( $this, 'assign_filters' ) );
|
226 |
+
add_action( 'wp_ajax_assign_group', array( $this, 'assign_group' ) );
|
227 |
+
add_action( 'wp_ajax_toggle_visibility', array( $this, 'toggle_visibility' ) );
|
228 |
+
add_action( 'wp_ajax_refresh_gallery', array( $this, 'refresh_gallery' ) );
|
229 |
+
add_action( 'wp_ajax_get_gallery_configuration', array( $this, 'get_configuration' ) );
|
230 |
+
add_action( 'wp_ajax_update_gallery_configuration', array( $this, 'update_configuration' ) );
|
231 |
+
add_action( 'wp_ajax_get_image_size_url', array( $this, 'get_image_size_url' ) );
|
232 |
+
add_filter( 'mce_buttons', array( $this, 'editor_button' ) );
|
233 |
+
add_filter( 'mce_external_plugins', array( $this, 'register_editor_plugin' ) );
|
234 |
+
add_action( 'wp_ajax_ftg_shortcode_editor', array( $this, 'ftg_shortcode_editor' ) );
|
235 |
+
add_filter(
|
236 |
+
'plugin_row_meta',
|
237 |
+
array( $this, 'register_links' ),
|
238 |
+
10,
|
239 |
+
2
|
240 |
+
);
|
241 |
+
add_action( 'wp_ajax_load_chunk', array( $this, 'load_chunk' ) );
|
242 |
+
add_action( 'wp_ajax_nopriv_load_chunk', array( $this, 'load_chunk' ) );
|
243 |
+
|
244 |
+
if ( ftg_fs()->is_not_paying() ) {
|
245 |
+
add_action( 'admin_notices', array( $this, 'review' ) );
|
246 |
+
add_action( 'wp_ajax_ftg_dismiss_review', array( $this, 'dismiss_review' ) );
|
247 |
+
add_filter(
|
248 |
+
'admin_footer_text',
|
249 |
+
array( $this, 'admin_footer' ),
|
250 |
+
1,
|
251 |
+
2
|
252 |
+
);
|
253 |
+
}
|
254 |
+
|
255 |
+
$this->resetFields();
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Register Gutenberg Block
|
260 |
+
*/
|
261 |
+
public function register_gutenberg_block()
|
262 |
+
{
|
263 |
+
if ( !function_exists( 'register_block_type' ) ) {
|
264 |
+
// Gutenberg is not active.
|
265 |
+
return;
|
266 |
+
}
|
267 |
+
// Register block js script
|
268 |
+
wp_register_script( 'ftg-gallery-block', plugins_url( 'scripts/gutenberg_block.js', __FILE__ ), array(
|
269 |
+
'wp-blocks',
|
270 |
+
'wp-i18n',
|
271 |
+
'wp-element',
|
272 |
+
'wp-editor',
|
273 |
+
'wp-components'
|
274 |
+
) );
|
275 |
+
// Editor CSS
|
276 |
+
wp_register_style( 'ftg-gallery-block-editor', plugins_url( 'admin/css/gutenberg_block.css', __FILE__ ), array( 'wp-edit-blocks' ) );
|
277 |
+
// Register block
|
278 |
+
register_block_type( 'ftg/gallery', array(
|
279 |
+
'editor_style' => 'ftg-gallery-block-editor',
|
280 |
+
'editor_script' => 'ftg-gallery-block',
|
281 |
+
) );
|
282 |
+
// Set block translation
|
283 |
+
wp_set_script_translations( 'FinalTiles-gallery', 'final-tiles-gallery', dirname( plugin_basename( __FILE__ ) ) . '/lib/languages/' );
|
284 |
+
$galls = [ [
|
285 |
+
'value' => 0,
|
286 |
+
'label' => esc_html__( 'Select gallery', 'final-tiles-grid-gallery-lite' ),
|
287 |
+
] ];
|
288 |
+
$galleries = $this->FinalTilesdb->getGalleries();
|
289 |
+
if ( $galleries ) {
|
290 |
+
foreach ( $galleries as $g ) {
|
291 |
+
$galls[] = [
|
292 |
+
'value' => $g->Id,
|
293 |
+
'label' => $g->name,
|
294 |
+
];
|
295 |
+
}
|
296 |
+
}
|
297 |
+
// send list of galleries to block
|
298 |
+
wp_localize_script( 'ftg-gallery-block', 'ftg_galleries', array(
|
299 |
+
'items' => $galls,
|
300 |
+
'add_new_galler_url' => admin_url( 'admin.php?page=ftg-add-gallery' ),
|
301 |
+
) );
|
302 |
+
}
|
303 |
+
|
304 |
+
public function review()
|
305 |
+
{
|
306 |
+
// Verify that we can do a check for reviews.
|
307 |
+
$review = get_option( 'ftg_review' );
|
308 |
+
$time = time();
|
309 |
+
$load = false;
|
310 |
+
$there_was_review = false;
|
311 |
+
|
312 |
+
if ( !$review ) {
|
313 |
+
$review = array(
|
314 |
+
'time' => $time,
|
315 |
+
'dismissed' => false,
|
316 |
+
);
|
317 |
+
$load = true;
|
318 |
+
$there_was_review = false;
|
319 |
+
} else {
|
320 |
+
// Check if it has been dismissed or not.
|
321 |
+
if ( isset( $review['dismissed'] ) && !$review['dismissed'] && (isset( $review['time'] ) && $review['time'] + DAY_IN_SECONDS <= $time) ) {
|
322 |
+
$load = true;
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
// If we cannot load, return early.
|
327 |
+
if ( !$load ) {
|
328 |
+
return;
|
329 |
+
}
|
330 |
+
// Update the review option now.
|
331 |
+
update_option( 'ftg_review', $review );
|
332 |
+
// Run through optins on the site to see if any have been loaded for more than a week.
|
333 |
+
$valid = false;
|
334 |
+
$galleries = $this->FinalTilesdb->getGalleries();
|
335 |
+
if ( !$galleries ) {
|
336 |
+
return;
|
337 |
+
}
|
338 |
+
$with_date = false;
|
339 |
+
foreach ( $galleries as $gallery ) {
|
340 |
+
if ( !isset( $gallery->date ) ) {
|
341 |
+
continue;
|
342 |
+
}
|
343 |
+
$with_date = true;
|
344 |
+
$data = $gallery->date;
|
345 |
+
// Check the creation date of the local optin. It must be at least one week after.
|
346 |
+
$created = ( isset( $data ) ? strtotime( $data ) + 7 * DAY_IN_SECONDS : false );
|
347 |
+
if ( !$created ) {
|
348 |
+
continue;
|
349 |
+
}
|
350 |
+
|
351 |
+
if ( $created <= $time ) {
|
352 |
+
$valid = true;
|
353 |
+
break;
|
354 |
+
}
|
355 |
+
|
356 |
+
}
|
357 |
+
if ( !$with_date && count( $galleries ) > 0 && !$there_was_review ) {
|
358 |
+
$valid = true;
|
359 |
+
}
|
360 |
+
// If we don't have a valid option yet, return.
|
361 |
+
if ( !$valid ) {
|
362 |
+
return;
|
363 |
+
}
|
364 |
+
// We have a candidate! Output a review message.
|
365 |
+
?>
|
366 |
+
<div class="notice notice-info is-dismissible ftg-review-notice">
|
367 |
+
<p><?php
|
368 |
+
esc_html_e( 'Hey, I noticed you created a photo gallery with Final Tiles - that’s awesome! Would you mind give it a 5-star rating on WordPress to help us spread the word and boost our motivation for new featrues?', 'final-tiles-grid-gallery-lite' );
|
369 |
+
?></p>
|
370 |
+
<p><strong><?php
|
371 |
+
esc_html_e( 'MachoThemes', 'final-tiles-grid-gallery-lite' );
|
372 |
+
?></strong></p>
|
373 |
+
<p>
|
374 |
+
<a href="https://wordpress.org/support/plugin/final-tiles-grid-gallery-lite/reviews/?filter=5#new-post" class="ftg-dismiss-review-notice ftg-review-out" target="_blank" rel="noopener"><?php
|
375 |
+
esc_html_e( 'Ok, you deserve it', 'final-tiles-grid-gallery-lite' );
|
376 |
+
?></a><br>
|
377 |
+
<a href="#" class="ftg-dismiss-review-notice" rel="noopener"><?php
|
378 |
+
esc_html_e( 'Nope, maybe later', 'final-tiles-grid-gallery-lite' );
|
379 |
+
?></a><br>
|
380 |
+
<a href="#" class="ftg-dismiss-review-notice" rel="noopener"><?php
|
381 |
+
esc_html_e( 'I already did', 'final-tiles-grid-gallery-lite' );
|
382 |
+
?></a><br>
|
383 |
+
</p>
|
384 |
+
</div>
|
385 |
+
<script type="text/javascript">
|
386 |
+
jQuery(document).ready( function($) {
|
387 |
+
$(document).on('click', '.ftg-dismiss-review-notice, .ftg-review-notice button', function( event ) {
|
388 |
+
if ( ! $(this).hasClass('ftg-review-out') ) {
|
389 |
+
event.preventDefault();
|
390 |
+
}
|
391 |
+
|
392 |
+
$.post( ajaxurl, {
|
393 |
+
action: 'ftg_dismiss_review'
|
394 |
+
});
|
395 |
+
|
396 |
+
$('.ftg-review-notice').remove();
|
397 |
+
});
|
398 |
+
});
|
399 |
+
</script>
|
400 |
+
<?php
|
401 |
+
}
|
402 |
+
|
403 |
+
public function dismiss_review()
|
404 |
+
{
|
405 |
+
$review = get_option( 'ftg_review' );
|
406 |
+
if ( !$review ) {
|
407 |
+
$review = array();
|
408 |
+
}
|
409 |
+
$review['time'] = time();
|
410 |
+
$review['dismissed'] = true;
|
411 |
+
update_option( 'ftg_review', $review );
|
412 |
+
die;
|
413 |
+
}
|
414 |
+
|
415 |
+
public function admin_footer( $text )
|
416 |
+
{
|
417 |
+
global $current_screen ;
|
418 |
+
|
419 |
+
if ( !empty($current_screen->id) && strpos( $current_screen->id, 'ftg' ) !== false ) {
|
420 |
+
$url = esc_url( 'https://wordpress.org/support/plugin/final-tiles-grid-gallery-lite/reviews/?filter=5#new-post' );
|
421 |
+
$text = sprintf( __( 'Please rate <strong>Final Tiles Gallery</strong> <a href="%s" target="_blank">★★★★★</a> on <a href="%s" target="_blank">WordPress.org</a> to help us spread the word. Thank you from the Final Tiles Gallery team!', 'final-tiles-grid-gallery-lite' ), $url, $url );
|
422 |
+
}
|
423 |
+
|
424 |
+
return $text;
|
425 |
+
}
|
426 |
+
|
427 |
+
private function resetFields()
|
428 |
+
{
|
429 |
+
$keys = array(
|
430 |
+
'name',
|
431 |
+
'hiddenFor',
|
432 |
+
'type',
|
433 |
+
'description',
|
434 |
+
'default',
|
435 |
+
'min',
|
436 |
+
'max',
|
437 |
+
'mu',
|
438 |
+
'excludeFrom'
|
439 |
+
);
|
440 |
+
foreach ( $this->fields as $tab_name => $tab ) {
|
441 |
+
foreach ( $tab["fields"] as $key => $field ) {
|
442 |
+
//print_r($field);
|
443 |
+
foreach ( $keys as $kk ) {
|
444 |
+
if ( !array_key_exists( $kk, $field ) ) {
|
445 |
+
$this->fields[$tab_name]["fields"][$key][$kk] = "";
|
446 |
+
}
|
447 |
+
}
|
448 |
+
}
|
449 |
+
}
|
450 |
+
//print_r($this->fields);
|
451 |
+
}
|
452 |
+
|
453 |
+
public function register_links( $links, $file )
|
454 |
+
{
|
455 |
+
$base = plugin_basename( __FILE__ );
|
456 |
+
|
457 |
+
if ( $file == $base ) {
|
458 |
+
$links[] = '<a href="admin.php?page=ftg-lite-gallery-admin" title="Final Tiles Grid Gallery Dashboard">Dashboard</a>';
|
459 |
+
$links[] = '<a href="https://www.machothemes.com/" title="MachoThemes website">MachoThemes</a>';
|
460 |
+
$links[] = '<a href="https://twitter.com/machothemes" title="@MachoThemes on Twitter">Twitter</a>';
|
461 |
+
$links[] = '<a href="https://www.facebook.com/machothemes" title="MachoThemes on Facebook">Facebook</a>';
|
462 |
+
}
|
463 |
+
|
464 |
+
return $links;
|
465 |
+
}
|
466 |
+
|
467 |
+
/*public function create_db_tables()
|
468 |
+
{
|
469 |
+
include_once 'lib/install-db.php';
|
470 |
+
install_db();
|
471 |
+
}
|
472 |
+
|
473 |
+
public function activation()
|
474 |
+
{
|
475 |
+
|
476 |
+
}*/
|
477 |
+
//Define textdomain
|
478 |
+
public function create_textdomain()
|
479 |
+
{
|
480 |
+
$plugin_dir = basename( dirname( __FILE__ ) );
|
481 |
+
load_plugin_textdomain( 'final-tiles-grid-gallery-lite', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
482 |
+
foreach ( $this->fields as $s => $section ) {
|
483 |
+
foreach ( $section["fields"] as $f => $field ) {
|
484 |
+
$this->fields[$s]["fields"][$f]["description"] = esc_html__( $this->fields[$s]["fields"][$f]["description"], 'final-tiles-grid-gallery-lite' );
|
485 |
+
}
|
486 |
+
}
|
487 |
+
}
|
488 |
+
|
489 |
+
//Define constants
|
490 |
+
public function define_constants()
|
491 |
+
{
|
492 |
+
if ( !defined( 'FINALTILESGALLERY_PLUGIN_BASENAME' ) ) {
|
493 |
+
define( 'FINALTILESGALLERY_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
494 |
+
}
|
495 |
+
if ( !defined( 'FINALTILESGALLERY_PLUGIN_NAME' ) ) {
|
496 |
+
define( 'FINALTILESGALLERY_PLUGIN_NAME', trim( dirname( FINALTILESGALLERY_PLUGIN_BASENAME ), '/' ) );
|
497 |
+
}
|
498 |
+
if ( !defined( 'FINALTILESGALLERY_PLUGIN_DIR' ) ) {
|
499 |
+
define( 'FINALTILESGALLERY_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . FINALTILESGALLERY_PLUGIN_NAME );
|
500 |
+
}
|
501 |
+
}
|
502 |
+
|
503 |
+
//Define DB tables
|
504 |
+
public static function define_db_tables()
|
505 |
+
{
|
506 |
+
global $wpdb ;
|
507 |
+
$wpdb->FinalTilesGalleries = $wpdb->prefix . 'FinalTiles_gallery';
|
508 |
+
$wpdb->FinalTilesImages = $wpdb->prefix . 'FinalTiles_gallery_images';
|
509 |
+
}
|
510 |
+
|
511 |
+
public function create_db_conn()
|
512 |
+
{
|
513 |
+
require 'lib/db-class.php';
|
514 |
+
$FinalTilesdb = FinalTilesDB::getInstance();
|
515 |
+
return $FinalTilesdb;
|
516 |
+
}
|
517 |
+
|
518 |
+
public function editor_button( $buttons )
|
519 |
+
{
|
520 |
+
array_push( $buttons, 'separator', 'ftg_shortcode_editor' );
|
521 |
+
return $buttons;
|
522 |
+
}
|
523 |
+
|
524 |
+
public function register_editor_plugin( $plugin_array )
|
525 |
+
{
|
526 |
+
$plugin_array['ftg_shortcode_editor'] = plugins_url( '/admin/scripts/editor-plugin.js', __FILE__ );
|
527 |
+
return $plugin_array;
|
528 |
+
}
|
529 |
+
|
530 |
+
public function ftg_shortcode_editor()
|
531 |
+
{
|
532 |
+
$css_path = plugins_url( 'assets/css/admin.css', __FILE__ );
|
533 |
+
$admin_url = admin_url();
|
534 |
+
$galleries = $this->FinalTilesdb->getGalleries();
|
535 |
+
//load all galleries
|
536 |
+
include 'admin/include/tinymce-galleries.php';
|
537 |
+
wp_die();
|
538 |
+
}
|
539 |
+
|
540 |
+
public function attachment_fields_to_edit( $form, $post )
|
541 |
+
{
|
542 |
+
$form["ftg_link"] = array(
|
543 |
+
"label" => "Link <small>FTG</small>",
|
544 |
+
"input" => "text",
|
545 |
+
"value" => get_post_meta( $post->ID, "_ftg_link", true ),
|
546 |
+
"helps" => "",
|
547 |
+
);
|
548 |
+
$form["ftg_target"] = array(
|
549 |
+
"label" => "_blank <small>FTG</small>",
|
550 |
+
"input" => "html",
|
551 |
+
"html" => "<input type='checkbox' name='attachments[{$post->ID}][ftg_target]' id='attachments[{$post->ID}][ftg_target]' value='_mblank' " . (( get_post_meta( $post->ID, "_ftg_target", true ) == "_mblank" ? "checked" : "" )) . " />",
|
552 |
+
);
|
553 |
+
return $form;
|
554 |
+
}
|
555 |
+
|
556 |
+
public function attachment_fields_to_save( $post, $attachment )
|
557 |
+
{
|
558 |
+
if ( isset( $attachment['ftg_link'] ) ) {
|
559 |
+
update_post_meta( $post['ID'], '_ftg_link', esc_url_raw( $attachment['ftg_link'] ) );
|
560 |
+
}
|
561 |
+
if ( isset( $attachment['ftg_target'] ) ) {
|
562 |
+
update_post_meta( $post['ID'], '_ftg_target', sanitize_text_field( $attachment['ftg_target'] ) );
|
563 |
+
}
|
564 |
+
return $post;
|
565 |
+
}
|
566 |
+
|
567 |
+
//Delete gallery
|
568 |
+
public function delete_gallery()
|
569 |
+
{
|
570 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) && isset( $_POST['id'] ) ) {
|
571 |
+
$this->FinalTilesdb->deleteGallery( intval( $_POST['id'] ) );
|
572 |
+
}
|
573 |
+
return array();
|
574 |
+
}
|
575 |
+
|
576 |
+
public function update_configuration()
|
577 |
+
{
|
578 |
+
|
579 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
580 |
+
$id = ( isset( $_POST['galleryId'] ) ? absint( $_POST['galleryId'] ) : 0 );
|
581 |
+
$config = ( isset( $_POST['config'] ) ? wp_unslash( $_POST['config'] ) : '' );
|
582 |
+
// phpcs:ignore
|
583 |
+
$this->FinalTilesdb->update_config( $id, $config );
|
584 |
+
}
|
585 |
+
|
586 |
+
exit;
|
587 |
+
}
|
588 |
+
|
589 |
+
public function get_configuration()
|
590 |
+
{
|
591 |
+
|
592 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
593 |
+
$id = ( isset( $_POST['galleryId'] ) ? absint( $_POST['galleryId'] ) : 0 );
|
594 |
+
$gallery = $this->FinalTilesdb->getGalleryConfig( $id );
|
595 |
+
echo stripslashes( $gallery ) ;
|
596 |
+
// phpcs:ignore
|
597 |
+
}
|
598 |
+
|
599 |
+
exit;
|
600 |
+
}
|
601 |
+
|
602 |
+
public function get_image_size_url()
|
603 |
+
{
|
604 |
+
|
605 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
606 |
+
$id = ( isset( $_POST['id'] ) ? absint( $_POST['id'] ) : 0 );
|
607 |
+
$size = ( isset( $_POST['size'] ) ? sanitize_text_field( wp_unslash( $_POST['size'] ) ) : 'thumbnail' );
|
608 |
+
echo esc_url( wp_get_attachment_image_url( $id, $size, false ) ) ;
|
609 |
+
}
|
610 |
+
|
611 |
+
exit;
|
612 |
+
}
|
613 |
+
|
614 |
+
//Clone gallery
|
615 |
+
public function clone_gallery()
|
616 |
+
{
|
617 |
+
|
618 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
619 |
+
$sourceId = ( isset( $_POST['id'] ) ? intval( $_POST['id'] ) : 0 );
|
620 |
+
$g = $this->FinalTilesdb->getGalleryById( $sourceId, true );
|
621 |
+
$g['name'] .= " (copy)";
|
622 |
+
$this->FinalTilesdb->addGallery( $g );
|
623 |
+
$id = $this->FinalTilesdb->getNewGalleryId();
|
624 |
+
$images = $this->FinalTilesdb->getImagesByGalleryId( $sourceId, 0, 0 );
|
625 |
+
foreach ( $images as &$image ) {
|
626 |
+
$image->Id = null;
|
627 |
+
$image->gid = $id;
|
628 |
+
}
|
629 |
+
$this->FinalTilesdb->addImages( $id, $images );
|
630 |
+
}
|
631 |
+
|
632 |
+
return array();
|
633 |
+
}
|
634 |
+
|
635 |
+
//Add gallery scripts
|
636 |
+
public function add_gallery_scripts()
|
637 |
+
{
|
638 |
+
wp_enqueue_script( 'jquery' );
|
639 |
+
wp_register_script(
|
640 |
+
'finalTilesGallery',
|
641 |
+
plugins_url( 'scripts/jquery.finalTilesGallery.js', __FILE__ ),
|
642 |
+
array( 'jquery' ),
|
643 |
+
FTGVERSION,
|
644 |
+
true
|
645 |
+
);
|
646 |
+
wp_enqueue_script( 'finalTilesGallery' );
|
647 |
+
wp_register_style(
|
648 |
+
'finalTilesGallery_stylesheet',
|
649 |
+
plugins_url( 'scripts/ftg.css', __FILE__ ),
|
650 |
+
array(),
|
651 |
+
FTGVERSION
|
652 |
+
);
|
653 |
+
wp_enqueue_style( 'finalTilesGallery_stylesheet' );
|
654 |
+
wp_register_script( 'lightbox2_script', plugins_url( 'lightbox/lightbox2/js/script.js', __FILE__ ), array( 'jquery' ) );
|
655 |
+
wp_register_style( 'lightbox2_stylesheet', plugins_url( 'lightbox/lightbox2/css/style.css', __FILE__ ) );
|
656 |
+
wp_register_style( 'fontawesome_stylesheet', '//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css' );
|
657 |
+
wp_enqueue_style( 'fontawesome_stylesheet' );
|
658 |
+
}
|
659 |
+
|
660 |
+
//Admin Section - register scripts and styles
|
661 |
+
public function gallery_admin_init()
|
662 |
+
{
|
663 |
+
if ( function_exists( 'wp_enqueue_media' ) ) {
|
664 |
+
wp_enqueue_media();
|
665 |
+
}
|
666 |
+
$ftg_db_version = '20190518';
|
667 |
+
$installed_ver = get_option( "FinalTiles_gallery_db_version" );
|
668 |
+
if ( !$installed_ver || empty($installed_ver) ) {
|
669 |
+
update_option( "FinalTiles_gallery_db_version", $ftg_db_version );
|
670 |
+
}
|
671 |
+
|
672 |
+
if ( $installed_ver != $ftg_db_version ) {
|
673 |
+
activate_finaltilesgallery();
|
674 |
+
update_option( "FinalTiles_gallery_db_version", $ftg_db_version );
|
675 |
+
}
|
676 |
+
|
677 |
+
function ftg_get_image_sizes()
|
678 |
+
{
|
679 |
+
global $_wp_additional_image_sizes ;
|
680 |
+
$sizes = array();
|
681 |
+
foreach ( get_intermediate_image_sizes() as $_size ) {
|
682 |
+
|
683 |
+
if ( in_array( $_size, array(
|
684 |
+
'thumbnail',
|
685 |
+
'medium',
|
686 |
+
'medium_large',
|
687 |
+
'large'
|
688 |
+
) ) ) {
|
689 |
+
$sizes[$_size]['width'] = get_option( "{$_size}_size_w" );
|
690 |
+
$sizes[$_size]['height'] = get_option( "{$_size}_size_h" );
|
691 |
+
$sizes[$_size]['crop'] = (bool) get_option( "{$_size}_crop" );
|
692 |
+
} elseif ( isset( $_wp_additional_image_sizes[$_size] ) ) {
|
693 |
+
$sizes[$_size] = array(
|
694 |
+
'width' => $_wp_additional_image_sizes[$_size]['width'],
|
695 |
+
'height' => $_wp_additional_image_sizes[$_size]['height'],
|
696 |
+
'crop' => $_wp_additional_image_sizes[$_size]['crop'],
|
697 |
+
);
|
698 |
+
}
|
699 |
+
|
700 |
+
}
|
701 |
+
return $sizes;
|
702 |
+
}
|
703 |
+
|
704 |
+
foreach ( ftg_get_image_sizes() as $name => $size ) {
|
705 |
+
$this->fields["Links & Lightbox"]["fields"]["lightboxImageSize"]["values"]["Size"][] = $name . "|" . $name . " (" . $size['width'] . 'x' . $size['height'] . (( $size['crop'] ? ' cropped)' : ')' ));
|
706 |
+
}
|
707 |
+
$this->fields["Links & Lightbox"]["fields"]["lightboxImageSize"]["values"]["Size"][] = "full|Original (full)";
|
708 |
+
wp_enqueue_script( 'jquery' );
|
709 |
+
wp_enqueue_script( 'jquery-ui-dialog' );
|
710 |
+
wp_enqueue_script( 'jquery-ui-sortable' );
|
711 |
+
wp_enqueue_script( 'wp-color-picker' );
|
712 |
+
wp_enqueue_style( 'wp-color-picker' );
|
713 |
+
wp_enqueue_script( 'media-upload' );
|
714 |
+
wp_enqueue_script( 'thickbox' );
|
715 |
+
wp_register_style( 'google-fonts', '//fonts.googleapis.com/css?family=Roboto:400,700,500,300,900' );
|
716 |
+
wp_enqueue_style( 'google-fonts' );
|
717 |
+
wp_register_style( 'google-icons', '//cdn.materialdesignicons.com/1.9.32/css/materialdesignicons.min.css', array() );
|
718 |
+
wp_enqueue_style( 'google-icons' );
|
719 |
+
wp_register_style( 'final-tiles-gallery-admin', plugins_url( 'admin/css/style.css', __FILE__ ), array( 'colors' ) );
|
720 |
+
wp_enqueue_style( 'final-tiles-gallery-admin' );
|
721 |
+
wp_register_script( 'materialize', plugins_url( 'admin/scripts/materialize.min.js', __FILE__ ), array( 'jquery' ) );
|
722 |
+
wp_enqueue_script( 'materialize' );
|
723 |
+
wp_register_script( 'final-tiles-gallery', plugins_url( 'admin/scripts/final-tiles-gallery-admin.js', __FILE__ ), array(
|
724 |
+
'jquery',
|
725 |
+
'media-upload',
|
726 |
+
'thickbox',
|
727 |
+
'materialize'
|
728 |
+
) );
|
729 |
+
wp_enqueue_script( 'final-tiles-gallery' );
|
730 |
+
wp_enqueue_style( 'thickbox' );
|
731 |
+
wp_register_style( 'fontawesome_stylesheet', '//netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.css' );
|
732 |
+
wp_enqueue_style( 'fontawesome_stylesheet' );
|
733 |
+
}
|
734 |
+
|
735 |
+
//Create Admin Menu
|
736 |
+
public function add_gallery_admin_menu()
|
737 |
+
{
|
738 |
+
$overview = add_menu_page(
|
739 |
+
'Final Tiles Gallery',
|
740 |
+
'Final Tiles Gallery',
|
741 |
+
'edit_posts',
|
742 |
+
'ftg-lite-gallery-admin',
|
743 |
+
array( $this, 'add_overview' ),
|
744 |
+
plugins_url( 'admin/icon.png', __FILE__ )
|
745 |
+
);
|
746 |
+
$add_gallery = add_submenu_page(
|
747 |
+
'ftg-lite-gallery-admin',
|
748 |
+
esc_html__( 'FinalTiles Gallery >> Add Gallery', 'final-tiles-grid-gallery-lite' ),
|
749 |
+
esc_html__( 'Add Gallery', 'final-tiles-grid-gallery-lite' ),
|
750 |
+
'edit_posts',
|
751 |
+
'ftg-add-gallery',
|
752 |
+
array( $this, 'add_gallery' )
|
753 |
+
);
|
754 |
+
add_action( 'load-' . $overview, array( $this, 'gallery_admin_init' ) );
|
755 |
+
add_action( 'load-' . $add_gallery, array( $this, 'gallery_admin_init' ) );
|
756 |
+
/*if(! class_exists("PhotoBlocks"))
|
757 |
+
{
|
758 |
+
$photoblocks = add_submenu_page('ftg-lite-gallery-admin', __('FinalTiles Gallery >> PhotoBlocks', 'FinalTiles-gallery'), __('PhotoBlocks', 'FinalTiles-gallery'), 'edit_posts', 'ftg-photoblocks', array($this, 'photoblocks'));
|
759 |
+
add_action('load-' . $photoblocks, array($this, 'gallery_admin_init'));
|
760 |
+
}
|
761 |
+
|
762 |
+
if(! class_exists("EverlightBox"))
|
763 |
+
{
|
764 |
+
$everlightbox = add_submenu_page('ftg-lite-gallery-admin', __('FinalTiles Gallery >> EverlightBox', 'FinalTiles-gallery'), __('EverlightBox', 'FinalTiles-gallery'), 'edit_posts', 'ftg-everlightbox', array($this, 'everlightbox'));
|
765 |
+
add_action('load-' . $everlightbox, array($this, 'gallery_admin_init'));
|
766 |
+
}*/
|
767 |
+
}
|
768 |
+
|
769 |
+
//Create Admin Pages
|
770 |
+
public function add_overview()
|
771 |
+
{
|
772 |
+
global $ftg_fields ;
|
773 |
+
$ftg_fields = $this->fields;
|
774 |
+
global $ftg_parent_page ;
|
775 |
+
$ftg_parent_page = "dashboard";
|
776 |
+
|
777 |
+
if ( array_key_exists( "id", $_GET ) ) {
|
778 |
+
$woocommerce_post_types = array(
|
779 |
+
"product",
|
780 |
+
"product_variation",
|
781 |
+
"shop_order",
|
782 |
+
"shop_order_refund",
|
783 |
+
"shop_coupon",
|
784 |
+
"shop_webhook"
|
785 |
+
);
|
786 |
+
$wp_post_types = array( "revision", "nav_menu_item" );
|
787 |
+
$excluded_post_types = array_merge( $wp_post_types, $woocommerce_post_types );
|
788 |
+
$woo_categories = $this->getWooCategories();
|
789 |
+
include "admin/edit-gallery.php";
|
790 |
+
} else {
|
791 |
+
include "admin/overview.php";
|
792 |
+
}
|
793 |
+
|
794 |
+
}
|
795 |
+
|
796 |
+
public function tutorial()
|
797 |
+
{
|
798 |
+
include "admin/tutorial.php";
|
799 |
+
}
|
800 |
+
|
801 |
+
public function support()
|
802 |
+
{
|
803 |
+
include "admin/support.php";
|
804 |
+
}
|
805 |
+
|
806 |
+
public function photoblocks()
|
807 |
+
{
|
808 |
+
include "admin/photoblocks.php";
|
809 |
+
}
|
810 |
+
|
811 |
+
public function everlightbox()
|
812 |
+
{
|
813 |
+
include "admin/everlightbox.php";
|
814 |
+
}
|
815 |
+
|
816 |
+
private function getWooCategories()
|
817 |
+
{
|
818 |
+
|
819 |
+
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
|
820 |
+
$taxonomy = 'product_cat';
|
821 |
+
$orderby = 'name';
|
822 |
+
$show_count = 0;
|
823 |
+
// 1 for yes, 0 for no
|
824 |
+
$pad_counts = 0;
|
825 |
+
// 1 for yes, 0 for no
|
826 |
+
$hierarchical = 1;
|
827 |
+
// 1 for yes, 0 for no
|
828 |
+
$title = '';
|
829 |
+
$empty = 0;
|
830 |
+
$args = array(
|
831 |
+
'taxonomy' => $taxonomy,
|
832 |
+
'orderby' => $orderby,
|
833 |
+
'show_count' => $show_count,
|
834 |
+
'pad_counts' => $pad_counts,
|
835 |
+
'hierarchical' => $hierarchical,
|
836 |
+
'title_li' => $title,
|
837 |
+
'hide_empty' => $empty,
|
838 |
+
);
|
839 |
+
return get_categories( $args );
|
840 |
+
} else {
|
841 |
+
return array();
|
842 |
+
}
|
843 |
+
|
844 |
+
}
|
845 |
+
|
846 |
+
public function add_gallery()
|
847 |
+
{
|
848 |
+
global $ftg_fields ;
|
849 |
+
$ftg_fields = $this->fields;
|
850 |
+
$gallery = null;
|
851 |
+
$woocommerce_post_types = array(
|
852 |
+
"product",
|
853 |
+
"product_variation",
|
854 |
+
"shop_order",
|
855 |
+
"shop_order_refund",
|
856 |
+
"shop_coupon",
|
857 |
+
"shop_webhook"
|
858 |
+
);
|
859 |
+
$wp_post_types = array( "revision", "nav_menu_item" );
|
860 |
+
$excluded_post_types = array_merge( $wp_post_types, $woocommerce_post_types );
|
861 |
+
$woo_categories = $this->getWooCategories();
|
862 |
+
include "admin/add-gallery.php";
|
863 |
+
}
|
864 |
+
|
865 |
+
public function delete_image()
|
866 |
+
{
|
867 |
+
|
868 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
869 |
+
$ids = ( isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : 0 );
|
870 |
+
foreach ( explode( ",", $ids ) as $id ) {
|
871 |
+
$this->FinalTilesdb->deleteImage( absint( $id ) );
|
872 |
+
}
|
873 |
+
}
|
874 |
+
|
875 |
+
wp_die();
|
876 |
+
}
|
877 |
+
|
878 |
+
public function assign_filters()
|
879 |
+
{
|
880 |
+
|
881 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
882 |
+
$ids = ( isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : 0 );
|
883 |
+
$filters = ( isset( $_POST['filters'] ) ? sanitize_text_field( wp_unslash( $_POST['filters'] ) ) : '' );
|
884 |
+
|
885 |
+
if ( isset( $_POST['source'] ) && $_POST['source'] == 'posts' ) {
|
886 |
+
foreach ( explode( ",", $ids ) as $id ) {
|
887 |
+
update_post_meta( absint( $id ), 'ftg_filters', sanitize_text_field( $filters ) );
|
888 |
+
}
|
889 |
+
} else {
|
890 |
+
foreach ( explode( ",", $ids ) as $id ) {
|
891 |
+
$result = $this->FinalTilesdb->editImage( absint( $id ), array(
|
892 |
+
"filters" => sanitize_text_field( $filters ),
|
893 |
+
) );
|
894 |
+
}
|
895 |
+
}
|
896 |
+
|
897 |
+
}
|
898 |
+
|
899 |
+
wp_die();
|
900 |
+
}
|
901 |
+
|
902 |
+
public function toggle_visibility()
|
903 |
+
{
|
904 |
+
|
905 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
906 |
+
$ids = ( isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : 0 );
|
907 |
+
foreach ( explode( ",", $ids ) as $id ) {
|
908 |
+
$image = $this->FinalTilesdb->getImage( $id );
|
909 |
+
$this->FinalTilesdb->editImage( absint( $id ), array(
|
910 |
+
"hidden" => ( $image->hidden == 'T' ? 'F' : 'T' ),
|
911 |
+
) );
|
912 |
+
}
|
913 |
+
}
|
914 |
+
|
915 |
+
wp_die();
|
916 |
+
}
|
917 |
+
|
918 |
+
public function assign_group()
|
919 |
+
{
|
920 |
+
|
921 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
922 |
+
$ids = ( isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : 0 );
|
923 |
+
$group = ( isset( $_POST['group'] ) ? sanitize_text_field( wp_unslash( $_POST['group'] ) ) : '' );
|
924 |
+
|
925 |
+
if ( isset( $_POST['source'] ) && $_POST['source'] == 'posts' ) {
|
926 |
+
foreach ( explode( ",", $ids ) as $id ) {
|
927 |
+
update_post_meta( intval( $id ), 'ftg_group', sanitize_text_field( $group ) );
|
928 |
+
}
|
929 |
+
} else {
|
930 |
+
foreach ( explode( ",", $ids ) as $id ) {
|
931 |
+
$result = $this->FinalTilesdb->editImage( $id, array(
|
932 |
+
"group" => sanitize_text_field( $group ),
|
933 |
+
) );
|
934 |
+
}
|
935 |
+
}
|
936 |
+
|
937 |
+
}
|
938 |
+
|
939 |
+
wp_die();
|
940 |
+
}
|
941 |
+
|
942 |
+
public function add_image()
|
943 |
+
{
|
944 |
+
|
945 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
946 |
+
$gid = ( isset( $_POST['galleryId'] ) ? intval( $_POST['galleryId'] ) : 0 );
|
947 |
+
$enc_images = ( isset( $_POST['enc_images'] ) ? wp_unslash( $_POST['enc_images'] ) : '' );
|
948 |
+
// phpcs:ignore
|
949 |
+
$images = json_decode( $enc_images );
|
950 |
+
$result = $this->FinalTilesdb->addImages( $gid, $images );
|
951 |
+
header( "Content-type: application/json" );
|
952 |
+
|
953 |
+
if ( $result === false ) {
|
954 |
+
echo "{\"success\":false}" ;
|
955 |
+
} else {
|
956 |
+
echo "{\"success\":true}" ;
|
957 |
+
}
|
958 |
+
|
959 |
+
}
|
960 |
+
|
961 |
+
wp_die();
|
962 |
+
}
|
963 |
+
|
964 |
+
public function list_thumbnail_sizes()
|
965 |
+
{
|
966 |
+
global $_wp_additional_image_sizes ;
|
967 |
+
$sizes = array();
|
968 |
+
foreach ( get_intermediate_image_sizes() as $s ) {
|
969 |
+
|
970 |
+
if ( in_array( $s, array( 'thumbnail', 'medium', 'large' ) ) ) {
|
971 |
+
$sizes[$s][0] = get_option( $s . '_size_w' );
|
972 |
+
$sizes[$s][1] = get_option( $s . '_size_h' );
|
973 |
+
} else {
|
974 |
+
if ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[$s] ) && $_wp_additional_image_sizes[$s]['width'] > 0 && $_wp_additional_image_sizes[$s]['height'] > 0 ) {
|
975 |
+
$sizes[$s] = array( $_wp_additional_image_sizes[$s]['width'], $_wp_additional_image_sizes[$s]['height'] );
|
976 |
+
}
|
977 |
+
}
|
978 |
+
|
979 |
+
}
|
980 |
+
return $sizes;
|
981 |
+
}
|
982 |
+
|
983 |
+
public function sort_images()
|
984 |
+
{
|
985 |
+
|
986 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
987 |
+
$ids = ( isset( $_POST['ids'] ) ? sanitize_text_field( wp_unslash( $_POST['ids'] ) ) : 0 );
|
988 |
+
$result = $this->FinalTilesdb->sortImages( explode( ',', $ids ) );
|
989 |
+
header( "Content-type: application/json" );
|
990 |
+
|
991 |
+
if ( $result === false ) {
|
992 |
+
echo "{\"success\":false}" ;
|
993 |
+
} else {
|
994 |
+
echo "{\"success\":true}" ;
|
995 |
+
}
|
996 |
+
|
997 |
+
}
|
998 |
+
|
999 |
+
wp_die();
|
1000 |
+
}
|
1001 |
+
|
1002 |
+
public function load_chunk()
|
1003 |
+
{
|
1004 |
+
require_once 'lib/gallery-class.php';
|
1005 |
+
|
1006 |
+
if ( check_admin_referer( 'finaltilesgallery', 'finaltilesgallery' ) ) {
|
1007 |
+
$gid = ( isset( $_POST['gallery'] ) ? intval( $_POST['gallery'] ) : 0 );
|
1008 |
+
$images = $this->FinalTilesdb->getImagesByGalleryId( $gid, 0, 0 );
|
1009 |
+
$FinalTilesGallery = new FinalTilesGallery( $gid, $this->FinalTilesdb, $this->defaultValues );
|
1010 |
+
echo $FinalTilesGallery->images_markup() ;
|
1011 |
+
// phpcs:ignore
|
1012 |
+
}
|
1013 |
+
|
1014 |
+
wp_die();
|
1015 |
+
}
|
1016 |
+
|
1017 |
+
public function refresh_gallery()
|
1018 |
+
{
|
1019 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
1020 |
+
if ( isset( $_POST['source'] ) && sanitize_text_field( wp_unslash( $_POST['source'] ) ) == 'images' ) {
|
1021 |
+
$this->list_images();
|
1022 |
+
}
|
1023 |
+
}
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
public function save_image()
|
1027 |
+
{
|
1028 |
+
|
1029 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
1030 |
+
$result = false;
|
1031 |
+
|
1032 |
+
if ( isset( $_POST['source'] ) && $_POST['source'] == 'posts' ) {
|
1033 |
+
$result = true;
|
1034 |
+
$postId = ( isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0 );
|
1035 |
+
$img_url = ( isset( $_POST['img_url'] ) ? esc_url_raw( $_POST['img_url'] ) : '' );
|
1036 |
+
update_post_meta( $postId, 'ftg_image_url', esc_url_raw( $img_url ) );
|
1037 |
+
if ( array_key_exists( "filters", $_POST ) && strlen( sanitize_text_field( wp_unslash( $_POST['filters'] ) ) ) ) {
|
1038 |
+
update_post_meta( $postId, 'ftg_filters', sanitize_text_field( wp_unslash( $_POST['filters'] ) ) );
|
1039 |
+
}
|
1040 |
+
} else {
|
1041 |
+
$type = ( isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '' );
|
1042 |
+
$imageUrl = ( isset( $_POST['img_url'] ) ? esc_url_raw( $_POST['img_url'] ) : '' );
|
1043 |
+
$imageCaption = ( isset( $_POST['description'] ) ? wp_kses_post( wp_unslash( $_POST['description'] ) ) : '' );
|
1044 |
+
$filters = ( isset( $_POST['filters'] ) ? sanitize_text_field( wp_unslash( $_POST['filters'] ) ) : '' );
|
1045 |
+
$title = ( isset( $_POST['imageTitle'] ) ? wp_kses_post( wp_unslash( $_POST['imageTitle'] ) ) : '' );
|
1046 |
+
$target = ( isset( $_POST['target'] ) ? sanitize_text_field( wp_unslash( $_POST['target'] ) ) : '' );
|
1047 |
+
$group = ( isset( $_POST['group'] ) ? sanitize_text_field( wp_unslash( $_POST['group'] ) ) : '' );
|
1048 |
+
$alt = ( isset( $_POST['alt'] ) ? sanitize_text_field( wp_unslash( $_POST['alt'] ) ) : '' );
|
1049 |
+
$hidden = $this->checkboxVal( 'hidden' );
|
1050 |
+
$link = ( isset( $_POST['link'] ) ? esc_url_raw( wp_unslash( $_POST['link'] ) ) : null );
|
1051 |
+
$imageId = ( isset( $_POST['img_id'] ) ? intval( wp_unslash( $_POST['img_id'] ) ) : 0 );
|
1052 |
+
$sortOrder = ( isset( $_POST['sortOrder'] ) ? intval( wp_unslash( $_POST['sortOrder'] ) ) : 0 );
|
1053 |
+
$data = array(
|
1054 |
+
"imagePath" => $imageUrl,
|
1055 |
+
"target" => $target,
|
1056 |
+
"link" => $link,
|
1057 |
+
"imageId" => $imageId,
|
1058 |
+
"description" => $imageCaption,
|
1059 |
+
"filters" => $filters,
|
1060 |
+
"title" => $title,
|
1061 |
+
"group" => $group,
|
1062 |
+
"alt" => $alt,
|
1063 |
+
"hidden" => $hidden,
|
1064 |
+
"sortOrder" => $sortOrder,
|
1065 |
+
);
|
1066 |
+
|
1067 |
+
if ( !empty($_POST["id"]) ) {
|
1068 |
+
$imageId = intval( $_POST['id'] );
|
1069 |
+
$result = $this->FinalTilesdb->editImage( $imageId, $data );
|
1070 |
+
} else {
|
1071 |
+
$data["gid"] = ( isset( $_POST['galleryId'] ) ? absint( $_POST['galleryId'] ) : 0 );
|
1072 |
+
$result = $this->FinalTilesdb->addFullImage( $data );
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
header( "Content-type: application/json" );
|
1078 |
+
|
1079 |
+
if ( $result === false ) {
|
1080 |
+
echo "{\"success\":false}" ;
|
1081 |
+
} else {
|
1082 |
+
echo "{\"success\":true}" ;
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
wp_die();
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
public function save_video()
|
1091 |
+
{
|
1092 |
+
|
1093 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
1094 |
+
$result = false;
|
1095 |
+
$type = ( isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : "" );
|
1096 |
+
$data = array(
|
1097 |
+
"imagePath" => wp_unslash( $_POST["embed"] ),
|
1098 |
+
"filters" => ( isset( $_POST['filters'] ) ? sanitize_text_field( wp_unslash( $_POST['filters'] ) ) : '' ),
|
1099 |
+
"gid" => ( isset( $_POST['galleryId'] ) ? absint( $_POST['galleryId'] ) : 0 ),
|
1100 |
+
);
|
1101 |
+
$id = ( isset( $_POST['id'] ) ? absint( $_POST['id'] ) : "" );
|
1102 |
+
$step = ( isset( $_POST['step'] ) ? sanitize_text_field( wp_unslash( $_POST['step'] ) ) : "" );
|
1103 |
+
if ( !empty($step) ) {
|
1104 |
+
|
1105 |
+
if ( $step == "add" ) {
|
1106 |
+
$result = $this->FinalTilesdb->addVideo( $data );
|
1107 |
+
} else {
|
1108 |
+
if ( $step == "edit" ) {
|
1109 |
+
$result = $this->FinalTilesdb->editVideo( $id, $data );
|
1110 |
+
}
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
}
|
1114 |
+
header( "Content-type: application/json" );
|
1115 |
+
|
1116 |
+
if ( $result === false ) {
|
1117 |
+
echo "{\"success\":false}" ;
|
1118 |
+
} else {
|
1119 |
+
echo "{\"success\":true}" ;
|
1120 |
+
}
|
1121 |
+
|
1122 |
+
}
|
1123 |
+
|
1124 |
+
wp_die();
|
1125 |
+
}
|
1126 |
+
|
1127 |
+
public function list_images()
|
1128 |
+
{
|
1129 |
+
|
1130 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
1131 |
+
$gid = ( isset( $_POST['gid'] ) ? absint( $_POST['gid'] ) : 0 );
|
1132 |
+
$imageResults = $this->FinalTilesdb->getImagesByGalleryId( $gid, 0, 0 );
|
1133 |
+
$gallery = $this->FinalTilesdb->getGalleryById( $gid );
|
1134 |
+
$list_size = "medium";
|
1135 |
+
$column_size = "s6 m3 l3";
|
1136 |
+
if ( isset( $_POST['list_size'] ) && !empty($_POST['list_size']) ) {
|
1137 |
+
$list_size = sanitize_text_field( wp_unslash( $_POST['list_size'] ) );
|
1138 |
+
}
|
1139 |
+
setcookie( 'ftg_imglist_size', $list_size );
|
1140 |
+
$_COOKIE['ftg_imglist_size'] = $list_size;
|
1141 |
+
if ( $list_size == 'small' ) {
|
1142 |
+
$column_size = 's4 m2 l2';
|
1143 |
+
}
|
1144 |
+
if ( $list_size == 'medium' ) {
|
1145 |
+
$column_size = 's6 m3 l3';
|
1146 |
+
}
|
1147 |
+
if ( $list_size == 'big' ) {
|
1148 |
+
$column_size = 's12 m4 l4';
|
1149 |
+
}
|
1150 |
+
include 'admin/include/image-list.php';
|
1151 |
+
}
|
1152 |
+
|
1153 |
+
wp_die();
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
public function add_new_gallery()
|
1157 |
+
{
|
1158 |
+
|
1159 |
+
if ( check_admin_referer( 'FinalTiles_gallery', 'FinalTiles_gallery' ) ) {
|
1160 |
+
$data = $this->defaultValues;
|
1161 |
+
// phpcs:ignore
|
1162 |
+
$data["name"] = ( isset( $_POST['ftg_name'] ) ? wp_kses_post( wp_unslash( $_POST['ftg_name'] ) ) : '' );
|
1163 |
+
// phpcs:ignore
|
1164 |
+
$data["description"] = ( isset( $_POST['ftg_description'] ) ? wp_kses_post( wp_unslash( $_POST['ftg_description'] ) ) : '' );
|
1165 |
+
$data["source"] = ( isset( $_POST['ftg_source'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_source'] ) ) : '' );
|
1166 |
+
$data["wp_field_caption"] = ( isset( $_POST['ftg_wp_field_caption'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_wp_field_caption'] ) ) : '' );
|
1167 |
+
$data["wp_field_title"] = ( isset( $_POST['ftg_wp_field_title'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_wp_field_title'] ) ) : '' );
|
1168 |
+
$data["captionEffect"] = ( isset( $_POST['ftg_captionEffect'] ) ? sanitize_text_field( wp_unslash( $_POST['ftg_captionEffect'] ) ) : '' );
|
1169 |
+
$data["post_types"] = ( isset( $_POST['post_types'] ) ? sanitize_text_field( wp_unslash( $_POST["post_types"] ) ) : '' );
|
1170 |
+
$data["layout"] = ( isset( $_POST['layout'] ) ? sanitize_text_field( wp_unslash( $_POST["layout"] ) ) : '' );
|