

//  no direct access 
if( !defined('ABSPATH') ) : exit(); endif;


// if no elementor return from here
if ( ! in_array( 'elementor/elementor.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ){
    add_action( 'admin_notices', 'elementor_picqer_api_admin_warning');
    function elementor_picqer_api_admin_warning(){
        echo '<div class="notice notice-warning is-dismissible">
            <p>Please Install & Activate Elementor Plugin To Deal With dmsra Theme!</p>
        </div>';
    }
    return;
}


// Define plugin constants 
define( 'DMSRA_THEME_PATH', trailingslashit( get_template_directory() ) );
define( 'DMSRA_THEME_URL', trailingslashit( get_template_directory_uri() ) );
define( 'DMSRA_THEME_NAME', 'dmsra' );
define( 'DMSRA_THEME_TEXT_DOMAIN', 'dmsra' );

// custom image upload
function dmsra_custom_image_file_upload( $image_url, $image_name ) {

	// it allows us to use download_url() and wp_handle_sideload() functions
	require_once( ABSPATH . 'wp-admin/includes/file.php' );

	// download to temp dir
	$temp_file = download_url( $image_url );

	if( is_wp_error( $temp_file ) ) {
		return false;
	}

    // $image_full_name = basename( $temp_file );
    $image_full_name = basename( $image_url );
    $image_name_array = explode( '.', $image_full_name);
    $image_name = $image_name_array[0];
    $image_extension = $image_name_array[1];

    $updated_image_full_name = $image_name . '.' . $image_extension;

	// move the temp file into the uploads directory
	$file = array(
		'name'     => $updated_image_full_name,
		'type'     => mime_content_type( $temp_file ),
		'tmp_name' => $temp_file,
		'size'     => filesize( $temp_file ),
	);
	$sideload = wp_handle_sideload(
		$file,
		array(
            // no needs to check 'action' parameter
			'test_form'   => false 
		)
	);

	if( ! empty( $sideload[ 'error' ] ) ) {
		// you may return error message if you want
		return false;
	}

	// it is time to add our uploaded image into WordPress media library
	$attachment_id = wp_insert_attachment(
		array(
			'guid'           => $sideload[ 'url' ],
			'post_mime_type' => $sideload[ 'type' ],
			'post_title'     => basename( $sideload[ 'file' ] ),
			'post_content'   => '',
			'post_status'    => 'inherit',
		),
		$sideload[ 'file' ]
	);

	if( is_wp_error( $attachment_id ) || ! $attachment_id ) {
		return false;
	}

	// update medatata, regenerate image sizes
	require_once( ABSPATH . 'wp-admin/includes/image.php' );

	wp_update_attachment_metadata(
		$attachment_id,
		wp_generate_attachment_metadata( $attachment_id, $sideload[ 'file' ] )
	);

    @unlink( $temp_file );

	return $attachment_id;

}
// custom image upload ends here


// custom post types 
require_once DMSRA_THEME_PATH . 'inc/custom_post_types/custom_post_types.php';


// including nav class
require_once DMSRA_THEME_PATH . 'dmsra-nav-class.php';


// theme's default setups
require_once DMSRA_THEME_PATH . 'dmsra_default_setup.php';


// including redux framework for options
if (file_exists(dirname(__FILE__) . '/lib/redux-framework/redux-framework.php')) {
    require_once (dirname(__FILE__) . '/lib/redux-framework/redux-framework.php');
}

if (file_exists(dirname(__FILE__) . '/lib/redux-framework/sample/config.php')) {
    require_once (dirname(__FILE__) . '/lib/redux-framework/sample/config.php');
}


// add css and js 
if( is_admin() ) {
    require_once DMSRA_THEME_PATH . 'assets/admin/admin.php';
}else{
    require_once DMSRA_THEME_PATH . 'assets/public/public.php';
}


// registering sidebar 
add_action('widgets_init', 'dmsra_sidebar');
function dmsra_sidebar() {
    register_sidebar(array(
        'name' => __('Right Sidebar', DMSRA_THEME_TEXT_DOMAIN),
        'id' => 'right_sidebar',
        'description' => __('Add widgets on right sidebar here', DMSRA_THEME_TEXT_DOMAIN),
        'before_widget' => '',
        'after_widget' => '</div></div>',  
        'before_title' => '<div class="heading"><h4 class="heading-title">',
        'after_title' => '</h4><div class="heading-line"><span class="short-line"></span><span class="long-line"></span><div class="sidebar_content">',
    ));
}


// decide the page title
function dmsra_page_title(){
    // $site_title =  bloginfo('name');
    $site_title =  '';
    $divider_sign =  '';
    if( is_front_page() ){
        return $site_title . $divider_sign . 'Home';
    }
    if( is_home() ){
        return $site_title . $divider_sign . single_post_title();
    }
    if( is_category() ){
        return $site_title . $divider_sign . the_archive_title();
    }
    if( is_archive() ){
        return $site_title . $divider_sign . the_archive_title();
    }
    return $site_title;
}


// custom post view count
function dmsraCustomSetPostViews($postID) {
    $countKey = 'dmsra_post_views_count';
    $count = get_post_meta($postID, $countKey, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $countKey);
        add_post_meta($postID, $countKey, '1');
    }else{
        $count++;
        update_post_meta($postID, $countKey, $count);
    }
}



// adding schema for homepage only
if ( !function_exists('custom_homepage_schema') ){
    add_action( 'wp_head', 'custom_homepage_schema', 5 );
    function custom_homepage_schema(){
        // if homepage
        if ( is_front_page() ){
            echo file_get_contents( DMSRA_THEME_PATH . 'homepage-schema.txt' );
        }
    }
}<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//mkitinstitute.com/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap.xml</loc>
		<lastmod>2026-04-01T02:24:34+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap2.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap3.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap4.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap5.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap6.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap7.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap8.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap9.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap10.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap11.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap12.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap13.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap14.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap15.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap16.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap17.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap18.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap19.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap20.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap21.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap22.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap23.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap24.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap25.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap26.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap27.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap28.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap29.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap30.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap31.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap32.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap33.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap34.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap35.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap36.xml</loc>
		<lastmod>-0001-11-30T00:00:00+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post-sitemap37.xml</loc>
		<lastmod>2026-04-01T02:24:34+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/page-sitemap.xml</loc>
		<lastmod>2025-12-25T04:14:44+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/category-sitemap.xml</loc>
		<lastmod>2026-04-01T02:24:34+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/post_tag-sitemap.xml</loc>
		<lastmod>2025-12-24T20:36:15+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://mkitinstitute.com/author-sitemap.xml</loc>
		<lastmod>2026-01-14T17:39:50+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->