| Server IP : 185.252.147.100 / Your IP : 216.73.217.33 Web Server : nginx/1.27.3 System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 User : mitr ( 1000) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/html/ephotel.ru/wordpress/wp-content/themes/generatepress_child/ |
Upload File : |
<?php
/*
* WP Tutorials :: Lightbox (WPTL)
*
* https://wp-tutorials.tech/refine-wordpress/turn-wordpress-image-gallery-blocks-into-responsive-lightbox/
*
* fslightbox.js : https://fslightbox.com/
*/
// Block direct access.
defined('WPINC') || die();
const WPTL_FSLIGHTBOX_VERSION = '3.4.1';
const WPTL_ONLY_ONE_LIGHTBOX_PER_PAGE = false; //true;
const WPTL_EXIT_FULL_SCREEN_ON_CLOSE = false; //true;
function wptl_enqueue_scripts() {
//if (307 != get_the_ID()) return;
$theme_version = wp_get_theme()->get('Version');
$base_url = get_stylesheet_directory_uri() . '/' . pathinfo(__FILE__, PATHINFO_FILENAME) . '/';
// The main fslightbox.js code.
// null means it doesn't depend on any other scripts.
// The last parameter (true) means it can be safely enqueued in the site's footer.
// Better for page-load speed.
wp_enqueue_script(
'fslightbox',
$base_url . 'fslightbox.min.js',
null,
WPTL_FSLIGHTBOX_VERSION,
true
);
// Our custom code to initialise fslightbox.js
// The array( 'lightbox' ) parameter tells WordPress that the fslightbox
// script must be loaded before our wpt-lightbox-frontend script.
wp_enqueue_script(
'wpt-lightbox-frontend',
$base_url . 'wpt-lightbox-frontend.js',
array('fslightbox'),
$theme_version
);
// Inject an inline script snippet into the HTML that defines a global
// JavaScript object called "wptLightbox".
wp_localize_script(
'wpt-lightbox-frontend',
'wptLightbox',
array(
'oneLightboxPerPage' => WPTL_ONLY_ONE_LIGHTBOX_PER_PAGE,
'exitFullScreenOnClose' => WPTL_EXIT_FULL_SCREEN_ON_CLOSE,
)
);
}
add_action('wp_enqueue_scripts', 'wptl_enqueue_scripts');