MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 8.0.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/imenso.imenso.co/wp-content/themes/imensosoftware/functions.php
<?php
/**
 * imensosoftware functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package imensosoftware
 */

if ( ! defined( '_S_VERSION' ) ) {
	// Replace the version number of the theme on each release.
	define( '_S_VERSION', '1.0.0' );
}

/**
 * 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 imensosoftware_setup() {
	/*
		* Make theme available for translation.
		* Translations can be filed in the /languages/ directory.
		* If you're building a theme based on imensosoftware, use a find and replace
		* to change 'imensosoftware' to the name of your theme in all the template files.
		*/
	load_theme_textdomain( 'imensosoftware', 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' );

	// This theme uses wp_nav_menu() in one location.
	register_nav_menus(
		array(
			'header_menu' => esc_html__( 'Header', 'imensosoftware' ),
			'footer_menu' => esc_html__( 'Footer', 'imensosoftware' ),
		)
	);

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

	// Set up the WordPress core custom background feature.
	add_theme_support(
		'custom-background',
		apply_filters(
			'imensosoftware_custom_background_args',
			array(
				'default-color' => 'ffffff',
				'default-image' => '',
			)
		)
	);

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

/**
 * Register widget area.
 *
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
 */
function imensosoftware_widgets_init() {
	register_sidebar(
		array(
			'name'          => esc_html__( 'Sidebar', 'imensosoftware' ),
			'id'            => 'sidebar-1',
			'description'   => esc_html__( 'Add widgets here.', 'imensosoftware' ),
			'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', 'imensosoftware_widgets_init' );

/**
 * Enqueue scripts and styles.
 */
function imensosoftware_scripts() {
	
	//wp_style_add_data( 'imensosoftware-style', 'rtl', 'replace' );

	

	//Theme CSS
	
	wp_enqueue_style( 'imensosoftware-style', get_stylesheet_uri(), array(), _S_VERSION );
	wp_enqueue_style( 'imensosoftware-bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.min.css', array(), _S_VERSION );
	
	wp_enqueue_style( 'imensosoftware-swiper', 'https://cdnjs.cloudflare.com/ajax/libs/Swiper/5.3.7/css/swiper.min.css', array(), _S_VERSION );
	wp_enqueue_style( 'imensosoftware-aos', 'https://unpkg.com/aos@2.3.1/dist/aos.css', array(), _S_VERSION );

	wp_enqueue_style( 'imensosoftware-custom_style', get_template_directory_uri() . '/assets/css/style.css?time='.time(), array(), _S_VERSION );

	wp_enqueue_style( 'imensosoftware-fontawsome', get_template_directory_uri() . '/assets/css/font-awesome.css', array(), _S_VERSION );

	//Home page CSS
	if ( is_front_page() || is_home() ) {
		wp_enqueue_style( 'imensosoftware-home', get_template_directory_uri() . '/assets/css/home.css', array(), _S_VERSION );
	}

	if ( is_archive() ) {
		//wp_enqueue_style( 'imensosoftware-home', get_template_directory_uri() . '/assets/css/home.css', array(), _S_VERSION );
	}
	
	
	//Theme JS
	wp_enqueue_script( 'imensosoftware-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), _S_VERSION, true );

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

	wp_enqueue_script( 'imensosoftware-jquery', get_template_directory_uri() . '/assets/js/jquery.min.js', array(), _S_VERSION, true );

	//wp_enqueue_script( 'imensosoftware-popper', 'https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js', array(), _S_VERSION, true );
	wp_enqueue_script( 'imensosoftware-bootstrap', 'https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js', array(), _S_VERSION, true );

	/*wp_print_script_tag(
		array(
			'id' => 'imensosoftware-popper',
			'integrity' => 'sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p',
			'src' => esc_url( 'https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js' ),
			'crossorigin' => 'anonymous'
		)
	);
	wp_print_script_tag(
		array(
			'id' => 'imensosoftware-bootstrap',
			'integrity' => 'sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF',
			'src' => esc_url( 'https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js' ),
			'crossorigin' => 'anonymous'
		)
	);*/
	wp_enqueue_script( 'imensosoftware-gsap', 'https://unpkg.co/gsap@3/dist/gsap.min.js', array(), _S_VERSION, true );
	wp_enqueue_script( 'imensosoftware-aos', 'https://unpkg.com/aos@2.3.1/dist/aos.js', array(), _S_VERSION, true );
	wp_enqueue_script( 'imensosoftware-swiper', 'https://unpkg.com/swiper/swiper-bundle.min.js', array(), _S_VERSION, true );
	wp_enqueue_script( 'imensosoftware-custom', get_template_directory_uri() . '/assets/js/custom.js', array(), _S_VERSION, true );
	/*


<script type="text/javascript" src=""></script>
 <!--AOS-->
 <script src=""></script>
<!-- Swiper -->
<script src=""></script>

<!-- Universal Custome css -->
<script src="js/custom.js"></script>
*/


}
add_action( 'wp_enqueue_scripts', 'imensosoftware_scripts' );

/**
 * Implement the Custom Header feature.
 */
require get_template_directory() . '/inc/custom-header.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';

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

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

/**
 * Load More Posts
 */
//require get_template_directory() . '/inc/template-loadmore-post.php';
//https://tutsocean.com/wordpress/wordpress-load-posts-ajax-without-plugin/


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


add_action( 'after_setup_theme', 'set_global_nav_var' );
function set_global_nav_var(){
	
	define( "SITE_URL", esc_url( home_url() ));
	define( "BASE_URL", esc_url( home_url() ));
	define( "THEME_URL", get_template_directory_uri());
	define( "MOBILE_IMAGE_URL", get_template_directory_uri().'/assets/images/mobile');
	define( "DESKTOP_IMAGE_URL", get_template_directory_uri().'/assets/images/desktop');
	define( "TABLAT_IMAGE_URL", get_template_directory_uri().'/assets/images/tablat');
	define( "ASSETS_URL", get_template_directory_uri().'/assets');
	define( "IMAGES_URL", get_template_directory_uri().'/assets/images');
	define( "CSS_URL", get_template_directory_uri().'/assets/css');
	define( "JS_URL", get_template_directory_uri().'/assets/js');

}

/**
 * Allow HTML in term (category, tag) descriptions
 */
foreach ( array( 'pre_term_description' ) as $filter ) {
	remove_filter( $filter, 'wp_filter_kses' );
	if ( ! current_user_can( 'unfiltered_html' ) ) {
		add_filter( $filter, 'wp_filter_post_kses' );
	}
}
 
foreach ( array( 'term_description' ) as $filter ) {
	remove_filter( $filter, 'wp_kses_data' );
}



/**
 * Disable the emoji's
 */
function disable_emojis() {
 remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
 remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
 remove_action( 'wp_print_styles', 'print_emoji_styles' );
 remove_action( 'admin_print_styles', 'print_emoji_styles' ); 
 remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
 remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); 
 remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
 add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
 add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 );
}
add_action( 'init', 'disable_emojis' );

/**
 * Filter function used to remove the tinymce emoji plugin.
 * 
 * @param array $plugins 
 * @return array Difference betwen the two arrays
 */
function disable_emojis_tinymce( $plugins ) {
 if ( is_array( $plugins ) ) {
 return array_diff( $plugins, array( 'wpemoji' ) );
 } else {
 return array();
 }
}

/**
 * Remove emoji CDN hostname from DNS prefetching hints.
 *
 * @param array $urls URLs to print for resource hints.
 * @param string $relation_type The relation type the URLs are printed for.
 * @return array Difference betwen the two arrays.
 */
function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {
 if ( 'dns-prefetch' == $relation_type ) {
 /** This filter is documented in wp-includes/formatting.php */
 $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' );

$urls = array_diff( $urls, array( $emoji_svg_url ) );
 }

return $urls;
}

function wpsites_disable_self_pingbacks( &$links ) {
 foreach ( $links as $l => $link )
 if ( 0 === strpos( $link, get_option( 'home' ) ) )
 unset($links[$l]);
}
add_action( 'pre_ping', 'wpsites_disable_self_pingbacks' );

//Add Preload inCSS files
function preload_filter( $html, $handle ){
    if (strcmp($handle, 'preload-style') == 0) {
        
    }
    $html = str_replace("rel='stylesheet'", "rel='preload stylesheet' as='style' ", $html);
    return $html;
    //return ''
}
add_filter( 'style_loader_tag',  'preload_filter', 10, 3 );

/* Disable WordPress Admin Bar for all users */
add_filter( 'show_admin_bar', '__return_false' );

//Remove Archoe page Title  Prefix
add_filter( 'get_the_archive_title_prefix', '__return_empty_string' );