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/classes/notices/DismissNotices.php
<?php

namespace WPML\Notices;

use WPML\Core\WP\App\Resources;

class DismissNotices implements \IWPML_Backend_Action {

	const OPTION    = 'wpml_dismiss_notice';
	const CSS_CLASS = 'wpml_dismiss_notice';

	public function add_hooks() {
		add_action( 'wp_ajax_wpml_dismiss_notice', [ $this, 'toggleDismiss' ] );

		add_action(
			'admin_enqueue_scripts',
			function () {
				wp_enqueue_script(
					'wpml-dismiss-notice',
					ICL_PLUGIN_URL . '/dist/js/notices/app.js',
					[ Resources::vendorAsDependency() ],
					ICL_SITEPRESS_SCRIPT_VERSION
				);
			}
		);
	}

	public function toggleDismiss() {
		$postData = wpml_collect( $_POST );
		$id       = $postData->get( 'id', null );
		if ( ! $id ) {
			return wp_send_json_error( 'ID of notice is not defined' );
		}

		$options        = get_option( self::OPTION, [] );
		$options[ $id ] = $postData->get( 'dismiss', false ) === 'true';

		update_option( self::OPTION, $options );

		return wp_send_json_success();

	}

	/**
	 * @param int $id
	 *
	 * @return bool
	 */
	public function isDismissed( $id ) {
		return wpml_collect( get_option( self::OPTION, [] ) )->get( $id, false );
	}

	/**
	 * @param int $id
	 *
	 * @return string
	 */
	public function renderCheckbox( $id ) {
		return sprintf(
			'<input type="checkbox" class="%s" data-id="%s" />',
			self::CSS_CLASS,
			$id
		);
	}
}