abilities
1 week ago
admin
1 week ago
compatibility
1 week ago
extensions
1 week ago
foopluginbase
1 week ago
public
1 week ago
thumbs
1 week ago
asset-manifest.php
1 week ago
class-attachment-filters.php
1 week ago
class-command-palette.php
1 week ago
class-foogallery-animated-gif-support.php
1 week ago
class-foogallery-attachment-custom-class.php
1 week ago
class-foogallery-attachment-filename.php
1 week ago
class-foogallery-attachment-type.php
1 week ago
class-foogallery-attachment.php
1 week ago
class-foogallery-cache.php
1 week ago
class-foogallery-common-fields.php
1 week ago
class-foogallery-crop-position.php
1 week ago
class-foogallery-datasource-media_library.php
1 week ago
class-foogallery-debug.php
1 week ago
class-foogallery-delayed-runtime-loader.php
1 week ago
class-foogallery-extensions-compatibility.php
1 week ago
class-foogallery-force-https.php
1 week ago
class-foogallery-lazyload.php
1 week ago
class-foogallery-license-constant-handler.php
1 week ago
class-foogallery-lightbox.php
1 week ago
class-foogallery-no-javascript-fallback.php
1 week ago
class-foogallery-paging.php
1 week ago
class-foogallery-password-protect.php
1 week ago
class-foogallery-sitemaps.php
1 week ago
class-foogallery-widget.php
1 week ago
class-foogallery.php
1 week ago
class-gallery-advanced-settings.php
1 week ago
class-il8n.php
1 week ago
class-override-thumbnail.php
1 week ago
class-posttypes.php
1 week ago
class-previews.php
1 week ago
class-retina.php
1 week ago
class-thumbnail-dimensions.php
1 week ago
class-thumbnails.php
1 week ago
class-version-check.php
1 week ago
constants.php
1 week ago
functions.php
1 week ago
gallery-management-functions.php
1 week ago
includes.php
1 week ago
index.php
1 week ago
render-functions.php
1 week ago
class-il8n.php
96 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * Foogallery class for enqueuing the FooGallery_il8n variable into the page |
| 9 | */ |
| 10 | |
| 11 | if ( ! class_exists( 'FooGallery_il8n' ) ) { |
| 12 | class FooGallery_il8n { |
| 13 | |
| 14 | function __construct() { |
| 15 | add_action( 'foogallery_enqueue_script-core', array( $this, 'enqueue_il8n' ), 10, 1 ); |
| 16 | add_action( 'foogallery_dequeue_script-core', array( $this, 'dequeue_core' ) ); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Enqueue the il8n script |
| 21 | * |
| 22 | * @param $js |
| 23 | * |
| 24 | * @return void |
| 25 | */ |
| 26 | function enqueue_il8n( $js ) { |
| 27 | global $foogallery_enqueue_il8n; |
| 28 | |
| 29 | if ( $foogallery_enqueue_il8n ) { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | $il8n = array(); |
| 34 | |
| 35 | $imageviewer_prev_entry = foogallery_get_language_array_value( 'language_imageviewer_prev_text', __( 'Prev', 'foogallery' ) ); |
| 36 | if ( $imageviewer_prev_entry !== false ) { |
| 37 | $il8n = array_merge_recursive( $il8n, array( |
| 38 | 'template' => array( |
| 39 | "image-viewer" => array( |
| 40 | 'prev' => esc_html( $imageviewer_prev_entry ) |
| 41 | ) |
| 42 | ) |
| 43 | ) ); |
| 44 | } |
| 45 | |
| 46 | $imageviewer_next_entry = foogallery_get_language_array_value( 'language_imageviewer_next_text', __( 'Next', 'foogallery' ) ); |
| 47 | if ( $imageviewer_next_entry !== false ) { |
| 48 | $il8n = array_merge_recursive( $il8n, array( |
| 49 | 'template' => array( |
| 50 | "image-viewer" => array( |
| 51 | 'next' => esc_html( $imageviewer_next_entry ) |
| 52 | ) |
| 53 | ) |
| 54 | ) ); |
| 55 | } |
| 56 | |
| 57 | $imageviewer_of_entry = foogallery_get_language_array_value( 'language_imageviewer_of_text', __( 'of', 'foogallery' ) ); |
| 58 | if ( $imageviewer_of_entry !== false ) { |
| 59 | $il8n = array_merge_recursive( $il8n, array( |
| 60 | 'template' => array( |
| 61 | "image-viewer" => array( |
| 62 | 'of' => esc_html( $imageviewer_of_entry ) |
| 63 | ) |
| 64 | ) |
| 65 | ) ); |
| 66 | } |
| 67 | |
| 68 | $il8n = apply_filters( 'foogallery_il8n', $il8n ); |
| 69 | |
| 70 | // Keep client-side mobile options aligned with the Responsive template's CSS breakpoint. |
| 71 | $mobile_size = foogallery_get_mobile_size(); |
| 72 | |
| 73 | $script = 'var FooGallery_mobileSize = ' . wp_json_encode( $mobile_size . 'px' ) . ';'; |
| 74 | |
| 75 | // Only add the localization object when there is data to be added. |
| 76 | if ( count( $il8n ) > 0 ) { |
| 77 | $script .= "\nvar FooGallery_il8n = " . foogallery_json_encode( $il8n ) . ';'; |
| 78 | } |
| 79 | |
| 80 | wp_add_inline_script( 'foogallery-core', $script, 'before' ); |
| 81 | |
| 82 | $foogallery_enqueue_il8n = true; // To ensure we do not add multiple times on a page with more than 1 gallery. |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Clears |
| 87 | * |
| 88 | * @return void |
| 89 | */ |
| 90 | function dequeue_core() { |
| 91 | global $foogallery_enqueue_il8n; |
| 92 | $foogallery_enqueue_il8n = null; // To ensure we once again add the correct il8n script |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 |