HEX
Server: CentOS WebPanel: Protected by Mod Security
System: Linux sites.annaiservers.com 3.10.0-1160.118.1.el7.x86_64 #1 SMP Wed Apr 24 16:01:50 UTC 2024 x86_64
User: freeval (1012)
PHP: 8.1.10
Disabled: NONE
Upload Files
File: /home/freeval/public_html/wp-content/themes/lovely-blog/functions.php
<?php
/**
 * Lovely Blog functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Lovely Blog
 */

add_theme_support( 'title-tag' );

add_theme_support( 'automatic-feed-links' );

add_theme_support( 'register_block_style' );

add_theme_support( 'register_block_pattern' );

add_theme_support( 'responsive-embeds' );

add_theme_support( 'wp-block-styles' );

add_theme_support( 'align-wide' );

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

add_theme_support(
	'custom-logo',
	array(
		'height'      => 250,
		'width'       => 250,
		'flex-width'  => true,
		'flex-height' => true,
	)
);

if ( ! function_exists( 'lovely_blog_setup' ) ) :
	function lovely_blog_setup() {
		/*
		* Make child theme available for translation.
		* Translations can be filed in the /languages/ directory.
		*/
		load_child_theme_textdomain( 'lovely-blog', get_stylesheet_directory() . '/languages' );
	}
endif;
add_action( 'after_setup_theme', 'lovely_blog_setup' );

if ( ! function_exists( 'lovely_blog_enqueue_styles' ) ) :
	/**
	 * Enqueue scripts and styles.
	 */
	function lovely_blog_enqueue_styles() {
		$parenthandle = 'popular-blog-style';
		$theme        = wp_get_theme();

		wp_enqueue_style(
			$parenthandle,
			get_template_directory_uri() . '/style.css',
			array(
				'popular-blog-fonts',
				'popular-blog-slick-style',
				'popular-blog-fontawesome-style',
				'popular-blog-blocks-style',
			),
			$theme->parent()->get( 'Version' )
		);

		wp_enqueue_style(
			'lovely-blog-style',
			get_stylesheet_uri(),
			array( $parenthandle ),
			$theme->get( 'Version' )
		);

	}

endif;

add_action( 'wp_enqueue_scripts', 'lovely_blog_enqueue_styles' );

require get_theme_file_path() . '/inc/customizer/customizer.php';


 /**
 * Function to display number of posts.
 */
 function getPostViews( $postID ) {
 	$count_key = 'post_views_count';
 	$count     = get_post_meta( $postID, $count_key, true );
 	if ( $count == '' ) {
 		delete_post_meta( $postID, $count_key );
 		add_post_meta( $postID, $count_key, '0' );
 		return '0 View';
 	}
 	return $count;
 }

/**
 * Function to count views.
 */
function setPostViews( $postID ) {
	$count_key = 'post_views_count';
	$count     = get_post_meta( $postID, $count_key, true );
	if ( $count == '' ) {
		$count = 0;
		delete_post_meta( $postID, $count_key );
		add_post_meta( $postID, $count_key, '0' );
	} else {
		$count++;
		update_post_meta( $postID, $count_key, $count );
	}
}

function lovely_blog_load_custom_wp_admin_style() {
	?>
	<style type="text/css">

		.ocdi p.demo-data-download-link {
			display: none !important;
		}

	</style>

	<?php
}
add_action( 'admin_enqueue_scripts', 'lovely_blog_load_custom_wp_admin_style' );

// Style for demo data download link
function lovely_blog_admin_panel_demo_data_download_link() {
	?>
	<style type="text/css">
		p.lovely-blog-demo-data {
			font-size: 16px;
			font-weight: 700;
			display: inline-block;
			border: 0.5px solid #dfdfdf;
			padding: 8px;
			background: #ffff;
		}
	</style>
	<?php
}
add_action( 'admin_enqueue_scripts', 'lovely_blog_admin_panel_demo_data_download_link' );

/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function lovely_blog_body_classes( $classes ) {
	
	// added class for sticky header.
	$fixed_header = get_theme_mod( 'lovely_blog_make_sticky_header', false );
	$classes[]    = $fixed_header === true ? 'header-fixed' : '';

	return $classes;
}
add_filter( 'body_class', 'lovely_blog_body_classes' );

/**
 * Widgets.
 */
require get_theme_file_path() . '/inc/widgets/widgets.php';

// One Click Demo Import after import setup.
if ( class_exists( 'OCDI_Plugin' ) ) {
	require get_theme_file_path() . '/inc/demo-import.php';
}