Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.96.1
Your Ip: 216.73.216.223
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : abstract-api.php
<?php

/**
 * Class Brizy_Admin_AbstractApi
 */
abstract class Brizy_Admin_AbstractApi {

	use Brizy_Editor_Trait_Sanitize;

	abstract protected function initializeApiActions();

	abstract protected function getRequestNonce();

	/**
	 * Brizy_Admin_AbstractApi constructor.
	 */
	public function __construct() {
		$this->initializeApiActions();
	}

	/**
	 * @param $action
	 */
	protected function verifyNonce( $action ) {

		$version = $this->param( 'version' );
		if ( $version !== BRIZY_EDITOR_VERSION ) {
			Brizy_Logger::instance()->critical( 'Request with invalid editor version',
				[
					'editorVersion'   => BRIZY_EDITOR_VERSION,
					'providedVersion' => $version
				] );

			$this->error( 400, "Invalid editor version. Please refresh the page and try again" );
		}

		$this->checkNonce( $action );
	}

	protected function checkNonce( $action ) {
		if ( ! wp_verify_nonce( $this->getRequestNonce(), $action ) ) {
			Brizy_Logger::instance()->error( 'Invalid request nonce', $_REQUEST );
			$this->error( 400, "Bad request" );
		}
	}

	/**
	 * @param int|string $name
	 *
	 * @return null
	 */
	protected function param( $name ) {
		if ( isset( $_REQUEST[ $name ] ) ) {
			return $_REQUEST[ $name ];
		}

		return null;
	}

	/**
	 * @param $code
	 * @param $message
	 */
	protected function error( $code, $message ) {
		wp_send_json_error( $message, $code );
	}

	/**
	 * @param $data
	 */
	protected function success( $data ) {
		wp_send_json_success( $data );
	}
}
© 2025 XylotrechusZ