<?php
/**
 * Plugin Name: Custom Auto Featured Image
 * Description: Automatically generates and sets a featured image for posts using a selected template and the post title.
 * Version:     1.0.0
 * Author:      Shamiul Bishal
 * Author URI:  https://profiles.wordpress.org/shamiulbishal/
 * License:     GPL-2.0+
 * Text Domain: custom-auto-featured-image
 * Domain Path: /languages
 */

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

// Define Plugin Constants
define( 'CAFI_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'CAFI_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'CAFI_VERSION', '1.0.0' );

// Include core plugin files
require_once CAFI_PLUGIN_DIR . 'includes/image-generator.php';
require_once CAFI_PLUGIN_DIR . 'includes/class-cafi-font-manager.php';
require_once CAFI_PLUGIN_DIR . 'includes/helpers.php';
require_once CAFI_PLUGIN_DIR . 'admin/settings-page.php';
require_once CAFI_PLUGIN_DIR . 'admin/post-list.php';

// Activation Hook
register_activation_hook( __FILE__, 'cafi_activate_plugin' );

/**
 * Set up default settings upon plugin activation.
 */
function cafi_activate_plugin() {
    if ( ! get_option( 'cafi_settings' ) ) {
        $default_settings = [
            'template'       => 'min_02',
            'post_types'     => ['post'],
            'text_position'  => 'middle',
            'text_alignment' => 'center',
            'padding_top'    => 60,
            'padding_right'  => 60,
            'padding_bottom' => 60,
            'padding_left'   => 60,
            'font_family'    => 'Raleway',
            'font_weight'    => 'Bold',
            'font_size'      => 60,
            'font_color'     => '#6700b8',
            'enable_plugin'  => 1
        ];
        update_option( 'cafi_settings', $default_settings );
    }
}

// Initialize Plugin
add_action( 'plugins_loaded', 'cafi_init' );

function cafi_init() {
    // Localization is handled automatically in newer WP versions
}
