Plugin Directory

Changeset 2982111


Ignore:
Timestamp:
10/21/2023 09:10:38 PM (17 months ago)
Author:
firmcatalyst
Message:

Tested up to 6.3

Location:
fcp-lightest-lightbox/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fcp-lightest-lightbox/trunk/fcp-lightbox.php

    r2907686 r2982111  
    44Plugin Name: FCP Lightest Lightbox
    55Description: 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
     6Version: 1.4.1
    77Requires at least: 5.7
    8 Tested up to: 6.2
    9 Requires PHP: 7.4
     8Tested up to: 6.3
     9Requires PHP: 7.0.0
    1010Author: Firmcatalyst, Vadim Volkov
    1111Author URI: https://firmcatalyst.com
     
    1616defined( 'ABSPATH' ) || exit;
    1717
    18 define( 'FCPLB_DEV', false );
     18define( 'FCPLB_DEV', true );
    1919define( 'FCPLB_VER', get_file_data( __FILE__, [ 'ver' => 'Version' ] )[ 'ver' ] . ( FCPLB_DEV ? time() : '' ) );
    2020
     
    2323add_action( 'wp_enqueue_scripts', function() {
    2424
    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 );
    3840    }, 10, 2);
    3941   
    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    ];
    5051   
    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  
    33Tags: lightbox, gallery, photography, images
    44Requires at least: 5.7
    5 Tested up to: 6.2
    6 Requires PHP: 7.4
    7 Stable tag: 1.4
     5Tested up to: 6.3
     6Requires PHP: 7.0.0
     7Stable tag: 1.4.1
    88Author: Firmcatalyst, Vadim Volkov
    99Author URI: https://firmcatalyst.com
Note: See TracChangeset for help on using the changeset viewer.