Image Photo Gallery Final Tiles Grid - Version 3.0.0

Version Description

  • [Add] Removed limit of 20 images per gallery
  • [Add] New masonry layout available
  • [Add] Dozens of improvements
Download this release

Release Info

Developer GreenTreeLabs
Plugin Icon 128x128 Image Photo Gallery Final Tiles Grid
Version 3.0.0
Comparing to
See all releases

Code changes from version 2.0.15 to 3.0.0

FinalTilesGalleryLite.php CHANGED
@@ -4,803 +4,1076 @@ Plugin Name: Final Tiles Grid Gallery Lite
4
  Plugin URI: http://codecanyon.net/item/final-tiles-gallery-for-wordpress/5189351?ref=GreenTreeLabs
5
  Description: Wordpress Plugin for creating responsive image galleries. By: Green Tree Labs
6
  Author: Green Tree Labs
7
- Version: 2.0.15
8
  Author URI: http://codecanyon.net/user/GreenTreeLabs
9
  */
10
 
11
- define("FTGLITEVERSION", "2.0.15");
12
  define("PRO_CALL", "<span class='procall'>(<a href='http://1.envato.market/c/288541/275988/4415?u=https%3A%2F%2Fcodecanyon.net%2Fitem%2Ffinal-tiles-wordpress-gallery%2F5189351' target='_blank'>available with PRO version</a>)</span>");
13
  define("PRO_UNLOCK", "<a href='http://1.envato.market/c/288541/275988/4415?u=https%3A%2F%2Fcodecanyon.net%2Fitem%2Ffinal-tiles-wordpress-gallery%2F5189351' target='_blank'>Add unlimited images with PRO version</a>");
14
 
 
15
  if (!class_exists("FinalTiles_GalleryLite"))
