Sindbad~EG File Manager

Current Path : /home/infinitibizsol/public_html/wp-content/themes/infiniti-biz-solutions/
Upload File :
Current File : /home/infinitibizsol/public_html/wp-content/themes/infiniti-biz-solutions/functions.php

<?php
/**
 * Infiniti Biz Solutions functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Infiniti_Biz_Solutions
 */
 
 
 global $get_in_touch;
 global $get_in_touch_url;
 global $bg;
 $get_in_touch  = "Request Demo";
 $get_in_touch_url = "/request-demo/";
 $request_demo_heading = "Request Demo";
 
 $bg = "/wp-content/uploads/2023/02/bg-bg-bg.jpg";


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 infiniti_biz_solutions_setup() {
	/*
		* Make theme available for translation.
		* Translations can be filed in the /languages/ directory.
		* If you're building a theme based on Infiniti Biz Solutions, use a find and replace
		* to change 'infiniti-biz-solutions' to the name of your theme in all the template files.
		*/
	load_theme_textdomain( 'infiniti-biz-solutions', 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(
			'menu-1' => esc_html__( 'Primary', 'infiniti-biz-solutions' ),
		)
	);

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

/**
 * Register widget area.
 *
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
 */
function infiniti_biz_solutions_widgets_init() {
	register_sidebar(
		array(
			'name'          => esc_html__( 'Sidebar', 'infiniti-biz-solutions' ),
			'id'            => 'sidebar-1',
			'description'   => esc_html__( 'Add widgets here.', 'infiniti-biz-solutions' ),
			'before_widget' => '<section id="%1$s" class="widget %2$s">',
			'after_widget'  => '</section>',
			'before_title'  => '<h2 class="widget-title">',
			'after_title'   => '</h2>',
		)
	);
	register_sidebar( array(
		'name'          => __( 'Post Left Sidebar', 'infiniti-biz-solutions' ),
		'id'            => 'post-left-sidebar',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
	register_sidebar( array(
		'name'          => __( 'Post Right Sidebar', 'infiniti-biz-solutions' ),
		'id'            => 'post-right-sidebar',
		'before_widget' => '<aside id="%1$s" class="">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
}
add_action( 'widgets_init', 'infiniti_biz_solutions_widgets_init' );

/**
 * Enqueue scripts and styles.
 */
function infiniti_biz_solutions_scripts() {
	wp_enqueue_style( 'infiniti-biz-solutions-style', get_stylesheet_uri(), array(), _S_VERSION );
	wp_style_add_data( 'infiniti-biz-solutions-style', 'rtl', 'replace' );

	wp_enqueue_script( 'infiniti-biz-solutions-navigation', get_template_directory_uri() . '/js/navigation.js', array(), _S_VERSION, true );

	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}
}
add_action( 'wp_enqueue_scripts', 'infiniti_biz_solutions_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';

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

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

// if(isset($_REQUEST['submit'])){  
//     $post_information = array(  
//       'post_title' =>  $_POST['postTitle'] ,  
//       'post_content' => $_POST['postContent'],  
//       'post_type' => 'page',  
//       'post_status' => 'pending'  
//   );  
//  $post_id = wp_insert_post( $post_information );  
//  if ( $post_id ) {  
//       wp_redirect( home_url() );// Here give your thank you page url.  
//       exit;  
//   }  
// }  


function awesome_excerpt() {
    if( ! $raw_excerpt ) {
        $content = apply_filters( 'the_content', get_the_content() );
        $text = substr( $content, 0, strpos( $content, '</p>' ) + 4 );
        remove_filter($text,'wpautop');
    }    
    return $text;
}
add_filter( 'wp_trim_excerpt', 'awesome_excerpt', 10, 2 );

function wpbeginner_numeric_posts_nav() {
  $post_type = get_post_type($post);
  
    if( is_singular() || is_page('Blog'))
        return;
  
    global $wp_query;
  
    /** Stop execution if there's only 1 page */
    if( $wp_query->max_num_pages <= 1 )
        return;
  
    $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
    $max   = intval( $wp_query->max_num_pages );
  
    /** Add current page to the array */
    if ( $paged >= 1 )
        $links[] = $paged;
  
    /** Add the pages around the current page to the array */
    if ( $paged >= 3 ) {
        $links[] = $paged - 1;
        $links[] = $paged - 2;
    }
  
    if ( ( $paged + 2 ) <= $max ) {
        $links[] = $paged + 2;
        $links[] = $paged + 1;
    }
  
    echo '<div class="Page navigation"><ul class="pagination pagination-sm justify-content-end">' . "\n";
  
    /** Previous Post Link */
    if ( get_previous_posts_link() )
        printf( '<li class="btn btn-outline-secondary btn-sm mb-2 rounded-pill" style="margin-top:0px;">%s</li>' . "\n", get_previous_posts_link() );
  
    /** Link to first page, plus ellipses if necessary */
    if ( ! in_array( 1, $links ) ) {
        $class = 1 == $paged ? ' class="active"' : '';
  
        printf( '<li%s  class="page-item"><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
  
        if ( ! in_array( 2, $links ) )
            echo '<li class="page-item">…</li>';
    }
  
    /** Link to current page, plus 2 pages in either direction if necessary */
    sort( $links );
    foreach ( (array) $links as $link ) {
        $class = $paged == $link ? ' class="page-item active"' : '';
        printf( '<li%s class="page-item"><a class="page-link active" href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
    }
  
    /** Link to last page, plus ellipses if necessary */
    if ( ! in_array( $max, $links ) ) {
        if ( ! in_array( $max - 1, $links ) )
            echo '<li class="page-item">…</li>' . "\n";
  
        $class = $paged == $max ? ' class="page-item active"' : '';
        printf( '<li%s class="page-item"><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
    }
  
    /** Next Post Link */
    if ( get_next_posts_link() )
        printf( '<li class="btn btn-outline-secondary btn-sm mb-2 rounded-pill" style="margin-top:0px;">%s</li>' . "\n", get_next_posts_link() );
  
    echo '</ul></div>' . "\n";
  
}
// add_action( '', 'wpbeginner_numeric_posts_nav' );


function wpbeginner_numeric_posts_nav_cat() {
  $post_type = get_post_type($post);
  
    if( is_singular() || is_page('Blog'))
        return;
  
    global $wp_query;
    $categories = get_the_category();
    $category_id = $categories[0]->cat_ID;
        $cat = get_category($category_id);
        // return $cat->count;
        // $cat->count;
    
    $countcatpostspage = intval($cat->count / 5);
    $div = $cat->count / 5;
    if( $countcatpostspage >= 1 ){
        if($div > $countcatpostspage){
            $countcatpostspage = $countcatpostspage + 1;
        }
    }
// wp_die($countcatpostspage);
    /** Stop execution if there's only 1 page */
    if( $countcatpostspage <= 1 )
        return;
  
    $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
    $max   = intval( $countcatpostspage );
  
    /** Add current page to the array */
    if ( $paged >= 1 )
        $links[] = $paged;
  
    /** Add the pages around the current page to the array */
    if ( $paged >= 3 ) {
        $links[] = $paged - 1;
        $links[] = $paged - 2;
    }
  
    if ( ( $paged + 2 ) <= $max ) {
        $links[] = $paged + 2;
        $links[] = $paged + 1;
    }
  
    echo '<div class="Page navigation"><ul class="pagination pagination-sm justify-content-end">' . "\n";
  
    /** Previous Post Link */
    if ( get_previous_posts_link() )
        printf( '<li class="btn btn-outline-secondary btn-sm mb-2 rounded-pill" style="margin-top:0px;">%s</li>' . "\n", get_previous_posts_link() );
  
    /** Link to first page, plus ellipses if necessary */
    if ( ! in_array( 1, $links ) ) {
        $class = 1 == $paged ? ' class="active"' : '';
  
        printf( '<li%s  class="page-item"><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
  
        if ( ! in_array( 2, $links ) )
            echo '<li class="page-item">…</li>';
    }
  
    /** Link to current page, plus 2 pages in either direction if necessary */
    sort( $links );
    foreach ( (array) $links as $link ) {
        $class = $paged == $link ? ' class="page-item active"' : '';
        printf( '<li%s class="page-item"><a class="page-link active" href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
    }
  
    /** Link to last page, plus ellipses if necessary */
    if ( ! in_array( $max, $links ) ) {
        if ( ! in_array( $max - 1, $links ) )
            echo '<li class="page-item">…</li>' . "\n";
  
        $class = $paged == $max ? ' class="page-item active"' : '';
        printf( '<li%s class="page-item"><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
    }
  
    /** Next Post Link */
    if ( get_next_posts_link() )
        printf( '<li class="btn btn-outline-secondary btn-sm mb-2 rounded-pill" style="margin-top:0px;">%s</li>' . "\n", get_next_posts_link() );
  
    echo '</ul></div>' . "\n";
  
}

add_filter( "litespeed_media_ignore_remote_missing_sizes", "__return_true" );


function my_theme_screenshot( $screenshot ) { 
    $WP_Theme = new WP_Theme();
    $WP_Theme->get_screenshot( $uri );
    $screenshot = "https://infinitibizsol.com/wp-content/themes/infiniti-biz-solutions/screenshot.png";
    return $screenshot; 
    } 
add_filter( "theme_screenshot", "my_theme_screenshot" );

function allow_svg_mime_types( $mimes ) {
  $mimes['svg'] = 'image/svg+xml';
  $mimes['svgz'] = 'image/svg+xml';
  return $mimes;
}
add_filter( 'upload_mimes', 'allow_svg_mime_types' );

function allow_svg_in_media_library( $response, $attachment, $meta ) {
  $response['ext'] = pathinfo( $response['file'], PATHINFO_EXTENSION );
  $svg_mime_types = array( 'image/svg+xml', 'image/svg+xml-compressed' );
  if ( in_array( $response['type'], $svg_mime_types ) ) {
    $response['mime'] = 'image/svg+xml';
  }
  return $response;
}
add_filter( 'wp_prepare_attachment_for_js', 'allow_svg_in_media_library', 10, 3 );

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists