<?php


namespace Fliegerlogin\WpAdmin;


use Fliegerlogin\WpAdmin\Pages\ConfigurePlugin;
use Fliegerlogin\WpAdmin\Pages\WpVereinsflieger;

class WpAdmin {

	public function __construct() {
		$this->setupDependencies();
		$this->setupHooks();
	}

	private function setupDependencies(): void {
	}

	private function setupHooks(): void {
		add_action('admin_menu', [WpVereinsflieger::class, 'setup']);
		add_filter('plugin_action_links_' . plugin_basename(FLIEGERLOGIN_BASE_FILE), [self::class, 'setupPluginActionLinks']);
	}

	public static function setupPluginActionLinks(array $links): array {
		// settings
		$settings_url = esc_url(add_query_arg(
			'page',
			ConfigurePlugin::getSlug(),
			get_admin_url() . 'admin.php'
		));
		array_unshift($links, '<a href="' . $settings_url . '">' . __('Settings', 'sso-for-vereinsflieger') . '</a>');

		return $links;
	}

	private static $admin = null;
	public static function init(): self {
		if (!self::$admin) {
			self::$admin = new self();
		}

		return self::$admin;
	}

}