Changeset 2982111
- Timestamp:
- 10/21/2023 09:10:38 PM (17 months ago)
- Location:
- fcp-lightest-lightbox/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fcp-lightest-lightbox/trunk/fcp-lightbox.php
r2907686 r2982111 4 4 Plugin Name: FCP Lightest Lightbox 5 5 Description: Super lightweight lighbox. It tracks the links to images and makes it open in a popup lightbox. It also adds prev-next navigation to galleries or image sequences. 6 Version: 1.4 6 Version: 1.4.1 7 7 Requires at least: 5.7 8 Tested up to: 6. 29 Requires PHP: 7. 48 Tested up to: 6.3 9 Requires PHP: 7.0.0 10 10 Author: Firmcatalyst, Vadim Volkov 11 11 Author URI: https://firmcatalyst.com … … 16 16 defined( 'ABSPATH' ) || exit; 17 17 18 define( 'FCPLB_DEV', false );18 define( 'FCPLB_DEV', true ); 19 19 define( 'FCPLB_VER', get_file_data( __FILE__, [ 'ver' => 'Version' ] )[ 'ver' ] . ( FCPLB_DEV ? time() : '' ) ); 20 20 … … 23 23 add_action( 'wp_enqueue_scripts', function() { 24 24 25 $assets_url = function($name, $ext, $ver = '') { 26 return plugin_dir_url(__FILE__) . $name . ( FCPLB_DEV ? '' : '.min' ) . '.' . $ext . ( $ver ? '?' . $ver : '' ); 27 }; 28 29 $translations = ['Previous', 'Next', 'Close']; 30 $translations = array_map( function( $a ) use ( $translations ) { 31 return __( $translations[ $a ] ); 32 }, array_flip( $translations ) ); 33 34 wp_enqueue_script( 'fcp-lightbox', $assets_url( 'loader', 'js' ), [], FCPLB_VER ); 35 add_filter('script_loader_tag', function ($tag, $handle) { // change to async 36 if ( $handle !== 'fcp-lightbox' ) { return $tag; } 37 return str_replace( ' src', ' async src', $tag ); 25 // list of used phrases 26 $to_translate = ['Previous', 'Next', 'Close', 'Caption']; 27 $translations = array_map( function( $a ) use ( $to_translate ) { 28 return __( $to_translate[ $a ] ); 29 }, array_flip( $to_translate ) ); 30 31 // enqueue the loader script 32 $loader_name = 'fcp-lightbox-loader'; 33 $loader_file_url = plugins_url( '/loader'.( FCPLB_DEV ? '' : '.min' ).'.js', __FILE__ ); 34 wp_enqueue_script( $loader_name, $loader_file_url, [], FCPLB_VER ); 35 36 // defer the script loading 37 add_filter('script_loader_tag', function ($tag, $handle) { 38 if ( $handle !== $loader_name || strpos( $tag, 'defer ' ) !== false) { return $tag; } 39 return str_replace( ' src', ' defer src', $tag ); 38 40 }, 10, 2); 39 41 40 // global js values 41 wp_add_inline_script( 'fcp-lightbox', preg_replace( '/[\n\t ]+/', '', ' 42 window.fcp_lightbox = { 43 "path" : "' . esc_js( plugin_dir_url(__FILE__) ) . '", 44 "dev" : ' . ( FCPLB_DEV ? 'true' : 'false' ) . ', 45 "ver" : "' . esc_js( FCPLB_VER ) . '", 46 "selector" : "a[href$=\".jpg\"], a[href$=\".jpeg\"], a[href$=\".png\"]", 47 "translations" : ' . json_encode( $translations ) . ', 48 }; 49 ')); 42 // global js values // ++ eliminate 43 $settings = [ 44 'loader' => $loader_name.'-js', 45 'path' => esc_js( plugin_dir_url(__FILE__) ), // ++almost can remove 46 'dev' => FCPLB_DEV, 47 'ver' => esc_js( FCPLB_VER ), 48 'selector' => 'a[href$=".jpg"], a[href$=".jpeg"], a[href$=".png"]', 49 'translations' => $translations, 50 ]; 50 51 51 // wp_enqueue_style( 'fcp-lightbox', $assets_url( 'style', 'css' ), [], FCPLB_VER ); // moved to script.js to eleminate render blocking 52 }); 52 wp_add_inline_script( $loader_name, 'window.fcp_lightbox = '.json_encode( $settings ).';' ); 53 54 }, 10 ); -
fcp-lightest-lightbox/trunk/readme.txt
r2907686 r2982111 3 3 Tags: lightbox, gallery, photography, images 4 4 Requires at least: 5.7 5 Tested up to: 6. 26 Requires PHP: 7. 47 Stable tag: 1.4 5 Tested up to: 6.3 6 Requires PHP: 7.0.0 7 Stable tag: 1.4.1 8 8 Author: Firmcatalyst, Vadim Volkov 9 9 Author URI: https://firmcatalyst.com
Note: See TracChangeset
for help on using the changeset viewer.