Gallery – Photo Gallery – Image Gallery - Version 1.2.0

Version Description

Download this release

Release Info

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

Code changes from version 1.1.13 to 1.2.0

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