<?php
namespace Sifency_Addons\Includes\Admin;

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

class Sifency_Addons_Admin_Widgets {
	/**
	 * Renders a generic admin notice.
	 *
	 * @param string $message The message to display.
	 * @param string $class   The class for the notice div (e.g., 'notice-warning', 'notice-error').
	 */
	public static function render_sifency_admin_notice( $message, $class = 'notice-warning' ) {
		if ( isset( $_GET['activate'] ) && check_admin_referer( 'sifency_notice_action' ) ) {
			wp_safe_redirect( remove_query_arg( array( 'activate', '_wpnonce' ) ) );
			exit;
		}
		
		printf( '<div class="notice %1$s is-dismissible"><p>%2$s</p></div>', esc_attr( $class ), wp_kses_post( $message ) );
	}

	/**
	 * Loads the widget configuration array from its dedicated file.
	 * This is used to build the settings page.
	 *
	 * @return array A list of all available widgets.
	 */
	public static function get_all_sifency_widgets_for_settings() {
		$widgets_config_path = SIFENCY_ADDONS_DIR . 'includes/elementor/sifency-widgets.php';
        
		if ( file_exists( $widgets_config_path ) ) {
			return include $widgets_config_path;
		}
		
		return [];
	}
}