Gallery – Photo Gallery – Image Gallery - Version 1.1.7

Version Description

  • Tool to fix broken images after version 1.1.0
Download this release

Release Info

Developer GreenTreeLabs
Plugin Icon wp plugin Gallery – Photo Gallery – Image Gallery
Version 1.1.7
Comparing to
See all releases

Code changes from version 1.1.6 to 1.1.7

Files changed (6) hide show
  1. Modula.php +43 -10
  2. README.txt +9 -1
  3. admin/fix.php +112 -0
  4. admin/header.php +5 -2
  5. admin/images/survey.png +0 -0
  6. admin/overview.php +1 -0
Modula.php CHANGED
@@ -4,7 +4,7 @@ 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.6
8
  Author URI: http://modula.greentreelabs.net
9
  */
10
 
@@ -20,7 +20,7 @@ if (!class_exists("ModulaLite"))
20
  {
21
  private $loadedData;
22
 
23
- private $version = "1.1.6";
24
 
25
  private $defaultValues = array(
26
  'width' => 100,
@@ -58,7 +58,7 @@ if (!class_exists("ModulaLite"))
58
  'hoverOpacity' => '50',
59
  'hoverEffect' => 'pufrobo',
60
  'hasResizedImages' => false,
61
- 'importedFrom' => ''
62
  );
63
 
64
  public function __construct()
@@ -500,13 +500,40 @@ if (!class_exists("ModulaLite"))
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'), WP_PLUGIN_URL.'/modula-best-grid-gallery/admin/icon.png');
504
- $tutorial = add_submenu_page('ModulaLite-admin', __('Modula >> Tutorial','Modula'), __('Tutorial','Modula'), 'edit_posts', 'modula-lite-tutorial', array($this, 'tutorial'));
505
- $add_gallery = add_submenu_page('ModulaLite-admin', __('Modula >> Add Gallery','Modula'), __('Add Gallery','Modula'), 'edit_posts', 'add-modula-lite', array($this, 'add_gallery'));
506
- $edit_gallery = add_submenu_page('ModulaLite-admin', __('Modula >> Edit Gallery','Modula'), __('Edit Gallery','Modula'), 'edit_posts', 'edit-modula-lite', array($this, 'edit_gallery'));
507
- $plugins = add_submenu_page('ModulaLite-admin', __('Modula >> Other galleries','Modula'), __('Other galleries','Modula'), 'edit_posts', 'modula-lite-gallery-others', array($this, 'other_galleries'));
508
- $import = add_submenu_page('ModulaLite-admin', __('Modula >> Import','Modula'), __('Import galleries','Modula'), 'edit_posts', 'modula-lite-gallery-import', array($this, 'import_galleries'));
509
- $upgrade = add_submenu_page('ModulaLite-admin', __('Modula >> Upgrade','Modula'), __('Upgrade','Modula'), 'edit_posts', 'modula-lite-gallery-upgrade', array($this, 'upgrade'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
 
511
  add_action('load-'.$tutorial, array($this, 'gallery_admin_init'));
512
  add_action('load-'.$overview, array($this, 'gallery_admin_init'));
@@ -548,6 +575,12 @@ if (!class_exists("ModulaLite"))
548
  include("admin/import.php");
549
  }
550
 
 
 
 
 
 
 
551
  public function delete_image()
552
  {
553
  if(check_admin_referer('Modula','Modula'))
4
  Plugin URI: http://modula.greentreelabs.net
5
  Description: The Most Creative Grid Wordpress Gallery.
6
  Author: GreenTreeLabs
7
+ Version: 1.1.7
8
  Author URI: http://modula.greentreelabs.net
9
  */
10
 
20
  {
21
  private $loadedData;
22
 
23
+ private $version = "1.1.7";
24
 
25
  private $defaultValues = array(
26
  'width' => 100,
58
  'hoverOpacity' => '50',
59
  'hoverEffect' => 'pufrobo',
60
  'hasResizedImages' => false,
61
+ 'importedFrom' => ''
62
  );
63
 
64
  public function __construct()
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'), WP_PLUGIN_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'));
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'))
README.txt CHANGED
@@ -110,6 +110,9 @@ Free support is included only with a PRO license: http://modula.greentreelabs.ne
110
 
111
  == Changelog ==
112
 
 
 
 
113
  = 1.1.6 =
114
  * Bug fix (impossible to select effect "None")
115
 
@@ -170,4 +173,9 @@ Free support is included only with a PRO license: http://modula.greentreelabs.ne
170
  * Fixed issue when activating the plugin
171
 
172
  = 1.0.0 =
173
- * This is the launch version. No changes yet.
 
 
 
 
 
110
 
111
  == Changelog ==
112
 
113
+ = 1.1.7 =
114
+ * Tool to fix broken images after version 1.1.0
115
+
116
  = 1.1.6 =
117
  * Bug fix (impossible to select effect "None")
118
 
173
  * Fixed issue when activating the plugin
174
 
175
  = 1.0.0 =
176
+ * This is the launch version. No changes yet.
177
+
178
+ == Upgrade Notice ==
179
+
180
+ = 1.1.7 =
181
+ * This update contains a tool to fix broken images.
admin/fix.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die(_e('You are not allowed to call this page directly.','modula-gallery')); }
3
+
4
+ $nobanner = true;
5
+ if(empty($tg_subtitle))
6
+ {
7
+ $tg_subtitle = "Fix images";
8
+ }
9
+
10
+ $imageUrl = null;
11
+ foreach($this->ModulaDB->getGalleries() as $gallery)
12
+ {
13
+ $gid = $gallery->Id;
14
+ $images = $this->ModulaDB->getImagesByGalleryId($gid);
15
+ if(count($images) > 0) {
16
+ $imageUrl = $images[0]->imagePath;
17
+ break;
18
+ }
19
+ }
20
+ $oldUrl = "&lt;OLD URL&gt;";
21
+ if(strpos($imageUrl, '/wp-content') > 0)
22
+ {
23
+ $oldUrl = strtolower(substr($imageUrl, 0, strpos($imageUrl, '/wp-content')));
24
+ }
25
+
26
+ ?>
27
+
28
+ <?php include("header.php"); ?>
29
+ <style>
30
+ #fix-panel h2 {
31
+ font-size: 18px;
32
+ font-weight:bold;
33
+ margin-bottom:4px;
34
+ padding-bottom: 0;
35
+ line-height:1;
36
+ }
37
+ #fix-panel pre {
38
+ background: #fff;
39
+ padding:10px;
40
+ }
41
+ </style>
42
+ <?php if(isset($_GET['fix']) && $_GET['fix'] == '1') : ?>
43
+
44
+ <?php
45
+
46
+ $lines = array();
47
+ foreach($this->ModulaDB->getGalleries() as $gallery)
48
+ {
49
+ $gid = $gallery->Id;
50
+ $images = $this->ModulaDB->getImagesByGalleryId($gid);
51
+ foreach($images as $image)
52
+ {
53
+ if(strpos(strtolower($image->imagePath), $oldUrl) === 0)
54
+ $lines []= $image->imagePath;
55
+ }
56
+ }
57
+
58
+ ?>
59
+ <div class="row">
60
+ <div class="col">
61
+ <div class="card-panel lime lighten-4" id="fix-panel">
62
+ <?php echo count($lines) ?> image to be processed:
63
+ <pre><?php echo implode("\n", $lines) ?></pre>
64
+
65
+ <?php
66
+ $dir = wp_upload_dir();
67
+ file_put_contents( $dir['basedir'] . "/old-images.txt", implode("\n", $lines));
68
+
69
+ $res = $wpdb->query('UPDATE ' . $wpdb->prefix . 'modula_images SET imagePath=REPLACE(imagePath, "'.$oldUrl.'", "'.site_url().'")');
70
+ add_option('Modula_skip_fix', true);
71
+ ?>
72
+
73
+ <?php if($res > 0) : ?>
74
+ <h2>Fix completed successfully!</h2>
75
+ <?php else : ?>
76
+ <h2>No images where updated</h2>
77
+ <?php endif ?>
78
+ <a class="btn" href="?page=ModulaLite-admin">Go to dashboard</a>
79
+ </div>
80
+ </div>
81
+ </div>
82
+ <?php else : ?>
83
+
84
+ <div class="row">
85
+ <div class="col">
86
+ <div class="card-panel lime lighten-4" id="fix-panel">
87
+ <strong>FIX</strong>: version 1.1.0 introduced a new way to resize images,
88
+ now you can choose a custom image size for your galleries, regardless the
89
+ sizes defined by your theme.<br>
90
+ Although we thoroughly tested the new feature, <strong>some website may encounter
91
+ an issue where images don't appear anymore</strong>.<br>
92
+ <h2>For tech savvy:</h2>
93
+ The cause is a wrong url inside the MySQL table <strong><?php echo $wpdb->prefix ?>modula_images</strong><br>
94
+ If you know how to do it, you can easily fix the wrong urls inside the field <strong>imagePath</strong>.
95
+ The query to use is:
96
+ <pre>UPDATE <?php echo $wpdb->prefix ?>modula_images REPLACE(imagePath, '<?php echo $oldUrl ?>', '<?php echo site_url() ?>');</pre>
97
+
98
+ <?php if($oldUrl == "&lt;OLD URL&gt;") : ?>
99
+ where &lt;old URL&gt; is the previous URL of this site.
100
+ <?php endif ?>
101
+ <h2>For everyone:</h2>
102
+ If you have updated the plugin and you have run into this issue then
103
+ you can use the <strong>Fix tool</strong> by clicking the following button:
104
+ <br>
105
+ <br>
106
+ <a href="?page=modula-lite-gallery-fix&fix=1" class="btn">Fix image paths</a>
107
+ <br>
108
+ <strong>If you're unsure about what to do then please contact <a href="mailto:diego@greentreelabs.net?subject=Help with Modula fix tool">diego@greentreelabs.net</a></strong>.
109
+ </div>
110
+ </div>
111
+ </div>
112
+ <?php endif ?>
admin/header.php CHANGED
@@ -2,8 +2,11 @@
2
  <h1 class="header center-on-small-only">Modula Lite</h1>
