Filter tin-canny-learndash-reporting

uo_tincanny_glightbox_config

Filter the configuration settings for the Tin Canny Lightbox. This filter allows customization of the default Lightbox behavior. Filters the configuration for the Tin Canny Lightbox, allowing customization of its behavior before it's applied.

add_filter( 'uo_tincanny_glightbox_config', $callback, 10, 1 );

Description

Filter Tin Canny Lightbox configuration before it's applied. Developers can modify settings like `closeOnOutsideClick` to customize lightbox behavior. This filter runs when the lightbox script is enqueued, offering precise control over its frontend interactions.


Usage

add_filter( 'uo_tincanny_glightbox_config', 'your_function_name', 10, 1 );

Parameters

$glighbox_data (array)
{ Array of configuration options. '0' = disabled, '1' = enabled. Default is '0'.

Return Value

array Modified configuration settings.


Examples

add_filter('uo_tincanny_glightbox_config', 'my_custom_glightbox_config', 10, 1);

/**
 * Example function to customize the Tin Canny Lightbox configuration.
 * This example enables closing the lightbox when clicking outside of it.
 *
 * @param array $glighbox_data The existing Lightbox configuration array.
 * @return array The modified Lightbox configuration array.
 */
function my_custom_glightbox_config( $glighbox_data ) {
    // Check if the 'closeOnOutsideClick' key exists, if not, initialize it.
    // We're setting it to '1' to enable closing on outside click.
    if ( !isset( $glighbox_data['closeOnOutsideClick'] ) || '0' === $glighbox_data['closeOnOutsideClick'] ) {
        $glighbox_data['closeOnOutsideClick'] = '1';
    }

    // You could add other customizations here if needed, for example:
    // $glighbox_data['animationSpeed'] = '200'; // Set animation speed in milliseconds

    return $glighbox_data;
}

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/uncanny-articulate-and-captivate/classes/Shortcode.php:572

protected function enqueue_glightbox() {
        // TODO: Remove this enqueue for iframe type.
        wp_enqueue_style('glightbox', SnC_ASSET_URL . 'css/min/glightbox.min.css', array(), UNCANNY_REPORTING_VERSION);

        wp_enqueue_script('glightbox', SnC_ASSET_URL . 'scripts/min/glightbox.min.js', array(), UNCANNY_REPORTING_VERSION, true);

        /**
         * Filter the configuration settings for the Tin Canny Lightbox.
         *
         * This filter allows customization of the default Lightbox behavior.
         *
         * @param array $glighbox_data {
         * Array of configuration options.
         *
         * @type string $closeOnOutsideClick Whether clicking outside the Lightbox should close it.
         *  '0' = disabled, '1' = enabled. Default is '0'.
         * }
         *
         * @return array Modified configuration settings.
         */
        $glighbox_data = apply_filters('uo_tincanny_glightbox_config', array(
            'closeOnOutsideClick' => '0',
        ));

        if (!is_array($glighbox_data)) {
            $glighbox_data = array();
        }

        // Add Tin Canny data
        wp_localize_script('glightbox', 'Tincanny', $glighbox_data);
    }

Scroll to Top