Photo Gallery by Envira – Responsive Image Gallery for WordPress - Version 1.5.6

Version Description

  • Fix: PHP optimizations to improve performance
  • Fix: Automatic Layout option now selects default images based on the specified row height to improve gallery loading times
  • Fix: Minor bug fixes
Download this release

Release Info

Developer chrisakelley
Plugin Icon 128x128 Photo Gallery by Envira – Responsive Image Gallery for WordPress
Version 1.5.6
Comparing to
See all releases

Code changes from version 1.5.5 to 1.5.6

assets/css/admin.css CHANGED
@@ -101,11 +101,12 @@ body.post-type-envira_album {
101
  body.post-type-envira_album div.wrap > h1,
102
  body.post-type-envira_album div.wrap > h2 {
103
  margin: 0 0 20px 0;
104
- padding: 15px 20px 10px 20px;
105
  background: #ffffff;
106
  font-weight: 600;
107
  font-size: 20px;
108
  width: 100%;
 
109
  /**
110
  * Page Title Action (i.e. Add New)
111
  */
101
  body.post-type-envira_album div.wrap > h1,
102
  body.post-type-envira_album div.wrap > h2 {
103
  margin: 0 0 20px 0;
104
+ padding: 15px 0 10px;
105
  background: #ffffff;
106
  font-weight: 600;
107
  font-size: 20px;
108
  width: 100%;
109
+ text-indent: 20px;
110
  /**
111
  * Page Title Action (i.e. Add New)
112
  */
assets/scss/admin.scss CHANGED
@@ -81,11 +81,12 @@ body.post-type-envira_album {
81
  > h1,
82
  > h2 {
83
  margin: 0 0 20px 0;
84
- padding: 15px 20px 10px 20px;
85
  background: $white;
86
  font-weight: 600;
87
  font-size: 20px;
88
  width: 100%;
 
89
 
90
  /**
91
  * Page Title Action (i.e. Add New)
81
  > h1,
82
  > h2 {
83
  margin: 0 0 20px 0;
84
+ padding: 15px 0 10px;
85
  background: $white;
86
  font-weight: 600;
87
  font-size: 20px;
88
  width: 100%;
89
+ text-indent: 20px;
90
 
91
  /**
92
  * Page Title Action (i.e. Add New)
envira-gallery-lite.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Envira Gallery is best responsive WordPress gallery plugin. This is the lite version.
6
  * Author: Thomas Griffin
7
  * Author URI: http://enviragallery.com
8
- * Version: 1.5.5
9
  * Text Domain: envira-gallery
10
  *
11
  * Envira Gallery is free software: you can redistribute it and/or modify
@@ -53,7 +53,7 @@ class Envira_Gallery_Lite {
53
  *
54
  * @var string
55
  */
56
- public $version = '1.5.5';
57
 
58
  /**
59
  * The name of the plugin.
@@ -161,6 +161,7 @@ class Envira_Gallery_Lite {
161
  require plugin_dir_path( __FILE__ ) . 'includes/admin/notice.php';
162
  require plugin_dir_path( __FILE__ ) . 'includes/admin/posttype.php';
163
  require plugin_dir_path( __FILE__ ) . 'includes/admin/table.php';
 
164
 
165
  }
166
 
@@ -511,22 +512,27 @@ function envira_gallery_lite_activation_hook( $network_wide ) {
511
  // Load the main plugin class.
512
  $envira_gallery_lite = Envira_Gallery_Lite::get_instance();
513
 
514
- /**
515
- * Holder for mobile detect.
516
- *
517
- * @access public
518
- * @return void
519
- */
520
- function envira_mobile_detect(){
521
-
522
- //Check for mobile detect class before loading it again //prevents conflicts with themes
523
- if ( ! class_exists( 'Mobile_Detect' ) ) {
524
-
525
- require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/global/Mobile_Detect.php';
526
-
 
 
 
 
 
 
 
527
  }
528
-
529
- return new Mobile_Detect;
530
 
531
  }
532
 
5
  * Description: Envira Gallery is best responsive WordPress gallery plugin. This is the lite version.
6
  * Author: Thomas Griffin
7
  * Author URI: http://enviragallery.com
8
+ * Version: 1.5.6
9
  * Text Domain: envira-gallery
10
  *
11
  * Envira Gallery is free software: you can redistribute it and/or modify
53
  *
54
  * @var string
55
  */
56
+ public $version = '1.5.6';
57
 
58
  /**
59
  * The name of the plugin.
161
  require plugin_dir_path( __FILE__ ) . 'includes/admin/notice.php';
162
  require plugin_dir_path( __FILE__ ) . 'includes/admin/posttype.php';
163
  require plugin_dir_path( __FILE__ ) . 'includes/admin/table.php';
164
+ require plugin_dir_path( __FILE__ ) . 'includes/admin/review.php';
165
 
166
  }
167
 
512
  // Load the main plugin class.
513
  $envira_gallery_lite = Envira_Gallery_Lite::get_instance();
514
 
515
+
516
+ if ( ! function_exists( 'envira_mobile_detect' ) ) {
517
+
518
+ /**
519
+ * Holder for mobile detect.
520
+ *
521
+ * @access public
522
+ * @return void
523
+ */
524
+ function envira_mobile_detect(){
525
+
526
+ //Check for mobile detect class before loading it again //prevents conflicts with themes
527
+ if ( ! class_exists( 'Mobile_Detect' ) ) {
528
+
529
+ require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/global/Mobile_Detect.php';
530
+
531
+ }
532
+
533
+ return new Mobile_Detect;
534
+
535
  }
 
 
536
 
537
  }
538
 
includes/admin/addons.php CHANGED
@@ -44,7 +44,7 @@ class Envira_Gallery_Addons {
44
  * @var string
45
  */
46
  public $hook;
47
-
48
  /**
49
  * Primary class constructor.
50
  *
@@ -363,10 +363,12 @@ class Envira_Gallery_Addons {
363
  * @return array Array of addon data otherwise.
364
  */
365
  public function get_addons_data( $key ) {
366
-
 
 
367
  // Get Addons
368
  // If the key is valid, we'll get personalised upgrade URLs for each Addon (if necessary) and plugin update information.
369
- $addons = Envira_Gallery_License::get_instance()->perform_remote_request( 'get-addons-data-v15', array( 'tgm-updater-key' => $key ) );
370
 
371
  // If there was an API error, set transient for only 10 minutes.
372
  if ( ! $addons ) {
@@ -565,6 +567,60 @@ class Envira_Gallery_Addons {
565
  </div>
566
  <?php
567
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
568
  }
569
 
570
  /**
44
  * @var string
45
  */
46
  public $hook;
47
+ public $key;
48
  /**
49
  * Primary class constructor.
50
  *
363
  * @return array Array of addon data otherwise.
364
  */
365
  public function get_addons_data( $key ) {
366
+
367
+ $this->key = $key;
368
+
369
  // Get Addons
370
  // If the key is valid, we'll get personalised upgrade URLs for each Addon (if necessary) and plugin update information.
371
+ $addons = $this->perform_remote_request( 'get-addons-data-v15', array( 'tgm-updater-key' => $key ) );
372
 
373
  // If there was an API error, set transient for only 10 minutes.
374
  if ( ! $addons ) {
567
  </div>
568
  <?php
569
 
570
+ }
571
+ /**
572
+ * Queries the remote URL via wp_remote_post and returns a json decoded response.
573
+ *
574
+ * @since 1.0.0
575
+ *
576
+ * @param string $action The name of the $_POST action var.
577
+ * @param array $body The content to retrieve from the remote URL.
578
+ * @param array $headers The headers to send to the remote URL.
579
+ * @param string $return_format The format for returning content from the remote URL.
580
+ * @return string|bool Json decoded response on success, false on failure.
581
+ */
582
+ public function perform_remote_request( $action, $body = array(), $headers = array(), $return_format = 'json' ) {
583
+
584
+ // Build the body of the request.
585
+ $body = wp_parse_args(
586
+ $body,
587
+ array(
588
+ 'tgm-updater-action' => $action,
589
+ 'tgm-updater-key' => $this->key,
590
+ 'tgm-updater-wp-version' => get_bloginfo( 'version' ),
591
+ 'tgm-updater-referer' => site_url()
592
+ )
593
+ );
594
+ $body = http_build_query( $body, '', '&' );
595
+
596
+ // Build the headers of the request.
597
+ $headers = wp_parse_args(
598
+ $headers,
599
+ array(
600
+ 'Content-Type' => 'application/x-www-form-urlencoded',
601
+ 'Content-Length' => strlen( $body )
602
+ )
603
+ );
604
+
605
+ // Setup variable for wp_remote_post.
606
+ $post = array(
607
+ 'headers' => $headers,
608
+ 'body' => $body
609
+ );
610
+
611
+ // Perform the query and retrieve the response.
612
+ $response = wp_remote_post( 'http://enviragallery.com', $post );
613
+ $response_code = wp_remote_retrieve_response_code( $response );
614
+ $response_body = wp_remote_retrieve_body( $response );
615
+
616
+ // Bail out early if there are any errors.
617
+ if ( 200 != $response_code || is_wp_error( $response_body ) ) {
618
+ return false;
619
+ }
620
+
621
+ // Return the json decoded content.
622
+ return json_decode( $response_body );
623
+
624
  }
625
 
626
  /**
includes/admin/common.php CHANGED
@@ -35,7 +35,7 @@ class Envira_Gallery_Common_Admin {
35
  * @var object
36
  */
37
  public $base;
38
-
39
  /**
40
  * Holds the metabox class object.
41
  *
@@ -57,11 +57,11 @@ class Envira_Gallery_Common_Admin {
57
 
58
  // Handle any necessary DB upgrades.
59
  add_action( 'admin_init', array( $this, 'db_upgrade' ) );
60
-
61
  // Load admin assets.
62
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
63
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
64
-
65
  // Delete any gallery association on attachment deletion. Also delete any extra cropped images.
66
  add_action( 'delete_attachment', array( $this, 'delete_gallery_association' ) );
67
  add_action( 'delete_attachment', array( $this, 'delete_cropped_image' ) );
@@ -104,7 +104,7 @@ class Envira_Gallery_Common_Admin {
104
  if ( ! $cptGalleries ) {
105
  // Get Post Types, excluding our own
106
  // We don't use post_status => 'any', as this doesn't include CPTs where exclude_from_search = true.
107
- $postTypes = get_post_types( array(
108
  'public' => true,
109
  ) );
110
  $excludedPostTypes = array( 'envira', 'envira_album', 'attachment' );
@@ -113,7 +113,7 @@ class Envira_Gallery_Common_Admin {
113
  unset( $postTypes[ $key ] );
114
  }
115
  }
116
-
117
  // Get all Posts that have _eg_gallery_data set
118
  $inPostGalleries = new WP_Query( array(
119
  'post_type' => $postTypes,
@@ -126,7 +126,7 @@ class Envira_Gallery_Common_Admin {
126
  ),
127
  )
128
  ) );
129
-
130
  // Check if any Posts with galleries exist
131
  if ( count( $inPostGalleries->posts ) > 0 ) {
132
  $migrated_galleries = 0;
@@ -138,7 +138,7 @@ class Envira_Gallery_Common_Admin {
138
  if ( $post->post_type == 'envira' || $post->post_type == 'envira_album' ) {
139
  continue;
140
  }
141
-
142
  // Get metadata
143
  $data = get_post_meta( $post->ID, '_eg_gallery_data', true);
144
  $in = get_post_meta( $post->ID, '_eg_in_gallery', true);
@@ -239,7 +239,7 @@ class Envira_Gallery_Common_Admin {
239
  <?php
240
 
241
  }
242
-
243
  /**
244
  * Loads styles for all Envira-based Administration Screens.
245
  *
@@ -251,7 +251,7 @@ class Envira_Gallery_Common_Admin {
251
 
252
  // Get current screen.
253
  $screen = get_current_screen();
254
-
255
  // Bail if we're not on the Envira Post Type screen.
256
  if ( 'envira' !== $screen->post_type && 'envira_album' !== $screen->post_type ) {
257
  return;
@@ -277,7 +277,7 @@ class Envira_Gallery_Common_Admin {
277
 
278
  // Get current screen.
279
  $screen = get_current_screen();
280
-
281
  // Bail if we're not on the Envira Post Type screen.
282
  if ( 'envira' !== $screen->post_type && 'envira_album' !== $screen->post_type ) {
283
  return;
@@ -299,7 +299,7 @@ class Envira_Gallery_Common_Admin {
299
  do_action( 'envira_gallery_admin_scripts' );
300
 
301
  }
302
-
303
  /**
304
  * Deletes the Envira gallery association for the image being deleted.
305
  *
@@ -467,11 +467,11 @@ class Envira_Gallery_Common_Admin {
467
  public function delete_gallery( $id ) {
468
 
469
  // Check if the media_delete setting is enabled
470
- $media_delete = Envira_Gallery_Settings::get_instance()->get_setting( 'media_delete' );
471
  if ( $media_delete != '1' ) {
472
  return;
473
- }
474
-
475
  // Get post
476
  $gallery = get_post( $id );
477
 
@@ -527,7 +527,7 @@ class Envira_Gallery_Common_Admin {
527
 
528
  // Whether we have an ID or not, filter the ID.
529
  $shareasale_id = apply_filters( 'envira_gallery_shareasale_id', $shareasale_id );
530
-
531
  // If at this point we still don't have an ID, we really don't have one!
532
  // Just return the standard upgrade URL.
533
  if ( empty( $shareasale_id ) ) {
35
  * @var object
36
  */
37
  public $base;
38
+
39
  /**
40
  * Holds the metabox class object.
41
  *
57
 
58
  // Handle any necessary DB upgrades.
59
  add_action( 'admin_init', array( $this, 'db_upgrade' ) );
60
+
61
  // Load admin assets.
62
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
63
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
64
+
65
  // Delete any gallery association on attachment deletion. Also delete any extra cropped images.
66
  add_action( 'delete_attachment', array( $this, 'delete_gallery_association' ) );
67
  add_action( 'delete_attachment', array( $this, 'delete_cropped_image' ) );
104
  if ( ! $cptGalleries ) {
105
  // Get Post Types, excluding our own
106
  // We don't use post_status => 'any', as this doesn't include CPTs where exclude_from_search = true.
107
+ $postTypes = get_post_types( array(
108
  'public' => true,
109
  ) );
110
  $excludedPostTypes = array( 'envira', 'envira_album', 'attachment' );
113
  unset( $postTypes[ $key ] );
114
  }
115
  }
116
+
117
  // Get all Posts that have _eg_gallery_data set
118
  $inPostGalleries = new WP_Query( array(
119
  'post_type' => $postTypes,
126
  ),
127
  )
128
  ) );
129
+
130
  // Check if any Posts with galleries exist
131
  if ( count( $inPostGalleries->posts ) > 0 ) {
132
  $migrated_galleries = 0;
138
  if ( $post->post_type == 'envira' || $post->post_type == 'envira_album' ) {
139
  continue;
140
  }
141
+
142
  // Get metadata
143
  $data = get_post_meta( $post->ID, '_eg_gallery_data', true);
144
  $in = get_post_meta( $post->ID, '_eg_in_gallery', true);
239
  <?php
240
 
241
  }
242
+
243
  /**
244
  * Loads styles for all Envira-based Administration Screens.
245
  *
251
 
252
  // Get current screen.
253
  $screen = get_current_screen();
254
+
255
  // Bail if we're not on the Envira Post Type screen.
256
  if ( 'envira' !== $screen->post_type && 'envira_album' !== $screen->post_type ) {
257
  return;
277
 
278
  // Get current screen.
279
  $screen = get_current_screen();
280
+
281
  // Bail if we're not on the Envira Post Type screen.
282
  if ( 'envira' !== $screen->post_type && 'envira_album' !== $screen->post_type ) {
283
  return;
299
  do_action( 'envira_gallery_admin_scripts' );
300
 
301
  }
302
+
303
  /**
304
  * Deletes the Envira gallery association for the image being deleted.
305
  *
467
  public function delete_gallery( $id ) {
468
 
469
  // Check if the media_delete setting is enabled
470
+ $media_delete = false;
471
  if ( $media_delete != '1' ) {
472
  return;
473
+ }
474
+
475
  // Get post
476
  $gallery = get_post( $id );
477
 
527
 
528
  // Whether we have an ID or not, filter the ID.
529
  $shareasale_id = apply_filters( 'envira_gallery_shareasale_id', $shareasale_id );
530
+
531
  // If at this point we still don't have an ID, we really don't have one!
532
  // Just return the standard upgrade URL.
533
  if ( empty( $shareasale_id ) ) {
includes/admin/review.php ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Review class.
4
+ *
5
+ * @since 1.1.4.5
6
+ *
7
+ * @package envira
8
+ * @author Devin Vinson
9
+ */
10
+ class Envira_Lite_Review {
11
+
12
+ /**
13
+ * Holds the class object.
14
+ *
15
+ * @since 1.1.4.5
16
+ *
17
+ * @var object
18
+ */
19
+ public static $instance;
20
+
21
+ /**
22
+ * Path to the file.
23
+ *
24
+ * @since 1.1.4.5
25
+ *
26
+ * @var string
27
+ */
28
+ public $file = __FILE__;
29
+
30
+ /**
31
+ * Holds the review slug.
32
+ *
33
+ * @since 1.1.4.5
34
+ *
35
+ * @var string
36
+ */
37
+ public $hook;
38
+
39
+ /**
40
+ * Holds the base class object.
41
+ *
42
+ * @since 1.1.4.5
43
+ *
44
+ * @var object
45
+ */
46
+ public $base;
47
+
48
+ /**
49
+ * API Username.
50
+ *
51
+ * @since 1.1.4.5
52
+ *
53
+ * @var bool|string
54
+ */
55
+ public $user = false;
56
+
57
+
58
+ /**
59
+ * Primary class constructor.
60
+ *
61
+ * @since 1.1.4.5
62
+ */
63
+ public function __construct() {
64
+
65
+ $this->base = Envira_Gallery_Lite::get_instance();
66
+
67
+ add_action( 'admin_notices', array( $this, 'review' ) );
68
+ add_action( 'wp_ajax_envira_dismiss_review', array( $this, 'dismiss_review' ) );
69
+ add_filter( 'admin_footer_text', array( $this, 'admin_footer' ), 1, 2 );
70
+
71
+ }
72
+
73
+ /**
74
+ * When user is on a Envira related admin page, display footer text
75
+ * that graciously asks them to rate us.
76
+ *
77
+ * @since
78
+ * @param string $text
79
+ * @return string
80
+ */
81
+ public function admin_footer( $text ) {
82
+ global $current_screen;
83
+ if ( !empty( $current_screen->id ) && strpos( $current_screen->id, 'envira' ) !== false ) {
84
+ $url = 'https://wordpress.org/support/plugin/envira-gallery-lite/reviews/?filter=5#new-post';
85
+ $text = sprintf( __( 'Please rate <strong>Envira Gallery</strong> <a href="%s" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a> on <a href="%s" target="_blank">WordPress.org</a> to help us spread the word. Thank you from the Envira Gallery team!', 'wpforms' ), $url, $url );
86
+ }
87
+ return $text;
88
+ }
89
+
90
+ /**
91
+ * Add admin notices as needed for reviews.
92
+ *
93
+ * @since 1.1.6.1
94
+ */
95
+ public function review() {
96
+
97
+ // Verify that we can do a check for reviews.
98
+ $review = get_option( 'envira_gallery_review' );
99
+ $time = time();
100
+ $load = false;
101
+
102
+ if ( ! $review ) {
103
+ $review = array(
104
+ 'time' => $time,
105
+ 'dismissed' => false
106
+ );
107
+ $load = true;
108
+ } else {
109
+ // Check if it has been dismissed or not.
110
+ if ( (isset( $review['dismissed'] ) && ! $review['dismissed']) && (isset( $review['time'] ) && (($review['time'] + DAY_IN_SECONDS) <= $time)) ) {
111
+ $load = true;
112
+ }
113
+ }
114
+
115
+ // If we cannot load, return early.
116
+ if ( ! $load ) {
117
+ return;
118
+ }
119
+
120
+ // Update the review option now.
121
+ update_option( 'envira_gallery_review', $review );
122
+
123
+ // Run through optins on the site to see if any have been loaded for more than a week.
124
+ $valid = false;
125
+ $galleries = $this->base->get_galleries();
126
+
127
+ if ( ! $galleries ) {
128
+ return;
129
+ }
130
+
131
+ foreach ( $galleries as $gallery ) {
132
+
133
+ $data = get_post( $gallery['id']);
134
+
135
+ // Check the creation date of the local optin. It must be at least one week after.
136
+ $created = isset( $data->post_date ) ? strtotime( $data->post_date ) + (7 * DAY_IN_SECONDS) : false;
137
+ if ( ! $created ) {
138
+ continue;
139
+ }
140
+
141
+ if ( $created <= $time ) {
142
+ $valid = true;
143
+ break;
144
+ }
145
+ }
146
+
147
+ // If we don't have a valid optin yet, return.
148
+ if ( ! $valid ) {
149
+ return;
150
+ }
151
+
152
+ // We have a candidate! Output a review message.
153
+ ?>
154
+ <div class="notice notice-info is-dismissible envira-review-notice">
155
+ <p><?php _e( 'Hey, I noticed you created a photo gallery with Envira - that’s awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation.', 'envira-gallery-lite' ); ?></p>
156
+ <p><strong><?php _e( '~ Syed Balkhi<br>Co-Founder of OptinMonster', 'envira-gallery-lite' ); ?></strong></p>
157
+ <p>
158
+ <a href="https://wordpress.org/support/plugin/envira-gallery-lite/reviews/?filter=5#new-post" class="envira-dismiss-review-notice envira-review-out" target="_blank" rel="noopener"><?php _e( 'Ok, you deserve it', 'envira-gallery-lite' ); ?></a><br>
159
+ <a href="#" class="envira-dismiss-review-notice" target="_blank" rel="noopener"><?php _e( 'Nope, maybe later', 'envira-gallery-lite' ); ?></a><br>
160
+ <a href="#" class="envira-dismiss-review-notice" target="_blank" rel="noopener"><?php _e( 'I already did', 'envira-gallery-lite' ); ?></a><br>
161
+ </p>
162
+ </div>
163
+ <script type="text/javascript">
164
+ jQuery(document).ready( function($) {
165
+ $(document).on('click', '.envira-dismiss-review-notice, .envira-review-notice button', function( event ) {
166
+ if ( ! $(this).hasClass('envira-review-out') ) {
167
+ event.preventDefault();
168
+ }
169
+
170
+ $.post( ajaxurl, {
171
+ action: 'envira_dismiss_review'
172
+ });
173
+
174
+ $('.envira-review-notice').remove();
175
+ });
176
+ });
177
+ </script>
178
+ <?php
179
+ }
180
+
181
+ /**
182
+ * Dismiss the review nag
183
+ *
184
+ * @since 1.1.6.1
185
+ */
186
+ public function dismiss_review() {
187
+
188
+ $review = get_option( 'envira_gallery_review' );
189
+ if ( ! $review ) {
190
+ $review = array();
191
+ }
192
+
193
+ $review['time'] = time();
194
+ $review['dismissed'] = true;
195
+
196
+ update_option( 'envira_gallery_review', $review );
197
+ die;
198
+ }
199
+
200
+
201
+ public static function get_instance() {
202
+
203
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Envira_Lite_Review ) ) {
204
+ self::$instance = new Envira_Lite_Review();
205
+ }
206
+
207
+ return self::$instance;
208
+
209
+ }
210
+ }
211
+
212
+ $envira_lite_review = Envira_Lite_Review::get_instance();
includes/global/shortcode.php CHANGED
@@ -72,6 +72,10 @@ class Envira_Gallery_Shortcode {
72
  */
73
  public $index = array();
74
 
 
 
 
 
75
  /**
76
  * Primary class constructor.
77
  *
@@ -81,6 +85,8 @@ class Envira_Gallery_Shortcode {
81
 
82
  // Load the base class object.
83
  $this->base = Envira_Gallery_Lite::get_instance();
 
 
84
 
85
  // Register main gallery style.
86
  wp_register_style( $this->base->plugin_slug . '-style', plugins_url( 'assets/css/envira.css', $this->base->file ), array(), $this->base->version );
@@ -150,11 +156,13 @@ class Envira_Gallery_Shortcode {
150
  return;
151
  }
152
 
 
 
153
  // Get rid of any external plugins trying to jack up our stuff where a gallery is present.
154
  $this->plugin_humility();
155
 
156
  // Prepare variables.
157
- $this->data[ $data['id'] ] = $data;
158
  $this->index[ $data['id'] ] = array();
159
  $gallery = '';
160
  $i = 1;
@@ -171,37 +179,37 @@ class Envira_Gallery_Shortcode {
171
  wp_enqueue_script( $this->base->plugin_slug . '-script' );
172
 
173
  // Load custom gallery themes if necessary.
174
- if ( 'base' !== $this->get_config( 'gallery_theme', $data ) && $this->get_config( 'columns', $data ) > 0 ) {
175
  // if columns is zero, then it's automattic which means we do not load gallery themes because it will mess up the new javascript layout
176
- $this->load_gallery_theme( $this->get_config( 'gallery_theme', $data ) );
177
  }
178
 
179
  // Load custom lightbox themes if necessary.
180
- if ( 'base' !== $this->get_config( 'lightbox_theme', $data ) ) {
181
- $this->load_lightbox_theme( $this->get_config( 'lightbox_theme', $data ) );
182
  }
183
 
184
  // Load gallery init code in the footer.
185
  add_action( 'wp_footer', array( $this, 'gallery_init' ), 1000 );
186
 
187
  // Run a hook before the gallery output begins but after scripts and inits have been set.
188
- do_action( 'envira_gallery_before_output', $data );
189
 
190
  // Apply a filter before starting the gallery HTML.
191
- $gallery = apply_filters( 'envira_gallery_output_start', $gallery, $data );
192
 
193
  // Build out the gallery HTML.
194
- $gallery .= '<div id="envira-gallery-wrap-' . sanitize_html_class( $data['id'] ) . '" class="' . $this->get_gallery_classes( $data ) . '" itemscope itemtype="http://schema.org/ImageGallery">';
195
- $gallery = apply_filters( 'envira_gallery_output_before_container', $gallery, $data );
196
 
197
  // Description
198
- if ( isset( $data['config']['description_position'] ) && $data['config']['description_position'] == 'above' ) {
199
- $gallery = $this->description( $gallery, $data );
200
  }
201
 
202
 
203
  $opacity_insert = false;
204
- if ( $this->get_config( 'columns', $data ) == 0 ) {
205
  $opacity_insert = ' style="opacity: 0.0" ';
206
  }
207
 
@@ -209,20 +217,20 @@ class Envira_Gallery_Shortcode {
209
  $extra_css = 'envira-gallery-justified-public';
210
  $row_height = false;
211
  $justified_gallery_theme = false;
212
- if ( $this->get_config( 'columns', $data ) > 0 ) {
213
  $extra_css = false;
214
  } else {
215
- $row_height = $this->get_config( 'justified_row_height', $data );
216
- $justified_gallery_theme = $this->get_config( 'justified_gallery_theme', $data );
217
  }
218
 
219
- $gallery .= '<div' . $opacity_insert . ' data-row-height="'.$row_height.'" data-gallery-theme="'.$justified_gallery_theme.'" id="envira-gallery-' . sanitize_html_class( $data['id'] ) . '" class="envira-gallery-public '.$extra_css.' envira-gallery-' . sanitize_html_class( $this->get_config( 'columns', $data ) ) . '-columns envira-clear' . ( $this->get_config( 'isotope', $data ) ? ' enviratope' : '' ) . ( $this->get_config( 'css_animations', $data ) ? ' envira-gallery-css-animations' : '' ) . '" data-envira-columns="' . $this->get_config( 'columns', $data ) . '">';
220
 
221
  // Start image loop
222
  foreach ( $data['gallery'] as $id => $item ) {
223
 
224
  // Add the gallery item to the markup
225
- $gallery = $this->generate_gallery_item_markup( $gallery, $data, $item, $id, $i );
226
 
227
  // Increment the iterator.
228
  $i++;
@@ -232,31 +240,31 @@ class Envira_Gallery_Shortcode {
232
 
233
  $gallery .= '</div>';
234
  // Description
235
- if ( isset( $data['config']['description_position'] ) && $data['config']['description_position'] == 'below' ) {
236
- $gallery = $this->description( $gallery, $data );
237
  }
238
 
239
- $gallery = apply_filters( 'envira_gallery_output_after_container', $gallery, $data );
240
 
241
  $gallery .= '</div>';
242
- $gallery = apply_filters( 'envira_gallery_output_end', $gallery, $data );
243
 
244
  // Increment the counter.
245
  $this->counter++;
246
 
247
  // Remove any contextual filters so they don't affect other galleries on the page.
248
- if ( $this->get_config( 'mobile', $data ) ) {
249
  remove_filter( 'envira_gallery_output_image_attr', array( $this, 'mobile_image' ), 999, 4 );
250
  }
251
 
252
  // Add no JS fallback support.
253
  $no_js = '<noscript>';
254
- $no_js .= $this->get_indexable_images( $data['id'] );
255
  $no_js .= '</noscript>';
256
  $gallery .= $no_js;
257
 
258
  // Return the gallery HTML.
259
- return apply_filters( 'envira_gallery_output', $gallery, $data );
260
 
261
  }
262
 
@@ -859,7 +867,7 @@ class Envira_Gallery_Shortcode {
859
  $lightbox_transition_effect = $this->get_config( 'effect', $data );
860
 
861
  /* Get standard effects */
862
- $lightbox_standard_effects = Envira_Gallery_Common::get_instance()->get_transition_effects_values();
863
 
864
  /* If open/close is standard, use openEffect, closeEffect */
865
  if ( in_array( $lightbox_open_close_effect, $lightbox_standard_effects ) ) {
@@ -1205,7 +1213,7 @@ class Envira_Gallery_Shortcode {
1205
  public function load_gallery_theme( $theme ) {
1206
 
1207
  // Loop through the available themes and enqueue the one called.
1208
- foreach ( Envira_Gallery_Common::get_instance()->get_gallery_themes() as $array => $data ) {
1209
  if ( $theme !== $data['value'] ) {
1210
  continue;
1211
  }
@@ -1231,7 +1239,7 @@ class Envira_Gallery_Shortcode {
1231
  public function load_lightbox_theme( $theme ) {
1232
 
1233
  // Loop through the available themes and enqueue the one called.
1234
- foreach ( Envira_Gallery_Common::get_instance()->get_lightbox_themes() as $array => $data ) {
1235
  if ( $theme !== $data['value'] ) {
1236
  continue;
1237
  }
@@ -1347,32 +1355,6 @@ class Envira_Gallery_Shortcode {
1347
  // Inject new image size into $item
1348
  $item['link'] = $image[0];
1349
 
1350
- /*
1351
- // Generate a retina version of the image
1352
- $common = Envira_Gallery_Common::get_instance();
1353
- $wordpress_image_sizes = $common->get_image_sizes();
1354
- foreach ( $wordpress_image_sizes as $size ) {
1355
- if ( $size['value'] !== $image_size ) {
1356
- continue;
1357
- }
1358
-
1359
- // We found the image size. Use its dimensions
1360
- $args = array(
1361
- 'position' => 'c',
1362
- 'width' => $size['width'],
1363
- 'height' => $size['height'],
1364
- 'quality' => 100,
1365
- 'retina' => true,
1366
- );
1367
-
1368
- // Get full image
1369
- $full_image = wp_get_attachment_image_src( $id, 'full' );
1370
- $item['lightbox_retina_image'] = $common->resize_image( $full_image[0], $args['width'], $args['height'], false, $args['position'], $args['quality'], $args['retina'] );
1371
- break;
1372
-
1373
- }
1374
- */
1375
-
1376
  // Return
1377
  return $item;
1378
 
@@ -1428,7 +1410,7 @@ class Envira_Gallery_Shortcode {
1428
 
1429
  if ( count( $image_sizes_random ) == 0 ) {
1430
  // The user didn't choose any image sizes - use them all.
1431
- $wordpress_image_sizes = Envira_Gallery_Common::get_instance()->get_image_sizes( true );
1432
  $wordpress_image_size_random_key = array_rand( $wordpress_image_sizes, 1 );
1433
  $image_size = $wordpress_image_sizes[ $wordpress_image_size_random_key ]['value'];
1434
  } else {
@@ -1443,8 +1425,23 @@ class Envira_Gallery_Shortcode {
1443
  $src = wp_get_attachment_image_src( $id, $image_size );
1444
  }
1445
  } else {
1446
- // Get the full image
1447
- $src = wp_get_attachment_image_src( $id, 'full' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1448
 
1449
  }
1450
 
@@ -1483,7 +1480,6 @@ class Envira_Gallery_Shortcode {
1483
  // This is safe to call every time, as resize_image() will check if the image already exists, preventing thumbnails
1484
  // from being generated every single time.
1485
  $type = $mobile ? 'mobile' : 'crop'; // 'crop' is misleading here - it's the key that stores the thumbnail width + height
1486
- $common = Envira_Gallery_Common::get_instance();
1487
  $args = array(
1488
  'position' => 'c',
1489
  'width' => $this->get_config( $type . '_width', $data ),
@@ -1497,7 +1493,7 @@ class Envira_Gallery_Shortcode {
1497
  // image width and height, which are hidden settings.
1498
  if ( $image_size != 'default' && $retina ) {
1499
  // Find WordPress registered image size
1500
- $wordpress_image_sizes = $common->get_image_sizes( true ); // true = WordPress only image sizes (excludes random)
1501
 
1502
  foreach ( $wordpress_image_sizes as $size ) {
1503
  if ( $size['value'] !== $image_size ) {
@@ -1515,7 +1511,7 @@ class Envira_Gallery_Shortcode {
1515
  // Filter
1516
  $args = apply_filters( 'envira_gallery_crop_image_args', $args);
1517
 
1518
- $resized_image = $common->resize_image( $image, $args['width'], $args['height'], $this->get_config( 'crop', $data ), $args['position'], $args['quality'], $args['retina'], $data );
1519
 
1520
  // If there is an error, possibly output error message and return the default image src.
1521
  if ( is_wp_error( $resized_image ) ) {
@@ -1632,9 +1628,7 @@ class Envira_Gallery_Shortcode {
1632
  */
1633
  public function get_config( $key, $data ) {
1634
 
1635
- $instance = Envira_Gallery_Common::get_instance();
1636
-
1637
- return isset( $data['config'][$key] ) ? $data['config'][$key] : $instance->get_config_default( $key );
1638
 
1639
  }
1640
 
72
  */
73
  public $index = array();
74
 
75
+ public $gallery_data = array();
76
+ public $common;
77
+ public $is_mobile;
78
+
79
  /**
80
  * Primary class constructor.
81
  *
85
 
86
  // Load the base class object.
87
  $this->base = Envira_Gallery_Lite::get_instance();
88
+ $this->common = Envira_Gallery_Common::get_instance();
89
+ $this->is_mobile = envira_mobile_detect()->isMobile();
90
 
91
  // Register main gallery style.
92
  wp_register_style( $this->base->plugin_slug . '-style', plugins_url( 'assets/css/envira.css', $this->base->file ), array(), $this->base->version );
156
  return;
157
  }
158
 
159
+ $this->gallery_data = $data;
160
+
161
  // Get rid of any external plugins trying to jack up our stuff where a gallery is present.
162
  $this->plugin_humility();
163
 
164
  // Prepare variables.
165
+ $this->data[ $data['id'] ] = $this->gallery_data;
166
  $this->index[ $data['id'] ] = array();
167
  $gallery = '';
168
  $i = 1;
179
  wp_enqueue_script( $this->base->plugin_slug . '-script' );
180
 
181
  // Load custom gallery themes if necessary.
182
+ if ( 'base' !== $this->get_config( 'gallery_theme', $this->gallery_data ) && $this->get_config( 'columns', $this->gallery_data ) > 0 ) {
183
  // if columns is zero, then it's automattic which means we do not load gallery themes because it will mess up the new javascript layout
184
+ $this->load_gallery_theme( $this->get_config( 'gallery_theme', $this->gallery_data ) );
185
  }
186
 
187
  // Load custom lightbox themes if necessary.
188
+ if ( 'base' !== $this->get_config( 'lightbox_theme', $this->gallery_data ) ) {
189
+ $this->load_lightbox_theme( $this->get_config( 'lightbox_theme', $this->gallery_data ) );
190
  }
191
 
192
  // Load gallery init code in the footer.
193
  add_action( 'wp_footer', array( $this, 'gallery_init' ), 1000 );
194
 
195
  // Run a hook before the gallery output begins but after scripts and inits have been set.
196
+ do_action( 'envira_gallery_before_output', $this->gallery_data );
197
 
198
  // Apply a filter before starting the gallery HTML.
199
+ $gallery = apply_filters( 'envira_gallery_output_start', $gallery, $this->gallery_data );
200
 
201
  // Build out the gallery HTML.
202
+ $gallery .= '<div id="envira-gallery-wrap-' . sanitize_html_class( $this->gallery_data['id'] ) . '" class="' . $this->get_gallery_classes( $this->gallery_data ) . '" itemscope itemtype="http://schema.org/ImageGallery">';
203
+ $gallery = apply_filters( 'envira_gallery_output_before_container', $gallery, $this->gallery_data );
204
 
205
  // Description
206
+ if ( isset( $this->gallery_data['config']['description_position'] ) && $this->gallery_data['config']['description_position'] == 'above' ) {
207
+ $gallery = $this->description( $gallery, $this->gallery_data );
208
  }
209
 
210
 
211
  $opacity_insert = false;
212
+ if ( $this->get_config( 'columns', $this->gallery_data ) == 0 ) {
213
  $opacity_insert = ' style="opacity: 0.0" ';
214
  }
215
 
217
  $extra_css = 'envira-gallery-justified-public';
218
  $row_height = false;
219
  $justified_gallery_theme = false;
220
+ if ( $this->get_config( 'columns', $this->gallery_data ) > 0 ) {
221
  $extra_css = false;
222
  } else {
223
+ $row_height = $this->get_config( 'justified_row_height', $this->gallery_data );
224
+ $justified_gallery_theme = $this->get_config( 'justified_gallery_theme', $this->gallery_data );
225
  }
226
 
227
+ $gallery .= '<div' . $opacity_insert . ' data-row-height="'.$row_height.'" data-gallery-theme="'.$justified_gallery_theme.'" id="envira-gallery-' . sanitize_html_class( $this->gallery_data['id'] ) . '" class="envira-gallery-public '.$extra_css.' envira-gallery-' . sanitize_html_class( $this->get_config( 'columns', $this->gallery_data ) ) . '-columns envira-clear' . ( $this->get_config( 'isotope', $this->gallery_data ) ? ' enviratope' : '' ) . ( $this->get_config( 'css_animations', $this->gallery_data ) ? ' envira-gallery-css-animations' : '' ) . '" data-envira-columns="' . $this->get_config( 'columns', $this->gallery_data ) . '">';
228
 
229
  // Start image loop
230
  foreach ( $data['gallery'] as $id => $item ) {
231
 
232
  // Add the gallery item to the markup
233
+ $gallery = $this->generate_gallery_item_markup( $gallery, $this->gallery_data, $item, $id, $i );
234
 
235
  // Increment the iterator.
236
  $i++;
240
 
241
  $gallery .= '</div>';
242
  // Description
243
+ if ( isset( $this->gallery_data['config']['description_position'] ) && $this->gallery_data['config']['description_position'] == 'below' ) {
244
+ $gallery = $this->description( $gallery, $this->gallery_data );
245
  }
246
 
247
+ $gallery = apply_filters( 'envira_gallery_output_after_container', $gallery, $this->gallery_data );
248
 
249
  $gallery .= '</div>';
250
+ $gallery = apply_filters( 'envira_gallery_output_end', $gallery, $this->gallery_data );
251
 
252
  // Increment the counter.
253
  $this->counter++;
254
 
255
  // Remove any contextual filters so they don't affect other galleries on the page.
256
+ if ( $this->get_config( 'mobile', $this->gallery_data ) ) {
257
  remove_filter( 'envira_gallery_output_image_attr', array( $this, 'mobile_image' ), 999, 4 );
258
  }
259
 
260
  // Add no JS fallback support.
261
  $no_js = '<noscript>';
262
+ $no_js .= $this->get_indexable_images( $this->gallery_data['id'] );
263
  $no_js .= '</noscript>';
264
  $gallery .= $no_js;
265
 
266
  // Return the gallery HTML.
267
+ return apply_filters( 'envira_gallery_output', $gallery, $this->gallery_data );
268
 
269
  }
270
 
867
  $lightbox_transition_effect = $this->get_config( 'effect', $data );
868
 
869
  /* Get standard effects */
870
+ $lightbox_standard_effects = $this->common->get_transition_effects_values();
871
 
872
  /* If open/close is standard, use openEffect, closeEffect */
873
  if ( in_array( $lightbox_open_close_effect, $lightbox_standard_effects ) ) {
1213
  public function load_gallery_theme( $theme ) {
1214
 
1215
  // Loop through the available themes and enqueue the one called.
1216
+ foreach ( $this->common->get_gallery_themes() as $array => $data ) {
1217
  if ( $theme !== $data['value'] ) {
1218
  continue;
1219
  }
1239
  public function load_lightbox_theme( $theme ) {
1240
 
1241
  // Loop through the available themes and enqueue the one called.
1242
+ foreach ( $this->common->get_lightbox_themes() as $array => $data ) {
1243
  if ( $theme !== $data['value'] ) {
1244
  continue;
1245
  }
1355
  // Inject new image size into $item
1356
  $item['link'] = $image[0];
1357
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1358
  // Return
1359
  return $item;
1360
 
1410
 
1411
  if ( count( $image_sizes_random ) == 0 ) {
1412
  // The user didn't choose any image sizes - use them all.
1413
+ $wordpress_image_sizes = $this->common->get_image_sizes( true );
1414
  $wordpress_image_size_random_key = array_rand( $wordpress_image_sizes, 1 );
1415
  $image_size = $wordpress_image_sizes[ $wordpress_image_size_random_key ]['value'];
1416
  } else {
1425
  $src = wp_get_attachment_image_src( $id, $image_size );
1426
  }
1427
  } else {
1428
+
1429
+ $row_height = $retina ? intval( $this->get_config( 'justified_row_height', $data ) ) * 2 : intval( $this->get_config( 'justified_row_height', $data ) );
1430
+
1431
+ if ( $row_height <= 300 ){
1432
+
1433
+ // Get the full image
1434
+ $src = apply_filters( 'envira_gallery_retina_image_src', wp_get_attachment_image_src( $id, 'medium' ), $id, $item, $data, $this->is_mobile );
1435
+
1436
+ } elseif ( $row_height <= 640 && ! $retina ){
1437
+
1438
+ $src = apply_filters( 'envira_gallery_retina_image_src', wp_get_attachment_image_src( $id, 'large' ), $id, $item, $data, $this->is_mobile );
1439
+
1440
+ }else{
1441
+
1442
+ $src = apply_filters( 'envira_gallery_retina_image_src', wp_get_attachment_image_src( $id, 'full' ), $id, $item, $data, $this->is_mobile );
1443
+
1444
+ }
1445
 
1446
  }
1447
 
1480
  // This is safe to call every time, as resize_image() will check if the image already exists, preventing thumbnails
1481
  // from being generated every single time.
1482
  $type = $mobile ? 'mobile' : 'crop'; // 'crop' is misleading here - it's the key that stores the thumbnail width + height
 
1483
  $args = array(
1484
  'position' => 'c',
1485
  'width' => $this->get_config( $type . '_width', $data ),
1493
  // image width and height, which are hidden settings.
1494
  if ( $image_size != 'default' && $retina ) {
1495
  // Find WordPress registered image size
1496
+ $wordpress_image_sizes = $this->common->get_image_sizes( true ); // true = WordPress only image sizes (excludes random)
1497
 
1498
  foreach ( $wordpress_image_sizes as $size ) {
1499
  if ( $size['value'] !== $image_size ) {
1511
  // Filter
1512
  $args = apply_filters( 'envira_gallery_crop_image_args', $args);
1513
 
1514
+ $resized_image = $this->common->resize_image( $image, $args['width'], $args['height'], $this->get_config( 'crop', $data ), $args['position'], $args['quality'], $args['retina'], $data );
1515
 
1516
  // If there is an error, possibly output error message and return the default image src.
1517
  if ( is_wp_error( $resized_image ) ) {
1628
  */
1629
  public function get_config( $key, $data ) {
1630
 
1631
+ return isset( $data['config'][$key] ) ? $data['config'][$key] : $this->common->get_config_default( $key );
 
 
1632
 
1633
  }
1634
 
readme.txt CHANGED
@@ -185,6 +185,16 @@ Also, I'm an <a href="https://thomasgriffin.io" rel="me" title="WordPress Develo
185
 
186
  == Changelog ==
187
 
 
 
 
 
 
 
 
 
 
 
188
  = 1.5.5 =
189
  * Added: Select Image sizes for Automatic Layout.
190
  * Fix: Some servers limit how many images can be inserted at a time.
185
 
186
  == Changelog ==
187
 
188
+ = 1.5.6 =
189
+
190
+ * Fix: PHP optimizations to improve performance
191
+ * Fix: Automatic Layout option now selects default images based on the specified row height to improve gallery loading times
192
+ * Fix: Minor bug fixes
193
+
194
+ = 1.5.5.1 =
195
+
196
+ * Fix: Fatal Error on empty trash for galleries
197
+
198
  = 1.5.5 =
199
  * Added: Select Image sizes for Automatic Layout.
200
  * Fix: Some servers limit how many images can be inserted at a time.