3
  <h4 class="light text-lighten-4 center-on-small-only"><?php print $tg_subtitle ?></h4>
4
  </header>
 
 
5
  <a id="modula-survey" class="typeform-share button" href="https://greentreelabs.typeform.com/to/Ieyk9T" data-mode="1" target="_blank">
6
  <img src="<?php print plugins_url('/images/survey.png',__file__) ?>" alt="Survey">
7
- <span>Give us a feedback and get your <strong>10% discount!</strong></span>
8
  </a>
9
- <script>(function(){var qs,js,q,s,d=document,gi=d.getElementById,ce=d.createElement,gt=d.getElementsByTagName,id='typef_orm',b='https://s3-eu-west-1.amazonaws.com/share.typeform.com/';if(!gi.call(d,id)){js=ce.call(d,'script');js.id=id;js.src=b+'share.js';q=gt.call(d,'script')[0];q.parentNode.insertBefore(js,q)}id=id+'_';if(!gi.call(d,id)){qs=ce.call(d,'link');qs.rel='stylesheet';qs.id=id;qs.href=b+'share-button.css';s=gt.call(d,'head')[0];s.appendChild(qs,s)}})()</script>
 
2
  <h1 class="header center-on-small-only">Modula Lite</h1>
3
  <h4 class="light text-lighten-4 center-on-small-only"><?php print $tg_subtitle ?></h4>
