Skip to content

Commit

Permalink
Return early if no lightboxes are used
Browse files Browse the repository at this point in the history
  • Loading branch information
ocean90 committed Nov 7, 2024
1 parent d1bc811 commit 138d07b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ function enable_lightbox_for_images( string $content ): string {
$link->setAttribute( 'data-group', $image_id );
}

// Return original content if no lightboxes were added.
if ( 0 === $lightboxes ) {
return $content;
}

// Strip XML tag, internal encoding placeholders and stray end tags of void elements unknown to libxml2.
$document_html = trim(
str_replace(
Expand All @@ -167,7 +172,7 @@ function enable_lightbox_for_images( string $content ): string {

// phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase

if ( $lightboxes > 0 && ! wp_script_is( 'required-tobii-integration' ) ) {
if ( ! wp_script_is( 'required-tobii-integration' ) ) {
wp_add_inline_script(
'required-tobii-integration',
sprintf(
Expand Down

0 comments on commit 138d07b

Please sign in to comment.