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/wpml-string-translation/inc/admin-texts/UI.php
<?php

namespace WPML\ST\AdminTexts;

use WPML\Ajax\ST\AdminText\Register;
use WPML\Collect\Support\Collection;
use WPML\FP\Obj;
use WPML\FP\Fns;
use WPML\ST\WP\App\Resources;
use function WPML\Container\make;
use WPML\LIB\WP\Hooks as WPHooks;
use function WPML\FP\pipe;

class UI implements \IWPML_Backend_Action_Loader {

	// shouldShow :: Collection -> bool
	public static function shouldShow( Collection $data ) {
		if ( ! current_user_can( 'manage_options' ) ) {
			return false;
		}

		return $data->get( 'page' ) === WPML_ST_FOLDER . '/menu/string-translation.php' &&
			(int) $data->get( 'trop' ) === 1;
	}


	public static function localize( Collection $model ) {
		$esc_value = Obj::over( Obj::lensProp( 'value' ), 'esc_js' );

		return [
			'name' => 'wpml_admin_strings',
			'data' => [
				'model'    => $model->map( $esc_value )->toArray(),
				'endpoint' => Register::class,
			],
		];
	}

	/**
	 * @return callable|null
	 */
	public function create() {
		if ( self::shouldShow( wpml_collect( $_GET ) ) ) {

			return function() {
				WPHooks::onAction( 'admin_enqueue_scripts' )
					->then( [ make( \WPML_Admin_Texts::class ), 'getModelForRender' ] )
					->then( [ self::class, 'localize' ] )
					->then( Resources::enqueueApp( 'admin-strings' ) );
			};
		}
		return null;
	}
}