HEX
Server: Apache
System: Linux web15f74.uni5.net 5.4.282-1.el8.elrepo.x86_64 #1 SMP Mon Aug 19 18:33:22 EDT 2024 x86_64
User: lucendi (859622)
PHP: 7.4.33
Disabled: apache_child_terminate,c99_buff_prepare,c99_sess_put,dl,exec,leak,link,myshellexec,openlog,passthru,pclose,pcntl_exec,php_check_syntax,php_strip_whitespace,popen,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,symlink,system,socket_listen,socket_create_listen,putenv
Upload Files
File: /home/lucendi/www/wp-content/plugins/mesmerize-companion/src/Customizer/Settings/ObjectSetting.php
<?php

namespace Mesmerize\Customizer\Settings;

class ObjectSetting extends \Mesmerize\Customizer\BaseSetting {

	private $settingPattern = '';

	public function init() {
		$this->settingPattern = '/' . $this->id . '\[(.*)\]/s';

		$controls = isset( $this->cpData['controlsMap'] ) ? $this->cpData['controlsMap'] : array();

		if ( isset( $this->cpData['title'] ) ) {
			$titleControl = array(
				'cp__element__title' => array(
					'class'   => '\\Mesmerize\\Customizer\\Controls\\LabelControl',
					'wp_data' => array(
						'label' => $this->cpData['title'],
					),
				),
			);

			$controls = array_merge( $titleControl, $controls );
		}

		foreach ( $controls as $key => $value ) {
			$this->companion()->customizer()->registerSettings(
				$this->manager,
				array(
					"{$this->id}[{$key}]" => array(
						'section' => $this->cpData['section'],
						'wp_data' => array(
							'default'  => $this->companion()->getCustomizerData( "customizer:settings:{$this->id}:wp_data:default:{$key}" ),
							'tranport' => $this->transport,
						),
						'control' => $value,
					),
				)
			);
		}

		add_filter( 'cloudpress\customizer\temp_mod_exists', array( $this, 'tempKeyExists' ), 10, 2 );
		add_filter( 'cloudpress\customizer\temp_mod_content', array( $this, '_tempContent' ), 10, 2 );
	}

	public function tempKeyExists( $value, $mod ) {
		return ( $value || ( $mod === $this->id ) );
	}


	public function _tempContent( $value, $mod ) {
		if ( $mod === $this->id ) {
			return $this->tempContent();
		}

		return $value;
	}

	public function tempContent() {
		$settings = $this->manager->unsanitized_post_values();

		$result = array();
		foreach ( $settings as $setting => $value ) {
			if ( strpos( $setting, $this->id . '[' ) === 0 ) {
				$matches = array();
				preg_match( $this->settingPattern, $setting, $matches );

				$key            = $matches[1];
				$result[ $key ] = $value;
			}
		}

		$savedData = get_theme_mod( $this->id );
		$result    = array_merge( $savedData, $result );

		return $result;
	}


	public function setControl() {
	}


	public function update( $value ) {
		$value = $this->tempContent();
		$value = array_merge( $value, $currentValue );

		if ( isset( $value['cp__element__title'] ) ) {
			unset( $value['cp__element__title'] );
		}

		if ( isset( $value[ "{$this->id}[cp__element__title]" ] ) ) {
			unset( $value[ "{$this->id}[cp__element__title]" ] );
		}

		set_theme_mod( $this->id, $value );
	}


	public function value() {
		if ( $this->is_previewed ) {
			$value = $this->tempContent();
		} else {
			$mod   = $this->id;
			$value = get_theme_mod( $mod, false );
		}

		if ( isset( $value['cp__element__title'] ) ) {
			unset( $value['cp__element__title'] );
		}

		if ( isset( $value[ "{$this->id}[cp__element__title]" ] ) ) {
			unset( $value[ "{$this->id}[cp__element__title]" ] );
		}

		return $value;
	}
}