Gallery – Photo Gallery – Image Gallery - Version 1.3.5

Version Description

  • second wp.org review
Download this release

Release Info

Developer machothemes
Plugin Icon wp plugin Gallery – Photo Gallery – Image Gallery
Version 1.3.5
Comparing to
See all releases

Code changes from version 1.3.4 to 1.3.5

Modula.php CHANGED
@@ -5,14 +5,14 @@
5
* Description: Modula is one of the best & most creative WordPress gallery plugins. Use it to create a great grid or
6
* masonry image gallery.
7
* Author: Macho Themes
8
- * Version: 1.3.4
9
* Author URI: https://www.machothemes.com/
10
*/
11
12
define( 'MODULA_PLUGIN_DIR_PATH', plugin_dir_path( __FILE__ ) );
13
define( 'MODULA_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) );
14
15
- define( 'MODULA_VERSION', '1.3.4' );
16
define( 'MODULA_PLUGIN_BASE', plugin_basename( __FILE__ ) );
17
define( 'MODULA_PREVIOUS_PLUGIN_VERSION', '1.3.3' );
18
define( 'MODULA_FILE_', __FILE__ );
@@ -22,1236 +22,1234 @@ function modula_lite_create_db_tables() {
22
modula_lite_install_db();
23
}
24
25
- if ( ! class_exists( "ModulaLite" ) ) {
26
- class ModulaLite {
27
-
28
- private $loadedData;
29
- private $fields = array();
30
-
31
- private $version = "1.3.4";
32
-
33
- private $defaultValues = array(
34
- 'width' => 100,
35
- 'height' => 800,
36
- 'img_size' => 500,
37
- 'margin' => 10,
38
- 'filters' => '',
39
- 'filterClick' => 'F',
40
- 'allFilterLabel' => 'All',
41
- 'lightbox' => 'lightbox2',
42
- 'shuffle' => 'F',
43
- 'captionColor' => '#ffffff',
44
- 'wp_field_caption' => 'caption',
45
- 'wp_field_title' => 'title',
46
- 'captionFontSize' => 14,
47
- 'titleFontSize' => 16,
48
- 'enableTwitter' => 'T',
49
- 'enableFacebook' => 'T',
50
- 'enableGplus' => 'T',
51
- 'enablePinterest' => 'T',
52
- 'socialIconColor' => '#ffffff',
53
- 'loadedScale' => 100,
54
- 'loadedRotate' => 0,
55
- 'loadedHSlide' => 0,
56
- 'loadedVSlide' => 0,
57
- 'borderSize' => 0,
58
- 'borderRadius' => 0,
59
- 'borderColor' => '#ffffff',
60
- 'shadowSize' => 0,
61
- 'shadowColor' => '#ffffff',
62
- 'style' => '',
63
- 'script' => '',
64
- 'randomFactor' => 50,
65
- 'hoverColor' => '#000000',
66
- 'hoverOpacity' => '50',
67
- 'hoverEffect' => 'pufrobo',
68
- 'hasResizedImages' => false,
69
- 'importedFrom' => '',
70
- 'hide_title' => false,
71
- 'hide_description' => false,
72
- );
73
-
74
- public function __construct() {
75
- $this->plugin_name = plugin_basename( __FILE__ );
76
- $this->plugin_url = plugins_url( '', __FILE__ );
77
- $this->define_constants();
78
- $this->define_db_tables();
79
- $this->define_hover_effects();
80
- $this->ModulaDB = $this->create_db_conn();
81
-
82
- add_filter( 'widget_text', 'do_shortcode' );
83
- add_filter( 'mce_buttons', array( $this, 'editor_button' ) );
84
- add_filter( 'mce_external_plugins', array( $this, 'register_editor_plugin' ) );
85
-
86
- add_action( 'init', array( $this, 'create_textdomain' ) );
87
-
88
- add_action( 'wp_enqueue_scripts', array( $this, 'add_gallery_scripts' ) );
89
-
90
- add_action( 'admin_menu', array( $this, 'add_gallery_admin_menu' ) );
91
-
92
- add_shortcode( 'Modula', array( $this, 'gallery_shortcode_handler' ) );
93
- add_filter( 'the_content', array( $this, 'shortcode_empty_paragraph_fix' ), 99 );
94
-
95
- add_action( 'wp_ajax_modula_save_gallery', array( $this, 'save_gallery' ) );
96
- add_action( 'wp_ajax_modula_save_image', array( $this, 'save_image' ) );
97
- add_action( 'wp_ajax_modula_add_image', array( $this, 'add_image' ) );
98
- add_action( 'wp_ajax_modula_list_images', array( $this, 'list_images' ) );
99
- add_action( 'wp_ajax_modula_sort_images', array( $this, 'sort_images' ) );
100
- add_action( 'wp_ajax_modula_delete_image', array( $this, 'delete_image' ) );
101
- add_action( 'wp_ajax_modula_resize_images', array( $this, 'resize_images' ) );
102
- add_action( 'wp_ajax_modula_delete_gallery', array( $this, 'delete_gallery' ) );
103
- add_action( 'wp_ajax_modula_clone_gallery', array( $this, 'clone_gallery' ) );
104
- add_action( 'wp_ajax_modula_create_gallery', array( $this, 'create_gallery' ) );
105
- add_action( 'wp_ajax_mtg_shortcode_editor', array( $this, 'mtg_shortcode_editor' ) );
106
- add_action( 'wp_ajax_modula_get_config', array( $this, 'get_config' ) );
107
- add_action( 'wp_ajax_modula_update_config', array( $this, 'update_config' ) );
108
- add_action( 'wp_ajax_modula_get_ext_galleries', array( $this, 'get_ext_galleries' ) );
109
- add_action( 'wp_ajax_modula_do_import_galleries', array( $this, 'do_import_galleries' ) );
110
-
111
- add_filter( 'plugin_row_meta', array( $this, 'register_links' ), 10, 2 );
112
- add_filter( 'admin_footer_text', array( $this, 'admin_footer' ), 1, 2 );
113
-
114
- // Enqueue Fancybox for Modula 2.0 Page
115
- add_action( 'admin_enqueue_scripts', array( $this, 'modula_beta_scripts' ) );
116
-
117
-
118
- // Set fields
119
- $this->fields[ __( 'General', 'modula-gallery' ) ] = array(
120
- "icon" => "mdi mdi-settings",
121
- "fields" => array(
122
- "name" => array(
123
- "name" => esc_html__( 'Name', 'modula-gallery' ),
124
- "type" => "text",
125
- "description" => esc_html__( 'Name of the gallery, for internal use.', 'modula-gallery' ),
126
- "excludeFrom" => array(),
127
- ),
128
- "description" => array(
129
- "name" => esc_html__( 'Description', 'modula-gallery' ),
130
- "type" => "text",
131
- "description" => esc_html__( 'This description is for internal use.', 'modula-gallery' ),
132
- "excludeFrom" => array(),
133
- ),
134
- "width" => array(
135
- "name" => esc_html__( 'Width', 'modula-gallery' ),
136
- "type" => "text",
137
- "description" => esc_html__( 'Width of the gallery (i.e.: 100% or 500px)', 'modula-gallery' ),
138
- "mu" => "px or %",
139
- "excludeFrom" => array(),
140
- ),
141
- "height" => array(
142
- "name" => esc_html__( 'Height', 'modula-gallery' ),
143
- "type" => "number",
144
- "description" => esc_html__( 'Height of the gallery in pixels', 'modula-gallery' ),
145
- "mu" => "px",
146
- "excludeFrom" => array(),
147
- ),
148
- "img_size" => array(
149
- "name" => esc_html__( 'Minimum image size', 'modula-gallery' ),
150
- "type" => "number",
151
- "description" => esc_html__( 'Minimum width or height of the images', 'modula-gallery' ),
152
- "mu" => "px or %",
153
- "excludeFrom" => array(),
154
- ),
155
- "margin" => array(
156
- "name" => esc_html__( 'Margin', 'modula-gallery' ),
157
- "type" => "number",
158
- "description" => esc_html__( 'Margin between images', 'modula-gallery' ),
159
- "mu" => "px",
160
- "excludeFrom" => array(),
161
- ),
162
- "randomFactor" => array(
163
- "name" => esc_html__( 'Random factor', 'modula-gallery' ),
164
- "type" => "ui-slider",
165
- "description" => "",
166
- "min" => 0,
167
- "max" => 100,
168
- "mu" => "%",
169
- "default" => 20,
170
- "excludeFrom" => array(),
171
- ),
172
- "filters" => array(
173
- "name" => esc_html__( 'Filters', 'modula-gallery' ),
174
- "type" => "PRO_FEATURE",
175
- "description" => esc_html__( 'Add your own filters here. Each image can have one or more filters.', 'modula-gallery' ),
176
- "excludeFrom" => array(),
177
- ),
178
- "filterClick" => array(
179
- "name" => esc_html__( 'Reload Page on filter click', 'modula-gallery' ),
180
- "type" => "PRO_FEATURE",
181
- "description" => esc_html__( 'Turn this feature ON if you want to use filters with most lightboxes', 'modula-gallery' ),
182
- "excludeFrom" => array(),
183
- ),
184
- "allFilterLabel" => array(
185
- "name" => esc_html__( 'Text for "All" filter', 'modula-gallery' ),
186
- "type" => "PRO_FEATURE",
187
- "description" => esc_html__( 'Write here the label for the "All" filter', 'modula-gallery' ),
188
- "default" => "All",
189
- "excludeFrom" => array(),
190
- ),
191
- "lightbox" => array(
192
- "name" => esc_html__( 'Lightbox & Links', 'modula-gallery' ),
193
- "type" => "select",
194
- "description" => esc_html__( 'Define here what happens when user click on the images.', 'modula-gallery' ),
195
- "values" => array(
196
- "Link" => array(
197
- "|" . esc_html__( 'No link', 'modula-gallery' ),
198
- "direct|" . esc_html__( 'Direct link to image', 'modula-gallery' ),
199
- "|" . esc_html__( 'Attachment page', 'modula-gallery' )
200
- ),
201
- "Lightboxes" => array( "lightbox2|Lightbox" ),
202
- ),
203
- "disabled" => array(
204
- "Lightboxes with PRO license" => array(
205
- "magnific|Magnific popup",
206
- "prettyphoto|PrettyPhoto",
207
- "fancybox|FancyBox",
208
- "swipebox|SwipeBox",
209
- "lightbox2|Lightbox",
210
- ),
211
),
212
- "excludeFrom" => array(),
213
),
214
- "shuffle" => array(
215
- "name" => esc_html__( 'Shuffle images', 'modula-gallery' ),
216
- "type" => "toggle",
217
- "default" => "T",
218
- "description" => esc_html__( 'Flag it if you want to shuffle the gallery at each page load', 'modula-gallery' ),
219
- "excludeFrom" => array(),
220
),
221
),
222
- );
223
- $this->fields[ esc_html__( 'Captions', 'modula-gallery' ) ] = array(
224
- "icon" => "mdi mdi-comment-text-outline",
225
- "fields" => array(
226
- "captionColor" => array(
227
- "name" => esc_html__( 'Caption color', 'modula-gallery' ),
228
- "type" => "color",
229
- "description" => esc_html__( 'Color of the caption.', 'modula-gallery' ),
230
- "default" => "#ffffff",
231
- "excludeFrom" => array(),
232
- ),
233
- "wp_field_caption" => array(
234
- "name" => esc_html__( 'Populate caption from', 'modula-gallery' ),
235
- "type" => "select",
236
- "description" => __( '<strong>This field is used ONLY when images are added to the gallery. </strong> If you don\'t want to automatically populate the caption field select <i>Don\'t Populate</i>', 'modula-gallery' ),
237
- "values" => array(
238
- "Field" => array(
239
- "none|" . esc_html__( 'Don\'t Populate', 'modula-gallery' ),
240
- "title|" . esc_html__( 'WP Image title', 'modula-gallery' ),
241
- "caption|" . esc_html__( 'WP Image caption', 'modula-gallery' ),
242
- "description|" . esc_html__( 'WP Image description', 'modula-gallery' ),
243
- ),
244
),
245
- "excludeFrom" => array( "shortcode" ),
246
),
247
- "wp_field_title" => array(
248
- "name" => esc_html__( 'Populate title from', 'modula-gallery' ),
249
- "type" => "select",
250
- "description" => __( '<strong>This field is used ONLY when images are added to the gallery. </strong> If you don\'t want to automatically populate the title field select <i>Don\'t Populate</i>', 'modula-gallery' ),
251
- "values" => array(
252
- "Field" => array(
253
- "none|" . esc_html__( 'Don\'t Populate', 'modula-gallery' ),
254
- "title|" . esc_html__( 'WP Image title', 'modula-gallery' ),
255
- "description|" . esc_html__( 'WP Image description', 'modula-gallery' ),
256
- ),
257
),
258
- "excludeFrom" => array( "shortcode" ),
259
- ),
260
- "hide_title" => array(
261
- "name" => esc_html__( 'Image Title', 'modula-gallery' ),
262
- "type" => "toggle",
263
- "default" => "T",
264
- "description" => esc_html__( 'Hide image title from frontend', 'modula-gallery' ),
265
- "excludeFrom" => array(),
266
- ),
267
- "hide_description" => array(
268
- "name" => esc_html__( 'Image Description', 'modula-gallery' ),
269
- "type" => "toggle",
270
- "default" => "T",
271
- "description" => esc_html__( 'Hide image description from frontend', 'modula-gallery' ),
272
- "excludeFrom" => array(),
273
- ),
274
- "captionFontSize" => array(
275
- "name" => esc_html__( 'Caption Font Size', 'modula-gallery' ),
276
- "type" => "number",
277
- "description" => "",
278
- "mu" => "px",
279
- "excludeFrom" => array(),
280
- ),
281
- "titleFontSize" => array(
282
- "name" => esc_html__( 'Title Font Size', 'modula-gallery' ),
283
- "type" => "number",
284
- "description" => "",
285
- "mu" => "px",
286
- "excludeFrom" => array(),
287
),
288
),
289
- );
290
-
291
- $this->fields[ esc_html__( 'Social', 'modula-gallery' ) ] = array(
292
- "icon" => "mdi mdi-link-variant",
293
- "fields" => array(
294
- "enableTwitter" => array(
295
- "name" => esc_html__( 'Add Twitter icon', 'modula-gallery' ),
296
- "type" => "toggle",
297
- "default" => "T",
298
- "description" => esc_html__( 'Enable Twitter Sharing', 'modula-gallery' ),
299
- "excludeFrom" => array(),
300
- ),
301
- "enableFacebook" => array(
302
- "name" => esc_html__( 'Add Facebook icon', 'modula-gallery' ),
303
- "type" => "toggle",
304
- "default" => "T",
305
- "description" => esc_html__( 'Enable Facebook Sharing', 'modula-gallery' ),
306
- "excludeFrom" => array(),
307
- ),
308
- "enableGplus" => array(
309
- "name" => esc_html__( 'Add Google Plus icon', 'modula-gallery' ),
310
- "type" => "toggle",
311
- "default" => "T",
312
- "description" => esc_html__( 'Enable Google Plus Sharing', 'modula-gallery' ),
313
- "excludeFrom" => array(),
314
- ),
315
- "enablePinterest" => array(
316
- "name" => esc_html__( 'Add Pinterest icon', 'modula-gallery' ),
317
- "type" => "toggle",
318
- "default" => "T",
319
- "description" => esc_html__( 'Enable Pinterest Sharing', 'modula-gallery' ),
320
- "excludeFrom" => array(),
321
- ),
322
- "socialIconColor" => array(
323
- "name" => esc_html__( 'Color of social sharing icons', 'modula-gallery' ),
324
- "type" => "color",
325
- "description" => esc_html__( 'Set the color of the social sharing icons', 'modula-gallery' ),
326
- "default" => "#ffffff",
327
- "excludeFrom" => array(),
328
- ),
329
),
330
331
- );
332
- $this->fields[ esc_html__( 'Image loaded effects', 'modula-gallery' ) ] = array(
333
- "icon" => "mdi mdi-reload",
334
- "fields" => array(
335
- "loadedScale" => array(
336
- "name" => esc_html__( 'Scale', 'modula-gallery' ),
337
- "description" => esc_html__( 'Choose a value below 100% for a zoom-in effect. Choose a value over 100% for a zoom-out effect', 'modula-gallery' ),
338
- "type" => "ui-slider",
339
- "min" => 0,
340
- "max" => 200,
341
- "mu" => "%",
342
- "default" => 100,
343
- "excludeFrom" => array(),
344
- ),
345
- "loadedRotate" => array(
346
- "name" => esc_html__( 'Rotate', 'modula-gallery' ),
347
- "description" => "",
348
- "type" => "PRO_FEATURE",
349
- "min" => - 180,
350
- "max" => 180,
351
- "default" => 0,
352
- "mu" => "deg",
353
- "excludeFrom" => array(),
354
- ),
355
- "loadedHSlide" => array(
356
- "name" => esc_html__( 'Horizontal slide', 'modula-gallery' ),
357
- "description" => "",
358
- "type" => "PRO_FEATURE",
359
- "min" => - 100,
360
- "max" => 100,
361
- "mu" => "px",
362
- "default" => 0,
363
- "excludeFrom" => array(),
364
- ),
365
- "loadedVSlide" => array(
366
- "name" => esc_html__( 'Vertical slide', 'modula-gallery' ),
367
- "description" => "",
368
- "type" => "PRO_FEATURE",
369
- "min" => - 100,
370
- "max" => 100,
371
- "mu" => "px",
372
- "default" => 0,
373
- "excludeFrom" => array(),
374
- ),
375
-
376
),
377
- );
378
- $this->fields[ esc_html__( 'Hover effect', 'modula-gallery' ) ] = array(
379
- "icon" => "mdi mdi-blur",
380
- "fields" => array(
381
- "Effect" => array(
382
- "name" => esc_html__( 'Effect', 'modula-gallery' ),
383
- "description" => esc_html__( 'Select an hover effect', 'modula-gallery' ),
384
- "type" => "hover-effect",
385
- "excludeFrom" => array(),
386
- ),
387
),
388
- );
389
- $this->fields[ esc_html__( 'Style', 'modula-gallery' ) ] = array(
390
- "icon" => "mdi mdi-format-paint",
391
- "fields" => array(
392
- "borderSize" => array(
393
- "name" => esc_html__( 'Border Size', 'modula-gallery' ),
394
- "type" => "ui-slider",
395
- "description" => "",
396
- "mu" => "px",
397
- "min" => 0,
398
- "max" => 10,
399
- "default" => 0,
400
- "excludeFrom" => array(),
401
- ),
402
- "borderRadius" => array(
403
- "name" => esc_html__( 'Border Radius', 'modula-gallery' ),
404
- "type" => "ui-slider",
405
- "description" => "",
406
- "mu" => "px",
407
- "min" => 0,
408
- "max" => 100,
409
- "default" => 0,
410
- "excludeFrom" => array(),
411
- ),
412
- "borderColor" => array(
413
- "name" => esc_html__( 'Border Color', 'modula-gallery' ),
414
- "type" => "color",
415
- "description" => "",
416
- "default" => "#ffffff",
417
- "excludeFrom" => array(),
418
- ),
419
- "shadowSize" => array(
420
- "name" => esc_html__( 'Shadow Size', 'modula-gallery' ),
421
- "type" => "ui-slider",
422
- "description" => "",
423
- "mu" => "px",
424
- "min" => 0,
425
- "max" => 20,
426
- "default" => 0,
427
- "excludeFrom" => array(),
428
- ),
429
- "shadowColor" => array(
430
- "name" => esc_html__( 'Shadow Color', 'modula-gallery' ),
431
- "type" => "color",
432
- "description" => "",
433
- "default" => "#ffffff",
434
- "excludeFrom" => array(),
435
- ),
436
437
),
438
- );
439
- $this->fields[ esc_html__( 'Customizations', 'modula-gallery' ) ] = array(
440
- "icon" => "mdi mdi-puzzle",
441
- "fields" => array(
442
- "script" => array(
443
- "name" => esc_html__( 'Custom scripts', 'modula-gallery' ),
444
- "type" => "textarea",
445
- "description" => esc_html__( 'This script will be called after the gallery initialization. Useful for custom lightboxes.', 'modula-gallery' ) . "
446
- <br />
447
- <br />
448
- <strong>Write just the code without using the &lt;script&gt;&lt;/script&gt; tags</strong>",
449
- "excludeFrom" => array( "shortcode" ),
450
- ),
451
- "style" => array(
452
- "name" => esc_html__( 'Custom css', 'modula-gallery' ),
453
- "type" => "textarea",
454
- "description" => '<strong>' . esc_html__( 'Write just the code without using the &lt;style&gt;&lt;/style&gt; tags', 'modula-gallery' ) . '</strong>',
455
- "excludeFrom" => array( "shortcode" ),
456
- ),
457
),
458
- );
459
460
- }
461
462
- public function modula_beta_scripts( $hook ) {
463
464
- if ( 'modula_page_modula-lite-gallery-v2' != $hook ) {
465
- return;
466
- }
467
468
- wp_enqueue_script( 'modula-fancybox', plugins_url( 'admin/fancybox/jquery.fancybox.min.js', __FILE__), array( 'jquery' ) );
469
- wp_enqueue_style( 'modula-fancybox', plugins_url( 'admin/fancybox/jquery.fancybox.min.css', __FILE__) );
470
471
}
472
473
- //Define textdomain
474
- public function create_textdomain() {
475
- $plugin_dir = basename( dirname( __FILE__ ) );
476
- load_plugin_textdomain( 'modula-gallery', false, $plugin_dir . '/lib/languages' );
477
- }
478
479
- function define_hover_effects() {
480
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'None', 'none', false, false, 0 );
481
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Pufrobo', 'pufrobo', true, true, 4 );
482
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Fluid Up', '', true, true, 0 );
483
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Hide', '', true, true, 4 );
484
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Quiet', '', true, false, 4 );
485
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Catinelle', '', false, false, 4 );
486
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Reflex', '', true, true, 4 );
487
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Curtain', '', true, false, 4 );
488
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Lens', '', true, true, 4 );
489
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Appear', '', true, false, 4 );
490
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Crafty', '', true, true, 0 );
491
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Seemo', '', true, false, 4 );
492
- $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Comodo', '', true, false, 4 );
493
- }
494
495
- public function get_ext_galleries() {
496
- header( "Content-type: application/json" );
497
498
- global $wpdb;
499
-
500
- if ( check_admin_referer( "Modula", "Modula" ) ) {
501
- $res = array( "success" => 0 );
502
-
503
- $source = $_POST['source'];
504
- if ( $source ) {
505
- $res['success'] = 1;
506
- $res['galleries'] = array();
507
-
508
- switch ( $source ) {
509
- case 'Envira':
510
- $galleries = get_posts( array(
511
- 'post_type' => 'envira',
512
- 'posts_per_page' => 1000,
513
- ) );
514
- foreach ( $galleries as $g ) {
515
- $item = array();
516
- $item['id'] = $g->ID;
517
- $item['title'] = $g->post_title;
518
- $res['galleries'] [] = $item;
519
- }
520
- break;
521
- case 'NextGen':
522
- $galleries = $wpdb->get_results( "SELECT title, gid FROM $wpdb->nggallery" );
523
- foreach ( $galleries as $g ) {
524
- $item = array();
525
- $item['id'] = $g->gid;
526
- $item['title'] = $g->title;
527
- $res['galleries'] [] = $item;
528
- }
529
- break;
530
- }
531
- }
532
533
- echo json_encode( $res );
534
- }
535
- die();
536
- }
537
538
- public function admin_footer( $text ) {
539
- global $current_screen;
540
- if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'modula-lite' ) !== false ) {
541
- $url = 'https://wordpress.org/support/plugin/modula-best-grid-gallery/reviews/?rate=5#new-post';
542
- $text = sprintf( __( 'Please rate <strong>Modula 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, on behalf of the Modula team!', 'modula-gallery' ), $url, $url );
543
- }
544
545
- return $text;
546
- }
547
548
- public function do_import_galleries() {
549
- global $wpdb;
550
551
- header( "Content-type: application/json" );
552
- if ( check_admin_referer( "Modula", "Modula" ) ) {
553
- $res = array( "success" => 0 );
554
- $source = $_POST['source'];
555
- $ids = explode( ",", $_POST['ids'] );
556
switch ( $source ) {
557
case 'Envira':
558
- foreach ( $ids as $id ) {
559
- $gallery = get_post( $id );
560
- $meta = get_post_meta( $id );
561
- $data = unserialize( $meta['_eg_gallery_data'][0] );
562
-
563
- $g = array(
564
- 'name' => $data['config']['title'],
565
- 'description' => 'Imported from Envira (' . $id . ') on ' . date( 'M, d Y' ),
566
- 'margin' => $data['config']['gutter'],
567
- 'hasResizedImages' => true,
568
- 'importedFrom' => 'Envira',
569
- );
570
- $gdb = array_merge( $this->defaultValues, $g );
571
-
572
- $saved = $this->ModulaDB->addGallery( $gdb );
573
- $newId = $this->ModulaDB->getNewGalleryId();
574
-
575
- if ( $newId && count( $data['gallery'] ) ) {
576
- $images = array();
577
- //TODO only active images
578
- foreach ( $data['gallery'] as $item ) {
579
- $toAdd = new stdClass();
580
- $toAdd->imageId = $this->ModulaDB->getIDbyGUID( $item['src'] );
581
- $toAdd->title = $item['title'];
582
- $toAdd->description = $item['caption'];
583
- $toAdd->imagePath = $item['src'];
584
-
585
- $images [] = $toAdd;
586
- }
587
- $imgResult = $this->ModulaDB->addImages( $newId, $images );
588
- }
589
}
590
- $res['success'] = 1;
591
break;
592
case 'NextGen':
593
- foreach ( $ids as $id ) {
594
- $gallery = $wpdb->get_row( $wpdb->prepare( "SELECT title, gid, path FROM $wpdb->nggallery WHERE gid=%s", $id ) );
595
-
596
- $dbimages = $wpdb->get_results( $wpdb->prepare( "SELECT filename, description, alttext FROM $wpdb->nggpictures WHERE exclude <> 1 AND galleryid=%s", $id ) );
597
-
598
- $g = array(
599
- 'name' => $gallery->title,
600
- 'description' => 'Imported from NextGet (' . $id . ') on ' . date( 'M, d Y' ),
601
- 'hasResizedImages' => true,
602
- 'importedFrom' => 'NextGen',
603
- );
604
- $gdb = array_merge( $this->defaultValues, $g );
605
-
606
- $saved = $this->ModulaDB->addGallery( $gdb );
607
- $newId = $this->ModulaDB->getNewGalleryId();
608
-
609
- if ( $newId && count( $dbimages ) ) {
610
- $images = array();
611
- foreach ( $dbimages as $item ) {
612
- $toAdd = new stdClass();
613
- $toAdd->imageId = - 1;
614
- $toAdd->title = $item->alttext;
615
- $toAdd->description = $item->description;
616
- $toAdd->imagePath = plugins_url( 'image.php', __FILE__ ) . "?w=" . $this->defaultValues['img_size'] . "&src=" . $gallery->path . "/" . $item->filename;
617
-
618
- $images [] = $toAdd;
619
- }
620
- $imgResult = $this->ModulaDB->addImages( $newId, $images );
621
-
622
- }
623
}
624
- $res['success'] = 1;
625
break;
626
}
627
-
628
- echo json_encode( $res );
629
}
630
- die();
631
}
632
633
- public function register_links( $links, $file ) {
634
- $base = plugin_basename( __FILE__ );
635
- if ( $file == $base ) {
636
- $links[] = '<a href="admin.php?page=modula-lite-admin" title="' . esc_html__( 'Modula Grid Gallery Dashboard', 'modula-gallery' ) . '">' . esc_html__( 'Dashboard', 'modula-gallery' ) . '</a>';
637
- $links[] = '<a href="https://twitter.com/MachoThemez" title="@MachoThemez on Twitter">Twitter</a>';
638
- $links[] = '<a href="https://www.facebook.com/machothemes" title="MachoThemes on Facebook">Facebook</a>';
639
- }
640
641
- return $links;
642
643
- }
644
645
- //delete gallery
646
- function delete_gallery() {
647
- if ( check_admin_referer( "Modula", "Modula" ) ) {
648
- $id = absint( $_POST['gid'] );
649
- $this->ModulaDB->deleteGallery( $id );
650
- }
651
652
- die();
653
- }
654
655
- public function update_config() {
656
- if ( check_admin_referer( "Modula", "Modula" ) ) {
657
- $id = absint($_POST['id']);
658
- $config = stripslashes( $_POST['config'] );
659
660
- $this->ModulaDB->update_config( $id, $config );
661
}
662
663
- die();
664
}
665
666
- public function get_config() {
667
- if ( check_admin_referer( "Modula", "Modula" ) ) {
668
- $id = absint($_POST['id']);
669
-
670
- $data = $this->ModulaDB->getConfig( $id );
671
672
- print json_encode( $data );
673
674
- }
675
676
- die();
677
}
678
679
- //add gallery
680
-
681
- function create_gallery() {
682
- if ( check_admin_referer( "Modula", "Modula" ) ) {
683
- $data = $this->defaultValues;
684
- $data["name"] = sanitize_text_field($_POST['name']);
685
- $data["description"] = wp_filter_post_kses($_POST['description']);
686
- $data["width"] = sanitize_text_field($_POST['width']);
687
- $data["height"] = absint($_POST['height']);
688
- $data["img_size"] = absint( $_POST['img_size'] );
689
- $data["hasResizedImages"] = true;
690
-
691
- $this->ModulaDB->addGallery( $data );
692
- $id = $this->ModulaDB->getLastGalleryId()->Id;
693
-
694
- if ( $id > 0 && array_key_exists( 'images', $_POST ) && strlen( $_POST['images'] ) ) {
695
- $enc_images = stripslashes( $_POST["images"] );
696
- $images = array_splice( json_decode( $enc_images ), 0, 11 + 9 );
697
- ModulaLiteTools::check_and_resize( $images, $data['img_size'] );
698
- $result = $this->ModulaDB->addImages( $id, $images );
699
- }
700
- print $id;
701
- }
702
- die;
703
}
704
705
- //clone gallery
706
- function clone_gallery() {
707
- if ( check_admin_referer( 'Modula', 'Modula' ) ) {
708
- $sourceId = absint( $_POST['gid'] );
709
- $g = $this->ModulaDB->getGalleryById( $sourceId, $this->defaultValues );
710
- $g->name .= "(copy)";
711
- $this->ModulaDB->addGallery( $g );
712
- $id = $this->ModulaDB->getNewGalleryId();
713
- $images = $this->ModulaDB->getImagesByGalleryId( $sourceId );
714
715
- foreach ( $images as &$image ) {
716
- $image->Id = null;
717
- $image->gid = $id;
718
- }
719
720
- $this->ModulaDB->addImages( $id, $images );
721
- }
722
723
- die();
724
}
725
726
727
- //Define constants
728
- public function define_constants() {
729
- if ( ! defined( 'Modula_PLUGIN_BASENAME' ) ) {
730
- define( 'Modula_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
731
}
732
733
- if ( ! defined( 'Modula_PLUGIN_NAME' ) ) {
734
- define( 'Modula_PLUGIN_NAME', trim( dirname( Modula_PLUGIN_BASENAME ), '/' ) );
735
}
736
737
- if ( ! defined( 'Modula_PLUGIN_DIR' ) ) {
738
- define( 'Modula_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . Modula_PLUGIN_NAME );
739
- }
740
}
741
742
- //delete Gallery
743
744
745
- //Define DB tables
746
- public function define_db_tables() {
747
- global $wpdb;
748
749
- $wpdb->ModulaGalleries = $wpdb->prefix . 'modula';
750
- $wpdb->ModulaImages = $wpdb->prefix . 'modula_images';
751
}
752
753
754
- public function create_db_conn() {
755
- require( 'lib/db-class.php' );
756
- $ModulaDB = ModulaLiteDB::getInstance();
757
758
- return $ModulaDB;
759
- }
760
761
- public function editor_button( $buttons ) {
762
- array_push( $buttons, 'separator', 'mtg_shortcode_editor' );
763
764
- return $buttons;
765
- }
766
767
- public function register_editor_plugin( $plugin_array ) {
768
- $plugin_array['mtg_shortcode_editor'] = plugins_url( '/admin/scripts/editor-plugin.js', __file__ );
769
770
- return $plugin_array;
771
- }
772
773
- public function mtg_shortcode_editor() {
774
- $css_path = plugins_url( 'assets/css/admin.css', __FILE__ );
775
- $admin_url = admin_url();
776
777
- $galleries = $this->ModulaDB->getGalleries(); //load all galleries
778
779
- include 'admin/include/tinymce-galleries.php';
780
- die();
781
- }
782
783
- //Add gallery scripts
784
- public function add_gallery_scripts() {
785
- wp_enqueue_script( 'jquery' );
786
787
- wp_register_script( 'modula', plugins_url( 'scripts/jquery.modula.js', __FILE__ ) , array( 'jquery' ) );
788
- wp_enqueue_script( 'modula' );
789
790
- wp_register_style( 'modula_stylesheet', plugins_url( 'scripts/modula.css', __FILE__ ), null, $this->version );
791
- wp_enqueue_style( 'modula_stylesheet' );
792
793
- wp_register_style( 'effects_stylesheet', plugins_url( 'scripts/effects.css', __FILE__ ), null, $this->version );
794
- wp_enqueue_style( 'effects_stylesheet' );
795
796
- wp_register_script( 'lightbox2_script', plugins_url( 'lightbox/lightbox2/js/lightbox.min.js', __FILE__ ), array( 'jquery' ), $this->version, true );
797
- wp_register_style( 'lightbox2_stylesheet', plugins_url( 'lightbox/lightbox2/css/lightbox.min.css', __FILE__ ) );
798
- }
799
800
- //Admin Section - register scripts and styles
801
- public function gallery_admin_init() {
802
- if ( function_exists( 'wp_enqueue_media' ) ) {
803
- wp_enqueue_media();
804
- }
805
806
- wp_enqueue_script( 'jquery' );
807
808
- wp_enqueue_script( 'wp-color-picker' );
809
- wp_enqueue_style( 'wp-color-picker' );
810
811
- wp_enqueue_script( 'media-upload' );
812
- wp_enqueue_script( 'thickbox' );
813
814
- wp_register_style( 'materialize', plugins_url( 'admin/css/materialize.css', __FILE__ ) );
815
- wp_enqueue_style( 'materialize' );
816
817
- wp_register_style( 'styles', plugins_url( 'admin/css/style.css', __FILE__ ) );
818
- wp_enqueue_style( 'styles' );
819
820
- wp_register_style( 'effects', plugins_url( 'scripts/effects.css', __FILE__ ) );
821
- wp_enqueue_style( 'effects' );
822
823
- wp_register_script( 'materialize', plugins_url( 'admin/scripts/materialize.js', __FILE__ ), array( 'jquery' ) );
824
825
- wp_register_script( 'modula', plugins_url( 'admin/scripts/modula-admin.js', __FILE__ ), array(
826
- 'materialize',
827
- 'jquery',
828
- 'media-upload',
829
- 'thickbox',
830
- ), false, false );
831
832
- wp_enqueue_script( 'modula' );
833
834
- wp_register_style( 'materialdesign-icons', plugins_url( 'admin/css/materialdesignicons.css', __FILE__ ) );
835
- wp_enqueue_style( 'materialdesign-icons' );
836
837
- wp_enqueue_style( 'thickbox' );
838
839
- $tg_db_version = '1.0';
840
- $installed_ver = get_option( "Modula_db_version" );
841
842
- if ( $installed_ver != $tg_db_version ) {
843
- modula_lite_create_db_tables();
844
- update_option( "Modula_db_version", $tg_db_version );
845
- }
846
}
847
848
849
- //Create Admin Menu
850
- public function add_gallery_admin_menu() {
851
- $overview = add_menu_page( esc_html__( 'Manage Galleries', 'modula-gallery' ), esc_html__( 'Modula', 'modula-gallery' ), 'edit_posts', 'modula-lite-admin', array(
852
- $this,
853
- 'add_overview',
854
- ), plugins_url( 'admin/icon.png', __FILE__ ) );
855
856
857
- if ( ! get_option( "Modula_skip_fix" ) && get_option( "Modula_db_version" ) && count( $this->ModulaDB->getGalleries() ) > 0 ) {
858
859
- $imageUrl = null;
860
- foreach ( $this->ModulaDB->getGalleries() as $gallery ) {
861
- $gid = $gallery->Id;
862
- $images = $this->ModulaDB->getImagesByGalleryId( $gid );
863
- if ( count( $images ) > 0 ) {
864
- $imageUrl = $images[0]->imagePath;
865
- break;
866
- }
867
}
868
869
- if ( $imageUrl ) {
870
- if ( strncmp( strtolower( $imageUrl ), strtolower( site_url() ), strlen( site_url() ) ) != 0 ) {
871
- $fix = add_submenu_page( 'modula-lite-admin', __( 'Modula >> Fix', 'modula-gallery' ), '❗️ ' . __( 'Fix', 'modula-gallery' ), 'edit_posts', 'modula-lite-gallery-fix', array(
872
- $this,
873
- 'fix',
874
- ) );
875
- add_action( 'load-' . $fix, array( $this, 'gallery_admin_init' ) );
876
- }
877
}
878
- } else {
879
- add_option( 'Modula_skip_fix', true );
880
}
881
882
- $add_gallery = add_submenu_page( 'modula-lite-admin', __( 'Modula - Add Gallery', 'modula-gallery' ), __( 'Add Gallery', 'modula-gallery' ), 'edit_posts', 'modula-lite-add', array(
883
- $this,
884
- 'add_gallery',
885
- ) );
886
- $edit_gallery = add_submenu_page( NULL, __( 'Modula - Edit Gallery', 'modula-gallery' ), __( 'Edit Gallery', 'modula-gallery' ), 'edit_posts', 'modula-lite-edit', array(
887
- $this,
888
- 'edit_gallery',
889
- ) );
890
- $upgrade = add_submenu_page( 'modula-lite-admin', __( 'Modula - Upgrade to PRO', 'modula-gallery' ), __( 'Upgrade to PRO', 'modula-gallery' ), 'edit_posts', 'modula-lite-gallery-upgrade', array(
891
- $this,
892
- 'upgrade',
893
- ) );
894
- $v2 = add_submenu_page( 'modula-lite-admin', __( 'Try Modula 2.0', 'modula-gallery' ), __( 'Try Modula 2.0', 'modula-gallery' ), 'edit_posts', 'modula-lite-gallery-v2', array(
895
- $this,
896
- 'new_modula',
897
- ) );
898
-
899
-
900
- add_action( 'load-' . $overview, array( $this, 'gallery_admin_init' ) );
901
- add_action( 'load-' . $add_gallery, array( $this, 'gallery_admin_init' ) );
902
- add_action( 'load-' . $edit_gallery, array( $this, 'gallery_admin_init' ) );
903
- add_action( 'load-' . $upgrade, array( $this, 'gallery_admin_init' ) );
904
905
- }
906
907
- //Create Admin Pages
908
- public function add_overview() {
909
- include( "admin/overview.php" );
910
- }
911
912
- public function upgrade() {
913
- include( "admin/upgrade.php" );
914
- }
915
916
- public function add_gallery() {
917
- include( "admin/add-gallery.php" );
918
- }
919
920
- public function new_modula() {
921
- include( "admin/modula-v2.php" );
922
- }
923
924
- public function fix() {
925
- global $wpdb;
926
- include( "admin/fix.php" );
927
- }
928
929
- public function delete_image() {
930
- if ( check_admin_referer( 'Modula', 'Modula' ) ) {
931
- foreach ( explode( ",", $_POST["id"] ) as $id ) {
932
- $this->ModulaDB->deleteImage( absint( $id ) );
933
- }
934
}
935
- die();
936
}
937
938
- public function add_image() {
939
- if ( check_admin_referer( 'Modula', 'Modula' ) ) {
940
- $gid = intval( $_POST['galleryId'] );
941
- $this->loadedData = $this->ModulaDB->getGalleryById( $gid, $this->defaultValues );
942
- $prev = $this->ModulaDB->getImagesByGalleryId( $gid );
943
-
944
- $enc_images = stripslashes( $_POST["enc_images"] );
945
- $images = json_decode( $enc_images );
946
-
947
- $d = 18 + log10( 100 );
948
- $images = array_slice( $images, 0, $d - count( $prev ) );
949
- $images = ModulaLiteTools::check_and_resize( $images, $this->loadedData->img_size );
950
- $result = $this->ModulaDB->addImages( $gid, $images );
951
-
952
- header( "Content-type: application/json" );
953
- if ( $result === false ) {
954
- print "{\"success\":false}";
955
- } else {
956
- print "{\"success\":true}";
957
- }
958
}
959
- die();
960
}
961
962
- public function sort_images() {
963
- if ( check_admin_referer( 'Modula', 'Modula' ) ) {
964
- $result = $this->ModulaDB->sortImages( explode( ',', $_POST['ids'] ) );
965
966
- header( "Content-type: application/json" );
967
- if ( $result === false ) {
968
- print "{\"success\":false}";
969
- } else {
970
- print "{\"success\":true}";
971
- }
972
}
973
- die();
974
}
975
976
- public function save_image() {
977
- if ( check_admin_referer( 'Modula', 'Modula' ) ) {
978
- $result = false;
979
- // $type = $_POST['type'];
980
-
981
- $target_values = array( '', '_self', '_blank' );
982
- $halign_values = array( 'left', 'right', 'center' );
983
- $valign_values = array( 'top', 'bottom', 'middle' );
984
-
985
- $imageUrl = esc_url( $_POST['img_url'] );
986
- $imageCaption = stripslashes( $_POST['description'] );
987
- $title = stripslashes( $_POST['title'] );
988
- if ( in_array( $_POST['target'], $target_values ) ) {
989
- $target = sanitize_text_field($_POST['target']);
990
- }else{
991
- $target = '';
992
- }
993
-
994
- $link = isset( $_POST['link'] ) ? esc_url_raw( $_POST['link'] ) : null;
995
- $imageId = intval( $_POST['img_id'] );
996
- $sortOrder = intval( $_POST['sortOrder'] );
997
-
998
- if ( in_array( $_POST['halign'], $halign_values ) ) {
999
- $halign = sanitize_text_field($_POST['halign']);
1000
- }else{
1001
- $halign = 'center';
1002
- }
1003
1004
- if ( in_array( $_POST['valign'], $valign_values ) ) {
1005
- $valign = sanitize_text_field($_POST['valign']);
1006
- }else{
1007
- $valign = 'middle';
1008
- }
1009
1010
- $data = array(
1011
- "target" => $target,
1012
- "link" => $link,
1013
- "imageId" => $imageId,
1014
- "description" => $imageCaption,
1015
- 'title' => $title,
1016
- "halign" => $halign,
1017
- "valign" => $valign,
1018
- "sortOrder" => $sortOrder,
1019
- );
1020
-
1021
- if ( ! empty( $_POST['id'] ) ) {
1022
- $imageId = intval( $_POST['id'] );
1023
- $result = $this->ModulaDB->editImage( $imageId, $data );
1024
- } else {
1025
- $data["gid"] = intval( $_POST['galleryId'] );
1026
- $result = $this->ModulaDB->addFullImage( $data );
1027
- }
1028
1029
- header( "Content-type: application/json" );
1030
1031
- if ( $result === false ) {
1032
- print "{\"success\":false}";
1033
- } else {
1034
- print "{\"success\":true}";
1035
- }
1036
1037
}
1038
- die();
1039
}
1040
1041
- public function list_images() {
1042
- if ( check_admin_referer( 'Modula', 'Modula' ) ) {
1043
- $gid = intval( $_POST["gid"] );
1044
- $gallery = $this->ModulaDB->getGalleryById( $gid, $this->defaultValues );
1045
1046
- $imageResults = $this->ModulaDB->getImagesByGalleryId( $gid );
1047
1048
- include( 'admin/include/image-list.php' );
1049
- }
1050
- die();
1051
}
1052
1053
- private function checkboxVal( $field ) {
1054
- if ( isset( $_POST[ $field ] ) ) //return 'checked';
1055
- {
1056
- return 'T';
1057
- }
1058
-
1059
- //return '';
1060
- return 'F';
1061
}
1062
1063
- public function save_gallery() {
1064
- if ( check_admin_referer( 'Modula', 'Modula' ) ) {
1065
- $galleryName = stripslashes( $_POST['tg_name'] );
1066
- $galleryDescription = stripslashes( $_POST['tg_description'] );
1067
- $slug = strtolower( str_replace( " ", "", $galleryName ) );
1068
- $margin = intval( $_POST['tg_margin'] );
1069
- $shuffle = $this->checkboxVal( 'tg_shuffle' );
1070
- $width = $_POST['tg_width'];
1071
- $height = $_POST['tg_height'];
1072
- $enableTwitter = $this->checkboxVal( 'tg_enableTwitter' );
1073
- $enableFacebook = $this->checkboxVal( 'tg_enableFacebook' );
1074
- $enableGplus = $this->checkboxVal( 'tg_enableGplus' );
1075
- $enablePinterest = $this->checkboxVal( 'tg_enablePinterest' );
1076
- $lightbox = $_POST['tg_lightbox'];
1077
- $wp_field_caption = $_POST['tg_wp_field_caption'];
1078
- $wp_field_title = $_POST['tg_wp_field_title'];
1079
- $hide_title = $this->checkboxVal( 'tg_hide_title' );
1080
- $hide_description = $this->checkboxVal( 'tg_hide_description' );
1081
- $captionColor = $_POST['tg_captionColor'];
1082
- $borderSize = intval( $_POST['tg_borderSize'] );
1083
- $loadedScale = intval( $_POST['tg_loadedScale'] );
1084
- $loadedRotate = intval( $_POST['tg_loadedRotate'] );
1085
- $loadedVSlide = intval( $_POST['tg_loadedVSlide'] );
1086
- $loadedHSlide = intval( $_POST['tg_loadedHSlide'] );
1087
- $socialIconColor = $_POST['tg_socialIconColor'];
1088
- $hoverEffect = $_POST['tg_hoverEffect'];
1089
- $titleFontSize = intval( $_POST['tg_titleFontSize'] );
1090
- $captionFontSize = intval( $_POST['tg_captionFontSize'] );
1091
- $borderColor = $_POST['tg_borderColor'];
1092
- $borderRadius = intval( $_POST['tg_borderRadius'] );
1093
- $shadowColor = $_POST['tg_shadowColor'];
1094
- $shadowSize = intval( $_POST['tg_shadowSize'] );
1095
- $style = $_POST['tg_style'];
1096
- $script = $_POST['tg_script'];
1097
-
1098
- $id = isset( $_POST['ftg_gallery_edit'] ) ? intval( $_POST['ftg_gallery_edit'] ) : 0;
1099
-
1100
- $data = array(
1101
- 'name' => $galleryName,
1102
- 'slug' => $slug,
1103
- 'description' => $galleryDescription,
1104
- 'lightbox' => $lightbox,
1105
- 'img_size' => intval( $_POST['tg_img_size'] ),
1106
- 'hasResizedImages' => true,
1107
- 'wp_field_caption' => $wp_field_caption,
1108
- 'wp_field_title' => $wp_field_title,
1109
- 'hide_title' => $hide_title,
1110
- 'hide_description' => $hide_description,
1111
- 'margin' => $margin,
1112
- 'randomFactor' => $_POST['tg_randomFactor'],
1113
- 'shuffle' => $shuffle,
1114
- 'enableTwitter' => $enableTwitter,
1115
- 'enableFacebook' => $enableFacebook,
1116
- 'enableGplus' => $enableGplus,
1117
- 'enablePinterest' => $enablePinterest,
1118
- 'captionColor' => $captionColor,
1119
- 'hoverEffect' => $hoverEffect,
1120
- 'borderSize' => $borderSize,
1121
- 'loadedScale' => $loadedScale,
1122
- 'loadedHSlide' => $loadedHSlide,
1123
- 'loadedVSlide' => $loadedVSlide,
1124
- 'loadedRotate' => $loadedRotate,
1125
- 'socialIconColor' => $socialIconColor,
1126
- 'captionFontSize' => $captionFontSize,
1127
- 'titleFontSize' => $titleFontSize,
1128
- 'borderColor' => $borderColor,
1129
- 'borderRadius' => $borderRadius,
1130
- 'shadowSize' => $shadowSize,
1131
- 'shadowColor' => $shadowColor,
1132
- 'width' => $width,
1133
- 'height' => $height,
1134
- 'style' => $style,
1135
- 'script' => $script,
1136
- );
1137
-
1138
- header( "Content-type: application/json" );
1139
- if ( $id > 0 ) {
1140
- $result = $this->ModulaDB->editGallery( $id, $data );
1141
-
1142
- if ( intval( $this->loadedData->img_size ) != $data['img_size'] ) {
1143
- $images = $this->ModulaDB->getImagesByGalleryId( $id );
1144
- $images = ModulaLiteTools::check_and_resize( $images, $data['img_size'] );
1145
-
1146
- foreach ( $images as $img ) {
1147
- $this->ModulaDB->editImage( $img->Id, (array) $img );
1148
- }
1149
- }
1150
1151
- $this->loadedData = $this->ModulaDB->getGalleryById( $id, $this->defaultValues );
1152
- } else {
1153
- $result = $this->ModulaDB->addGallery( $data );
1154
- $id = $this->ModulaDB->getNewGalleryId();
1155
- }
1156
1157
1158
- if ( $result ) {
1159
- print "{\"success\":true,\"id\":" . $id . "}";
1160
- } else {
1161
- print "{\"success\":false}";
1162
}
1163
}
1164
- die();
1165
- }
1166
1167
- public function edit_gallery() {
1168
- if ( isset( $_GET['galleryId'] ) ) {
1169
- $this->loadedData = $this->ModulaDB->getGalleryById( absint( $_GET['galleryId'] ), $this->defaultValues );
1170
- $modula_fields = $this->fields;
1171
- $modula_parent_page = "dashboard";
1172
1173
- include( "admin/edit-gallery.php" );
1174
} else {
1175
- $redir = true;
1176
- $nobanner = true;
1177
- include( "admin/overview.php" );
1178
}
1179
}
1180
1181
- public function list_thumbnail_sizes() {
1182
- global $_wp_additional_image_sizes;
1183
- $sizes = array();
1184
- foreach ( get_intermediate_image_sizes() as $s ) {
1185
- $sizes[ $s ] = array( 0, 0 );
1186
- if ( in_array( $s, array( 'thumbnail', 'medium', 'large' ) ) ) {
1187
- $sizes[ $s ][0] = get_option( $s . '_size_w' );
1188
- $sizes[ $s ][1] = get_option( $s . '_size_h' );
1189
- } else {
1190
- if ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[ $s ] ) ) {
1191
- $sizes[ $s ] = array(
1192
- $_wp_additional_image_sizes[ $s ]['width'],
1193
- $_wp_additional_image_sizes[ $s ]['height'],
1194
- );
1195
- }
1196
}
1197
}
1198
-
1199
- return $sizes;
1200
}
1201
1202
- public function gallery_shortcode_handler( $atts ) {
1203
- require_once( 'lib/gallery-class.php' );
1204
- global $Modula;
1205
1206
- if ( class_exists( 'ModulaLiteFE' ) ) {
1207
- $Modula = new ModulaLiteFE( $this->ModulaDB, $atts['id'], $this->defaultValues );
1208
1209
- $settings = $Modula->getGallery();
1210
- switch ( $settings->lightbox ) {
1211
- case "lightbox2":
1212
- wp_enqueue_style( 'lightbox2_stylesheet' );
1213
- wp_enqueue_script( 'lightbox2_script' );
1214
- wp_add_inline_script( 'lightbox2_script', 'jQuery(document).ready(function(){lightbox.option({albumLabel: "' . esc_html__( 'Image %1 of %2', 'modula-gallery' ) . '"});});' );
1215
- break;
1216
- }
1217
1218
- return $Modula->render();
1219
- } else {
1220
- return esc_html__( 'Gallery not found.', 'modula-gallery' );
1221
}
1222
- }
1223
1224
- public function shortcode_empty_paragraph_fix( $content ) {
1225
1226
- $array = array (
1227
- '<p>[Modula' => '[Modula' ,
1228
- '<p>[/Modula' => '[/Modula',
1229
- 'Modula]</p>' => 'Modula]',
1230
- 'Modula]<br />' => 'Modula]'
1231
- );
1232
1233
- $content = strtr( $content, $array );
1234
1235
- return $content;
1236
- }
1237
1238
}
1239
1240
- class ModulaLiteHoverEffect {
1241
1242
- var $name;
1243
- var $code;
1244
- var $allowTitle;
1245
- var $allowSubtitle;
1246
- var $maxSocial;
1247
1248
- public function __construct( $name, $code, $allowTitle, $allowSubtitle, $maxSocial ) {
1249
- $this->name = $name;
1250
- $this->code = $code;
1251
- $this->allowTitle = $allowTitle;
1252
- $this->allowSubtitle = $allowSubtitle;
1253
- $this->maxSocial = $maxSocial;
1254
- }
1255
}
1256
}
1257
@@ -1431,20 +1429,3 @@ function modula_beta_ajax_script() {
1431
1432
<?php
1433
}
1434
-
1435
- /* RollBack functionality */
1436
- require MODULA_PLUGIN_DIR_PATH . '/lib/class-modula-plugin-rollback.php';
1437
- require MODULA_PLUGIN_DIR_PATH . '/lib/class-modula-rollback.php';
1438
-
1439
- /**
1440
- * Insert Rollback link for plugin in plugins page
1441
- */
1442
-
1443
- function modula_lite_rollback_link( $links ) {
1444
-
1445
- $links['rollback'] = sprintf( '<a href="%s" class="modula-rollback-button">%s</a>', wp_nonce_url( admin_url( 'admin-post.php?action=modula_rollback' ), 'modula_rollback' ), __( 'Rollback version', 'modula-gallery' ) );
1446
-
1447
- return $links;
1448
- }
1449
-
1450
- add_action( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'modula_lite_rollback_link' );
5
* Description: Modula is one of the best & most creative WordPress gallery plugins. Use it to create a great grid or
6
* masonry image gallery.
7
* Author: Macho Themes
8
+ * Version: 1.3.5
9
* Author URI: https://www.machothemes.com/
10
*/
11
12
define( 'MODULA_PLUGIN_DIR_PATH', plugin_dir_path( __FILE__ ) );
13
define( 'MODULA_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) );
14
15
+ define( 'MODULA_VERSION', '1.3.5' );
16
define( 'MODULA_PLUGIN_BASE', plugin_basename( __FILE__ ) );
17
define( 'MODULA_PREVIOUS_PLUGIN_VERSION', '1.3.3' );
18
define( 'MODULA_FILE_', __FILE__ );
22
modula_lite_install_db();
23
}
24
25
+ class ModulaLite {
26
+
27
+ private $loadedData;
28
+ private $fields = array();
29
+
30
+ private $version = "1.3.5";
31
+
32
+ private $defaultValues = array(
33
+ 'width' => 100,
34
+ 'height' => 800,
35
+ 'img_size' => 500,
36
+ 'margin' => 10,
37
+ 'filters' => '',
38
+ 'filterClick' => 'F',
39
+ 'allFilterLabel' => 'All',
40
+ 'lightbox' => 'lightbox2',
41
+ 'shuffle' => 'F',
42
+ 'captionColor' => '#ffffff',
43
+ 'wp_field_caption' => 'caption',
44
+ 'wp_field_title' => 'title',
45
+ 'captionFontSize' => 14,
46
+ 'titleFontSize' => 16,
47
+ 'enableTwitter' => 'T',
48
+ 'enableFacebook' => 'T',
49
+ 'enableGplus' => 'T',
50
+ 'enablePinterest' => 'T',
51
+ 'socialIconColor' => '#ffffff',
52
+ 'loadedScale' => 100,
53
+ 'loadedRotate' => 0,
54
+ 'loadedHSlide' => 0,
55
+ 'loadedVSlide' => 0,
56
+ 'borderSize' => 0,
57
+ 'borderRadius' => 0,
58
+ 'borderColor' => '#ffffff',
59
+ 'shadowSize' => 0,
60
+ 'shadowColor' => '#ffffff',
61
+ 'style' => '',
62
+ 'script' => '',
63
+ 'randomFactor' => 50,
64
+ 'hoverColor' => '#000000',
65
+ 'hoverOpacity' => '50',
66
+ 'hoverEffect' => 'pufrobo',
67
+ 'hasResizedImages' => false,
68
+ 'importedFrom' => '',
69
+ 'hide_title' => false,
70
+ 'hide_description' => false,
71
+ );
72
+
73
+ public function __construct() {
74
+ $this->plugin_name = plugin_basename( __FILE__ );
75
+ $this->plugin_url = plugins_url( '', __FILE__ );
76
+ $this->define_constants();
77
+ $this->define_db_tables();
78
+ $this->define_hover_effects();
79
+ $this->ModulaDB = $this->create_db_conn();
80
+
81
+ add_filter( 'widget_text', 'do_shortcode' );
82
+ add_filter( 'mce_buttons', array( $this, 'editor_button' ) );
83
+ add_filter( 'mce_external_plugins', array( $this, 'register_editor_plugin' ) );
84
+
85
+ add_action( 'init', array( $this, 'create_textdomain' ) );
86
+
87
+ add_action( 'wp_enqueue_scripts', array( $this, 'add_gallery_scripts' ) );
88
+
89
+ add_action( 'admin_menu', array( $this, 'add_gallery_admin_menu' ) );
90
+
91
+ add_shortcode( 'Modula', array( $this, 'gallery_shortcode_handler' ) );
92
+ add_filter( 'the_content', array( $this, 'shortcode_empty_paragraph_fix' ), 99 );
93
+
94
+ add_action( 'wp_ajax_modula_save_gallery', array( $this, 'save_gallery' ) );
95
+ add_action( 'wp_ajax_modula_save_image', array( $this, 'save_image' ) );
96
+ add_action( 'wp_ajax_modula_add_image', array( $this, 'add_image' ) );
97
+ add_action( 'wp_ajax_modula_list_images', array( $this, 'list_images' ) );
98
+ add_action( 'wp_ajax_modula_sort_images', array( $this, 'sort_images' ) );
99
+ add_action( 'wp_ajax_modula_delete_image', array( $this, 'delete_image' ) );
100
+ add_action( 'wp_ajax_modula_resize_images', array( $this, 'resize_images' ) );
101
+ add_action( 'wp_ajax_modula_delete_gallery', array( $this, 'delete_gallery' ) );
102
+ add_action( 'wp_ajax_modula_clone_gallery', array( $this, 'clone_gallery' ) );
103
+ add_action( 'wp_ajax_modula_create_gallery', array( $this, 'create_gallery' ) );
104
+ add_action( 'wp_ajax_mtg_shortcode_editor', array( $this, 'mtg_shortcode_editor' ) );
105
+ add_action( 'wp_ajax_modula_get_config', array( $this, 'get_config' ) );
106
+ add_action( 'wp_ajax_modula_update_config', array( $this, 'update_config' ) );
107
+ add_action( 'wp_ajax_modula_get_ext_galleries', array( $this, 'get_ext_galleries' ) );
108
+ add_action( 'wp_ajax_modula_do_import_galleries', array( $this, 'do_import_galleries' ) );
109
+
110
+ add_filter( 'plugin_row_meta', array( $this, 'register_links' ), 10, 2 );
111
+ add_filter( 'admin_footer_text', array( $this, 'admin_footer' ), 1, 2 );
112
+
113
+ // Enqueue Fancybox for Modula 2.0 Page
114
+ add_action( 'admin_enqueue_scripts', array( $this, 'modula_beta_scripts' ) );
115
+
116
+
117
+ // Set fields
118
+ $this->fields[ __( 'General', 'modula-gallery' ) ] = array(
119
+ "icon" => "mdi mdi-settings",
120
+ "fields" => array(
121
+ "name" => array(
122
+ "name" => esc_html__( 'Name', 'modula-gallery' ),
123
+ "type" => "text",
124
+ "description" => esc_html__( 'Name of the gallery, for internal use.', 'modula-gallery' ),
125
+ "excludeFrom" => array(),
126
+ ),
127
+ "description" => array(
128
+ "name" => esc_html__( 'Description', 'modula-gallery' ),
129
+ "type" => "text",
130
+ "description" => esc_html__( 'This description is for internal use.', 'modula-gallery' ),
131
+ "excludeFrom" => array(),
132
+ ),
133
+ "width" => array(
134
+ "name" => esc_html__( 'Width', 'modula-gallery' ),
135
+ "type" => "text",
136
+ "description" => esc_html__( 'Width of the gallery (i.e.: 100% or 500px)', 'modula-gallery' ),
137
+ "mu" => "px or %",
138
+ "excludeFrom" => array(),
139
+ ),
140
+ "height" => array(
141
+ "name" => esc_html__( 'Height', 'modula-gallery' ),
142
+ "type" => "number",
143
+ "description" => esc_html__( 'Height of the gallery in pixels', 'modula-gallery' ),
144
+ "mu" => "px",
145
+ "excludeFrom" => array(),
146
+ ),
147
+ "img_size" => array(
148
+ "name" => esc_html__( 'Minimum image size', 'modula-gallery' ),
149
+ "type" => "number",
150
+ "description" => esc_html__( 'Minimum width or height of the images', 'modula-gallery' ),
151
+ "mu" => "px or %",
152
+ "excludeFrom" => array(),
153
+ ),
154
+ "margin" => array(
155
+ "name" => esc_html__( 'Margin', 'modula-gallery' ),
156
+ "type" => "number",
157
+ "description" => esc_html__( 'Margin between images', 'modula-gallery' ),
158
+ "mu" => "px",
159
+ "excludeFrom" => array(),
160
+ ),
161
+ "randomFactor" => array(
162
+ "name" => esc_html__( 'Random factor', 'modula-gallery' ),
163
+ "type" => "ui-slider",
164
+ "description" => "",
165
+ "min" => 0,
166
+ "max" => 100,
167
+ "mu" => "%",
168
+ "default" => 20,
169
+ "excludeFrom" => array(),
170
+ ),
171
+ "filters" => array(
172
+ "name" => esc_html__( 'Filters', 'modula-gallery' ),
173
+ "type" => "PRO_FEATURE",
174
+ "description" => esc_html__( 'Add your own filters here. Each image can have one or more filters.', 'modula-gallery' ),
175
+ "excludeFrom" => array(),
176
+ ),
177
+ "filterClick" => array(
178
+ "name" => esc_html__( 'Reload Page on filter click', 'modula-gallery' ),
179
+ "type" => "PRO_FEATURE",
180
+ "description" => esc_html__( 'Turn this feature ON if you want to use filters with most lightboxes', 'modula-gallery' ),
181
+ "excludeFrom" => array(),
182
+ ),
183
+ "allFilterLabel" => array(
184
+ "name" => esc_html__( 'Text for "All" filter', 'modula-gallery' ),
185
+ "type" => "PRO_FEATURE",
186
+ "description" => esc_html__( 'Write here the label for the "All" filter', 'modula-gallery' ),
187
+ "default" => "All",
188
+ "excludeFrom" => array(),
189
+ ),
190
+ "lightbox" => array(
191
+ "name" => esc_html__( 'Lightbox &amp; Links', 'modula-gallery' ),
192
+ "type" => "select",
193
+ "description" => esc_html__( 'Define here what happens when user click on the images.', 'modula-gallery' ),
194
+ "values" => array(
195
+ "Link" => array(
196
+ "|" . esc_html__( 'No link', 'modula-gallery' ),
197
+ "direct|" . esc_html__( 'Direct link to image', 'modula-gallery' ),
198
+ "|" . esc_html__( 'Attachment page', 'modula-gallery' )
199
),
200
+ "Lightboxes" => array( "lightbox2|Lightbox" ),
201
),
202
+ "disabled" => array(
203
+ "Lightboxes with PRO license" => array(
204
+ "magnific|Magnific popup",
205
+ "prettyphoto|PrettyPhoto",
206
+ "fancybox|FancyBox",
207
+ "swipebox|SwipeBox",
208
+ "lightbox2|Lightbox",
209
+ ),
210
),
211
+ "excludeFrom" => array(),
212
),
213
+ "shuffle" => array(
214
+ "name" => esc_html__( 'Shuffle images', 'modula-gallery' ),
215
+ "type" => "toggle",
216
+ "default" => "T",
217
+ "description" => esc_html__( 'Flag it if you want to shuffle the gallery at each page load', 'modula-gallery' ),
218
+ "excludeFrom" => array(),
219
+ ),
220
+ ),
221
+ );
222
+ $this->fields[ esc_html__( 'Captions', 'modula-gallery' ) ] = array(
223
+ "icon" => "mdi mdi-comment-text-outline",
224
+ "fields" => array(
225
+ "captionColor" => array(
226
+ "name" => esc_html__( 'Caption color', 'modula-gallery' ),
227
+ "type" => "color",
228
+ "description" => esc_html__( 'Color of the caption.', 'modula-gallery' ),
229
+ "default" => "#ffffff",
230
+ "excludeFrom" => array(),
231
+ ),
232
+ "wp_field_caption" => array(
233
+ "name" => esc_html__( 'Populate caption from', 'modula-gallery' ),
234
+ "type" => "select",
235
+ "description" => __( '<strong>This field is used ONLY when images are added to the gallery. </strong> If you don\'t want to automatically populate the caption field select <i>Don\'t Populate</i>', 'modula-gallery' ),
236
+ "values" => array(
237
+ "Field" => array(
238
+ "none|" . esc_html__( 'Don\'t Populate', 'modula-gallery' ),
239
+ "title|" . esc_html__( 'WP Image title', 'modula-gallery' ),
240
+ "caption|" . esc_html__( 'WP Image caption', 'modula-gallery' ),
241
+ "description|" . esc_html__( 'WP Image description', 'modula-gallery' ),
242
),
243
),
244
+ "excludeFrom" => array( "shortcode" ),
245
+ ),
246
+ "wp_field_title" => array(
247
+ "name" => esc_html__( 'Populate title from', 'modula-gallery' ),
248
+ "type" => "select",
249
+ "description" => __( '<strong>This field is used ONLY when images are added to the gallery. </strong> If you don\'t want to automatically populate the title field select <i>Don\'t Populate</i>', 'modula-gallery' ),
250
+ "values" => array(
251
+ "Field" => array(
252
+ "none|" . esc_html__( 'Don\'t Populate', 'modula-gallery' ),
253
+ "title|" . esc_html__( 'WP Image title', 'modula-gallery' ),
254
+ "description|" . esc_html__( 'WP Image description', 'modula-gallery' ),
255
),
256
),
257
+ "excludeFrom" => array( "shortcode" ),
258
),
259
+ "hide_title" => array(
260
+ "name" => esc_html__( 'Image Title', 'modula-gallery' ),
261
+ "type" => "toggle",
262
+ "default" => "T",
263
+ "description" => esc_html__( 'Hide image title from frontend', 'modula-gallery' ),
264
+ "excludeFrom" => array(),
265
),
266
+ "hide_description" => array(
267
+ "name" => esc_html__( 'Image Description', 'modula-gallery' ),
268
+ "type" => "toggle",
269
+ "default" => "T",
270
+ "description" => esc_html__( 'Hide image description from frontend', 'modula-gallery' ),
271
+ "excludeFrom" => array(),
272
+ ),
273
+ "captionFontSize" => array(
274
+ "name" => esc_html__( 'Caption Font Size', 'modula-gallery' ),
275
+ "type" => "number",
276
+ "description" => "",
277
+ "mu" => "px",
278
+ "excludeFrom" => array(),
279
+ ),
280
+ "titleFontSize" => array(
281
+ "name" => esc_html__( 'Title Font Size', 'modula-gallery' ),
282
+ "type" => "number",
283
+ "description" => "",
284
+ "mu" => "px",
285
+ "excludeFrom" => array(),
286
+ ),
287
+ ),
288
+ );
289
290
+ $this->fields[ esc_html__( 'Social', 'modula-gallery' ) ] = array(
291
+ "icon" => "mdi mdi-link-variant",
292
+ "fields" => array(
293
+ "enableTwitter" => array(
294
+ "name" => esc_html__( 'Add Twitter icon', 'modula-gallery' ),
295
+ "type" => "toggle",
296
+ "default" => "T",
297
+ "description" => esc_html__( 'Enable Twitter Sharing', 'modula-gallery' ),
298
+ "excludeFrom" => array(),
299
),
300
+ "enableFacebook" => array(
301
+ "name" => esc_html__( 'Add Facebook icon', 'modula-gallery' ),
302
+ "type" => "toggle",
303
+ "default" => "T",
304
+ "description" => esc_html__( 'Enable Facebook Sharing', 'modula-gallery' ),
305
+ "excludeFrom" => array(),
306
),
307
+ "enableGplus" => array(
308
+ "name" => esc_html__( 'Add Google Plus icon', 'modula-gallery' ),
309
+ "type" => "toggle",
310
+ "default" => "T",
311
+ "description" => esc_html__( 'Enable Google Plus Sharing', 'modula-gallery' ),
312
+ "excludeFrom" => array(),
313
+ ),
314
+ "enablePinterest" => array(
315
+ "name" => esc_html__( 'Add Pinterest icon', 'modula-gallery' ),
316
+ "type" => "toggle",
317
+ "default" => "T",
318
+ "description" => esc_html__( 'Enable Pinterest Sharing', 'modula-gallery' ),
319
+ "excludeFrom" => array(),
320
+ ),
321
+ "socialIconColor" => array(
322
+ "name" => esc_html__( 'Color of social sharing icons', 'modula-gallery' ),
323
+ "type" => "color",
324
+ "description" => esc_html__( 'Set the color of the social sharing icons', 'modula-gallery' ),
325
+ "default" => "#ffffff",
326
+ "excludeFrom" => array(),
327
+ ),
328
+ ),
329
330
+ );
331
+ $this->fields[ esc_html__( 'Image loaded effects', 'modula-gallery' ) ] = array(
332
+ "icon" => "mdi mdi-reload",
333
+ "fields" => array(
334
+ "loadedScale" => array(
335
+ "name" => esc_html__( 'Scale', 'modula-gallery' ),
336
+ "description" => esc_html__( 'Choose a value below 100% for a zoom-in effect. Choose a value over 100% for a zoom-out effect', 'modula-gallery' ),
337
+ "type" => "ui-slider",
338
+ "min" => 0,
339
+ "max" => 200,
340
+ "mu" => "%",
341
+ "default" => 100,
342
+ "excludeFrom" => array(),
343
),
344
+ "loadedRotate" => array(
345
+ "name" => esc_html__( 'Rotate', 'modula-gallery' ),
346
+ "description" => "",
347
+ "type" => "PRO_FEATURE",
348
+ "min" => - 180,
349
+ "max" => 180,
350
+ "default" => 0,
351
+ "mu" => "deg",
352
+ "excludeFrom" => array(),
353
+ ),
354
+ "loadedHSlide" => array(
355
+ "name" => esc_html__( 'Horizontal slide', 'modula-gallery' ),
356
+ "description" => "",
357
+ "type" => "PRO_FEATURE",
358
+ "min" => - 100,
359
+ "max" => 100,
360
+ "mu" => "px",
361
+ "default" => 0,
362
+ "excludeFrom" => array(),
363
+ ),
364
+ "loadedVSlide" => array(
365
+ "name" => esc_html__( 'Vertical slide', 'modula-gallery' ),
366
+ "description" => "",
367
+ "type" => "PRO_FEATURE",
368
+ "min" => - 100,
369
+ "max" => 100,
370
+ "mu" => "px",
371
+ "default" => 0,
372
+ "excludeFrom" => array(),
373
),
374
375
+ ),
376
+ );
377
+ $this->fields[ esc_html__( 'Hover effect', 'modula-gallery' ) ] = array(
378
+ "icon" => "mdi mdi-blur",
379
+ "fields" => array(
380
+ "Effect" => array(
381
+ "name" => esc_html__( 'Effect', 'modula-gallery' ),
382
+ "description" => esc_html__( 'Select an hover effect', 'modula-gallery' ),
383
+ "type" => "hover-effect",
384
+ "excludeFrom" => array(),
385
+ ),
386
+ ),
387
+ );
388
+ $this->fields[ esc_html__( 'Style', 'modula-gallery' ) ] = array(
389
+ "icon" => "mdi mdi-format-paint",
390
+ "fields" => array(
391
+ "borderSize" => array(
392
+ "name" => esc_html__( 'Border Size', 'modula-gallery' ),
393
+ "type" => "ui-slider",
394
+ "description" => "",
395
+ "mu" => "px",
396
+ "min" => 0,
397
+ "max" => 10,
398
+ "default" => 0,
399
+ "excludeFrom" => array(),
400
+ ),
401
+ "borderRadius" => array(
402
+ "name" => esc_html__( 'Border Radius', 'modula-gallery' ),
403
+ "type" => "ui-slider",
404
+ "description" => "",
405
+ "mu" => "px",
406
+ "min" => 0,
407
+ "max" => 100,
408
+ "default" => 0,
409
+ "excludeFrom" => array(),
410
+ ),
411
+ "borderColor" => array(
412
+ "name" => esc_html__( 'Border Color', 'modula-gallery' ),
413
+ "type" => "color",
414
+ "description" => "",
415
+ "default" => "#ffffff",
416
+ "excludeFrom" => array(),
417
+ ),
418
+ "shadowSize" => array(
419
+ "name" => esc_html__( 'Shadow Size', 'modula-gallery' ),
420
+ "type" => "ui-slider",
421
+ "description" => "",
422
+ "mu" => "px",
423
+ "min" => 0,
424
+ "max" => 20,
425
+ "default" => 0,
426
+ "excludeFrom" => array(),
427
+ ),
428
+ "shadowColor" => array(
429
+ "name" => esc_html__( 'Shadow Color', 'modula-gallery' ),
430
+ "type" => "color",
431
+ "description" => "",
432
+ "default" => "#ffffff",
433
+ "excludeFrom" => array(),
434
+ ),
435
436
+ ),
437
+ );
438
+ $this->fields[ esc_html__( 'Customizations', 'modula-gallery' ) ] = array(
439
+ "icon" => "mdi mdi-puzzle",
440
+ "fields" => array(
441
+ "script" => array(
442
+ "name" => esc_html__( 'Custom scripts', 'modula-gallery' ),
443
+ "type" => "textarea",
444
+ "description" => esc_html__( 'This script will be called after the gallery initialization. Useful for custom lightboxes.', 'modula-gallery' ) . "
445
+ <br />
446
+ <br />
447
+ <strong>Write just the code without using the &lt;script&gt;&lt;/script&gt; tags</strong>",
448
+ "excludeFrom" => array( "shortcode" ),
449
+ ),
450
+ "style" => array(
451
+ "name" => esc_html__( 'Custom css', 'modula-gallery' ),
452
+ "type" => "textarea",
453
+ "description" => '<strong>' . esc_html__( 'Write just the code without using the &lt;style&gt;&lt;/style&gt; tags', 'modula-gallery' ) . '</strong>',
454
+ "excludeFrom" => array( "shortcode" ),
455
+ ),
456
+ ),
457
+ );
458
459
+ }
460
461
+ public function modula_beta_scripts( $hook ) {
462
463
+ if ( 'modula_page_modula-lite-gallery-v2' != $hook ) {
464
+ return;
465
}
466
467
+ wp_enqueue_script( 'modula-fancybox', plugins_url( 'admin/fancybox/jquery.fancybox.min.js', __FILE__), array( 'jquery' ) );
468
+ wp_enqueue_style( 'modula-fancybox', plugins_url( 'admin/fancybox/jquery.fancybox.min.css', __FILE__) );
469
470
+ }
471
472
+ //Define textdomain
473
+ public function create_textdomain() {
474
+ $plugin_dir = basename( dirname( __FILE__ ) );
475
+ load_plugin_textdomain( 'modula-gallery', false, $plugin_dir . '/lib/languages' );
476
+ }
477
478
+ function define_hover_effects() {
479
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'None', 'none', false, false, 0 );
480
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Pufrobo', 'pufrobo', true, true, 4 );
481
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Fluid Up', '', true, true, 0 );
482
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Hide', '', true, true, 4 );
483
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Quiet', '', true, false, 4 );
484
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Catinelle', '', false, false, 4 );
485
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Reflex', '', true, true, 4 );
486
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Curtain', '', true, false, 4 );
487
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Lens', '', true, true, 4 );
488
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Appear', '', true, false, 4 );
489
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Crafty', '', true, true, 0 );
490
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Seemo', '', true, false, 4 );
491
+ $this->hoverEffects[] = new ModulaLiteHoverEffect( 'Comodo', '', true, false, 4 );
492
+ }
493
494
+ public function get_ext_galleries() {
495
+ header( "Content-type: application/json" );
496
497
+ global $wpdb;
498
499
+ if ( check_admin_referer( "Modula", "Modula" ) ) {
500
+ $res = array( "success" => 0 );
501
502
+ $source = $_POST['source'];
503
+ if ( $source ) {
504
+ $res['success'] = 1;
505
+ $res['galleries'] = array();
506
507
switch ( $source ) {
508
case 'Envira':
509
+ $galleries = get_posts( array(
510
+ 'post_type' => 'envira',
511
+ 'posts_per_page' => 1000,
512
+ ) );
513
+ foreach ( $galleries as $g ) {
514
+ $item = array();
515
+ $item['id'] = $g->ID;
516
+ $item['title'] = $g->post_title;
517
+ $res['galleries'] [] = $item;
518
}
519
break;
520
case 'NextGen':
521
+ $galleries = $wpdb->get_results( "SELECT title, gid FROM $wpdb->nggallery" );
522
+ foreach ( $galleries as $g ) {
523
+ $item = array();
524
+ $item['id'] = $g->gid;
525
+ $item['title'] = $g->title;
526
+ $res['galleries'] [] = $item;
527
}
528
break;
529
}
530
}
531
+
532
+ echo json_encode( $res );
533
}
534
+ die();
535
+ }
536
537
+ public function admin_footer( $text ) {
538
+ global $current_screen;
539
+ if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'modula-lite' ) !== false ) {
540
+ $url = 'https://wordpress.org/support/plugin/modula-best-grid-gallery/reviews/?rate=5#new-post';
541
+ $text = sprintf( __( 'Please rate <strong>Modula 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, on behalf of the Modula team!', 'modula-gallery' ), $url, $url );
542
+ }
543
544
+ return $text;
545
+ }
546
547
+ public function do_import_galleries() {
548
+ global $wpdb;
549
+
550
+ header( "Content-type: application/json" );
551
+ if ( check_admin_referer( "Modula", "Modula" ) ) {
552
+ $res = array( "success" => 0 );
553
+ $source = $_POST['source'];
554
+ $ids = explode( ",", $_POST['ids'] );
555
+ switch ( $source ) {
556
+ case 'Envira':
557
+ foreach ( $ids as $id ) {
558
+ $gallery = get_post( $id );
559
+ $meta = get_post_meta( $id );
560
+ $data = unserialize( $meta['_eg_gallery_data'][0] );
561
+
562
+ $g = array(
563
+ 'name' => $data['config']['title'],
564
+ 'description' => 'Imported from Envira (' . $id . ') on ' . date( 'M, d Y' ),
565
+ 'margin' => $data['config']['gutter'],
566
+ 'hasResizedImages' => true,
567
+ 'importedFrom' => 'Envira',
568
+ );
569
+ $gdb = array_merge( $this->defaultValues, $g );
570
+
571
+ $saved = $this->ModulaDB->addGallery( $gdb );
572
+ $newId = $this->ModulaDB->getNewGalleryId();
573
+
574
+ if ( $newId && count( $data['gallery'] ) ) {
575
+ $images = array();
576
+ //TODO only active images
577
+ foreach ( $data['gallery'] as $item ) {
578
+ $toAdd = new stdClass();
579
+ $toAdd->imageId = $this->ModulaDB->getIDbyGUID( $item['src'] );
580
+ $toAdd->title = $item['title'];
581
+ $toAdd->description = $item['caption'];
582
+ $toAdd->imagePath = $item['src'];
583
+
584
+ $images [] = $toAdd;
585
+ }
586
+ $imgResult = $this->ModulaDB->addImages( $newId, $images );
587
+ }
588
+ }
589
+ $res['success'] = 1;
590
+ break;
591
+ case 'NextGen':
592
+ foreach ( $ids as $id ) {
593
+ $gallery = $wpdb->get_row( $wpdb->prepare( "SELECT title, gid, path FROM $wpdb->nggallery WHERE gid=%s", $id ) );
594
+
595
+ $dbimages = $wpdb->get_results( $wpdb->prepare( "SELECT filename, description, alttext FROM $wpdb->nggpictures WHERE exclude <> 1 AND galleryid=%s", $id ) );
596
+
597
+ $g = array(
598
+ 'name' => $gallery->title,
599
+ 'description' => 'Imported from NextGet (' . $id . ') on ' . date( 'M, d Y' ),
600
+ 'hasResizedImages' => true,
601
+ 'importedFrom' => 'NextGen',
602
+ );
603
+ $gdb = array_merge( $this->defaultValues, $g );
604
605
+ $saved = $this->ModulaDB->addGallery( $gdb );
606
+ $newId = $this->ModulaDB->getNewGalleryId();
607
608
+ if ( $newId && count( $dbimages ) ) {
609
+ $images = array();
610
+ foreach ( $dbimages as $item ) {
611
+ $toAdd = new stdClass();
612
+ $toAdd->imageId = - 1;
613
+ $toAdd->title = $item->alttext;
614
+ $toAdd->description = $item->description;
615
+ $toAdd->imagePath = plugins_url( 'image.php', __FILE__ ) . "?w=" . $this->defaultValues['img_size'] . "&src=" . $gallery->path . "/" . $item->filename;
616
617
+ $images [] = $toAdd;
618
+ }
619
+ $imgResult = $this->ModulaDB->addImages( $newId, $images );
620
621
+ }
622
+ }
623
+ $res['success'] = 1;
624
+ break;
625
}
626
627
+ echo json_encode( $res );
628
}
629
+ die();
630
+ }
631
632
+ public function register_links( $links, $file ) {
633
+ $base = plugin_basename( __FILE__ );
634
+ if ( $file == $base ) {
635
+ $links[] = '<a href="admin.php?page=modula-lite-admin" title="' . esc_html__( 'Modula Grid Gallery Dashboard', 'modula-gallery' ) . '">' . esc_html__( 'Dashboard', 'modula-gallery' ) . '</a>';
636
+ $links[] = '<a href="https://twitter.com/MachoThemez" title="@MachoThemez on Twitter">Twitter</a>';
637
+ $links[] = '<a href="https://www.facebook.com/machothemes" title="MachoThemes on Facebook">Facebook</a>';
638
+ }
639
640
+ return $links;
641
642
+ }
643
644
+ //delete gallery
645
+ function delete_gallery() {
646
+ if ( check_admin_referer( "Modula", "Modula" ) ) {
647
+ $id = absint( $_POST['gid'] );
648
+ $this->ModulaDB->deleteGallery( $id );
649
}
650
651
+ die();
652
+ }
653
+
654
+ public function update_config() {
655
+ if ( check_admin_referer( "Modula", "Modula" ) ) {
656
+ $id = absint($_POST['id']);
657
+ $config = stripslashes( $_POST['config'] );
658
+
659
+ $this->ModulaDB->update_config( $id, $config );
660
}
661
662
+ die();
663
+ }
664
665
+ public function get_config() {
666
+ if ( check_admin_referer( "Modula", "Modula" ) ) {
667
+ $id = absint($_POST['id']);
668
669
+ $data = $this->ModulaDB->getConfig( $id );
670
+
671
+ print json_encode( $data );
672
673
}
674
675
+ die();
676
+ }
677
678
+ //add gallery
679
+
680
+ function create_gallery() {
681
+ if ( check_admin_referer( "Modula", "Modula" ) ) {
682
+ $data = $this->defaultValues;
683
+ $data["name"] = sanitize_text_field($_POST['name']);
684
+ $data["description"] = wp_filter_post_kses($_POST['description']);
685
+ $data["width"] = sanitize_text_field($_POST['width']);
686
+ $data["height"] = absint($_POST['height']);
687
+ $data["img_size"] = absint( $_POST['img_size'] );
688
+ $data["hasResizedImages"] = true;
689
+
690
+ $this->ModulaDB->addGallery( $data );
691
+ $id = $this->ModulaDB->getLastGalleryId()->Id;
692
+
693
+ if ( $id > 0 && array_key_exists( 'images', $_POST ) && strlen( $_POST['images'] ) ) {
694
+ $enc_images = stripslashes( $_POST["images"] );
695
+ $images = array_splice( json_decode( $enc_images ), 0, 11 + 9 );
696
+ ModulaLiteTools::check_and_resize( $images, $data['img_size'] );
697
+ $result = $this->ModulaDB->addImages( $id, $images );
698
}
699
+ print $id;
700
+ }
701
+ die;
702
+ }
703
704
+ //clone gallery
705
+ function clone_gallery() {
706
+ if ( check_admin_referer( 'Modula', 'Modula' ) ) {
707
+ $sourceId = absint( $_POST['gid'] );
708
+ $g = $this->ModulaDB->getGalleryById( $sourceId, $this->defaultValues );
709
+ $g->name .= "(copy)";
710
+ $this->ModulaDB->addGallery( $g );
711
+ $id = $this->ModulaDB->getNewGalleryId();
712
+ $images = $this->ModulaDB->getImagesByGalleryId( $sourceId );
713
+
714
+ foreach ( $images as &$image ) {
715
+ $image->Id = null;
716
+ $image->gid = $id;
717
}
718
719
+ $this->ModulaDB->addImages( $id, $images );
720
}
721
722
+ die();
723
+ }
724
725
726
+ //Define constants
727
+ public function define_constants() {
728
+ if ( ! defined( 'Modula_PLUGIN_BASENAME' ) ) {
729
+ define( 'Modula_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
730
+ }
731
732
+ if ( ! defined( 'Modula_PLUGIN_NAME' ) ) {
733
+ define( 'Modula_PLUGIN_NAME', trim( dirname( Modula_PLUGIN_BASENAME ), '/' ) );
734
}
735
736
+ if ( ! defined( 'Modula_PLUGIN_DIR' ) ) {
737
+ define( 'Modula_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . Modula_PLUGIN_NAME );
738
+ }
739
+ }
740
741
+ //delete Gallery
742
743
744
+ //Define DB tables
745
+ public function define_db_tables() {
746
+ global $wpdb;
747
748
+ $wpdb->ModulaGalleries = $wpdb->prefix . 'modula';
749
+ $wpdb->ModulaImages = $wpdb->prefix . 'modula_images';
750
+ }
751
752
753
+ public function create_db_conn() {
754
+ require( 'lib/db-class.php' );
755
+ $ModulaDB = ModulaLiteDB::getInstance();
756
757
+ return $ModulaDB;
758
+ }
759
760
+ public function editor_button( $buttons ) {
761
+ array_push( $buttons, 'separator', 'mtg_shortcode_editor' );
762
763
+ return $buttons;
764
+ }
765
766
+ public function register_editor_plugin( $plugin_array ) {
767
+ $plugin_array['mtg_shortcode_editor'] = plugins_url( '/admin/scripts/editor-plugin.js', __file__ );
768
769
+ return $plugin_array;
770
+ }
771
772
+ public function mtg_shortcode_editor() {
773
+ $css_path = plugins_url( 'assets/css/admin.css', __FILE__ );
774
+ $admin_url = admin_url();
775
776
+ $galleries = $this->ModulaDB->getGalleries(); //load all galleries
777
778
+ include 'admin/include/tinymce-galleries.php';
779
+ die();
780
+ }
781
782
+ //Add gallery scripts
783
+ public function add_gallery_scripts() {
784
+ wp_enqueue_script( 'jquery' );
785
786
+ wp_register_script( 'modula', plugins_url( 'scripts/jquery.modula.js', __FILE__ ) , array( 'jquery' ) );
787
+ wp_enqueue_script( 'modula' );
788
789
+ wp_register_style( 'modula_stylesheet', plugins_url( 'scripts/modula.css', __FILE__ ), null, $this->version );
790
+ wp_enqueue_style( 'modula_stylesheet' );
791
792
+ wp_register_style( 'effects_stylesheet', plugins_url( 'scripts/effects.css', __FILE__ ), null, $this->version );
793
+ wp_enqueue_style( 'effects_stylesheet' );
794
795
+ wp_register_script( 'lightbox2_script', plugins_url( 'lightbox/lightbox2/js/lightbox.min.js', __FILE__ ), array( 'jquery' ), $this->version, true );
796
+ wp_register_style( 'lightbox2_stylesheet', plugins_url( 'lightbox/lightbox2/css/lightbox.min.css', __FILE__ ) );
797
+ }
798
799
+ //Admin Section - register scripts and styles
800
+ public function gallery_admin_init() {
801
+ if ( function_exists( 'wp_enqueue_media' ) ) {
802
+ wp_enqueue_media();
803
+ }
804
805
+ wp_enqueue_script( 'jquery' );
806
807
+ wp_enqueue_script( 'wp-color-picker' );
808
+ wp_enqueue_style( 'wp-color-picker' );
809
810
+ wp_enqueue_script( 'media-upload' );
811
+ wp_enqueue_script( 'thickbox' );
812
813
+ wp_register_style( 'materialize', plugins_url( 'admin/css/materialize.css', __FILE__ ) );
814
+ wp_enqueue_style( 'materialize' );
815
816
+ wp_register_style( 'styles', plugins_url( 'admin/css/style.css', __FILE__ ) );
817
+ wp_enqueue_style( 'styles' );
818
819
+ wp_register_style( 'effects', plugins_url( 'scripts/effects.css', __FILE__ ) );
820
+ wp_enqueue_style( 'effects' );
821
822
+ wp_register_script( 'materialize', plugins_url( 'admin/scripts/materialize.js', __FILE__ ), array( 'jquery' ) );
823
824
+ wp_register_script( 'modula', plugins_url( 'admin/scripts/modula-admin.js', __FILE__ ), array(
825
+ 'materialize',
826
+ 'jquery',
827
+ 'media-upload',
828
+ 'thickbox',
829
+ ), false, false );
830
+
831
+ wp_enqueue_script( 'modula' );
832
+
833
+ wp_register_style( 'materialdesign-icons', plugins_url( 'admin/css/materialdesignicons.css', __FILE__ ) );
834
+ wp_enqueue_style( 'materialdesign-icons' );
835
+
836
+ wp_enqueue_style( 'thickbox' );
837
+
838
+ $tg_db_version = '1.0';
839
+ $installed_ver = get_option( "Modula_db_version" );
840
+
841
+ if ( $installed_ver != $tg_db_version ) {
842
+ modula_lite_create_db_tables();
843
+ update_option( "Modula_db_version", $tg_db_version );
844
}
845
+ }
846
847
848
+ //Create Admin Menu
849
+ public function add_gallery_admin_menu() {
850
+ $overview = add_menu_page( esc_html__( 'Manage Galleries', 'modula-gallery' ), esc_html__( 'Modula', 'modula-gallery' ), 'edit_posts', 'modula-lite-admin', array(
851
+ $this,
852
+ 'add_overview',
853
+ ), plugins_url( 'admin/icon.png', __FILE__ ) );
854
855
856
+ if ( ! get_option( "Modula_skip_fix" ) && get_option( "Modula_db_version" ) && count( $this->ModulaDB->getGalleries() ) > 0 ) {
857
858
+ $imageUrl = null;
859
+ foreach ( $this->ModulaDB->getGalleries() as $gallery ) {
860
+ $gid = $gallery->Id;
861
+ $images = $this->ModulaDB->getImagesByGalleryId( $gid );
862
+ if ( count( $images ) > 0 ) {
863
+ $imageUrl = $images[0]->imagePath;
864
+ break;
865
}
866
+ }
867
868
+ if ( $imageUrl ) {
869
+ if ( strncmp( strtolower( $imageUrl ), strtolower( site_url() ), strlen( site_url() ) ) != 0 ) {
870
+ $fix = add_submenu_page( 'modula-lite-admin', __( 'Modula >> Fix', 'modula-gallery' ), '❗️ ' . __( 'Fix', 'modula-gallery' ), 'edit_posts', 'modula-lite-gallery-fix', array(
871
+ $this,
872
+ 'fix',
873
+ ) );
874
+ add_action( 'load-' . $fix, array( $this, 'gallery_admin_init' ) );
875
}
876
}
877
+ } else {
878
+ add_option( 'Modula_skip_fix', true );
879
+ }
880
881
+ $add_gallery = add_submenu_page( 'modula-lite-admin', __( 'Modula - Add Gallery', 'modula-gallery' ), __( 'Add Gallery', 'modula-gallery' ), 'edit_posts', 'modula-lite-add', array(
882
+ $this,
883
+ 'add_gallery',
884
+ ) );
885
+ $edit_gallery = add_submenu_page( NULL, __( 'Modula - Edit Gallery', 'modula-gallery' ), __( 'Edit Gallery', 'modula-gallery' ), 'edit_posts', 'modula-lite-edit', array(
886
+ $this,
887
+ 'edit_gallery',
888
+ ) );
889
+ $upgrade = add_submenu_page( 'modula-lite-admin', __( 'Modula - Upgrade to PRO', 'modula-gallery' ), __( 'Upgrade to PRO', 'modula-gallery' ), 'edit_posts', 'modula-lite-gallery-upgrade', array(
890
+ $this,
891
+ 'upgrade',
892
+ ) );
893
+ $v2 = add_submenu_page( 'modula-lite-admin', __( 'Try Modula 2.0', 'modula-gallery' ), __( 'Try Modula 2.0', 'modula-gallery' ), 'edit_posts', 'modula-lite-gallery-v2', array(
894
+ $this,
895
+ 'new_modula',
896
+ ) );
897
+
898
+
899
+ add_action( 'load-' . $overview, array( $this, 'gallery_admin_init' ) );
900
+ add_action( 'load-' . $add_gallery, array( $this, 'gallery_admin_init' ) );
901
+ add_action( 'load-' . $edit_gallery, array( $this, 'gallery_admin_init' ) );
902
+ add_action( 'load-' . $upgrade, array( $this, 'gallery_admin_init' ) );
903
904
+ }
905
906
+ //Create Admin Pages
907
+ public function add_overview() {
908
+ include( "admin/overview.php" );
909
+ }
910
911
+ public function upgrade() {
912
+ include( "admin/upgrade.php" );
913
+ }
914
915
+ public function add_gallery() {
916
+ include( "admin/add-gallery.php" );
917
+ }
918
919
+ public function new_modula() {
920
+ include( "admin/modula-v2.php" );
921
+ }
922
923
+ public function fix() {
924
+ global $wpdb;
925
+ include( "admin/fix.php" );
926
+ }
927
928
+ public function delete_image() {
929
+ if ( check_admin_referer( 'Modula', 'Modula' ) ) {
930
+ foreach ( explode( ",", $_POST["id"] ) as $id ) {
931
+ $this->ModulaDB->deleteImage( absint( $id ) );
932
}
933
}
934
+ die();
935
+ }
936
937
+ public function add_image() {
938
+ if ( check_admin_referer( 'Modula', 'Modula' ) ) {
939
+ $gid = intval( $_POST['galleryId'] );
940
+ $this->loadedData = $this->ModulaDB->getGalleryById( $gid, $this->defaultValues );
941
+ $prev = $this->ModulaDB->getImagesByGalleryId( $gid );
942
+
943
+ $enc_images = stripslashes( $_POST["enc_images"] );
944
+ $images = json_decode( $enc_images );
945
+
946
+ $d = 18 + log10( 100 );
947
+ $images = array_slice( $images, 0, $d - count( $prev ) );
948
+ $images = ModulaLiteTools::check_and_resize( $images, $this->loadedData->img_size );
949
+ $result = $this->ModulaDB->addImages( $gid, $images );
950
+
951
+ header( "Content-type: application/json" );
952
+ if ( $result === false ) {
953
+ print "{\"success\":false}";
954
+ } else {
955
+ print "{\"success\":true}";
956
}
957
}
958
+ die();
959
+ }
960
961
+ public function sort_images() {
962
+ if ( check_admin_referer( 'Modula', 'Modula' ) ) {
963
+ $result = $this->ModulaDB->sortImages( explode( ',', $_POST['ids'] ) );
964
965
+ header( "Content-type: application/json" );
966
+ if ( $result === false ) {
967
+ print "{\"success\":false}";
968
+ } else {
969
+ print "{\"success\":true}";
970
}
971
}
972
+ die();
973
+ }
974
975
+ public function save_image() {
976
+ if ( check_admin_referer( 'Modula', 'Modula' ) ) {
977
+ $result = false;
978
+ // $type = $_POST['type'];
979
+
980
+ $target_values = array( '', '_self', '_blank' );
981
+ $halign_values = array( 'left', 'right', 'center' );
982
+ $valign_values = array( 'top', 'bottom', 'middle' );
983
+
984
+ $imageUrl = esc_url( $_POST['img_url'] );
985
+ $imageCaption = wp_filter_post_kses( $_POST['description'] );
986
+ $title = sanitize_text_field( $_POST['title'] );
987
+ if ( in_array( $_POST['target'], $target_values ) ) {
988
+ $target = sanitize_text_field($_POST['target']);
989
+ }else{
990
+ $target = '';
991
+ }
992
+
993
+ $link = isset( $_POST['link'] ) ? esc_url_raw( $_POST['link'] ) : null;
994
+ $imageId = intval( $_POST['img_id'] );
995
+ $sortOrder = intval( $_POST['sortOrder'] );
996
+
997
+ if ( in_array( $_POST['halign'], $halign_values ) ) {
998
+ $halign = sanitize_text_field($_POST['halign']);
999
+ }else{
1000
+ $halign = 'center';
1001
+ }
1002
1003
+ if ( in_array( $_POST['valign'], $valign_values ) ) {
1004
+ $valign = sanitize_text_field($_POST['valign']);
1005
+ }else{
1006
+ $valign = 'middle';
1007
+ }
1008
1009
+ $data = array(
1010
+ "target" => $target,
1011
+ "link" => $link,
1012
+ "imageId" => $imageId,
1013
+ "description" => $imageCaption,
1014
+ 'title' => $title,
1015
+ "halign" => $halign,
1016
+ "valign" => $valign,
1017
+ "sortOrder" => $sortOrder,
1018
+ );
1019
1020
+ if ( ! empty( $_POST['id'] ) ) {
1021
+ $imageId = intval( $_POST['id'] );
1022
+ $result = $this->ModulaDB->editImage( $imageId, $data );
1023
+ } else {
1024
+ $data["gid"] = intval( $_POST['galleryId'] );
1025
+ $result = $this->ModulaDB->addFullImage( $data );
1026
+ }
1027
1028
+ header( "Content-type: application/json" );
1029
1030
+ if ( $result === false ) {
1031
+ print "{\"success\":false}";
1032
+ } else {
1033
+ print "{\"success\":true}";
1034
}
1035
+
1036
}
1037
+ die();
1038
+ }
1039
1040
+ public function list_images() {
1041
+ if ( check_admin_referer( 'Modula', 'Modula' ) ) {
1042
+ $gid = intval( $_POST["gid"] );
1043
+ $gallery = $this->ModulaDB->getGalleryById( $gid, $this->defaultValues );
1044
1045
+ $imageResults = $this->ModulaDB->getImagesByGalleryId( $gid );
1046
1047
+ include( 'admin/include/image-list.php' );
1048
}
1049
+ die();
1050
+ }
1051
1052
+ private function checkboxVal( $field ) {
1053
+ if ( isset( $_POST[ $field ] ) ) //return 'checked';
1054
+ {
1055
+ return 'T';
1056
}
1057
1058
+ //return '';
1059
+ return 'F';
1060
+ }
1061
1062
+ public function save_gallery() {
1063
+ if ( check_admin_referer( 'Modula', 'Modula' ) ) {
1064
+ $galleryName = sanitize_text_field( $_POST['tg_name'] );
1065
+ $galleryDescription = wp_filter_post_kses( $_POST['tg_description'] );
1066
+ $slug = strtolower( str_replace( " ", "", $galleryName ) );
1067
+ $margin = absint( $_POST['tg_margin'] );
1068
+ $shuffle = $this->checkboxVal( 'tg_shuffle' );
1069
+ $width = sanitize_text_field( $_POST['tg_width'] );
1070
+ $height = absint($_POST['tg_height']);
1071
+ $enableTwitter = $this->checkboxVal( 'tg_enableTwitter' );
1072
+ $enableFacebook = $this->checkboxVal( 'tg_enableFacebook' );
1073
+ $enableGplus = $this->checkboxVal( 'tg_enableGplus' );
1074
+ $enablePinterest = $this->checkboxVal( 'tg_enablePinterest' );
1075
+ $lightbox = $_POST['tg_lightbox'];
1076
+ $wp_field_caption = $_POST['tg_wp_field_caption'];
1077
+ $wp_field_title = $_POST['tg_wp_field_title'];
1078
+ $hide_title = $this->checkboxVal( 'tg_hide_title' );
1079
+ $hide_description = $this->checkboxVal( 'tg_hide_description' );
1080
+ $captionColor = sanitize_hex_color($_POST['tg_captionColor']);
1081
+ $borderSize = absint( $_POST['tg_borderSize'] );
1082
+ $loadedScale = absint( $_POST['tg_loadedScale'] );
1083
+ $loadedRotate = absint( $_POST['tg_loadedRotate'] );
1084
+ $loadedVSlide = absint( $_POST['tg_loadedVSlide'] );
1085
+ $loadedHSlide = absint( $_POST['tg_loadedHSlide'] );
1086
+ $socialIconColor = sanitize_hex_color($_POST['tg_socialIconColor']);
1087
+ $hoverEffect = $_POST['tg_hoverEffect'];
1088
+ $titleFontSize = absint( $_POST['tg_titleFontSize'] );
1089
+ $captionFontSize = absint( $_POST['tg_captionFontSize'] );
1090
+ $borderColor = sanitize_hex_color($_POST['tg_borderColor']);
1091
+ $borderRadius = intval( $_POST['tg_borderRadius'] );
1092
+ $shadowColor = sanitize_hex_color($_POST['tg_shadowColor']);
1093
+ $shadowSize = intval( $_POST['tg_shadowSize'] );
1094
+ $style = sanitize_text_field($_POST['tg_style']);
1095
+ $script = sanitize_text_field($_POST['tg_script']);
1096
+
1097
+ $id = isset( $_POST['ftg_gallery_edit'] ) ? intval( $_POST['ftg_gallery_edit'] ) : 0;
1098
+
1099
+ $data = array(
1100
+ 'name' => $galleryName,
1101
+ 'slug' => $slug,
1102
+ 'description' => $galleryDescription,
1103
+ 'lightbox' => $lightbox,
1104
+ 'img_size' => intval( $_POST['tg_img_size'] ),
1105
+ 'hasResizedImages' => true,
1106
+ 'wp_field_caption' => $wp_field_caption,
1107
+ 'wp_field_title' => $wp_field_title,
1108
+ 'hide_title' => $hide_title,
1109
+ 'hide_description' => $hide_description,
1110
+ 'margin' => $margin,
1111
+ 'randomFactor' => $_POST['tg_randomFactor'],
1112
+ 'shuffle' => $shuffle,
1113
+ 'enableTwitter' => $enableTwitter,
1114
+ 'enableFacebook' => $enableFacebook,
1115
+ 'enableGplus' => $enableGplus,
1116
+ 'enablePinterest' => $enablePinterest,
1117
+ 'captionColor' => $captionColor,
1118
+ 'hoverEffect' => $hoverEffect,
1119
+ 'borderSize' => $borderSize,
1120
+ 'loadedScale' => $loadedScale,
1121
+ 'loadedHSlide' => $loadedHSlide,
1122
+ 'loadedVSlide' => $loadedVSlide,
1123
+ 'loadedRotate' => $loadedRotate,
1124
+ 'socialIconColor' => $socialIconColor,
1125
+ 'captionFontSize' => $captionFontSize,
1126
+ 'titleFontSize' => $titleFontSize,
1127
+ 'borderColor' => $borderColor,
1128
+ 'borderRadius' => $borderRadius,
1129
+ 'shadowSize' => $shadowSize,
1130
+ 'shadowColor' => $shadowColor,
1131
+ 'width' => $width,
1132
+ 'height' => $height,
1133
+ 'style' => $style,
1134
+ 'script' => $script,
1135
+ );
1136
+
1137
+ header( "Content-type: application/json" );
1138
+ if ( $id > 0 ) {
1139
+ $result = $this->ModulaDB->editGallery( $id, $data );
1140
1141
+ if ( intval( $this->loadedData->img_size ) != $data['img_size'] ) {
1142
+ $images = $this->ModulaDB->getImagesByGalleryId( $id );
1143
+ $images = ModulaLiteTools::check_and_resize( $images, $data['img_size'] );
1144
1145
+ foreach ( $images as $img ) {
1146
+ $this->ModulaDB->editImage( $img->Id, (array) $img );
1147
+ }
1148
}
1149
+
1150
+ $this->loadedData = $this->ModulaDB->getGalleryById( $id, $this->defaultValues );
1151
+ } else {
1152
+ $result = $this->ModulaDB->addGallery( $data );
1153
+ $id = $this->ModulaDB->getNewGalleryId();
1154
}
1155
1156
1157
+ if ( $result ) {
1158
+ print "{\"success\":true,\"id\":" . $id . "}";
1159
} else {
1160
+ print "{\"success\":false}";
1161
}
1162
}
1163
+ die();
1164
+ }
1165
1166
+ public function edit_gallery() {
1167
+ if ( isset( $_GET['galleryId'] ) ) {
1168
+ $this->loadedData = $this->ModulaDB->getGalleryById( absint( $_GET['galleryId'] ), $this->defaultValues );
1169
+ $modula_fields = $this->fields;
1170
+ $modula_parent_page = "dashboard";
1171
+
1172
+ include( "admin/edit-gallery.php" );
1173
+ } else {
1174
+ $redir = true;
1175
+ $nobanner = true;
1176
+ include( "admin/overview.php" );
1177
+ }
1178
+ }
1179
+
1180
+ public function list_thumbnail_sizes() {
1181
+ global $_wp_additional_image_sizes;
1182
+ $sizes = array();
1183
+ foreach ( get_intermediate_image_sizes() as $s ) {
1184
+ $sizes[ $s ] = array( 0, 0 );
1185
+ if ( in_array( $s, array( 'thumbnail', 'medium', 'large' ) ) ) {
1186
+ $sizes[ $s ][0] = get_option( $s . '_size_w' );
1187
+ $sizes[ $s ][1] = get_option( $s . '_size_h' );
1188
+ } else {
1189
+ if ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[ $s ] ) ) {
1190
+ $sizes[ $s ] = array(
1191
+ $_wp_additional_image_sizes[ $s ]['width'],
1192
+ $_wp_additional_image_sizes[ $s ]['height'],
1193
+ );
1194
}
1195
}
1196
}
1197
1198
+ return $sizes;
1199
+ }
1200
1201
+ public function gallery_shortcode_handler( $atts ) {
1202
+ require_once( 'lib/gallery-class.php' );
1203
+ global $Modula;
1204
1205
+ if ( class_exists( 'ModulaLiteFE' ) ) {
1206
+ $Modula = new ModulaLiteFE( $this->ModulaDB, $atts['id'], $this->defaultValues );
1207
1208
+ $settings = $Modula->getGallery();
1209
+ switch ( $settings->lightbox ) {
1210
+ case "lightbox2":
1211
+ wp_enqueue_style( 'lightbox2_stylesheet' );
1212