FancyBox for WordPress - Version 3.2.7

Version Description

  • Fix for separate gutenberg blocks
  • Personalize script handles
  • Review dismiss fix
Download this release

Release Info

Developer giucu91
Plugin Icon wp plugin FancyBox for WordPress
Version 3.2.7
Comparing to
See all releases

Code changes from version 3.2.6 to 3.2.7

Files changed (3) hide show
  1. class-fancybox-review.php +170 -0
  2. fancybox.php +15 -8
  3. readme.txt +7 -2
class-fancybox-review.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fancybox_Review {
4
+
5
+ private $value;
6
+ private $messages;
7
+ private $link = 'https://wordpress.org/plugins/fancybox-for-wordpress/#reviews';
8
+ private $slug = 'mfbfw';
9
+
10
+ function __construct() {
11
+
12
+ $this->messages = array(
13
+ 'notice' => __( "Hi there! Stoked to see you're using Fancybox for a few days now - hope you like it! And if you do, please consider rating it. It would mean the world to us. Keep on rocking!", 'mfbfw' ),
14
+ 'rate' => __( 'Rate the plugin', 'mfbfw' ),
15
+ 'rated' => __( 'Remind me later', 'mfbfw' ),
16
+ 'no_rate' => __( 'Don\'t show again', 'mfbfw' ),
17
+ );
18
+
19
+ if ( isset( $args['messages'] ) ) {
20
+ $this->messages = wp_parse_args( $args['messages'], $this->messages );
21
+ }
22
+
23
+ add_action( 'init', array( $this, 'init' ) );
24
+
25
+ }
26
+
27
+ public function init() {
28
+ if ( ! is_admin() ) {
29
+ return;
30
+ }
31
+
32
+ $this->value = $this->value();
33
+
34
+ if ( $this->check() ) {
35
+ add_action( 'admin_notices', array( $this, 'five_star_wp_rate_notice' ) );
36
+ add_action( 'wp_ajax_epsilon_mfbfw_review', array( $this, 'ajax' ) );
37
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
38
+ add_action( 'admin_print_footer_scripts', array( $this, 'ajax_script' ) );
39
+ }
40
+
41
+ }
42
+
43
+ private function check() {
44
+
45
+ if ( ! current_user_can('manage_options') ) {
46
+ return false;
47
+ }
48
+
49
+ return( time() > $this->value );
50
+
51
+ }
52
+
53
+ private function value() {
54
+
55
+ $value = get_option( 'mfbfw-rate-time', false );
56
+
57
+ if ( $value ) {
58
+ return $value;
59
+ }
60
+
61
+ $value = time() + DAY_IN_SECONDS;
62
+ update_option( 'mfbfw-rate-time', $value );
63
+
64
+ return $value;
65
+
66
+ }
67
+
68
+ public function five_star_wp_rate_notice() {
69
+
70
+ $url = sprintf( $this->link, $this->slug );
71
+
72
+ ?>
73
+ <div id="<?php echo esc_attr($this->slug) ?>-epsilon-review-notice" class="notice notice-success is-dismissible" style="margin-top:30px;">
74
+ <p><?php echo sprintf( esc_html( $this->messages['notice'] ), $this->value ) ; ?></p>
75
+ <p class="actions">
76
+ <a id="epsilon-rate" href="<?php echo esc_url( $url ) ?>" target="_blank" class="button button-primary epsilon-review-button">
77
+ <?php echo esc_html( $this->messages['rate'] ); ?>
78
+ </a>
79
+ <a id="epsilon-later" href="#" style="margin-left:10px" class="epsilon-review-button"><?php echo esc_html( $this->messages['rated'] ); ?></a>
80
+ <a id="epsilon-no-rate" href="#" style="margin-left:10px" class="epsilon-review-button"><?php echo esc_html( $this->messages['no_rate'] ); ?></a>
81
+ </p>
82
+ </div>
83
+ <?php
84
+ }
85
+
86
+ public function ajax() {
87
+
88
+ check_ajax_referer( 'epsilon-mfbfw-review', 'security' );
89
+
90
+ if ( ! isset( $_POST['check'] ) ) {
91
+ wp_die( 'ok' );
92
+ }
93
+
94
+ $time = get_option( 'mfbfw-rate-time' );
95
+
96
+ if ( 'epsilon-rate' == $_POST['check'] ) {
97
+ $time = time() + YEAR_IN_SECONDS * 5;
98
+ }elseif ( 'epsilon-later' == $_POST['check'] ) {
99
+ $time = time() + WEEK_IN_SECONDS;
100
+ }elseif ( 'epsilon-no-rate' == $_POST['check'] ) {
101
+ $time = time() + YEAR_IN_SECONDS * 5;
102
+ }
103
+
104
+ update_option( 'mfbfw-rate-time', $time );
105
+ wp_die( 'ok' );
106
+
107
+ }
108
+
109
+ public function enqueue() {
110
+ wp_enqueue_script( 'jquery' );
111
+ }
112
+
113
+ public function ajax_script() {
114
+
115
+ $ajax_nonce = wp_create_nonce( "epsilon-mfbfw-review" );
116
+
117
+ ?>
118
+
119
+ <script type="text/javascript">
120
+ jQuery( document ).ready( function( $ ){
121
+
122
+ $( '.epsilon-review-button' ).click( function( evt ){
123
+ var href = $(this).attr('href'),
124
+ id = $(this).attr('id');
125
+
126
+ if ( 'epsilon-rate' != id ) {
127
+ evt.preventDefault();
128
+ }
129
+
130
+ var data = {
131
+ action: 'epsilon_mfbfw_review',
132
+ security: '<?php echo $ajax_nonce; ?>',
133
+ check: id
134
+ };
135
+
136
+ if ( 'epsilon-rated' === id || 'epsilon-rate' === id ) {
137
+ data['epsilon-review'] = 1;
138
+ }
139
+
140
+ $.post( '<?php echo admin_url( 'admin-ajax.php' ) ?>', data, function( response ) {
141
+ $( '#<?php echo $this->slug ?>-epsilon-review-notice' ).slideUp( 'fast', function() {
142
+ $( this ).remove();
143
+ } );
144
+ });
145
+
146
+ } );
147
+
148
+ $('#mfbfw-epsilon-review-notice .notice-dismiss').click(function(){
149
+
150
+ var data = {
151
+ action: 'epsilon_mfbfw_review',
152
+ security: '<?php echo $ajax_nonce; ?>',
153
+ check: 'epsilon-later'
154
+ };
155
+
156
+ $.post( '<?php echo admin_url( 'admin-ajax.php' ) ?>', data, function( response ) {
157
+ $( '#<?php echo $this->slug ?>-epsilon-review-notice' ).slideUp( 'fast', function() {
158
+ $( this ).remove();
159
+ } );
160
+ });
161
+ });
162
+
163
+ });
164
+ </script>
165
+
166
+ <?php
167
+ }
168
+ }
169
+
170
+ new Fancybox_Review();
fancybox.php CHANGED
@@ -3,10 +3,10 @@
3
  * Plugin Name: FancyBox for WordPress