16
  {
17
- class FinalTiles_GalleryLite
18
  {
19
- //Constructor
20
- public function __construct()
21
- {
22
- $this->plugin_name = plugin_basename(__FILE__);
23
- $this->define_constants();
24
- $this->define_db_tables();
25
- $this->FinalTilesdb = $this->create_db_conn();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- register_activation_hook( __FILE__, array($this, 'activation'));
 
 
29
 
30
- add_filter('widget_text', 'do_shortcode');
31
 
32
- add_action('init', array($this, 'create_textdomain'));
 
33
 
34
- add_action('wp_enqueue_scripts', array($this, 'add_gallery_scripts'));
 
 
35
 
36
- //add_action( 'admin_init', array($this,'gallery_admin_init') );
37
- add_action( 'admin_menu', array($this, 'add_gallery_admin_menu') );
38
 
39
- add_shortcode( 'FinalTilesGallery', array($this, 'gallery_shortcode_handler') );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
- add_action('wp_ajax_save_gallery', array($this,'save_gallery'));
42
- add_action('wp_ajax_add_new_gallery', array($this,'add_new_gallery'));
43
- add_action('wp_ajax_delete_gallery', array($this,'delete_gallery'));
44
- add_action('wp_ajax_clone_gallery', array($this,'clone_gallery'));
45
- add_action('wp_ajax_save_image', array($this,'save_image'));
46
- add_action('wp_ajax_add_image', array($this,'add_image'));
47
- add_action('wp_ajax_save_video', array($this,'save_video'));
48
- add_action('wp_ajax_sort_images', array($this,'sort_images'));
49
- add_action('wp_ajax_delete_image', array($this,'delete_image'));
50
- add_action('wp_ajax_refresh_gallery', array($this,'refresh_gallery'));
51
 
 
 
52
 
53
- add_filter('mce_buttons', array($this, 'editor_button'));
54
- add_filter('mce_external_plugins', array($this, 'register_editor_plugin'));
55
- add_action('wp_ajax_ftg_shortcode_editor', array($this, 'ftg_shortcode_editor'));
56
 
57
- add_filter( 'plugin_row_meta',array( $this, 'register_links' ),10,2);
 
 
 
58
 
 
 
 
 
 
59
 
 
 
60
 
61
- $this->resetFields();
62
- }
 
 
 
63
 
64
- public function gallery_admin_bar()
65
- {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  global $wp_admin_bar;
67
 
68
  $wp_admin_bar->add_menu( array(
69
  'id' => 'ftg-upgrade-bar',
70
  'href' => 'http://1.envato.market/c/288541/275988/4415?u=https%3A%2F%2Fcodecanyon.net%2Fitem%2Ffinal-tiles-wordpress-gallery%2F5189351',
71
  'parent' => 'top-secondary',
72
- 'title' => __('Upgrade to Final Tiles Grid Gallery PRO'),
73
  'meta' => array('class' => 'ftg-upgrade-to-pro', 'target' => '_blank' ),
74
  ) );
75
- }
76
-
77
- private function resetFields()
78
- {
79
- $keys = array('name', 'hiddenFor', 'type', 'description', 'default', 'min', 'max', 'mu', 'excludeFrom');
80
-
81
- foreach ($this->fields as $tab_name => $tab)
82
- {
83
- foreach ($tab["fields"] as $key => $field)
84
- {
85
- //print_r($field);
86
- foreach ($keys as $kk)
87
- {
88
- if(!array_key_exists($kk, $field)) {
89
- $this->fields[$tab_name]["fields"][$key][$kk] = "";
90
- }
91
- }
92
- }
93
 
94
  }
95
  //print_r($this->fields);
96
- }
97
-
98
- public function register_links($links, $file)
99
- {
100
- $base = plugin_basename(__FILE__);
101
- if ($file == $base) {
102
- $links[] = '<a href="admin.php?page=FinalTiles-gallery-admin" title="Final Tiles Grid Gallery Dashboard">Dashboard</a>';
103
- $links[] = '<a href="admin.php?page=support" title="Final Tiles Grid Gallery Support">Support</a>';
104
- $links[] = '<a href="https://twitter.com/greentreelabs" title="@GreenTreeLabs on Twitter">Twitter</a>';
105
- $links[] = '<a href="https://www.facebook.com/greentreelabs" title="GreenTreeLabs on Facebook">Facebook</a>';
106
- $links[] = '<a href="https://www.google.com/+GreentreelabsNetjs" title="GreenTreeLabs on Google+">Google+</a>';
107
- }
108
- return $links;
109
 
110
- }
111
 
112
  public function create_db_tables()
113
  {
114
- include_once (WP_PLUGIN_DIR . '/final-tiles-grid-gallery-lite/lib/install-db.php');
115
- install_db();
116
- //ftg_nullable();
117
  }
118
 
119
  public function activation()
120
  {
121
- $this->add_gallery_options();
122
- $this->FinalTilesdb->updateConfiguration();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
 
125
- //Define textdomain
126
- public function create_textdomain()
127
- {
128
- $plugin_dir = basename(dirname(__FILE__));
129
- load_plugin_textdomain( 'final-tiles-gallery', false, $plugin_dir.'/lib/languages' );
130
- }
131
-
132
- //Define constants
133
- public function define_constants()
134
- {
135
- if ( ! defined( 'FINALTILESGALLERY_PLUGIN_BASENAME' ) )
136
- define( 'FINALTILESGALLERY_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
137
-
138
- if ( ! defined( 'FINALTILESGALLERY_PLUGIN_NAME' ) )
139
- define( 'FINALTILESGALLERY_PLUGIN_NAME', trim( dirname( FINALTILESGALLERY_PLUGIN_BASENAME ), '/' ) );
140
-
141
- if ( ! defined( 'FINALTILESGALLERY_PLUGIN_DIR' ) )
142
- define( 'FINALTILESGALLERY_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . FINALTILESGALLERY_PLUGIN_NAME );
143
- }
144
-
145
- //Define DB tables
146
- public function define_db_tables()
147
- {
148
- global $wpdb;
149
-
150
- $wpdb->FinalTilesGalleries = $wpdb->prefix . 'FinalTiles_gallery';
151
- $wpdb->FinalTilesImages = $wpdb->prefix . 'FinalTiles_gallery_images';
152
- }
153
-
154
-
155
- public function create_db_conn()
156
- {
157
- require('lib/db-class.php');
158
- $FinalTilesdb = FinalTilesLiteDB::getInstance();
159
- return $FinalTilesdb;
160
- }
161
-
162
- public function editor_button($buttons)
163
- {
164
- array_push($buttons, 'separator', 'ftg_shortcode_editor');
165
- return $buttons;
166
- }
167
-
168
- public function register_editor_plugin($plugin_array)
169
- {
170
- $plugin_array['ftg_shortcode_editor'] = plugins_url('/admin/scripts/editor-plugin.js',__file__);
171
- return $plugin_array;
172
- }
173
-
174
- public function ftg_shortcode_editor()
175
- {
176
- $css_path = plugins_url( 'assets/css/admin.css', __FILE__ );
177
- $admin_url = admin_url();
178
-
179
- $galleries = $this->FinalTilesdb->getGalleries(); //load all galleries
180
-
181
- include 'admin/include/tinymce-galleries.php';
182
- die();
183
- }
184
-
185
  public function attachment_fields_to_edit($form, $post)
186
- {
187
- $form["ftg_link"] = array(
188
- "label" => "Link <small>FTG</small>",
189
- "input" => "text",
190
- "value" => get_post_meta($post->ID, "_ftg_link", true),
191
- "helps" => ""
192
- );
193
- $form["ftg_target"] = array(
194
- "label" => "_blank <small>FTG</small>",
195
- "input" => "html",
196
- "html" =>
197
- "<input type='checkbox' name='attachments[{$post->ID}][ftg_target]' id='attachments[{$post->ID}][ftg_target]' value='_mblank' ".
198
- (get_post_meta($post->ID, "_ftg_target", true) == "_mblank" ? "checked" : "")
199
- ." />"
200
- );
201
- return $form;
202
- }
203
-
204
- public function attachment_fields_to_save($post, $attachment)
205
- {
206
- if(isset($attachment['ftg_link'])){
207
- update_post_meta($post['ID'], '_ftg_link', $attachment['ftg_link']);
208
- }
209
- if(isset($attachment['ftg_target'])){
210
- update_post_meta($post['ID'], '_ftg_target', $attachment['ftg_target']);
211
- }
212
- return $post;
213
- }
214
-
215
- //Add gallery options
216
- public function add_gallery_options()
217
- {
218
- $gallery_options = array(
219
- 'margin' => 10,
220
- 'defaultSize' => 'medium',
221
- 'width' => '100%',
222
- 'minTileWidth' => '100',
223
- 'gridCellSize' => '25',
224
- 'lightbox' => 'lightbox',
225
- 'recentPostsCaption' => 'title',
226
- 'captionIcon' => 'zoom',
227
- 'reverseOrder' => false,
228
- 'captionIconColor' => '#ffffff',
229
- 'captionBackgroundColor' => '#000000',
230
- 'captionColor' => '#ffffff',
231
- 'captionEffectDuration' => 250,
232
- 'captionOpacity' => 80,
233
- 'borderSize' => 0,
234
- 'borderRadius' => 0,
235
- 'shadowSize' => 0,
236
- 'imageSizeFactor' => 90,
237
- 'imageSizeFactorTabletLandscape' => 80,
238
- 'imageSizeFactorTabletPortrait' => 70,
239
- 'imageSizeFactorPhoneLandscape' => 60,
240
- 'imageSizeFactorPhonePortrait' => 50,
241
- 'imageSizeFactorCustom' => '',
242
- 'enlargeImages' => 'T',
243
- 'wp_field_caption' => 'description',
244
- 'captionBehavior' => 'hidden',
245
- 'captionFullHeight' => 'T',
246
- 'captionEmpty' => 'hide',
247
- 'captionEffect' => 'fade',
248
- 'captionEasing' => 'linear',
249
- 'captionMobileBehavior' => "desktop",
250
- 'scrollEffect' => 'none',
251
- 'hoverZoom' => 100,
252
- 'hoverRotation' => 0,
253
- 'source' => 'images',
254
- 'delay' => 0,
255
- 'socialIconColor' => '#ffffff',
256
- 'support' => 'F',
257
- 'loadedScale' => 100,
258
- 'loadedRotate' => 0,
259
- 'loadedHSlide' => 0,
260
- 'loadedVSlide' => 0
261
-
262
- );
263
-
264
- update_option('FinalTiles_gallery_options', $gallery_options);
265
- }
266
-
267
- //Delete gallery
268
- public function delete_gallery()
269
- {
270
- if(check_admin_referer('FinalTiles_gallery','FinalTiles_gallery'))
271
- {
272
- $this->FinalTilesdb->deleteGallery(intval($_POST['id']));
273
- }
274
- exit();
275
- }
276
-
277
- //Clone gallery
278
- public function clone_gallery()
279
- {
280
- if(check_admin_referer('FinalTiles_gallery','FinalTiles_gallery'))
281
- {
282
- $sourceId = intval($_POST['id']);
283
- $g = $this->FinalTilesdb->getGalleryById($sourceId, true);
284
- $g['name'] .= " (copy)";
285
- $this->FinalTilesdb->addGallery($g);
286
- $id = $this->FinalTilesdb->getNewGalleryId();
287
- $images = $this->FinalTilesdb->getImagesByGalleryId($sourceId);
288
- foreach($images as &$image)
289
- {
290
- $image->Id = null;
291
- $image->gid = $id;
292
- }
293
- $this->FinalTilesdb->addImages($id, $images);
294
- }
295
- exit();
296
- }
297
-
298
- //Add gallery scripts
299
- public function add_gallery_scripts()
300
- {
301
- wp_enqueue_script('jquery');
302
-
303
- wp_register_script('finalTilesGallery', plugins_url() . '/final-tiles-grid-gallery-lite/scripts/script.js', array('jquery'), FTGLITEVERSION);
304
- wp_enqueue_script('finalTilesGallery');
305
-
306
-
307
- wp_register_style('finalTilesGallery_stylesheet', plugins_url() . '/final-tiles-grid-gallery-lite/scripts/ftg.css', array(), FTGLITEVERSION);
308
- wp_enqueue_style('finalTilesGallery_stylesheet');
309
-
310
- wp_register_script('lightbox2_script', plugins_url() . '/final-tiles-grid-gallery-lite/lightbox/lightbox2/js/script.js', array('jquery'));
311
- wp_register_style('lightbox2_stylesheet', plugins_url() . '/final-tiles-grid-gallery-lite/lightbox/lightbox2/css/style.css');
312
 
313
- wp_register_style('fontawesome_stylesheet', '//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css');
314
- wp_enqueue_style('fontawesome_stylesheet');
315
 
316
- }
 
 
 
 
 
 
 
 
 
 
 
317
 
318
- //Admin Section - register scripts and styles
319
- public function gallery_admin_init()
320
- {
321
- if(function_exists( 'wp_enqueue_media' ))
322
- {
323
- wp_enqueue_media();
324
- }
325
- //wp_enqueue_script( 'custom-header' );
326
- wp_register_style('google-fonts', '//fonts.googleapis.com/css?family=Roboto:400,700,500,300,900');
327
- wp_enqueue_style('google-fonts');
328
-
329
- wp_register_style('google-icons', '//cdn.materialdesignicons.com/1.1.34/css/materialdesignicons.min.css', array());
330
- wp_enqueue_style('google-icons');
331
 
 
332
 
333
- wp_enqueue_script('jquery');
334
- wp_enqueue_script('jquery-ui-dialog');
335
- wp_enqueue_script('jquery-ui-sortable');
 
336
 
337
- wp_enqueue_script( 'wp-color-picker' );
338
- wp_enqueue_style( 'wp-color-picker' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
 
340
- wp_enqueue_script('media-upload');
341
- wp_enqueue_script('thickbox');
 
 
342
 
343
- wp_register_style('final-tiles-gallery-admin', plugins_url() . '/final-tiles-grid-gallery-lite/admin/css/style.css', array('colors'), FTGLITEVERSION);
344
- wp_enqueue_style('final-tiles-gallery-admin');
345
 
346
- wp_register_script('materialize', plugins_url() . '/final-tiles-grid-gallery-lite/admin/scripts/materialize.min.js', array('jquery'));
347
- wp_enqueue_script('materialize');
348
 
349
- wp_register_script('final-tiles-gallery', plugins_url() . '/final-tiles-grid-gallery-lite/admin/scripts/final-tiles-gallery-admin.js', array('jquery','media-upload','thickbox', 'materialize'), FTGLITEVERSION);
350
- wp_enqueue_script('final-tiles-gallery');
351
 
352
- wp_enqueue_style('thickbox');
 
353
 
354
- wp_register_style('fontawesome_stylesheet', '//netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.css');
355
  wp_enqueue_style('fontawesome_stylesheet');
 
356
 
357
- $ftg_db_version = '3.1';
358
- $installed_ver = get_option( "FinalTiles_gallery_db_version" );
 
 
 
 
 
 
 
 
 
 
 
 
 
359
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
 
361
- if( $installed_ver != $ftg_db_version )
362
- {
363
- $this->create_db_tables();
364
- update_option( "FinalTiles_gallery_db_version", $ftg_db_version );
365
- }
366
- }
367
 
368
- public function FinalTiles_gallery_admin_style_load()
369
- {
370
- wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/ui-darkness/jquery-ui.min.css');
371
- }
372
 
373
- //Create Admin Menu
374
- public function add_gallery_admin_menu()
375
- {
376
- $overview = add_menu_page('Final Tiles Gallery', 'Final Tiles Gallery', 'edit_posts', 'ftg-lite-gallery-admin', array($this, 'add_overview'), plugins_url() . '/final-tiles-grid-gallery-lite/admin/icon.png');
377
- $add_gallery = add_submenu_page('ftg-lite-gallery-admin', __('FinalTiles Gallery >> Add Gallery','FinalTiles-gallery'), __('Add Gallery','FinalTiles-gallery'), 'edit_posts', 'ftg-lite-add-gallery', array($this, 'add_gallery'));
378
- $plugins = add_submenu_page('ftg-lite-gallery-admin', __('FinalTiles Gallery >> Other galleries','FinalTiles-gallery'), __('Other galleries','FinalTiles-gallery'), 'edit_posts', 'ftg-lite-gallery-others', array($this, 'other_galleries'));
379
- $tutorial = add_submenu_page('ftg-lite-gallery-admin', __('FinalTiles Gallery >> Tutorial','FinalTiles-gallery'), __('Tutorial','FinalTiles-gallery'), 'edit_posts', 'ftg-lite-tutorial', array($this, 'tutorial'));
380
- $upgrade = add_submenu_page('ftg-lite-gallery-admin', __('FinalTiles Gallery >> Upgrade','FinalTiles-gallery'), __('Upgrade','FinalTiles-gallery'), 'edit_posts', 'ftg-lite-gallery-upgrade', array($this, 'upgrade'));
381
 
382
- add_action('admin_print_styles-'.$add_gallery, array($this, 'FinalTiles_gallery_admin_style_load'));
 
383
 
384
- //
 
385
 
 
 
 
 
386
 
387
- add_action('load-'.$tutorial, array($this, 'gallery_admin_init'));
388
- add_action('load-'.$overview, array($this, 'gallery_admin_init'));
389
- add_action('load-'.$plugins, array($this, 'gallery_admin_init'));
390
- add_action('load-'.$add_gallery, array($this, 'gallery_admin_init'));
391
- add_action('load-'.$upgrade, array($this, 'gallery_admin_init'));
392
- // add_action('load-'.$edit_gallery, array($this, 'gallery_admin_init'));
393
- // add_action('load-'.$support, array($this, 'gallery_admin_init'));
394
 
395
- add_action( 'admin_bar_menu', array($this, 'gallery_admin_bar'), 100);
396
- }
397
 
398
- //Create Admin Pages
399
- public function add_overview()
400
- {
401
- global $ftg_fields;
402
- $ftg_fields = $this->fields;
403
 
404
- global $ftg_parent_page;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
405
  $ftg_parent_page = "dashboard";
406
-
407
- if(array_key_exists("id", $_GET))
408
- {
409
- include("admin/edit-gallery.php");
410
- }
411
- else
412
- {
413
- include("admin/overview.php");
414
- }
415
- }
416
-
417
- public function upgrade()
418
- {
419
- include("admin/upgrade.php");
420
- }
421
-
422
- public function other_galleries()
423
- {
424
- include("admin/galleries.php");
425
- }
426
-
427
- public function tutorial()
428
- {
429
- include("admin/tutorial.php");
430
- }
431
-
432
- public function support()
433
- {
434
- include("admin/support.php");
435
- }
436
-
437
-
438
-
439
- public function add_gallery()
440
- {
441
- global $ftg_fields;
442
- $ftg_fields = $this->fields;
443
- $gallery = null;
444
-
445
- include("admin/add-gallery.php");
446
- }
447
-
448
- public function delete_image()
449
- {
450
- if(check_admin_referer('FinalTiles_gallery','FinalTiles_gallery'))
451
- {
452
- foreach (explode(",", $_POST["id"]) as $id) {
453
- $this->FinalTilesdb->deleteImage(intval($id));
454
- }
455
- }
456
- die();
457
- }
458
-
459
-
460
-
461
- public function add_image()
462
- {
463
- if(check_admin_referer('FinalTiles_gallery','FinalTiles_gallery'))
464
- {
465
- $gid = intval($_POST['galleryId']);
466
- $enc_images = stripslashes($_POST["enc_images"]);
467
- $images = json_decode($enc_images);
468
-
469
- $result = $this->FinalTilesdb->addImages($gid, $images);
470
-
471
- header("Content-type: application/json");
472
- if($result === false)
473
- {
474
- print "{\"success\":false}";
475
- }
476
- else
477
- {
478
- print "{\"success\":true}";
479
- }
480
- }
481
- die();
482
- }
483
-
484
- public function list_thumbnail_sizes()
485
- {
486
- global $_wp_additional_image_sizes;
487
- $sizes = array();
488
- foreach( get_intermediate_image_sizes() as $s )
489
- {
490
- $sizes[ $s ] = array( 0, 0 );
491
- if( in_array( $s, array( 'thumbnail', 'medium', 'large' ) ) )
492
- {
493
- $sizes[ $s ][0] = get_option( $s . '_size_w' );
494
- $sizes[ $s ][1] = get_option( $s . '_size_h' );
495
- }
496
- else
497
- {
498
- if( isset( $_wp_additional_image_sizes ) &&
499
- isset( $_wp_additional_image_sizes[ $s ] ))
500
- $sizes[ $s ] = array( $_wp_additional_image_sizes[ $s ]['width'], $_wp_additional_image_sizes[ $s ]['height'], );
501
- }
502
- }
503
-
504
- return $sizes;
505
- }
506
-
507
- public function sort_images()
508
- {
509
- if(check_admin_referer('FinalTiles_gallery','FinalTiles_gallery'))
510
- {
511
- $result = $this->FinalTilesdb->sortImages(explode(',', $_POST['ids']));
512
-
513
- header("Content-type: application/json");
514
- if($result === false)
515
- {
516
- print "{\"success\":false}";
517
- }
518
- else
519
- {
520
- print "{\"success\":true}";
521
- }
522
- }
523
- die();
524
- }
525
-
526
- public function refresh_gallery()
527
- {
528
- if($_POST['source'] == 'images')
529
- $this->list_images();
530
- if($_POST['source'] == 'posts')
531
- $this->list_posts(null);
532
- if($_POST['source'] == 'woocommerce')
533
- $this->list_posts('product');
534
- }
535
 
 
 
 
 
 
 
 
 
 
 
 
536
 
 
 
 
 
 
 
 
 
 
537
 
538
- public function save_image()
539
- {
540
- if(check_admin_referer('FinalTiles_gallery','FinalTiles_gallery'))
541
- {
542
- $result = false;
543
-
544
- $type = $_POST['type'];
545
- $imageUrl = stripslashes($_POST['img_url']);
546
- $imageCaption = stripslashes($_POST['description']);
547
- $target = $_POST['target'];
548
- $link = isset($_POST['link']) ? stripslashes($_POST['link']) : null;
549
- $imageId = intval($_POST['img_id']);
550
- $sortOrder = intval($_POST['sortOrder']);
551
-
552
- $data = array("imagePath" => $imageUrl,
553
- "target" => $target,
554
- "link" => $link,
555
- "imageId" => $imageId,
556
- "description" => $imageCaption,
557
- "sortOrder" => $sortOrder);
558
- if(!empty($_POST["id"]))
559
- {
560
- $imageId = intval($_POST['id']);
561
- $result = $this->FinalTilesdb->editImage($imageId, $data);
562
- }
563
- else
564
- {
565
- $data["gid"] = intval($_POST['galleryId']);
566
- $result = $this->FinalTilesdb->addFullImage($data);
567
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
568
 
569
- header("Content-type: application/json");
570
-
571
- if($result === false)
572
- {
573
- print "{\"success\":false}";
574
- }
575
- else
576
- {
577
- print "{\"success\":true}";
578
- }
579
- }
580
- die();
581
- }
582
-
583
-
584
-
585
- public function list_images()
586
- {
587
- if(check_admin_referer('FinalTiles_gallery','FinalTiles_gallery'))
588
- {
589
-
590
- $gid = intval($_POST["gid"]);
591
- $imageResults = $this->FinalTilesdb->getImagesByGalleryId($gid);
592
-
593
- $list_size = "medium";
594
- $column_size = "s2 m2";
595
-
596
- if(isset($_POST['list_size']) && !empty($_POST['list_size']))
597
- {
598
- $list_size = $_POST['list_size'];
599
- }
600
-
601
- setcookie('ftg_imglist_size', $list_size);
602
- $_COOKIE['ftg_imglist_size'] = $list_size;
603
-
604
- if($list_size == 'small')
605
- $column_size = 's1 m1';
606
- if($list_size == 'medium')
607
- $column_size = 's2 m2';
608
- if($list_size == 'big')
609
- $column_size = 's3 m3';
610
-
611
- include('admin/include/image-list.php');
612
- }
613
- die();
614
- }
615
-
616
- public function add_new_gallery()
617
- {
618
- if(check_admin_referer('add_new_gallery', 'ftg'))
619
- {
620
- $data = get_option('FinalTiles_gallery_options');
621
-
622
- $data["name"] = $_POST['ftg_name'];
623
- $data["description"] = $_POST['ftg_description'];
624
- $data["source"] = $_POST['ftg_source'];
625
- $data["wp_field_caption"] = $_POST['ftg_wp_field_caption'];
626
- $data["captionEffect"] = $_POST['ftg_captionEffect'];
627
-
628
- $result = $this->FinalTilesdb->addGallery($data);
629
- $id = $this->FinalTilesdb->getNewGalleryId();
630
-
631
- if($id > 0 && array_key_exists('enc_images', $_POST) && strlen($_POST['enc_images']))
632
- {
633
- $enc_images = stripslashes($_POST["enc_images"]);
634
- $images = json_decode($enc_images);
635
- $images = array_slice($images, 0, 40/2);
636
- $result = $this->FinalTilesdb->addImages($id, $images);
637
- }
638
-
639
- print $id;
640
- }
641
- else
642
- {
643
- print -1;
644
- }
645
- die();
646
- }
647
-
648
- private function checkboxVal($field)
649
- {
650
- if(isset($_POST[$field]))
651
- return 'T';
652
-
653
- return 'F';
654
- }
655
-
656
- public function save_gallery()
657
- {
658
- if(check_admin_referer('FinalTiles_gallery','FinalTiles_gallery'))
659
- {
660
- $galleryName = stripslashes($_POST['ftg_name']);
661
- $galleryDescription = stripslashes($_POST['ftg_description']);
662
- $slug = strtolower(str_replace(" ", "", $galleryName));
663
- $margin = intval($_POST['ftg_margin']);
664
- $minTileWidth = intval($_POST['ftg_minTileWidth']);
665
- $gridCellSize = intval($_POST['ftg_gridCellSize']);
666
- $imagesOrder = $_POST['ftg_imagesOrder'];
667
  $width = $_POST['ftg_width'];
668
- $enableTwitter = $this->checkboxVal('ftg_enableTwitter');
669
- $enableFacebook = $this->checkboxVal('ftg_enableFacebook');
670
- $enableGplus = $this->checkboxVal('ftg_enableGplus');
671
- $enablePinterest = $this->checkboxVal('ftg_enablePinterest');
672
- $lightbox = $_POST['ftg_lightbox'];
673
- $blank = $this->checkboxVal('ftg_blank');
674
- $imageSizeFactor = intval($_POST['ftg_imageSizeFactor']);
 
 
 
675
  $scrollEffect = $_POST['ftg_scrollEffect'];
676
  $captionBehavior = $_POST['ftg_captionBehavior'];
677
- $captionEffect = $_POST['ftg_captionEffect'];
678
- $captionColor = $_POST['ftg_captionColor'];
679
- $captionBackgroundColor = $_POST['ftg_captionBackgroundColor'];
680
- $captionEasing = $_POST['ftg_captionEasing'];
681
- $captionEmpty = $_POST['ftg_captionEmpty'];
682
- $captionOpacity = intval($_POST['ftg_captionOpacity']);
683
- $borderSize = intval($_POST['ftg_borderSize']);
684
- $borderColor = $_POST['ftg_borderColor'];
685
- $loadingBarColor=$_POST['ftg_loadingBarColor'];
686
- $loadingBarBackgroundColor=$_POST['ftg_loadingBarBackgroundColor'];
687
- $borderRadius = intval($_POST['ftg_borderRadius']);
688
- $shadowColor = $_POST['ftg_shadowColor'];
689
- $shadowSize = intval($_POST['ftg_shadowSize']);
690
- $enlargeImages = $this->checkboxVal('ftg_enlargeImages');
691
- $backgroundColor = $_POST['ftg_backgroundColor'];
692
- $wp_field_caption = $_POST['ftg_wp_field_caption'];
693
- $style = $_POST['ftg_style'];
694
- $script = $_POST['ftg_script'];
695
- $loadedScale=intval($_POST['ftg_loadedScale']);
696
- $loadedRotate=intval($_POST['ftg_loadedRotate']);
697
- $loadedHSlide=intval($_POST['ftg_loadedHSlide']);
698
- $loadedVSlide=intval($_POST['ftg_loadedVSlide']);
699
-
700
- $captionEffectDuration = intval($_POST['ftg_captionEffectDuration']);
701
- $id = isset($_POST['ftg_gallery_edit']) ? intval($_POST['ftg_gallery_edit']) : 0;
702
-
703
- $data = array('name' => $galleryName,
704
- 'slug' => $slug,
705
- 'description' => $galleryDescription,
706
- 'lightbox' => $lightbox,
707
- 'blank' => $blank,
708
- 'margin' => $margin,
709
- 'minTileWidth' => $minTileWidth,
710
- 'gridCellSize' => $gridCellSize,
711
- 'shuffle' => $shuffle,
712
- 'enableTwitter' => $enableTwitter,
713
- 'enableFacebook' => $enableFacebook,
714
- 'enableGplus' => $enableGplus,
715
- 'enablePinterest' => $enablePinterest,
716
- 'imagesOrder' => $imagesOrder,
717
- 'compressHTML' => $this->checkboxVal('ftg_compressHTML'),
718
- 'sequentialImageLoading' =>$this->checkboxVal('ftg_sequentialImageLoading'),
719
- 'socialIconColor' => $_POST['ftg_socialIconColor'],
720
- 'recentPostsCaption' => $_POST['ftg_recentPostsCaption'],
721
- 'recentPostsCaptionAutoExcerptLength' => intval($_POST['ftg_recentPostsCaptionAutoExcerptLength']),
722
- 'captionBehavior' => $captionBehavior,
723
- 'captionEffect' => $captionEffect,
724
- 'captionEmpty' => $captionEmpty,
725
- 'captionFullHeight' => $this->checkboxVal('ftg_captionFullHeight'),
726
- 'captionBackgroundColor' => $captionBackgroundColor,
727
- 'captionColor' => $captionColor,
728
- 'captionFrame' => $_POST['ftg_captionFrame'],
729
- 'captionFrameColor' => $_POST['ftg_captionFrameColor'],
730
- 'captionEffectDuration' => $captionEffectDuration,
731
- 'captionEasing' => $captionEasing,
732
- 'captionOpacity' => $captionOpacity,
733
- 'captionIcon' => $_POST['ftg_captionIcon'],
734
- 'captionFrame' => $this->checkboxVal('ftg_captionFrame'),
735
- 'captionFrameColor' => $_POST['ftg_captionFrameColor'],
736
- 'customCaptionIcon' => $_POST['ftg_customCaptionIcon'],
737
- 'captionIconColor' => $_POST['ftg_captionIconColor'],
738
- 'captionIconSize' => intval($_POST['ftg_captionIconSize']),
739
- 'captionFontSize' => intval($_POST['ftg_captionFontSize']),
740
- 'hoverZoom' => intval($_POST['ftg_hoverZoom']),
741
- 'hoverRotation' => intval($_POST['ftg_hoverRotation']),
742
- 'hoverIconRotation' => $this->checkboxVal('ftg_hoverIconRotation'),
743
- 'wp_field_caption' => $wp_field_caption,
744
- 'borderSize' => $borderSize,
745
- 'borderColor' => $borderColor,
746
- 'loadingBarColor'=>$loadingBarColor,
747
- 'loadingBarBackgroundColor'=>$loadingBarBackgroundColor,
748
- 'enlargeImages' => $enlargeImages,
749
- 'backgroundColor' => $backgroundColor,
750
- 'borderRadius' => $borderRadius,
751
- 'imageSizeFactor' => $imageSizeFactor,
752
- 'imageSizeFactorTabletLandscape' => intval($_POST['ftg_imageSizeFactorTabletLandscape']),
753
- 'imageSizeFactorTabletPortrait' => intval($_POST['ftg_imageSizeFactorTabletPortrait']),
754
- 'imageSizeFactorPhoneLandscape' => intval($_POST['ftg_imageSizeFactorPhoneLandscape']),
755
- 'imageSizeFactorPhonePortrait' => intval($_POST['ftg_imageSizeFactorPhonePortrait']),
756
- 'imageSizeFactorCustom' => $_POST['ftg_imageSizeFactorCustom'],
757
- 'shadowSize' => $shadowSize,
758
- 'shadowColor' => $shadowColor,
759
- 'source' => $_POST['ftg_source'],
760
- 'post_types' => $_POST['ftg_post_types'],
761
- 'post_categories' => $_POST['ftg_post_categories'],
762
- 'post_tags' => $_POST['ftg_post_tags'],
763
- 'woo_categories' => $_POST['ftg_woo_categories'],
764
- 'defaultPostImageSize' => $_POST['ftg_defaultPostImageSize'],
765
- 'defaultWooImageSize' => $_POST['ftg_defaultWooImageSize'],
766
- 'width' => $width,
767
- 'beforeGalleryText' => $_POST['ftg_beforeGalleryText'],
768
- 'afterGalleryText' => $_POST['ftg_afterGalleryText'],
769
- 'aClass' => $_POST['ftg_aClass'],
770
- 'rel' => $_POST['ftg_rel'],
771
- 'style' => $style,
772
- 'delay' => intval($_POST['ftg_delay']),
773
- 'script' => $script,
774
- 'support' => $this->checkboxVal('ftg_support'),
775
- 'supportText' => $_POST['ftg_supportText'],
776
- 'envatoReferral' => $_POST['ftg_envatoReferral'],
777
- 'scrollEffect' => $scrollEffect,
778
- 'loadedScale' => $loadedScale,
779
- 'loadedRotate' => $loadedRotate,
780
- 'loadedHSlide' => $loadedHSlide,
781
- 'loadedVSlide' => $loadedVSlide
782
- );
783
-
784
- header("Content-type: application/json");
785
- if($id > 0)
786
- {
787
- $result = $this->FinalTilesdb->editGallery($id, $data);
788
- }
789
- else
790
- {
791
- $result = $this->FinalTilesdb->addGallery($data);
792
- $id = $this->FinalTilesdb->getNewGalleryId();
793
- }
794
-
795
- if($result)
796
- print "{\"success\":true,\"id\":" . $id ."}";
797
- else
798
- print "{\"success\":false}";
799
- }
800
- die();
801
- }
802
-
803
- public static function get_image_size_links($id)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
804
  {
805
  $result = array();
806
  $sizes = get_intermediate_image_sizes();
@@ -816,482 +1089,619 @@ if (!class_exists("FinalTiles_GalleryLite"))
816
  return $result;
817
  }
818
 
819
- //Create gallery
820
- public function create_gallery($galleryId)
821
- {
822
- require_once('lib/gallery-class.php');
823
- global $FinalTilesGallery;
824
-
825
- if (class_exists('FinalTilesGallery')) {
826
- $FinalTilesGallery = new FinalTilesGallery($galleryId, $this->FinalTilesdb);
827
- $settings = $FinalTilesGallery->getGallery();
828
- switch($settings->lightbox)
829
- {
830
- default:
831
- case "magnific":
832
- wp_enqueue_style('magnific_stylesheet');
833
- wp_enqueue_script('magnific_script');
834
- break;
835
- case "prettyphoto":
836
- wp_enqueue_style('prettyphoto_stylesheet');
837
- wp_enqueue_script('prettyphoto_script');
838
- break;
839
- case "fancybox":
840
- wp_enqueue_style('fancybox_stylesheet');
841
- wp_enqueue_script('fancybox_script');
842
- break;
843
- case "colorbox":
844
- wp_enqueue_style('colorbox_stylesheet');
845
- wp_enqueue_script('colorbox_script');
846
- break;
847
- case "swipebox":
848
- wp_enqueue_style('swipebox_stylesheet');
849
- wp_enqueue_script('swipebox_script');
850
- break;
851
- case "lightbox2":
852
- wp_enqueue_style('lightbox2_stylesheet');
853
- wp_enqueue_script('lightbox2_script');
854
- break;
855
- case "image-lightbox":
856
- wp_enqueue_script('image-lightbox_script');
857
- break;
858
- }
859
- return $FinalTilesGallery->render();
860
- }
861
- else {
862
- return "Gallery not found.";
863
- }
864
- }
865
-
866
- //Create Short Code
867
- public function gallery_shortcode_handler($atts) {
868
- return $this->create_gallery($atts['id']);
869
- }
870
-
871
- static public function slugify($text)
872
- {
873
- $text = preg_replace('~[^\\pL\d]+~u', '-', $text);
874
- $text = trim($text, '-');
875
- $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
876
- $text = strtolower($text);
877
- $text = preg_replace('~[^-\w]+~', '', $text);
878
-
879
- if (empty($text))
880
- {
881
- return 'n-a';
882
- }
883
-
884
- return $text;
885
- }
886
-
887
- var $fields = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
888
 
889
  "General" => array(
890
- "icon" => "mdi mdi-settings",
891
- "fields" => array(
892
- "name" => array(
893
- "name" => "Name",
894
- "hiddenFor" => array("dashboard", "shortcode"),
895
- "type" => "text",
896
- "description" => "Name of the gallery, for internal use.",
897
- "excludeFrom" => array("dashboard", "shortcode")
898
- ),
899
- "description" => array(
900
- "name" => "Description",
901
- "hiddenFor" => array("dashboard", "shortcode"),
902
- "type" => "text",
903
- "description" => "Description of the gallery, for internal use.",
904
- "excludeFrom" => array("dashboard", "shortcode")
905
- ),
906
- "width" => array(
907
- "name" => "Width",
908
- "type" => "text",
909
- "description" => "Width of the gallery in pixels or percentage.",
910
- "excludeFrom" => array()
911
- ),
912
- "margin" => array(
913
- "name" => "Margin",
914
- "type" => "number",
915
- "description" => "Margin between images",
916
- "mu" => "px",
917
- "min" => 0,
918
- "max" => 50,
919
- "excludeFrom" => array()
920
- ),
921
- "imageSizeFactor" => array(
922
- "name" => "Image size factor",
923
- "type" => "slider",
924
- "description" => "Percentage of image size, i.e.: if an image of the gallery is 300x200 and the size factor is 50% then the resulting image will be 150x100.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
925
  90% is a suggested default value, because under some circumstances, the images could be enlarged by the script (to fill gaps and avoid blank spaces between tiles).",
926
- "default" => 90,
927
- "min" => 1,
928
- "max" => 100,
929
- "mu" => "%",
930
- "excludeFrom" => array()
931
- ),
932
  "imageSizeFactorTabletLandscape" => array(
933
- "name" => "Image size factor Tablet Landscape",
934
- "type" => "slider",
935
- "description" => "Image size factor to apply when the viewport is 1024px, typically for tablets with landscape orientation",
936
- "default" => 80,
937
- "min" => 1,
938
- "max" => 100,
939
- "mu" => "%",
940
- "excludeFrom" => array()
941
- ),
942
  "imageSizeFactorTabletPortrait" => array(
943
- "name" => "Image size factor Tablet Portrait",
944
- "type" => "slider",
945
- "description" => "Image size factor to apply when the viewport is 768px, typically for tablets with portrait orientation",
946
- "default" => 70,
947
- "min" => 1,
948
- "max" => 100,
949
- "mu" => "%",
950
- "excludeFrom" => array()
951
- ),
952
  "imageSizeFactorPhoneLandscape" => array(
953
- "name" => "Image size factor Smartphone Landscape",
954
- "type" => "slider",
955
- "description" => "Image size factor to apply when the viewport is 640px, typically for smartphones with landscape orientation",
956
- "default" => 60,
957
- "min" => 1,
958
- "max" => 100,
959
- "mu" => "%",
960
- "excludeFrom" => array()
961
- ),
962
  "imageSizeFactorPhonePortrait" => array(
963
- "name" => "Image size factor Phone Portrait",
964
- "type" => "slider",
965
- "description" => "Image size factor to apply when the viewport is 320px, typically for smartphones with portrait orientation",
966
- "default" => 50,
967
- "min" => 1,
968
- "max" => 100,
969
- "mu" => "%",
970
- "excludeFrom" => array()
971
- ),
972
- "imageSizeFactorCustom" => array(
973
- "name" => "Custom image size factor",
974
- "hiddenFor" => array("dashboard", "shortcode"),
975
- "type" => "custom_isf",
976
- "description" => "Use this field if you need further resolutions.",
977
- "excludeFrom" => array("dashboard", "shortcode")
978
- ),
979
- "minTileWidth" => array(
980
- "name" => "Tile minimum width",
981
- "type" => "number",
982
- "description" => "Minimum width of each tile, <strong>multiply this value for the image size factor to get the real size</strong>.",
983
- "mu" => "px",
984
- "min" => 50,
985
- "max" => 500,
986
- "default" => 200,
987
- "excludeFrom" => array()
988
- ),
989
- "imagesOrder" => array(
990
- "name" => "Images order",
991
- "type" => "PRO_FEATURE",
992
- "description" => "Choose the order of the images",
993
- "default" => "",
994
- "values" => array(
995
- "Images order" => array(
996
- "user|User", "reverse|Reverse", "random|Random"
997
- )
998
- ),
999
- "excludeFrom" => array()
1000
- ),
1001
- "filter" => array(
1002
- "name" => "Filters",
1003
- "type" => "PRO_FEATURE",
1004
- "description" => "Manage here all the filters of this gallery",
1005
- "excludeFrom" => array("dashboard", "shortcode")
1006
- ),
1007
- "gridCellSize" => array(
1008
- "name" => "Size of the grid",
1009
- "type" => "number",
1010
- "default" => 25,
1011
- "min" => 1,
1012
- "max" => 100,
1013
- "mu" => "px",
1014
- "description" => "Tiles are snapped to a virtual grid, <strong>the higher this value the higher the chance to get bottom aligned tiles</strong> (but it needs to crop horizontally).",
1015
- "excludeFrom" => array()
1016
- ),
1017
- "enlargeImages" => array(
1018
- "name" => "Allow image enlargement",
1019
- "type" => "toggle",
1020
- "description" => "Images can be occasionally enlarged to avoid gaps. If you notice a quality loss try to reduce the <strong>Image size factor</strong> parameter.",
1021
- "default" => "T",
1022
- "excludeFrom" => array()
1023
- ),
1024
- "scrollEffect" => array(
1025
- "name" => "Scroll effect",
1026
- "type" => "PRO_FEATURE",
1027
- "description" => "Effect on tiles when scrolling the page",
1028
- "values" => array(
1029
- "Scroll effect" => array(
1030
- "none|None", "slide|Sliding tiles", "zoom|Zoom", "rotate-left|Left rotation", "rotate-right|Right rotation"
1031
- )
1032
- ),
1033
- "excludeFrom" => array()
1034
- ),
1035
- "compressHTML" => array(
1036
- "name" => "Compress HTML",
1037
- "type" => "toggle",
1038
- "description" => "Enable or disable HTML compression, some themes prefer uncompressed, switch it off in case of problems.",
1039
- "default" => "T",
1040
- "excludeFrom" => array()
1041
- ),
1042
- "sequentialImageLoading"=>array(
1043
- "name"=>"Sequential image loading",
1044
- "type"=>"toggle",
1045
- "description"=>"Load images sequentially for higher performances. N.B.: search engines won't index your images if sequential loading is activated.",
1046
- "default"=>"T",
1047
- "excludeFrom"=>array()
1048
- ),
1049
- )
1050
  ),
1051
  "Links & Lightbox" => array(
1052
- "icon" => "mdi mdi-link-variant",
1053
- "fields" => array(
1054
- "lightbox" => array(
1055
- "name" => "Lightbox &amp; Links",
1056
- "type" => "select",
1057
- "description" => "Define here what happens when user click on the images.<br><strong><a href='http://1.envato.market/c/288541/275988/4415?u=https%3A%2F%2Fcodecanyon.net%2Fitem%2Ffinal-tiles-wordpress-gallery%2F5189351' target='_blank'>Buy a PRO license</a></strong> to unlock 5 more lightboxes.",
1058
- "values" => array(
1059
- "Link" => array("|No link", "direct|Direct link to image"),
1060
- "Lightboxes" => array("lightbox2|Lightbox")
1061
- ),
1062
- "excludeFrom" => array()
1063
- ),
1064
- "blank" => array(
1065
- "name" => "Links target",
1066
- "type" => "toggle",
1067
- "description" => "Open links in a blank page.",
1068
- "excludeFrom" => array()
1069
- ),
1070
- "enableTwitter" => array(
1071
- "name" => "Enable Twitter icon",
1072
- "type" => "toggle",
1073
- "description" => "Enable Twitter sharing.",
1074
- "default" => "F",
1075
- "excludeFrom" => array()
1076
- ),
1077
- "enableFacebook" => array(
1078
- "name" => "Enable Facebook icon",
1079
- "type" => "toggle",
1080
- "description" => "Enable Facebook sharing.",
1081
- "default" => "F",
1082
- "excludeFrom" => array()
1083
- ),
1084
- "enableGplus" => array(
1085
- "name" => "Enable Google Plus icon",
1086
- "type" => "toggle",
1087
- "description" => "Enable Google Plus sharing",
1088
- "default" => "F",
1089
- "excludeFrom" => array()
1090
- ),
1091
- "enablePinterest" => array(
1092
- "name" => "Enable Pinterest icon",
1093
- "type" => "toggle",
1094
- "description" => "Enable Pinterest sharing",
1095
- "default" => "F",
1096
- "excludeFrom" => array()
1097
- ),
1098
- "socialIconColor" => array(
1099
- "name" => "Color of social sharing icons",
1100
- "type" => "color",
1101
- "description" => "Set the color of the social sharing icons",
1102
- "default" => "#ffffff",
1103
- "excludeFrom" => array()
1104
- )
1105
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1106
  ),
1107
  "Captions" => array(
1108
- "icon" => "mdi mdi-comment-text-outline",
1109
- "fields" => array(
1110
- "captionBehavior" => array(
1111
- "name" => "Caption behavior",
1112
- "type" => "PRO_FEATURE",
1113
- "description" => "Captions can have two different behaviors: start hidden and shown on mouse over or viceversa.",
1114
- "values" => array(
1115
- "Behavior" => array(
1116
- "hidden|Hidden, then show it on mouse over",
1117
- "visible|Visible, then hide it on mouse over",
1118
- "always-visible|Always visible"
1119
- )
1120
- ),
1121
- "excludeFrom" => array()
1122
- ),
1123
- "captionMobileBehavior" => array(
1124
- "name" => "Caption mobile behavior",
1125
- "type" => "PRO_FEATURE",
1126
- "description" => "Caption behavior for mobile devices.",
1127
- "values" => array(
1128
- "Behavior" => array(
1129
- "desktop|Same as desktop",
1130
- "none|Never show captions",
1131
- "hidden|Hidden, then show it on touch",
1132
- "visible|Visible, then hide it on touch",
1133
- "always-visible|Always visible"
1134
- )
1135
- ),
1136
- "excludeFrom" => array()
1137
- ),
1138
- "captionFullHeight" => array(
1139
- "name" => "Caption full height",
1140
- "type" => "PRO_FEATURE",
1141
- "description" => "Enable this option for full height captions. <strong>This is required if you want to use caption icons and caption effects other than <i>fade</i>.</strong>",
1142
- "default" => "T",
1143
- "excludeFrom" => array()
1144
- ),
1145
- "captionEmpty" => array(
1146
- "name" => "Empty captions",
1147
- "type" => "PRO_FEATURE",
1148
- "description" => "Choose if empty caption has to be shown. Consider that empty captions are never shown if <i>Caption full height</i> is switched off.",
1149
- "values" => array(
1150
- "Empty captions" => array(
1151
- "hide|Don't show empty captions",
1152
- "show|Show empty captions"
1153
- )
1154
- ),
1155
- "excludeFrom" => array()
1156
- ),
1157
- "captionIcon" => array(
1158
- "name" => "Caption icon",
1159
- "type" => "select",
1160
- "description" => "Choose the icon for the captions.",
1161
- "values" => array(
1162
- "Icon" => array("|None", "search|Lens", "search-plus|Lens (plus)", "link|Link", "heart|Heart", "heart-o|Heart empty",
1163
- "camera|Camera", "camera-retro|Camera retro", "picture-o|Picture", "star|Star", "star-o|Star empty",
1164
- "sun-o|Sun", "arrows-alt|Arrows", "hand-o-right|Hand")
1165
- ),
1166
- "excludeFrom" => array()
1167
- ),
1168
- "customCaptionIcon" => array(
1169
- "name" => "Custom caption icon",
1170
- "type" => "PRO_FEATURE",
1171
- "description" => "Use this field to insert the class of a FontAwesome icon (i.e.: fa-heart). <a href='http://fontawesome.io/icons/' target='blank'>See all available icons</a>. <strong>This value override the <i>Caption icon</i> value</strong>.",
1172
- "excludeFrom" => array()
1173
- ),
1174
- "captionIconColor" => array(
1175
- "name" => "Caption icon color",
1176
- "type" => "color",
1177
- "description" => "Color of the icon in captions.",
1178
- "default" => "#ffffff",
1179
- "excludeFrom" => array()
1180
- ),
1181
- "captionIconSize" => array(
1182
- "name" => "Caption icon size",
1183
- "type" => "number",
1184
- "description" => "Size of the icon in captions.",
1185
- "default" => 12,
1186
- "min" => 10,
1187
- "max" => 96,
1188
- "mu" => "px",
1189
- "excludeFrom" => array()
1190
- ),
1191
- "captionFontSize" => array(
1192
- "name" => "Caption font size",
1193
- "type" => "number",
1194
- "description" => "Size of the font in captions.",
1195
- "default" => 12,
1196
- "min" => 10,
1197
- "max" => 96,
1198
- "mu" => "px",
1199
- "excludeFrom" => array()
1200
- ),
1201
- "captionEffect" => array(
1202
- "name" => "Caption effect",
1203
- "type" => "PRO_FEATURE",
1204
- "description" => "Effect used to show the captions.",
1205
- "values" => array(
1206
- "Effect" => array("fade|Fade", "slide-top|Slide from top", "slide-bottom|Slide from bottom",
1207
- "slide-left|Slide from left", "slide-right|Slide from right", "rotate-left|Rotate from left",
1208
- "rotate-right|Rotate from right")
1209
- ),
1210
- "excludeFrom" => array()
1211
- ),
1212
- "captionEasing" => array(
1213
- "name" => "Caption effect easing",
1214
- "type" => "PRO_FEATURE",
1215
- "description" => "Easing function for the caption animation, works better with sliding animations.",
1216
- "values" => array(
1217
- "Easing" => array(
1218
- "ease|Ease", "linear|Linear", "ease-in|Ease in", "ease-out|Ease out", "ease-in-out|Ease in and out")
1219
- ),
1220
- "excludeFrom" => array()
1221
- ),
1222
- "captionFrame" => array(
1223
- "name" => "Caption frame",
1224
- "type" => "toggle",
1225
- "description" => "Add a frame around the caption",
1226
- "default" => "F",
1227
- "excludeFrom" => array()
1228
- ),
1229
- "captionFrameColor" => array(
1230
- "name" => "Caption frame color",
1231
- "type" => "color",
1232
- "description" => "Color of the frame around the caption",
1233
- "default" => "#ffffff",
1234
- "excludeFrom" => array()
1235
- ),
1236
- "captionColor" => array(
1237
- "name" => "Caption color",
1238
- "type" => "color",
1239
- "description" => "Text color of the captions.",
1240
- "default" => "#ffffff",
1241
- "excludeFrom" => array()
1242
- ),
1243
- "captionEffectDuration" => array(
1244
- "name" => "Caption effect duration",
1245
- "type" => "text",
1246
- "description" => "Duration of the caption animation.",
1247
- "default" => 250,
1248
- "mu" => "ms",
1249
- "min" => 0,
1250
- "max" => 1000,
1251
- "excludeFrom" => array()
1252
- ),
1253
- "captionBackgroundColor" => array(
1254
- "name" => "Caption background color",
1255
- "type" => "color",
1256
- "description" => "This background is visible only when the parameter '<i>Allow image enlargement</i>' is set to '<i>Off</i>' and only when a tile is wider than the contained image",
1257
- "default" => "#000000",
1258
- "excludeFrom" => array()
1259
- ),
1260
- "captionOpacity" => array(
1261
- "name" => "Caption opacity",
1262
- "type" => "text",
1263
- "description" => "Opacity of the caption, 0% means 'invisible' while 100% is a plain color without opacity.",
1264
- "default" => 80,
1265
- "min" => 0,
1266
- "max" => 100,
1267
- "mu" => "%",
1268
- "excludeFrom" => array()
1269
- )
1270
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1271
  ),
1272
  "Hover effects" => array(
1273
- "icon" => "mdi mdi-file-image",
1274
- "fields" => array(
1275
- "hoverZoom" => array(
1276
- "name" => "Zoom",
1277
- "type" => "PRO_FEATURE",
1278
- "description" => "Scale value.",
1279
- "default" => 100,
1280
- "min" => 0,
1281
- "max" => 600,
1282
  "mu" => "%",
1283
- "excludeFrom" => array()
1284
- ),
1285
- "hoverRotation" => array(
1286
- "name" => "Rotation",
1287
- "type" => "PRO_FEATURE",
1288
- "description" => "Rotation value in degrees.",
1289
- "min" => 0,
1290
- "max" => 360,
1291
  "mu" => "deg",
1292
  "default" => 0,
1293
- "excludeFrom" => array()
1294
- ),
1295
  "hoverIconRotation" => array(
1296
  "name" => "Rotate icon",
1297
  "type" => "toggle",
@@ -1299,150 +1709,157 @@ if (!class_exists("FinalTiles_GalleryLite"))
1299
  "description" => "Enable rotation of the icon.",
1300
  "excludeFrom" => array()
1301
  )
1302
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1303
  ),
1304
- "Image loaded effects" => array(
1305
- "icon" => "mdi mdi-reload",
1306
- "fields" => array(
1307
- "loadedScale" => array(
1308
- "name" => "Scale",
1309
- "description" => "",
1310
- "type" => "slider",
1311
- "min" => 0,
1312
- "max" => 200,
1313
- "mu" => "%",
1314
- "default"=>100,
1315
- "excludeFrom" => array()
1316
- ),
1317
- "loadedRotate" => array(
1318
- "name" => "Rotate",
1319
- "description" => "",
1320
- "type" => "slider",
1321
- "min" => -180,
1322
- "max" => 180,
1323
- "default" => 0,
1324
- "mu" => "deg",
1325
- "excludeFrom" => array()
1326
- ),
1327
- "loadedHSlide" => array(
1328
- "name" => "Horizontal slide",
1329
- "description" => "",
1330
- "type" => "slider",
1331
- "min" => -100,
1332
- "max" => 100,
1333
- "mu" => "px",
1334
- "default" => 0,
1335
- "excludeFrom" => array()
1336
- ),
1337
- "loadedVSlide" => array(
1338
- "name" => "Vertical slide",
1339
- "description" => "",
1340
- "type" => "slider",
1341
- "min" => -100,
1342
- "max" => 100,
1343
- "mu" => "px",
1344
- "default" => 0,
1345
- "excludeFrom" => array()
1346
- )
1347
-
1348
- )
1349
- ),
1350
  "Style" => array(
1351
- "icon" => "mdi mdi-format-paint",
1352
- "fields" => array(
1353
- "borderSize" => array(
1354
- "name" => "Border size",
1355
- "type" => "number",
1356
- "description" => "Size of the border of each image.",
1357
- "default" => 0,
1358
- "min" => 0,
1359
- "max" => 10,
1360
- "mu" => "px",
1361
- "excludeFrom" => array()
1362
- ),
1363
- "borderRadius" => array(
1364
- "name" => "Border radius",
1365
- "type" => "number",
1366
- "description" => "Border radius of the images.",
1367
- "default" => 0,
1368
- "min" => 0,
1369
- "max" => 100,
1370
- "mu" => "px",
1371
- "excludeFrom" => array()
1372
- ),
1373
- "borderColor" => array(
1374
- "name" => "Border color",
1375
- "type" => "color",
1376
- "description" => "Color of the border when size is greater than 0.",
1377
- "default" => "#000000",
1378
- "excludeFrom" => array()
1379
- ),
1380
- "loadingBarColor"=>array(
1381
- "name" => "Loading Bar color",
1382
- "type" => "color",
1383
- "description" => "Color of the loading bar",
1384
- "default" => "#000000",
1385
- "excludeFrom" => array()
1386
- ),
1387
- "loadingBarBackgroundColor"=>array(
1388
- "name" => "Loading Bar background color",
1389
- "type" => "color",
1390
- "description" => "Background color of the loading bar",
1391
- "default" => "#cccccc",
1392
- "excludeFrom" => array()
1393
- ),
1394
- "shadowSize" => array(
1395
- "name" => "Shadow size",
1396
- "type" => "number",
1397
- "description" => "Shadow size of the images.",
1398
- "default" => 0,
1399
- "min" => 0,
1400
- "max" => 20,
1401
- "mu" => "px",
1402
- "excludeFrom" => array()
1403
- ),
1404
- "shadowColor" => array(
1405
- "name" => "Shadow color",
1406
- "type" => "color",
1407
- "description" => "Color of the shadow when size is greater than 0.",
1408
- "default" => "#000000",
1409
- "excludeFrom" => array()
1410
- )
1411
- )
 
 
 
 
 
 
 
1412
  ),
1413
  "Customizations" => array(
1414
- "icon" => "mdi mdi-puzzle",
1415
- "fields" => array(
1416
  "aClass" => array(
1417
- "name" => "Additional CSS class on A tag",
1418
- "type" => "text",
1419
- "description" => "Use this field if you need to add additional CSS classes to the link that contains the image.",
1420
- "default" => "",
1421
- "excludeFrom" => array()
1422
- ),
1423
  "rel" => array(
1424
- "name" => "Value of 'rel' attribute on the link that contains the image.",
1425
- "type" => "text",
1426
- "description" => "Use this field if you need to add additional CSS classes to the link that contains the image. This is useful mostly to integrate the gallery with other lightbox plugins.",
1427
- "default" => "",
1428
- "excludeFrom" => array()
1429
- ),
1430
- "beforeGalleryText" => array(
1431
- "name" => "Text before gallery",
1432
- "type" => "textarea",
1433
- "description" => "Use this field to add text/html to be placed just before your gallery.",
1434
- "excludeFrom" => array("shortcode")
1435
- ),
1436
- "afterGalleryText" => array(
1437
- "name" => "Text after gallery",
1438
- "type" => "textarea",
1439
- "description" => "Use this field to add text/html to be placed just after your gallery.",
1440
- "excludeFrom" => array("shortcode")
1441
- ),
1442
- "style" => array(
1443
- "name" => "Custom CSS",
1444
- "type" => "textarea",
1445
- "description" => "<strong>Write just the code without using the &lt;style&gt; tag.</strong><br>List of useful selectors:<br>
1446
  <br>
1447
  <ul>
1448
  <li>
@@ -1467,57 +1884,57 @@ if (!class_exists("FinalTiles_GalleryLite"))
1467
  <em>.final-tiles-gallery .ftg-filters a.selected</em> : selected filter
1468
  </li>
1469
  </ul>",
1470
- "excludeFrom" => array("shortcode")
1471
- ),
1472
- "script" => array(
1473
- "name" => "Custom scripts",
1474
- "type" => "textarea",
1475
- "description" => "This script will be called after the gallery initialization. Useful for custom lightboxes.
1476
  <br />
1477
  <br />
1478
  <strong>Write just the code without using the &lt;script&gt;&lt;/script&gt; tags</strong>",
1479
- "excludeFrom" => array("shortcode")
1480
- ),
1481
- "delay" => array(
1482
- "name" => "Delay",
1483
- "type" => "text",
1484
- "description" => "Delay (in milliseconds) before firing the gallery. Sometimes it's needed to avoid conflicts with other plugins.",
1485
- "min" => 0,
1486
- "max" => 5000,
1487
  "mu" => "ms",
1488
  "default" => 0,
1489
- "excludeFrom" => array()
1490
- ),
1491
- "support" => array(
1492
- "name" => "Show developer link",
1493
- "type" => "toggle",
1494
- "description" => "I want to support this plugin, show the developer link!",
1495
- "default" => "F",
1496
- "excludeFrom" => array(),
1497
- "excludeFrom" => array()
1498
- ),
1499
- "supportText" => array(
1500
- "name" => "Developer link text",
1501
- "type" => "text",
1502
- "description" => "Text for the developer link",
1503
- "default" => "powered by Final Tiles Grid Gallery",
1504
- "excludeFrom" => array()
1505
- ),
1506
- "envatoReferral" => array(
1507
- "name" => "Envato username for referral",
1508
- "type" => "text",
1509
- "description" => "Enter your Envato username to earn money! Receive 30% of the first purchase or deposit of each referred user. You do not need to activate anything else, you are automatically eligible.",
1510
- "default" => "GreenTreeLabs",
1511
- "excludeFrom" => array()
1512
- )
1513
- )
1514
  )
1515
  );
1516
- }
1517
  }
1518
 
1519
  if (class_exists("FinalTiles_GalleryLite")) {
1520
  global $ob_FinalTiles_GalleryLite;
1521
- $ob_FinalTiles_GalleryLite = new FinalTiles_GalleryLite();
1522
  }
1523
- ?>
4
  Plugin URI: http://codecanyon.net/item/final-tiles-gallery-for-wordpress/5189351?ref=GreenTreeLabs
5
  Description: Wordpress Plugin for creating responsive image galleries. By: Green Tree Labs
6
  Author: Green Tree Labs
7
+ Version: 3.0.0
8
  Author URI: http://codecanyon.net/user/GreenTreeLabs
9
  */
10
 
11
+ define("FTGLITEVERSION", "3.0.0");
12
  define("PRO_CALL", "<span class='procall'>(<a href='http://1.envato.market/c/288541/275988/4415?u=https%3A%2F%2Fcodecanyon.net%2Fitem%2Ffinal-tiles-wordpress-gallery%2F5189351' target='_blank'>available with PRO version</a>)</span>");
13
  define("PRO_UNLOCK", "<a href='http://1.envato.market/c/288541/275988/4415?u=https%3A%2F%2Fcodecanyon.net%2Fitem%2Ffinal-tiles-wordpress-gallery%2F5189351' target='_blank'>Add unlimited images with PRO version</a>");
14
 
15
+
16
  if (!class_exists("FinalTiles_GalleryLite"))
17
  {
18
+ class FinalTiles_GalleryLite
19
  {
20
+ private $defaultValues = array(
21
+ 'aClass' => '',
22
+ 'afterGalleryText' => '',
23
+ 'allFilterLabel' => 'All',
24
+ 'ajaxLoading' => 'F',
25
+ 'backgroundColor' => 'transparent',
26
+ 'beforeGalleryText' => '',
27
+ 'blank' => 'F',
28
+ 'borderColor' => 'transparent',
29
+ 'borderRadius' => 0,
30
+ 'borderSize' => 0,
31
+ 'captionBackgroundColor' => '#000000',
32
+ 'captionBehavior' => 'hidden',
33
+ 'captionColor' => '#ffffff',
34
+ 'captionEasing' => 'linear',
35
+ 'captionEffect' => 'fade',
36
+ 'captionEffectDuration' => 250,
37
+ 'captionEmpty' => 'hide',
38
+ 'captionFontSize' => 12,
39
+ 'captionFrame' => 'F',
40
+ 'captionFrameColor' => '#ffffff',
41
+ 'captionFullHeight' => 'T',
42
+ 'captionHorizontalAlignment' => 'Center',
43
+ 'captionIcon' => 'zoom',
44
+ 'captionIconColor' => '#ffffff',
45
+ 'captionIconSize' => 12,
46
+ 'captionMobileBehavior' => "desktop",
47
+ 'captionOpacity' => 80,
48
+ 'captionPosition' => 'inside',
49
+ 'captionVerticalAlignment' => 'Middle',
50
+ 'columns' => 4,
51
+ 'columnsPhoneLandscape' => 3,
52
+ 'columnsPhonePortrait' => 2,
53
+ 'columnsTabletLandscape' => 4,
54
+ 'columnsTabletPortrait' => 3,
55
+ 'compressHTML' => 'T',
56
+ 'customCaptionIcon' =>'',
57
+ 'defaultFilter' => '',
58
+ 'defaultSize' => 'medium',
59
+ 'delay' => 0,
60
+ 'disableLightboxGroups' => 'F',
61
+ 'enableFacebook' => 'F',
62
+ 'enableGplus' => 'F',
63
+ 'enablePinterest' => 'F',
64
+ 'enableTwitter' => 'F',
65
+ 'enlargeImages' => 'T',
66
+ 'envatoReferral' => 'GreenTreeLabs',
67
+ 'filterClick' => 'F',
68
+ 'filters' => '',
69
+ 'gridCellSize' => '25',
70
+ 'hoverIconRotation' => 'F',
71
+ 'hoverRotation' => 0,
72
+ 'hoverZoom' => 100,
73
+ 'imageSizeFactor' => 90,
74
+ 'imageSizeFactorCustom' => '',
75
+ 'imageSizeFactorPhoneLandscape' => 60,
76
+ 'imageSizeFactorPhonePortrait' => 50,
77
+ 'imageSizeFactorTabletLandscape' => 80,
78
+ 'imageSizeFactorTabletPortrait' => 70,
79
+ 'imagesOrder' => 'user',
80
+ 'layout' => 'final',
81
+ 'lazyLoad' => false,
82
+ 'lightbox' => 'lightbox2',
83
+ 'lightboxImageSize' => 'large',
84
+ 'loadedHSlide' => 0,
85
+ 'loadedRotate' => 0,
86
+ 'loadedScale' => 100,
87
+ 'loadedVSlide' => 0,
88
+ 'loadingBarBackgroundColor' => "#fff",
89
+ 'loadingBarColor' => "#fff",
90
+ 'loadMethod' => 'sequential',
91
+ 'margin' => 10,
92
+ 'max_posts' => 0,
93
+ 'minTileWidth' => '250',
94
+ 'mobileLightbox' => 'swipebox',
95
+ 'post_types' => '',
96
+ 'recentPostsCaption' => 'title',
97
+ 'recentPostsCaptionAutoExcerptLength' => 20,
98
+ 'rel' => '',
99
+ 'reverseOrder' => false,
100
+ 'script' => '',
101
+ 'scrollEffect' => 'none',
102
+ 'shadowColor' => '#cccccc',
103
+ 'shadowSize' => 0,
104
+ 'socialIconColor' => '#ffffff',
105
+ 'source' => 'images',
106
+ 'style' => '',
107
+ 'support' => 'F',
108
+ 'supportText' => 'Powered by Final Tiles Grid Gallery',
109
+ 'tilesPerPage' => 0,
110
+ 'titleFontSize' => 14,
111
+ 'width' => '100%',
112
+ 'wp_field_caption' => 'description',
113
+ 'wp_field_title' => 'title'
114
+ );
115
+
116
+ //Constructor
117
+ public function __construct()
118
+ {
119
+ $this->plugin_name = plugin_basename(__FILE__);
120
+ $this->define_constants();
121
+ $this->define_db_tables();
122
+ $this->FinalTilesdb = $this->create_db_conn();
123
+
124
+
125
+ register_activation_hook(__FILE__, array($this, 'activation'));
126
+
127
+ add_filter('widget_text', 'do_shortcode');
128
+
129
+ add_action('plugins_loaded', array($this, 'create_textdomain'));
130
+
131
+ add_action('wp_enqueue_scripts', array($this, 'add_gallery_scripts'));
132
+
133
+ //add_action( 'admin_init', array($this,'gallery_admin_init') );
134
+ add_action('admin_menu', array($this, 'add_gallery_admin_menu'));
135
+
136
+ add_shortcode('FinalTilesGallery', array($this, 'gallery_shortcode_handler'));
137
 
138
+ add_action('wp_ajax_save_gallery', array($this, 'save_gallery'));
139
+ add_action('wp_ajax_add_new_gallery', array($this, 'add_new_gallery'));
140
+ add_action('wp_ajax_delete_gallery', array($this, 'delete_gallery'));
141
+ add_action('wp_ajax_clone_gallery', array($this, 'clone_gallery'));
142
+ add_action('wp_ajax_save_image', array($this, 'save_image'));
143
+ add_action('wp_ajax_add_image', array($this, 'add_image'));
144
+ add_action('wp_ajax_save_video', array($this, 'save_video'));
145
+ add_action('wp_ajax_sort_images', array($this, 'sort_images'));
146
+ add_action('wp_ajax_delete_image', array($this, 'delete_image'));
147
+ add_action('wp_ajax_assign_filters', array($this, 'assign_filters'));
148
+ add_action('wp_ajax_assign_group', array($this, 'assign_group'));
149
+ add_action('wp_ajax_toggle_visibility', array($this, 'toggle_visibility'));
150
+ add_action('wp_ajax_refresh_gallery', array($this, 'refresh_gallery'));
151
+ add_action('wp_ajax_get_gallery_configuration', array($this, 'get_configuration'));
152
+ add_action('wp_ajax_update_gallery_configuration', array($this, 'update_configuration'));
153
+ add_action('wp_ajax_get_image_size_url', array($this, 'get_image_size_url'));
154
 
155
+ add_filter('mce_buttons', array($this, 'editor_button'));
156
+ add_filter('mce_external_plugins', array($this, 'register_editor_plugin'));
157
+ add_action('wp_ajax_ftg_shortcode_editor', array($this, 'ftg_shortcode_editor'));
158
 
159
+ add_filter('plugin_row_meta', array($this, 'register_links'), 10, 2);
160
 
161
+ add_action( 'wp_ajax_load_chunk', array($this, 'load_chunk') );
162
+ add_action( 'wp_ajax_nopriv_load_chunk', array($this, 'load_chunk') );
163
 
164
+ add_action( 'admin_notices', array( $this, 'review' ) );
165
+ add_action( 'wp_ajax_ftg_dismiss_review', array( $this, 'dismiss_review' ) );
166
+ add_filter( 'admin_footer_text', array( $this, 'admin_footer' ), 1, 2 );
167
 
168
+ $this->resetFields();
169
+ }
170
 
171
+ public function review()
172
+ {
173
+ // Verify that we can do a check for reviews.
174
+ $review = get_option( 'ftg_review' );
175
+ $time = time();
176
+ $load = false;
177
+ $there_was_review = false;
178
+
179
+ if ( ! $review ) {
180
+ $review = array(
181
+ 'time' => $time,
182
+ 'dismissed' => false
183
+ );
184
+ $load = true;
185
+ $there_was_review = false;
186
+ } else {
187
+ // Check if it has been dismissed or not.
188
+ if ( (isset( $review['dismissed'] ) && ! $review['dismissed']) && (isset( $review['time'] ) && (($review['time'] + DAY_IN_SECONDS) <= $time)) ) {
189
+ $load = true;
190
+ }
191
+ }
192
 
193
+ // If we cannot load, return early.
194
+ if ( ! $load ) {
195
+ return;
196
+ }
 
 
 
 
 
 
197
 
198
+ // Update the review option now.
199
+ update_option( 'ftg_review', $review );
200
 
201
+ // Run through optins on the site to see if any have been loaded for more than a week.
202
+ $valid = false;
203
+ $galleries = $this->FinalTilesdb->getGalleries();
204
 
205
+ if ( ! $galleries )
206
+ {
207
+ return;
208
+ }
209
 
210
+ $with_date = false;
211
+ foreach ( $galleries as $gallery )
212
+ {
213
+ if(! isset($gallery->date))
214
+ continue;
215
 
216
+ $with_date = true;
217
+ $data = $gallery->date;
218
 
219
+ // Check the creation date of the local optin. It must be at least one week after.
220
+ $created = isset( $data ) ? strtotime( $data ) + (7 * DAY_IN_SECONDS) : false;
221
+ if ( ! $created ) {
222
+ continue;
223
+ }
224
 
225
+ if ( $created <= $time ) {
226
+ $valid = true;
227
+ break;
228
+ }
229
+ }
230
+
231
+ if(! $with_date && count($galleries) > 0 && ! $there_was_review)
232
+ {
233
+ $valid = true;
234
+ }
235
+
236
+ // If we don't have a valid optin yet, return.
237
+ if ( ! $valid )
238
+ {
239
+ return;
240
+ }
241
+
242
+ // We have a candidate! Output a review message.
243
+ ?>
244
+ <div class="notice notice-info is-dismissible ftg-review-notice">
245
+ <p><?php _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-gallery-lite' ); ?></p>
246
+ <p><strong><?php _e( 'Diego Imbriani<br>Founder of GreenTreeLabs', 'final-tiles-gallery' ); ?></strong></p>
247
+ <p>
248
+ <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 _e( 'Ok, you deserve it', 'final-tiles-gallery-lite' ); ?></a><br>
249
+ <a href="#" class="ftg-dismiss-review-notice" rel="noopener"><?php _e( 'Nope, maybe later', 'final-tiles-gallery' ); ?></a><br>
250
+ <a href="#" class="ftg-dismiss-review-notice" rel="noopener"><?php _e( 'I already did', 'final-tiles-gallery' ); ?></a><br>
251
+ </p>
252
+ </div>
253
+ <script type="text/javascript">
254
+ jQuery(document).ready( function($) {
255
+ $(document).on('click', '.ftg-dismiss-review-notice, .ftg-review-notice button', function( event ) {
256
+ if ( ! $(this).hasClass('ftg-review-out') ) {
257
+ event.preventDefault();
258
+ }
259
+
260
+ $.post( ajaxurl, {
261
+ action: 'ftg_dismiss_review'
262
+ });
263
+
264
+ $('.ftg-review-notice').remove();
265
+ });
266
+ });
267
+ </script>
268
+ <?php
269
+ }
270
+
271
+ public function dismiss_review() {
272
+
273
+ $review = get_option( 'ftg_review' );
274
+ if ( ! $review ) {
275
+ $review = array();
276
+ }
277
+
278
+ $review['time'] = time();
279
+ $review['dismissed'] = true;
280
+
281
+ update_option( 'ftg_review', $review );
282
+ die;
283
+ }
284
+
285
+ public function admin_footer( $text )
286
+ {
287
+ global $current_screen;
288
+ if ( !empty( $current_screen->id ) && strpos( $current_screen->id, 'ftg' ) !== false ) {
289
+ $url = 'https://wordpress.org/support/plugin/final-tiles-grid-gallery-lite/reviews/?filter=5#new-post';
290
+ $text = sprintf( __( 'Please rate <strong>Final Tiles Gallery</strong> <a href="%s" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a> on <a href="%s" target="_blank">WordPress.org</a> to help us spread the word. Thank you from the Final Tiles Gallery team!', 'wpforms' ), $url, $url );
291
+ }
292
+ return $text;
293
+ }
294
+
295
+ public function gallery_admin_bar()
296
+ {
297
  global $wp_admin_bar;
298
 
299
  $wp_admin_bar->add_menu( array(
300
  'id' => 'ftg-upgrade-bar',
301
  'href' => 'http://1.envato.market/c/288541/275988/4415?u=https%3A%2F%2Fcodecanyon.net%2Fitem%2Ffinal-tiles-wordpress-gallery%2F5189351',
302
  'parent' => 'top-secondary',
303
+ 'title' => __('Upgrade to Final Tiles Grid Gallery PRO'),
304
  'meta' => array('class' => 'ftg-upgrade-to-pro', 'target' => '_blank' ),
305
  ) );
306
+ }
307
+
308
+
309
+ private function resetFields()
310
+ {
311
+ $keys = array('name', 'hiddenFor', 'type', 'description', 'default', 'min', 'max', 'mu', 'excludeFrom');
312
+
313
+ foreach ($this->fields as $tab_name => $tab) {
314
+ foreach ($tab["fields"] as $key => $field) {
315
+ //print_r($field);
316
+ foreach ($keys as $kk) {
317
+ if (!array_key_exists($kk, $field)) {
318
+ $this->fields[$tab_name]["fields"][$key][$kk] = "";
319
+ }
320
+ }
321
+ }
 
 
322
 
323
  }
324
  //print_r($this->fields);
325
+ }
326
+
327
+ public function register_links($links, $file)
328
+ {
329
+ $base = plugin_basename(__FILE__);
330
+ if ($file == $base) {
331
+ $links[] = '<a href="admin.php?page=ftg-lite-gallery-admin" title="Final Tiles Grid Gallery Dashboard">Dashboard</a>';
332
+ $links[] = '<a href="admin.php?page=support" title="Final Tiles Grid Gallery Support">Support</a>';
333
+ $links[] = '<a href="https://twitter.com/greentreelabs" title="@GreenTreeLabs on Twitter">Twitter</a>';
334
+ $links[] = '<a href="https://www.facebook.com/greentreelabs" title="GreenTreeLabs on Facebook">Facebook</a>';
335
+ $links[] = '<a href="https://www.google.com/+GreentreelabsNetjs" title="GreenTreeLabs on Google+">Google+</a>';
336
+ }
337
+ return $links;
338
 
339
+ }
340
 
341
  public function create_db_tables()
342
  {
343
+ include_once(WP_PLUGIN_DIR . '/final-tiles-grid-gallery-lite/lib/install-db.php');
344
+ install_db();
 
345
  }
346
 
347
  public function activation()
348
  {
349
+
350
+ }
351
+
352
+ //Define textdomain
353
+ public function create_textdomain()
354
+ {