HEX
Server: LiteSpeed
System: Linux sarajevo.maychu.cloud 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64
User: inqua407 (1189)
PHP: 8.3.17
Disabled: exec,execl,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,ini_alter,proc_open,dl,popen,show_source,posix_getpwuid,getpwuid,posix_geteuid,posix_getegid,posix_getgrgid,open_basedir,safe_mode_include_dir,pcntl_exec,pcntl_fork,proc_get_status,proc_nice,proc_terminate,pclose,virtual,openlog,popen,pclose,virtual,openlog,escapeshellcmd,escapeshellarg,dl,show_source,symlink,mail
Upload Files
File: /home/inqua407/public_html/wp-content/plugins/easy-watermark/src/classes/Dashboard/Dashboard.php
<?php
/**
 * Settings class
 *
 * @package easy-watermark
 */

namespace EasyWatermark\Dashboard;

use EasyWatermark\Core\View;
use EasyWatermark\Traits\Hookable;

/**
 * Settings class
 */
class Dashboard {

	use Hookable;

	/**
	 * Page hook
	 *
	 * @var string
	 */
	private $page_hook;

	/**
	 * Tabs
	 *
	 * @var array
	 */
	private $tabs;

	/**
	 * Current tab
	 *
	 * @var string
	 */
	private $current_tab;

	/**
	 * Constructor
	 */
	public function __construct() {

		$this->hook();

		new Watermarks();
		new Settings();
		new Permissions();
		new Tools();

	}

	/**
	 * Adds options page
	 *
	 * @action admin_menu
	 *
	 * @return void
	 */
	public function add_options_page() {

		$this->page_hook = add_management_page(
			__( 'Easy Watermark', 'easy-watermark' ),
			__( 'Easy Watermark', 'easy-watermark' ),
			'apply_watermark',
			'easy-watermark',
			[ $this, 'page_content' ]
		);

	}

	/**
	 * Returns page hook
	 *
	 * @return string
	 */
	public function get_page_hook() {
		return $this->page_hook;
	}

	/**
	 * Displays options page content
	 *
	 * @return void
	 */
	public function page_content() {

		$current_tab = $this->get_current_tab();
		$tabs        = $this->get_tabs();
		$args        = apply_filters( "easy-watermark/dashboard/{$current_tab}/view-args", [] );
		$content     = new View( "dashboard/pages/{$current_tab}", $args );

		// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
		echo new View( 'dashboard/wrap', [
			'tabs'        => $tabs,
			'current_tab' => $current_tab,
			'content'     => $content,
		] );
		// phpcs:enable

	}

	/**
	 * Display admin notices
	 *
	 * @action admin_notices
	 *
	 * @return void
	 */
	public function admin_notices() {
		if ( get_current_screen()->id !== $this->get_page_hook() ) {
			return;
		}

		$tab = $this->get_current_tab();

		do_action( 'easy-watermark/dashboard/notices', $tab );
		do_action( "easy-watermark/dashboard/{$tab}/notices" );
	}

	/**
	 * Returns tabs array
	 *
	 * @return array
	 */
	private function get_tabs() {
		if ( ! $this->tabs ) {
			$this->tabs = apply_filters( 'easy-watermark/dashboard/tabs', [] );

			uasort( $this->tabs, function( $a, $b ) {
				return $a['priority'] - $b['priority'];
			} );
		}

		return $this->tabs;
	}

	/**
	 * Returns tabs array
	 *
	 * @return array
	 */
	private function get_current_tab() {
		if ( ! $this->current_tab ) {
			$tabs = $this->get_tabs();

			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
			$tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : null;

			if ( null === $tab || ! array_key_exists( $tab, $tabs ) ) {
				reset( $tabs );
				$tab = key( $tabs );
			}

			$this->current_tab = $tab;
		}

		return $this->current_tab;
	}
}