Easy FancyBox - Version 1.6.3

Version Description

Switch to wp_add_inline_script() and fix inline js minification incompatibility

=

Download this release

Release Info

Developer deployer
Plugin Icon 128x128 Easy FancyBox
Version 1.6.3
Comparing to
See all releases

Code changes from version 1.6.2 to 1.6.3

easy-fancybox.php CHANGED
@@ -5,12 +5,12 @@ Plugin URI: http://status301.net/wordpress-plugins/easy-fancybox/
5
  Description: Easily enable the <a href="http://fancybox.net/">FancyBox jQuery extension</a> on all image, SWF, PDF, YouTube, Dailymotion and Vimeo links. Also supports iFrame and inline content.
6
  Text Domain: easy-fancybox
7
  Domain Path: languages
8
- Version: 1.6.2
9
  Author: RavanH
10
  Author URI: http://status301.net/
11
  */
12
 
13
- /* Copyright 2016 RavanH (email : ravanhagen@gmail.com)
14
 
15
  This program is free software; you can redistribute it and/or modify
16
  it under the terms of the GNU General Public License as published by
@@ -37,16 +37,20 @@ if ( ! defined( 'ABSPATH' ) ) exit;
37
  * CONSTANTS
38
  **************/
39
 
40
- define( 'EASY_FANCYBOX_VERSION', '1.6.2' );
41
  define( 'FANCYBOX_VERSION', '1.3.8' );
42
  define( 'MOUSEWHEEL_VERSION', '3.1.13' );
43
  define( 'EASING_VERSION', '1.4.0' );
44
  define( 'METADATA_VERSION', '2.22.1' );
45
 
46
  /**************
47
- * CLASS
48
  **************/
49
 
50
  require_once dirname(__FILE__) . '/inc/class-easyfancybox.php';
51
-
52
  $efb = new easyFancyBox( __FILE__ );
 
 
 
 
 
5
  Description: Easily enable the <a href="http://fancybox.net/">FancyBox jQuery extension</a> on all image, SWF, PDF, YouTube, Dailymotion and Vimeo links. Also supports iFrame and inline content.
6
  Text Domain: easy-fancybox
7
  Domain Path: languages
8
+ Version: 1.6.3
9
  Author: RavanH
10
  Author URI: http://status301.net/
11
  */
12
 
13
+ /* Copyright 2018 RavanH (email : ravanhagen@gmail.com)
14
 
15
  This program is free software; you can redistribute it and/or modify
16
  it under the terms of the GNU General Public License as published by
37
  * CONSTANTS
38
  **************/
39
 
40
+ define( 'EASY_FANCYBOX_VERSION', '1.6.3' );
41
  define( 'FANCYBOX_VERSION', '1.3.8' );
42
  define( 'MOUSEWHEEL_VERSION', '3.1.13' );
43
  define( 'EASING_VERSION', '1.4.0' );
44
  define( 'METADATA_VERSION', '2.22.1' );
45
 
46
  /**************
47
+ * CLASSES
48
  **************/
49
 
50
  require_once dirname(__FILE__) . '/inc/class-easyfancybox.php';
 
51
  $efb = new easyFancyBox( __FILE__ );