4
  </header>
5
+
6
+ <?php if(! isset($nobanner)) : ?>
7
  <a id="modula-survey" class="typeform-share button" href="https://greentreelabs.typeform.com/to/Ieyk9T" data-mode="1" target="_blank">
8
  <img src="<?php print plugins_url('/images/survey.png',__file__) ?>" alt="Survey">
9
+ <span>I'd love a feedback from you! Please complete a short survey and get a <strong>10% discount</strong> for a Modula full license!</span>
10
  </a>
11
+ <script>(function(){var qs,js,q,s,d=document,gi=d.getElementById,ce=d.createElement,gt=d.getElementsByTagName,id='typef_orm',b='https://s3-eu-west-1.amazonaws.com/share.typeform.com/';if(!gi.call(d,id)){js=ce.call(d,'script');js.id=id;js.src=b+'share.js';q=gt.call(d,'script')[0];q.parentNode.insertBefore(js,q)}id=id+'_';if(!gi.call(d,id)){qs=ce.call(d,'link');qs.rel='stylesheet';qs.id=id;qs.href=b+'share-button.css';s=gt.call(d,'head')[0];s.appendChild(qs,s)}})()</script>
12
+ <?php endif ?>
admin/images/survey.png CHANGED
Binary file
admin/overview.php CHANGED
@@ -14,6 +14,7 @@
14
  <?php include("header.php"); ?>
15
 
16
  <div class="bd">
 
17
  <?php if(count($galleries) == 0) : ?>
18
  <div class="row ">
19
  <div class="col s12 m6 l4">
14
  <?php include("header.php"); ?>
15
 
16
  <div class="bd">
17
+
18
  <?php if(count($galleries) == 0) : ?>
19
  <div class="row ">
20
  <div class="col s12 m6 l4">