<?php // phpcs:ignore
/**
 * Mhub_Admin Class
 *
 * This class defines the administration functionality for the Meeting Hub plugin.
 *
 * @package SOVLIX\MHUB
 */

namespace SOVLIX\MHUB;



// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! class_exists( 'Mhub_Admin' ) ) {
	/**
	 * Mhub_Admin Class
	 *
	 * Responsible for handling administration-related tasks for the Meeting Hub plugin.
	 *
	 * @since 1.0.0
	 */
	class Mhub_Admin {
		/**
		 * Mhub_Admin constructor.
		 *
		 * Initializes the admin class.
		 */
		public function __construct() {
			new Admin\Mhub_Menu();
			new Admin\Mhub_Notices();

			add_filter( 'plugin_action_links', array( $this, 'mhub_settings_link' ), 11, 2 );
		}

		/**
		 * Adds a "Settings" link to the plugin actions on the WordPress Plugins page.
		 *
		 * This function is a WordPress filter function that specifically targets the "Meeting Hub" plugin.
		 *
		 * @param array  $actions     The existing array of action links for the plugin.
		 * @param string $plugin_file The file path of the plugin being processed.
		 *
		 * @return array The modified array of action links, including the additional "Settings" link if the plugin is "Meeting Hub".
		 *
		 * @since 1.2.0
		 */
		public function mhub_settings_link( $actions, $plugin_file ) {
			if ( 'meetinghub/meetinghub.php' === $plugin_file ) {
				$settings_link = '<a href="' . admin_url( 'admin.php?page=meetinghub-settings' ) . '">' . esc_html__( 'Settings', 'meetinghub' ) . '</a>';
				if ( ! in_array( $settings_link, $actions, true ) ) {
					array_push( $actions, $settings_link );
				}
			}

			return $actions;
		}


	}
}