52
+
53
+ if ( is_admin() ) {
54
+ require_once dirname(__FILE__) . '/inc/class-easyfancybox-admin.php';
55
+ $efb_admin = new easyFancyBox_Admin();
56
+ }
inc/class-easyfancybox-admin.php CHANGED
@@ -14,11 +14,18 @@ class easyFancyBox_Admin extends easyFancyBox {
14
  ADMIN FUNCTIONS
15
  ***********************/
16
 
17
- public static function register_settings($args = array()) {
 
 
 
 
 
18
  foreach ($args as $key => $value) {
19
  // check to see if the section is enabled, else skip to next
20
- if ( !isset($value['input']) || array_key_exists($key, parent::$options['Global']['options']['Enable']['options']) && !get_option( parent::$options['Global']['options']['Enable']['options'][$key]['id'], parent::$options['Global']['options']['Enable']['options'][$key]['default']) )
21
- continue;
 
 
22
 
23
  switch($value['input']) {
24
  case 'deep':
@@ -229,31 +236,11 @@ class easyFancyBox_Admin extends easyFancyBox {
229
  }
230
  }
231
 
232
- /**********************
233
- RUN
234
- **********************/
235
-
236
- public static function run() {
237
- add_action('plugins_loaded', array(__CLASS__, 'load_textdomain'));
238
- add_action('admin_init', array(__CLASS__, 'admin_init'));
239
- }
240
-
241
- public static function load_textdomain(){
242
  load_plugin_textdomain('easy-fancybox', false, dirname( parent::$plugin_basename ) . '/languages' );
243
  }
244
 
245
- public static function admin_init() {
246
- add_action('admin_notices', array(__CLASS__, 'admin_notice'));
247
-
248
- add_filter('plugin_action_links_'.parent::$plugin_basename, array(__CLASS__, 'add_action_link') );
249
-
250
- // in preparation of dedicated admin page move:
251
- //add_action('admin_menu', array(__CLASS__, 'add_menu'));
252
-
253
- add_settings_section('fancybox_section', __('FancyBox','easy-fancybox'), array(__CLASS__, 'settings_section'), 'media');
254
-
255
- self::register_settings( parent::$options );
256
-
257
  /* Dismissable notice */
258
  /* If user clicks to ignore the notice, add that to their user meta */
259
  global $current_user;
@@ -267,4 +254,20 @@ class easyFancyBox_Admin extends easyFancyBox {
267
  self::$do_compat_warning = true;
268
  }
269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  }
14
  ADMIN FUNCTIONS
15
  ***********************/
16
 
17
+ public static function add_settings_section() {
18
+ add_settings_section('fancybox_section', __('FancyBox','easy-fancybox'), array(__CLASS__, 'settings_section'), 'media');
19
+ }
20
+
21
+ public static function register_settings( $args = [] ) {
22
+ if ( empty( $args ) ) $args = parent::$options;
23
  foreach ($args as $key => $value) {
24
  // check to see if the section is enabled, else skip to next
25
+ if ( !isset($value['input'])
26
+ || array_key_exists($key, parent::$options['Global']['options']['Enable']['options'])
27
+ && !get_option( parent::$options['Global']['options']['Enable']['options'][$key]['id'], parent::$options['Global']['options']['Enable']['options'][$key]['default'])
28
+ ) continue;
29
 
30
  switch($value['input']) {
31
  case 'deep':
236
  }
237
  }
238
 
239
+ public static function load_textdomain() {
 
 
 
 
 
 
 
 
 
240
  load_plugin_textdomain('easy-fancybox', false, dirname( parent::$plugin_basename ) . '/languages' );
241
  }
242
 
243
+ public static function admin_notice_dismiss() {
 
 
 
 
 
 
 
 
 
 
 
244
  /* Dismissable notice */
245
  /* If user clicks to ignore the notice, add that to their user meta */
246
  global $current_user;
254
  self::$do_compat_warning = true;
255
  }
256
 
257
+ /**********************
258
+ RUN
259
+ **********************/
260
+
261
+ public function __construct() {
262
+ add_action('plugins_loaded', array(__CLASS__, 'load_textdomain'));
263
+ add_action('admin_notices', array(__CLASS__, 'admin_notice'));
264
+ add_filter('plugin_action_links_'.parent::$plugin_basename, array(__CLASS__, 'add_action_link') );
265
+
266
+ // in preparation of dedicated admin page move:
267
+ //add_action('admin_menu', array(__CLASS__, 'add_menu'));
268
+
269
+ add_action('admin_init', array(__CLASS__, 'add_settings_section'));
270
+ add_action('admin_init', array(__CLASS__, 'register_settings'));
271
+ add_action('admin_init', array(__CLASS__, 'admin_notice_dismiss'));
272
+ }
273
  }
inc/class-easyfancybox.php CHANGED
@@ -81,7 +81,8 @@ var fb_opts = {';
81
  }
82
  }
83
  echo ' };
84
- var easy_fancybox_handler = function(){';
 
85
 
86
  foreach (self::$options as $key => $value) {
87
  // check if not enabled or hide=true then skip
@@ -202,7 +203,7 @@ var easy_fancybox_handler = function(){';
202
  }
203
 
204
  echo '
205
- }
206
  var easy_fancybox_auto = function(){';
207
 
208
  if ( empty($delayClick) ) $delayClick = '0';
@@ -227,7 +228,7 @@ var easy_fancybox_auto = function(){';
227
  }
228
 
229
  echo '
230
- }
231
  /* ]]> */
232
  </script>
233
  ';
@@ -311,14 +312,21 @@ var easy_fancybox_auto = function(){';
311
  else
312
  wp_register_script('jquery-fancybox', self::$plugin_url.'fancybox/jquery.fancybox-'.FANCYBOX_VERSION.'.min.js', array('jquery'), EASY_FANCYBOX_VERSION, true);
313
 
314
- // easing in IMG settings?
315
- if ( ( '' == get_option( self::$options['IMG']['options']['easingIn']['id'], self::$options['IMG']['options']['easingIn']['default']) || 'linear' == get_option( self::$options['IMG']['options']['easingIn']['id'], self::$options['IMG']['options']['easingIn']['default']) ) && ( '' == get_option( self::$options['IMG']['options']['easingOut']['id'], self::$options['IMG']['options']['easingOut']['default']) || 'linear' == get_option( self::$options['IMG']['options']['easingOut']['id'], self::$options['IMG']['options']['easingOut']['default']) ) ) {
316
- // do nothing
317
- } else {
318
- if ( 'elastic' == get_option( self::$options['IMG']['options']['transitionIn']['id'], self::$options['IMG']['options']['transitionIn']['default']) || 'elastic' == get_option( self::$options['IMG']['options']['transitionOut']['id'], self::$options['IMG']['options']['transitionOut']['default']) ) {
319
- wp_deregister_script('jquery-easing');
320
- wp_register_script('jquery-easing', self::$plugin_url.'js/jquery.easing.min.js', array('jquery'), EASING_VERSION, true);
321
- }
 
 
 
 
 
 
 
322
  }
323
 
324
  // mousewheel in IMG settings?
@@ -363,25 +371,23 @@ var easy_fancybox_auto = function(){';
363
 
364
  public static function on_ready() {
365
 
366
- if (!self::$add_scripts) // abort mission, there is no need for any script files
367
- return;
368
 
369
  // 'gform_post_render' for gForms content triggers an error... Why?
370
  // 'post-load' is for Infinite Scroll by JetPack
371
 
372
  // first exclude some links by adding nolightbox class:
373
  // (1) nofancybox backwards compatibility and (2) tries to detect social sharing buttons with known issues
374
- echo '<script type="text/javascript">
375
- jQuery(document).on(\'ready post-load\', function(){ jQuery(\'.nofancybox,a.pin-it-button,a[href*="pinterest.com/pin/create"]\').addClass(\'nolightbox\'); });';
376
 
377
- echo apply_filters( 'easy_fancybox_onready_handler', '
378
- jQuery(document).on(\'ready post-load\',easy_fancybox_handler);' );
379
 
380
- echo apply_filters( 'easy_fancybox_onready_auto', '
381
- jQuery(document).on(\'ready\',easy_fancybox_auto);' );
382
 
383
- echo '</script>
384
- ';
 
385
  }
386
 
387
  // Hack to fix missing wmode in Youtube oEmbed code based on David C's code in the comments on
@@ -404,13 +410,6 @@ jQuery(document).on(\'ready\',easy_fancybox_auto);' );
404
  add_filter('embed_oembed_html', array(__CLASS__, 'add_video_wmode_opaque'), 10, 3);
405
  }
406
 
407
- public static function plugins_loaded(){
408
- if ( is_admin() ) {
409
- require_once dirname(__FILE__) . '/class-easyfancybox-admin.php';
410
- easyFancyBox_Admin::run();
411
- }
412
- }
413
-
414
  /**********************
415
  RUN
416
  **********************/
@@ -424,8 +423,6 @@ jQuery(document).on(\'ready\',easy_fancybox_auto);' );
424
  require_once dirname(__FILE__) . '/class-easyfancybox-options.php';
425
 
426
  // HOOKS //
427
- add_action('plugins_loaded', array(__CLASS__, 'plugins_loaded'));
428
-
429
  add_action('init', array(__CLASS__, 'init'));
430
  add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_styles'), 999);
431
  add_action('wp_head', array(__CLASS__, 'main_script'), 999);
81
  }
82
  }
83
  echo ' };
84
+ var easy_fancybox_handler = function(){
85
+ jQuery(\'.nofancybox,a.pin-it-button,a[href*="pinterest.com/pin/create"]\').addClass(\'nolightbox\');';
86
 
87
  foreach (self::$options as $key => $value) {
88
  // check if not enabled or hide=true then skip
203
  }
204
 
205
  echo '
206
+ };
207
  var easy_fancybox_auto = function(){';
208
 
209
  if ( empty($delayClick) ) $delayClick = '0';
228
  }
229
 
230
  echo '
231
+ };
232
  /* ]]> */
233
  </script>
234
  ';
312
  else
313
  wp_register_script('jquery-fancybox', self::$plugin_url.'fancybox/jquery.fancybox-'.FANCYBOX_VERSION.'.min.js', array('jquery'), EASY_FANCYBOX_VERSION, true);
314
 
315
+ $add_easing = false;
316
+ // test for easing in IMG settings
317
+ if ( get_option(self::$options['Global']['options']['Enable']['options']['IMG']['id'], self::$options['Global']['options']['Enable']['options']['IMG']['default'])
318
+ && ( 'elastic' == get_option( self::$options['IMG']['options']['transitionIn']['id'], self::$options['IMG']['options']['transitionIn']['default'])
319
+ || 'elastic' == get_option( self::$options['IMG']['options']['transitionOut']['id'], self::$options['IMG']['options']['transitionOut']['default']) ) )
320
+ $add_easing = true;
321
+ // test for easing in Inline settings
322
+ if ( get_option(self::$options['Global']['options']['Enable']['options']['Inline']['id'], self::$options['Global']['options']['Enable']['options']['Inline']['default'])
323
+ && ( 'elastic' == get_option( self::$options['Inline']['options']['transitionIn']['id'], self::$options['Inline']['options']['transitionIn']['default'])
324
+ || 'elastic' == get_option( self::$options['Inline']['options']['transitionOut']['id'], self::$options['Inline']['options']['transitionOut']['default']) ) )
325
+ $add_easing = true;
326
+ // register easing?
327
+ if ( $add_easing ) {
328
+ wp_deregister_script('jquery-easing');
329
+ wp_register_script('jquery-easing', self::$plugin_url.'js/jquery.easing.min.js', array('jquery'), EASING_VERSION, true);
330
  }
331
 
332
  // mousewheel in IMG settings?
371
 
372
  public static function on_ready() {
373
 
374
+ if (!self::$add_scripts)
375
+ return; // abort mission, there is no need for any script files
376
 
377
  // 'gform_post_render' for gForms content triggers an error... Why?
378
  // 'post-load' is for Infinite Scroll by JetPack
379
 
380
  // first exclude some links by adding nolightbox class:
381
  // (1) nofancybox backwards compatibility and (2) tries to detect social sharing buttons with known issues
382
+ echo '<script type="text/javascript">' . PHP_EOL;
 
383
 
384
+ echo apply_filters( 'easy_fancybox_onready_handler', 'jQuery(easy_fancybox_handler);' ) . PHP_EOL;
 
385
 
386
+ echo apply_filters( 'easy_fancybox_onpostload_handler', 'jQuery(document.body).on(\'post-load\',easy_fancybox_handler);' ) . PHP_EOL;
 
387
 
388
+ echo apply_filters( 'easy_fancybox_onready_auto', 'jQuery(easy_fancybox_auto);' ) . PHP_EOL;
389
+
390
+ echo '</script>' . PHP_EOL;
391
  }
392
 
393
  // Hack to fix missing wmode in Youtube oEmbed code based on David C's code in the comments on
410
  add_filter('embed_oembed_html', array(__CLASS__, 'add_video_wmode_opaque'), 10, 3);
411
  }
412
 
 
 
 
 
 
 
 
413
  /**********************
414
  RUN
415
  **********************/
423
  require_once dirname(__FILE__) . '/class-easyfancybox-options.php';
424
 
425
  // HOOKS //
 
 
426
  add_action('init', array(__CLASS__, 'init'));
427
  add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_styles'), 999);
428
  add_action('wp_head', array(__CLASS__, 'main_script'), 999);