<?php
/**
 * Plugin Name:       CodexShaper Framework
 * Plugin URI:        https://framework.codexshaper.com
 * Plugin URI:        https://themeforest.net/user/codexshaper/portfolio
 * Description:       An MVC framework for WordPress. It's a powerful, modern, and complete framework for building web applications using WordPress.
 * Version:           1.0.0
 * Requires at least: 5.2
 * Requires PHP:      7.2
 * Author:            Codexshaper
 * Author URI:        https://codexshaper.com/
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       codexshaper-framework
 * Domain Path:       /languages
 *
 * @package CodexShaper_Framework
 */

use CodexShaper\Framework\Providers\PluginServiceProvider;

/**
 * If this file is called directly, abort.
 *
 * @package CodexShaper_Framework
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Plugin directory path
 *
 * @package CodexShaper_Framework
 */

if ( ! defined( 'CSMF_VERSION' ) ) {
	define( 'CSMF_VERSION', '1.0.0' );
}

if ( ! defined( 'CSMF_ENV' ) ) {
	define( 'CSMF_ENV', 'prod' );
}

if ( ! defined( 'CSMF_MIN_EXTENSION' ) ) {
	define( 'CSMF_MIN_EXTENSION',  in_array( CSMF_ENV, [ 'dev', 'test', 'staging', 'local' ] ) ? '' : '.min' );
}

if ( ! defined( 'CSMF_FILE' ) ) {
	define( 'CSMF_FILE', trailingslashit( __FILE__ ) );
}

if ( ! defined( 'CSMF_PLUGIN_BASE' ) ) {
	define( 'CSMF_PLUGIN_BASE', trailingslashit( plugin_basename( CSMF_FILE ) ) );
}

if ( ! defined( 'CSMF_PATH' ) ) {
	define( 'CSMF_PATH', trailingslashit( plugin_dir_path( CSMF_FILE ) ) );
}

if ( ! defined( 'CSMF_CONFIG_PATH' ) ) {
	define( 'CSMF_CONFIG_PATH', CSMF_PATH . 'config/' );
}

if ( ! defined( 'CSMF_ASSETS_PATH' ) ) {
	define( 'CSMF_ASSETS_PATH', CSMF_PATH . 'assets/' );
}

if ( ! defined( 'CSMF_WP_ASSETS_PATH' ) ) {
	define( 'CSMF_WP_ASSETS_PATH', CSMF_PATH . 'widgets/wordpress/assets/' );
}

if ( ! defined( 'CSMF_WP_MODULES_PATH' ) ) {
	define( 'CSMF_WP_MODULES_PATH', CSMF_PATH . 'widgets/wordpress/modules/' );
}

if ( ! defined( 'CSMF_ELEMENTOR_ASSETS_PATH' ) ) {
	define( 'CSMF_ELEMENTOR_ASSETS_PATH', CSMF_PATH . 'widgets/elementor/assets/' );
}

if ( ! defined( 'CSMF_ELEMENTOR_MODULES_PATH' ) ) {
	define( 'CSMF_ELEMENTOR_MODULES_PATH', CSMF_PATH . 'widgets/elementor/modules/' );
}

if ( ! defined( 'CSMF_URL' ) ) {
	define( 'CSMF_URL', trailingslashit( plugins_url( '/', CSMF_FILE ) ) );
}

if ( ! defined( 'CSMF_CONFIG_URL' ) ) {
	define( 'CSMF_CONFIG_URL', CSMF_URL . 'config/' );
}

if ( ! defined( 'CSMF_ASSETS_URL' ) ) {
	define( 'CSMF_ASSETS_URL', CSMF_URL . 'assets/' );
}

if ( ! defined( 'CSMF_WP_ASSETS_URL' ) ) {
	define( 'CSMF_WP_ASSETS_URL', CSMF_URL . 'widgets/wordpress/assets/' );
}

if ( ! defined( 'CSMF_WP_MODULES_URL' ) ) {
	define( 'CSMF_WP_MODULES_URL', CSMF_URL . 'widgets/wordpress/modules/' );
}

if ( ! defined( 'CSMF_ELEMENTOR_ASSETS_URL' ) ) {
	define( 'CSMF_ELEMENTOR_ASSETS_URL', CSMF_URL . 'widgets/elementor/assets/' );
}

if ( ! defined( 'CSMF_ELEMENTOR_MODULES_URL' ) ) {
	define( 'CSMF_ELEMENTOR_MODULES_URL', CSMF_URL . 'widgets/elementor/modules/' );
}

if ( ! defined( 'CSMF_WP_MODULE_PREFIX' ) ) {
	define( 'CSMF_WP_MODULE_PREFIX', 'csmf--wp-module' );
}

if ( ! defined( 'CSMF_WP_WIDGET_PREFIX' ) ) {
	define( 'CSMF_WP_WIDGET_PREFIX', 'csmf--wp' );
}

if ( ! defined( 'CSMF_ELEMENTOR_MODULE_PREFIX' ) ) {
	define( 'CSMF_ELEMENTOR_MODULE_PREFIX', 'csmf-' );
}

if ( ! defined( 'CSMF_ELEMENTOR_WIDGET_PREFIX' ) ) {
	define( 'CSMF_ELEMENTOR_WIDGET_PREFIX', 'csmf-' );
}

if ( file_exists( CSMF_PATH . 'vendor/autoload.php' ) ) {
	require_once CSMF_PATH . 'vendor/autoload.php';

	// Initialize core plugin.
	if ( class_exists( '\CodexShaper\Framework\Application' ) ) {
		global $app;

		$app = new CodexShaper\Framework\Application();
		$app->register( PluginServiceProvider::class );
	}
}


if ( ! function_exists( 'csmf_plugin_activate' ) ) {

	function csmf_plugin_activate() {
		flush_rewrite_rules();
	}
}

register_activation_hook( CSMF_FILE, 'csmf_plugin_activate' );