HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux vm8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: afleverb (1000)
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/mussarq_bak/wp-content/themes/wpnull24/framework/plugins-support/wpml.php
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );

/**
 * WPML Support
 *
 * @link https://wpml.org/
 */

if ( ! ( class_exists( 'SitePress' ) AND defined( 'ICL_LANGUAGE_CODE' ) ) ) {
	return;
}

// Add class to body in admin pages in non-default language
global $sitepress;
$default_language = $sitepress->get_default_language();

if ( $default_language != ICL_LANGUAGE_CODE ) {
	global $pagenow;
	// Exception: do not add class on Theme Options page
	if ( ! ( ( $pagenow == 'admin.php' ) AND ( $_GET['page'] == 'us-theme-options' ) ) ) {
		function us_admin_add_wpml_nondefault_class( $class ) {
			return $class . ' us_wpml_non_default';
		}

		add_filter( 'admin_body_class', 'us_admin_add_wpml_nondefault_class' );
	} else {
		// For Theme Options page adding redirect to default language
		wp_redirect( admin_url() . 'admin.php?page=us-theme-options&lang=' . $default_language );
		die();
	}
}

// Remove select2 CSS to avoid overlapping with theme styles
add_action( 'admin_init', 'us_dequeue_wpml_select2' );
function us_dequeue_wpml_select2() {
	global $pagenow;

	if ( ( ( $pagenow == 'admin.php' ) AND ( $_GET['page'] == 'us-theme-options' ) ) OR ( $pagenow === 'post.php' AND isset( $_GET['post'] ) AND ( get_post_type( $_GET['post'] ) === 'us_header' OR get_post_type( $_GET['post'] ) === 'us_grid_layout' ) ) ) {
		wp_dequeue_style( 'wpml-select-2' );
	}
}

// Add support for encoded shortcodes
add_filter( 'wpml_pb_shortcode_encode', 'wpml_pb_shortcode_encode_us_urlencoded_json', 10, 3 );
function wpml_pb_shortcode_encode_us_urlencoded_json( $string, $encoding, $original_string ) {
	if ( $encoding !== 'us_urlencoded_json' ) {
		return $string;
	}

	$output = array();
	foreach ( $original_string as $combined_key => $value ) {
		$parts = explode( '_', $combined_key );
		$i = array_pop( $parts );
		$key = implode( '_', $parts );
		$output[ $i ][ $key ] = $value;
	}

	return urlencode( json_encode( $output ) );

}

add_filter( 'wpml_pb_shortcode_decode', 'wpml_pb_shortcode_decode_us_urlencoded_json', 10, 3 );
function wpml_pb_shortcode_decode_us_urlencoded_json( $string, $encoding, $original_string ) {
	if ( $encoding !== 'us_urlencoded_json' ) {
		return $string;
	}

	$fields_to_translate = array(
		'title',
		'label',
		'description',
		'placeholder',
		'price',
		'substring',
		'features',
		'btn_text',
		'btn_link',
		'image',
		'link',
		'url',
	);
	$rows = json_decode( urldecode( $original_string ), TRUE );
	$result = array();
	foreach ( $rows as $i => $row ) {
		foreach ( $row as $key => $value ) {
			if ( in_array( $key, $fields_to_translate ) ) {
				$result[ $key . '_' . $i ] = array( 'value' => $value, 'translate' => TRUE );
			} else {
				$result[ $key . '_' . $i ] = array( 'value' => $value, 'translate' => FALSE );
			}
		}
	}

	return $result;
}