4
  * Plugin URI: https://wordpress.org/plugins/fancybox-for-wordpress/
5
  * Description: Integrates <a href="http://fancyapps.com/fancybox/3/">FancyBox 3</a> into WordPress.
6
- * Version: 3.2.6
7
  * Author: Colorlib
8
  * Author URI: https://colorlib.com/wp/
9
- * Tested up to: 5.3
10
  * Requires: 4.6 or higher
11
  * License: GPLv3 or later
12
  * License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -36,7 +36,7 @@
36
  * Plugin Init
37
  */
38
  // Constants
39
- define( 'FBFW_VERSION', '3.2.6' );
40
  define( 'FBFW_PATH', plugin_dir_path( __FILE__ ) );
41
  define( 'FBFW_URL', plugin_dir_url( __FILE__ ) );
42
  define( 'FBFW_PLUGIN_BASE', plugin_basename( __FILE__ ) );
@@ -49,6 +49,8 @@ define( 'PLUGIN_NAME', 'fancybox-for-wordpress' );
49
  $mfbfw = get_option( 'mfbfw' );
50
  $mfbfw_version = get_option( 'mfbfw_active_version' );
51
 
 
 
52
  // If previous version detected
53
  if ( is_admin() && isset( $mfbfw_version ) && $mfbfw_version < FBFW_VERSION ) {
54
 
@@ -172,10 +174,10 @@ function mfbfw_enqueue_scripts() {
172
  }
173
 
174
  // Register Scripts
175
- wp_register_script( 'fancybox', FBFW_URL . 'assets/js/jquery.fancybox.js', $jquery, '1.3.4', $footer ); // Main Fancybox script
176
 
177
  // Enqueue Scripts
178
- wp_enqueue_script( 'fancybox' ); // Load fancybox
179
 
180
  if ( isset( $mfbfw['easing'] ) && $mfbfw['easing'] ) {
181
  wp_enqueue_script( 'jqueryeasing' ); // Load easing javascript file if required
@@ -186,9 +188,9 @@ function mfbfw_enqueue_scripts() {
186
  }
187
 
188
  // Register Styles
189
- wp_register_style( 'fancybox', FBFW_URL . 'assets/css/fancybox.css', false, '1.3.4' ); // Main Fancybox style
190
  // Enqueue Styles
191
- wp_enqueue_style( 'fancybox' );
192
 
193
  // Make IE specific styles load only on IE6-8
194
  $wp_styles->add_data( 'fancybox-ie', 'conditional', 'lt IE 9' );
@@ -371,7 +373,12 @@ function mfbfw_init() {
371
  <?php } else if( $mfbfw['galleryType'] == 'single_gutenberg_block'){
372
  ?>
373
 
374
- var gallery_block = jQuery('ul.wp-block-gallery');
 
 
 
 
 
375
  gallery_block.each(function() {
376
  jQuery(this).find(thumbnails).addClass("fancyboxforwp").attr("data-fancybox","gallery"+gallery_block.index(this)).attr("rel","fancybox"+gallery_block.index(this)).getTitle();
377
 
3
  * Plugin Name: FancyBox for WordPress
4
  * Plugin URI: https://wordpress.org/plugins/fancybox-for-wordpress/
5
  * Description: Integrates <a href="http://fancyapps.com/fancybox/3/">FancyBox 3</a> into WordPress.
6
+ * Version: 3.2.7
7
  * Author: Colorlib
8
  * Author URI: https://colorlib.com/wp/
9
+ * Tested up to: 5.4
10
  * Requires: 4.6 or higher
11
  * License: GPLv3 or later
12
  * License URI: http://www.gnu.org/licenses/gpl-3.0.html
36
  * Plugin Init
37
  */
38
  // Constants
39
+ define( 'FBFW_VERSION', '3.2.7' );
40
  define( 'FBFW_PATH', plugin_dir_path( __FILE__ ) );
41
  define( 'FBFW_URL', plugin_dir_url( __FILE__ ) );
42
  define( 'FBFW_PLUGIN_BASE', plugin_basename( __FILE__ ) );
49
  $mfbfw = get_option( 'mfbfw' );
50
  $mfbfw_version = get_option( 'mfbfw_active_version' );
51
 
52
+ include 'class-fancybox-review.php';
53
+
54
  // If previous version detected
55
  if ( is_admin() && isset( $mfbfw_version ) && $mfbfw_version < FBFW_VERSION ) {
56
 
174
  }
175
 
176
  // Register Scripts
177
+ wp_register_script( 'fancybox-for-wp', FBFW_URL . 'assets/js/jquery.fancybox.js', $jquery, '1.3.4', $footer ); // Main Fancybox script
178
 
179
  // Enqueue Scripts
180
+ wp_enqueue_script( 'fancybox-for-wp' ); // Load fancybox
181
 
182
  if ( isset( $mfbfw['easing'] ) && $mfbfw['easing'] ) {
183
  wp_enqueue_script( 'jqueryeasing' ); // Load easing javascript file if required
188
  }
189
 
190
  // Register Styles
191
+ wp_register_style( 'fancybox-for-wp', FBFW_URL . 'assets/css/fancybox.css', false, '1.3.4' ); // Main Fancybox style
192
  // Enqueue Styles
193
+ wp_enqueue_style( 'fancybox-for-wp' );
194
 
195
  // Make IE specific styles load only on IE6-8
196
  $wp_styles->add_data( 'fancybox-ie', 'conditional', 'lt IE 9' );
373
  <?php } else if( $mfbfw['galleryType'] == 'single_gutenberg_block'){
374
  ?>
375
 
376
+ var gallery_block;
377
+ if(jQuery('ul.wp-block-gallery').length){
378
+ var gallery_block = jQuery('ul.wp-block-gallery');
379
+ } else if(jQuery('ul.blocks-gallery-grid')) {
380
+ var gallery_block = jQuery('ul.blocks-gallery-grid');
381
+ }
382
  gallery_block.each(function() {
383
  jQuery(this).find(thumbnails).addClass("fancyboxforwp").attr("data-fancybox","gallery"+gallery_block.index(this)).attr("rel","fancybox"+gallery_block.index(this)).getTitle();
384
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: silkalns
3
  Tags: fancybox, lightbox, jquery, gallery, image, images, photo, photos, picture, pictures, zoom
4
  Requires at least: 4.6
5
- Tested up to: 5.3
6
- Stable tag: 3.2.6
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -31,6 +31,11 @@ If you enjoy using FancyBox lightbox for WordPress please leave a [positive feed
31
 
32
  == Changelog ==
33
 
 
 
 
 
 
34
  = 3.2.6 =
35
  * Admin bar overfloat fix
36
  * Tooltip description bug fix
2
  Contributors: silkalns
3
  Tags: fancybox, lightbox, jquery, gallery, image, images, photo, photos, picture, pictures, zoom
4
  Requires at least: 4.6
5
+ Tested up to: 5.4
6
+ Stable tag: 3.2.7
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
31
 
32
  == Changelog ==
33
 
34
+ = 3.2.7 =
35
+ * Fix for separate gutenberg blocks
36
+ * Personalize script handles
37
+ * Review dismiss fix
38
+
39
  = 3.2.6 =
40
  * Admin bar overfloat fix
41
  * Tooltip description bug fix