<?php
/**
 * Plugin Name:       Author Website Templates
 * Plugin URI:		  https://rswpthemes.com/author-portfolio-pro-wordpress-theme/
 * Description:       Effortlessly design stunning websites for authors, writers, publishers, and bloggers with Elementor using Author Website Templates.
 * Version:           1.1.9
 * Requires at least: 4.9
 * Requires PHP:      8.1
 * Author:            RS WP THEMES
 * Author URI:        https://rswpthemes.com
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       author-website-templates
 */

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

// Plugin Constants
if (!defined('RSWPTHEMES_AWT_PLUGIN_URL')) {
    define('RSWPTHEMES_AWT_PLUGIN_URL', plugin_dir_url(__FILE__));
}

if (!defined('RSWPTHEMES_AWT_PLUGIN_PATH')) {
    define('RSWPTHEMES_AWT_PLUGIN_PATH', plugin_dir_path(__FILE__));
}

// Legacy Version Constant (Use class constant instead where possible)
$getplugindata = get_file_data(__FILE__, array('Version' => 'Version'), false);
if (!defined('RSWPTHEMES_AWT_VERSION')) {
    define('RSWPTHEMES_AWT_VERSION', $getplugindata['Version']);
}

// Load Main Class
require_once RSWPTHEMES_AWT_PLUGIN_PATH . 'includes/core/class-awt-loader.php';

// Instantiate
Rswpthemes_Author_Website_Templates::instance();

// functions.php বা প্লাগিন ফাইলে
add_filter('render_block', function ($block_content, $block) {

    if (!isset($block['blockName']) || strpos($block['blockName'], 'awt/') !== 0) {
        return $block_content;
    }

    $is_rest_request = defined('REST_REQUEST') && REST_REQUEST;

    if (!is_admin() && !$is_rest_request) {
        return '<div class="awt-wrapper">' . $block_content . '</div>';
    }

    return $block_content;
}, 10, 2);