HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/delta/wp-content/plugins/sitepress-multilingual-cms/inc/plugin-integration-nextgen.php
<?php
/*
 * NextGen Gallery plugin integration.
 *
 * - Filters the_content
 * -- Adjusts gallery preview image URL from default to current language (2.0.66 <=)
 */

class WPML_Plugin_Integration_Nexgen_Gallery {


	function __construct() {
		if ( defined( 'NEXTGEN_GALLERY_PLUGIN_VERSION' ) && version_compare( NEXTGEN_GALLERY_PLUGIN_VERSION, '2.0.66', '<=' ) ) {
			add_filter( 'the_content', array( 'WPML_Plugin_Integration_Nexgen_Gallery', 'the_content_gallery_preview_images' ), 1 );
		}
	}

	/**
	 * Filters post content and fixes gallery preview images URL.
	 *
	 * Adjust gallery preview image URL from default to current language.
	 * Allows NextGen to match and replace preview images with gallery.
	 * NextGen inserts image previews with default language URL.
	 *
	 * @global SitePress $sitepress
	 * @param string $content
	 * @return string
	 */
	public static function the_content_gallery_preview_images( $content ) {
		global $sitepress;
		if ( $sitepress->get_current_language() != $sitepress->get_default_language() ) {
			$default_url     = preg_replace(
				'/(^http[s]?:\/\/)/',
				'',
				$sitepress->language_url( $sitepress->get_default_language() )
			);
			$current_url     = preg_replace( '/(^http[s]?:\/\/)/', '', home_url() );
			$preview_url     = $default_url . 'nextgen-attach_to_post/preview';
			$alt_preview_url = $default_url . 'index.php/nextgen-attach_to_post/preview';
			if ( preg_match_all( "#<img(.*)http(s)?://({$preview_url}|{$alt_preview_url})/id--(\\d+)(.*)\\/>#mi", $content, $matches, PREG_SET_ORDER ) ) {
				foreach ( $matches as $match ) {
					$content = str_replace( $match[0], "<img{$match[1]}http{$match[2]}://{$current_url}nextgen-attach_to_post/preview/id--{$match[4]}\"{$match[5]}/>", $content );
				}
			}
		}
		return $content;
	}

}

$wpml_ngg = new WPML_Plugin_Integration_Nexgen_Gallery();