<?php
/**
 * Name:    Dev4Press\v55\Core\Admin\Help
 * Version: v5.5
 * Author:  Milan Petrovic
 * Email:   support@dev4press.com
 * Website: https://www.dev4press.com/
 *
 * @package Dev4PressLibrary
 *
 * == Copyright ==
 * Copyright 2008 - 2026 Milan Petrovic (email: support@dev4press.com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>
 */

namespace Dev4Press\v55\Core\Admin;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

abstract class Help {
	protected $admin;

	protected function __construct( $admin ) {
		$this->admin = $admin;
	}

	/** @deprecated 5.5.0 Use self::i() instead. */
	public static function instance( $admin ) : static {
		return static::i( $admin );
	}

	public static function i( $admin ) : static {
		static $instance = array();

		if ( ! isset( $instance[ static::class ] ) ) {
			$instance[ static::class ] = new static( $admin );
		}

		return $instance[ static::class ];
	}

	/** @return \Dev4Press\v55\Core\Admin\Plugin|\Dev4Press\v55\Core\Admin\Menu\Plugin|\Dev4Press\v55\Core\Admin\Submenu\Plugin */
	protected function a() {
		return $this->admin;
	}

	protected function panel() : string {
		return $this->a()->panel;
	}

	protected function subpanel() : string {
		return $this->a()->subpanel;
	}

	protected function tab( $code, $title, $content ) {
		$this->a()->screen()->add_help_tab(
			array(
				'id'      => $this->a()->plugin . '-' . $this->a()->panel . '-' . $code,
				'title'   => $title,
				'content' => '<h2>' . $title . '</h2>' . $content,
			)
		);
	}
}
