<?php
/**
 * Writer Ancora Framework
 *
 * @package writer_ancora
 * @since writer_ancora 1.0
 */

// Disable direct call
if ( ! defined( 'ABSPATH' ) ) { exit; }

// Framework directory path from theme root
if ( ! defined( 'WRITER_ANCORA_FW_DIR' ) )		    define( 'WRITER_ANCORA_FW_DIR',		'fw' );
if ( ! defined( 'WRITER_ANCORA_THEME_PATH' ) )	    define( 'WRITER_ANCORA_THEME_PATH',	trailingslashit( get_template_directory() ) );
if ( ! defined( 'WRITER_ANCORA_FW_PATH' ) )		    define( 'WRITER_ANCORA_FW_PATH',		WRITER_ANCORA_THEME_PATH . WRITER_ANCORA_FW_DIR . '/' );

// Include theme variables storage
require_once WRITER_ANCORA_FW_PATH . 'core/core.storage.php';

// Theme timing
if ( ! defined( 'WRITER_ANCORA_START_TIME' ) )		define( 'WRITER_ANCORA_START_TIME', microtime(true));		// Framework start time
if ( ! defined( 'WRITER_ANCORA_START_MEMORY' ) )		define( 'WRITER_ANCORA_START_MEMORY', memory_get_usage());	// Memory usage before core loading
if ( ! defined( 'WRITER_ANCORA_START_QUERIES' ) )	    define( 'WRITER_ANCORA_START_QUERIES', get_num_queries());	// DB queries used

// Global variables storage
$WRITER_ANCORA_STORAGE = array(
	'options_prefix' => 'writer_ancora',	// Used as prefix for store theme's options in the post meta and wp options
	'page_template'	=> '',			// Storage for current page template name (used in the inheritance system)
	'widgets_args' => array(		// Arguments to register widgets
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h5 class="widget_title">',
		'after_title'   => '</h5>',
	),
    'allowed_tags'	=> array(		// Allowed tags list (with attributes) in translations
    	'p' => array(),
    	'br' => array(),
    	'b' => array(),
    	'strong' => array(),
    	'i' => array(),
    	'em' => array(),
    	'u' => array(),
    	'a' => array(
			'href' => array(),
			'title' => array(),
			'target' => array(),
			'id' => array(),
			'class' => array()
		),
    	'span' => array(
			'id' => array(),
			'class' => array()
		)
    )	
);

/* Theme setup section
-------------------------------------------------------------------- */
if ( !function_exists( 'writer_ancora_loader_theme_setup' ) ) {
	add_action( 'after_setup_theme', 'writer_ancora_loader_theme_setup', 20 );
	function writer_ancora_loader_theme_setup() {

		writer_ancora_profiler_add_point(esc_html__('After load theme required files', 'writer-ancora'));

		// Before init theme
		do_action('writer_ancora_action_before_init_theme');

		// Load current values for main theme options
		writer_ancora_load_main_options();

		// Theme core init - only for admin side. In frontend it called from header.php
		if ( is_admin() ) {
			writer_ancora_core_init_theme();
		}
	}
}


/* Include core parts
------------------------------------------------------------------------ */


// String utilities. core.strings must be first - we use writer_ancora_str...() in the writer_ancora_get_file_dir()
require_once WRITER_ANCORA_FW_PATH . 'core/core.strings.php';
// File utilities. core.files must be first - we use writer_ancora_get_file_dir() to include all rest parts
require_once WRITER_ANCORA_FW_PATH . 'core/core.files.php';
// Debug utilities
require_once WRITER_ANCORA_FW_PATH . 'core/core.debug.php';

// Include custom theme files
require_once WRITER_ANCORA_THEME_PATH . 'includes/theme.options.php';

// Include core files
require_once WRITER_ANCORA_FW_PATH . 'core/core.admin.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.arrays.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.date.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.html.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.http.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.ini.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.less.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.lists.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.media.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.messages.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.templates.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.theme.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.users.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.wp.php';
require_once WRITER_ANCORA_FW_PATH . 'core/support.attachment.php';
require_once WRITER_ANCORA_FW_PATH . 'core/support.post.php';
require_once WRITER_ANCORA_FW_PATH . 'core/support.post_type.php';
require_once WRITER_ANCORA_FW_PATH . 'core/support.taxonomy.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.customizer/core.customizer.php';
require_once WRITER_ANCORA_FW_PATH . 'core/core.options/core.options.php';

// Include theme-specific plugins and post types
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.contact-form-7.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.elegro-payment.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.essgrids.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.gdpr-compliance.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.gutenberg.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.instagram-feed.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.mailchimp.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.instagram-widget.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.revslider.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.tribe-events.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.trx_updater.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.trx_socials.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.visual-composer.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.woocommerce.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/plugin.wpml.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/support.clients.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/support.services.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/support.team.php';
require_once WRITER_ANCORA_THEME_PATH . 'plugins/support.testimonials.php';

// Include theme templates.
// Using get_template_part(), because templates can be replaced in the child theme
get_template_part('templates/404');
get_template_part('templates/attachment');
get_template_part('templates/excerpt');
get_template_part('templates/expert');
get_template_part('templates/masonry');
get_template_part('templates/no-articles');
get_template_part('templates/no-search');
get_template_part('templates/portfolio');
get_template_part('templates/related');
get_template_part('templates/single-portfolio');
get_template_part('templates/single-standard');
get_template_part('templates/single-team');
get_template_part('templates/headers/header_2');
get_template_part('templates/headers/header_8');
get_template_part('templates/headers/header_9');
get_template_part('templates/trx_blogger/accordion');
get_template_part('templates/trx_blogger/date');
get_template_part('templates/trx_blogger/list');
get_template_part('templates/trx_blogger/plain');
get_template_part('templates/trx_blogger/polaroid');
get_template_part('templates/trx_clients/clients-1');
get_template_part('templates/trx_clients/clients-2');
get_template_part('templates/trx_events/events-1');
get_template_part('templates/trx_events/events-2');
get_template_part('templates/trx_form/form_1');
get_template_part('templates/trx_form/form_2');
get_template_part('templates/trx_form/form_custom');
get_template_part('templates/trx_recent_news/news-announce');
get_template_part('templates/trx_recent_news/news-excerpt');
get_template_part('templates/trx_recent_news/news-magazine');
get_template_part('templates/trx_recent_news/news-portfolio');
get_template_part('templates/trx_services/services-1');
get_template_part('templates/trx_services/services-2');
get_template_part('templates/trx_services/services-3');
get_template_part('templates/trx_services/services-4');
get_template_part('templates/trx_services/services-5');
get_template_part('templates/trx_team/team-1');
get_template_part('templates/trx_team/team-2');
get_template_part('templates/trx_team/team-3');
get_template_part('templates/trx_team/team-4');
get_template_part('templates/trx_testimonials/testimonials-1');
get_template_part('templates/trx_testimonials/testimonials-2');
get_template_part('templates/trx_testimonials/testimonials-3');
get_template_part('templates/trx_testimonials/testimonials-4');
?>