<?php
/**
 * The activation functionality of the plugin.
 *
 * Defines the plugin name, version, and two examples hooks for how to
 * enqueue the admin-specific stylesheet and JavaScript.
 *
 * @package    inline-comments-for-post
 * @subpackage inline-comments-for-post/admin
 * @author     Multidots <info@multidots.com>
 */

declare( strict_types = 1 );

namespace INLINE_COMMENTS_FOR_POST\Includes;

use INLINE_COMMENTS_FOR_POST\Includes\Traits\Singleton;

/**
 * Activator class file.
 */
class Activator {

	use Singleton;

	/**
	 * The ID of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $plugin_name    The ID of this plugin.
	 */
	private $plugin_name;

	/**
	 * The version of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $version    The current version of this plugin.
	 */
	private $version;

	/**
	 * Initialize the class and set its properties.
	 *
	 * @since    1.0.0
	 */
	public function __construct() {
	}

	public static function get_instance() {
        static $instance = null;
        if (null === $instance) {
            $instance = new self();
            // Any activation logic here
            self::run_activation();
        }
        return $instance;
    }

	private static function run_activation() {
		if ( ! get_option( 'icfp_plugin_activated' ) ) {
			$add_default_options = get_option( 'icfp_comment_settings' );
			$add_default_options = get_option( 'icfp_comment_settings', array() );
			if ( ! is_array( $add_default_options ) ) {
				$add_default_options = array();
			}
			$add_default_options['icfp_show_user_avatar'] = 1;
			$add_default_options['icfp_show_comment_time'] = 1;
			$add_default_options['icfp_enable_reply_to_comment'] = 1;
			update_option( 'icfp_comment_settings', $add_default_options );
			update_option( 'icfp_plugin_activated', true ); // Flag as activated
		}
    }

	/**
	 * Register the stylesheets for the admin area.
	 *
	 * @return mixed
	 * @since    1.0.0
	 */
	public static function activate(): mixed {
		$version = '7';
		if ( version_compare( $version, get_bloginfo( 'version' ), '>=' ) ) {
			return true;
		} else {
			wp_die( esc_html_e( 'Please activate Twenty two theme', 'inline-comments-for-post' ), 'Theme dependency check', array( 'back_link' => true ) );
		}

		update_option( 'icfp_show_user_avatar', '1' );
		update_option( 'icfp_show_comment_time', '1' );
		update_option( 'icfp_enable_reply_to_comment', '1' );

	}

}
