PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /home/trave494/stockphotos.kerihosting.com/wp-content/themes/stockyr/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : /home/trave494/stockphotos.kerihosting.com/wp-content/themes/stockyr/functions.php

<?php
function remove_update_notifications( $value ) {
    if ( isset( $value ) && is_object( $value ) ) {
        unset( $value->response[ 'easy-digital-downloads/easy-digital-downloads.php' ] );
		unset( $value->response[ 'edd-commissions/edd-commissions.php' ] );
        unset( $value->response[ 'downloadimagewatermark/edd-download-image-watermark.php' ] );
		unset( $value->response[ 'gravityforms/gravityforms.php' ] );
		unset( $value->response[ 'woocommerce/woocommerce.php' ] );
		unset( $value->response[ 'js_composer/js_composer.php' ] );
		unset( $value->response[ 'revslider/revslider.php' ] );
		unset( $value->response[ 'elementor/elementor.php' ] );
		unset( $value->response[ 'elementor-pro/elementor-pro.php' ] );	
    }

    return $value;
}
add_filter( 'site_transient_update_plugins', 'remove_update_notifications' );

add_action( 'init', 'dcs_initialize_cmb_meta_boxes', 9999 );
function dcs_initialize_cmb_meta_boxes() {

	if ( ! class_exists( 'cmb_Meta_Box' ) )
		require_once 'includes/metabox/init.php';

}
	
/* =================================== Related Products =================================== */

function dcs_related_products() {

    global $post;
    $orig_post = $post;
    $tags = wp_get_post_terms($post->ID, 'download_tag');
    
    if ($tags) {
    	$tag_ids = array();
		foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
		$args=array(
			'tax_query' => array(
				array(
				    'taxonomy'  => 'download_tag',
				    'terms'     => $tag_ids,
				    'operator'  => 'IN'
				)
			),
			'post__not_in' => array($post->ID),
			'posts_per_page'=>8,
			'ignore_sticky_posts'=>0,
			'orderby'=>'rand'
		);
    
		$my_query = new wp_query( $args );
    
		if( $my_query->have_posts() ) {

			echo '<div class="related_products_wrap"><div class="box_title"><h3>'. __('Related Products', 'designcrumbs') .'</h3></div><div class="related_products clearfix">';

			while( $my_query->have_posts() ) {
				$my_query->the_post(); ?>

				<?php get_template_part('loop','related'); ?>
				
			<?php }
			
			echo '</div></div>';
		}
    
    }
    
    $post = $orig_post;
    wp_reset_query();

}
	
/* =================================== Count How Many Widgets are in a Sidebar =================================== */

function dcs_count_sidebar_widgets( $sidebar_id, $echo = true ) {
    $the_sidebars = wp_get_sidebars_widgets();
    if( !isset( $the_sidebars[$sidebar_id] ) )
        return __( 'Invalid sidebar ID', 'designcrumbs' );
    if( $echo )
        echo count( $the_sidebars[$sidebar_id] );
    else
        return count( $the_sidebars[$sidebar_id] );
}

// To call it on the front end - dcs_count_sidebar_widgets( 'some-sidebar-id' );

/* =================================== Author Box =================================== */

function dcs_author_box() { ?>

<div class="about_the_author clearfix">
	<?php echo get_avatar( get_the_author_meta('email'), '200' ); ?>
	<div class="author_info clearfix">
		<h3 class="author_title">
			<?php $written_by_string = sprintf( __('This post was written by <a href="%1$s">%2$s</a>', 'designcrumbs'), get_author_posts_url( get_the_author_meta( 'ID' ) ), get_the_author_meta( 'display_name' ) );
			echo $written_by_string; ?>
		</h3>
		<div class="author_about">
			<?php the_author_meta( 'description' ); ?>
		</div>
	</div>
</div>
	
<?php }
	
/* =================================== Featured User Widget =================================== */

class dcs_featured_user_widget extends WP_Widget {

	//function to set up widget in admin
	function dcs_featured_user_widget() {
	
		$widget_ops = array( 'classname' => 'featured-user', 
		'description' => __('A widget that will display a specified user\'s gravatar, display name, bio, and link to their author post archive.', 'designcrumbs') );
		
		$control_ops = array( 'width' => 200, 'height' => 350, 'id_base' => 'featured-user' );
		$this->WP_Widget( 'featured-user', __('Featured User', 'designcrumbs'), $widget_ops, $control_ops );
	
	}

	//function to echo out widget on sidebar
	function widget( $args, $instance ) {
		
		extract( $args );
	
		$title = $instance['title'];
		
		echo $before_widget;
		echo "<div class='featured_user'>";

		// if user written title echo out
		if ( $title ){
		echo $before_title . esc_attr($title) . $after_title;
		}
	    //don't touch this!
		$userid = $instance['user_id'];
		
		//user information array
		//refer to http://codex.wordpress.org/Function_Reference/get_userdata
		$userinfo = get_userdata($userid);
		
		//user meta data
		//refer to http://codex.wordpress.org/Function_Reference/get_user_meta
		$userbio = get_user_meta($userid,'description',true);
		
		//user post url
		//refer to http://codex.wordpress.org/Function_Reference/get_author_posts_url
		$userposturl = get_author_posts_url($userid);	
		
		?>			
		
		<!--Now we print out speciifc user informations to screen!-->
		<div class='specific_user clearfix'>
			<?php echo get_avatar($userid,200); ?>
			<h4 class='featured_user_name'>
				<a href='<?php echo esc_attr( $userposturl ); ?>' title='<?php echo esc_attr($userinfo->display_name); ?>'>
					<?php echo esc_attr($userinfo->display_name); ?>
				</a>
			</h4>
			<?php echo esc_attr( $userbio ); ?>
		</div>
		<!--end-->
		
		<?php

		echo '</div>';
		echo $after_widget;
	
	 }//end of function widget



	//function to update widget setting
	function update( $new_instance, $old_instance ) {
	
		$instance = $old_instance;
		$instance['title'] = strip_tags( $new_instance['title'] );
		$instance['user_id'] = strip_tags( $new_instance['user_id'] );
		return $instance;
	
	}//end of function update


	//function to create Widget Admin form
	function form($instance) {
	
		$instance = wp_parse_args( (array) $instance, array( 'title' => '','user_id' => '') );
		
		$instance['title'] = $instance['title'];
		$instance['user_id'] = $instance['user_id'];
				
		?>

		<p>
			<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Widget Title:', 'designcrumbs'); ?></label> 
			<input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>"
			 type="text" value="<?php echo esc_attr($instance['title']); ?>" />
		</p>
		
		<p>
			<label for="<?php echo esc_attr($this->get_field_id( 'user_id' )); ?>"><?php _e('Select User:', 'designcrumbs'); ?></label> 
			
			<select id="<?php echo esc_attr($this->get_field_id( 'user_id' ));?>" name="<?php echo esc_attr($this->get_field_name( 'user_id' ));?>" class="widefat" style="width:100%;">
			<?php
			$instance = $instance['user_id'];
			$option_list = user_get_users_list_option($instance);
			echo $option_list;
			?>
			</select>
		
		</p>
		
		
	
	<?php } //end of function form($instance)

}//end of  Class

//function to get all users
function user_get_users_list_option($instance){
$output = '';
global $wpdb; 
$users = $wpdb->get_results("SELECT display_name, ID FROM $wpdb->users");
	foreach($users as $u){
    $uname = $u->display_name;
    $uid = $u->ID;
    $output .="<option value='$uid'";
    if($instance == $uid){
    $output.= 'selected="selected"';
    } 
    $output.= ">$uname</option>";
	}
return $output;
}

register_widget('dcs_featured_user_widget');
  
/* =================================== Recent Posts Widget =================================== */

class dcs_widget_recent_posts extends WP_Widget {

    function dcs_widget_recent_posts() {
        $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( 'Displays a grid of thumbnails of your latest products.', 'designcrumbs') );
        $this->WP_Widget('my-recent-posts', __('New Products', 'designcrumbs'), $widget_ops);
        $this->alt_option_name = 'widget_recent_entries';

        add_action( 'save_post', array(&$this, 'flush_widget_cache') );
        add_action( 'deleted_post', array(&$this, 'flush_widget_cache') );
        add_action( 'switch_theme', array(&$this, 'flush_widget_cache') );
    }

    function widget($args, $instance) {
        $cache = wp_cache_get('dcs_widget_recent_posts', 'widget');

        if ( !is_array($cache) )
            $cache = array();

        if ( isset($cache[$args['widget_id']]) ) {
            echo $cache[$args['widget_id']];
            return;
        }

        ob_start();
        extract($args);

        $title = apply_filters('widget_title', empty($instance['title']) ? __('New Products', 'designcrumbs') : $instance['title'], $instance, $this->id_base);
        if ( !$number = (int) $instance['number'] )
            $number = 9;
        else if ( $number < 1 )
            $number = 1;
        else if ( $number > 15 )
            $number = 15;

        $r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'post_type' => 'download'));
        if ($r->have_posts()) : ?>
        <?php echo $before_widget; ?>
        <?php if ( $title ) echo $before_title . esc_attr($title) . $after_title; ?>
        
        <div id="recent_products" class="clearfix">
       
        <?php while ($r->have_posts()) : $r->the_post(); ?>
        	
        	<?php if (has_post_thumbnail()) { ?>
        	<a href="<?php the_permalink(); ?>">
				<?php the_post_thumbnail( 'thumbnail', array( 'alt' => get_the_title()) ); ?>
			</a>
			<?php } ?>
			
        <?php endwhile; ?>
        
        </div>
        
        <?php echo $after_widget;
        
        // Reset the global $the_post as this query will have stomped on it
        wp_reset_postdata();

        endif;

        $cache[$args['widget_id']] = ob_get_flush();
        wp_cache_set('dcs_widget_recent_posts', $cache, 'widget');
    }

    function update( $new_instance, $old_instance ) {
        $instance = $old_instance;
        $instance['title'] = strip_tags($new_instance['title']);
        $instance['number'] = (int) $new_instance['number'];
        $this->flush_widget_cache();

        $alloptions = wp_cache_get( 'alloptions', 'options' );
        if ( isset($alloptions['widget_recent_entries']) )
            delete_option('widget_recent_entries');

        return $instance;
    }

    function flush_widget_cache() {
        wp_cache_delete('dcs_widget_recent_posts', 'widget');
    }

    function form( $instance ) {
        $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
        if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
            $number = 8;
?>
        <p><label for="<?php echo esc_attr($this->get_field_id('title')); ?>"<?php _e('Title:', 'designcrumbs'); ?></label>
        <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>

        <p><label for="<?php echo esc_attr( $this->get_field_id('number')); ?>"><?php _e('Number of posts to show:', 'designcrumbs'); ?></label>
        <input id="<?php echo esc_attr( $this->get_field_id('number') ); ?>" name="<?php echo esc_attr( $this->get_field_name('number') ); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3" /></p>
<?php
    }
}

register_widget('dcs_widget_recent_posts');

/* ====================================================== EDD Ratings ====================================================== */

function dcs_star_ratings() {
	// make sure edd reviews is active
	if ( ! function_exists( 'edd_reviews' ) )
		return;
	
	$edd_reviews = edd_reviews();
	// get the average rating for this download
	$average_rating = (int) $edd_reviews->average_rating( false );	
	$rating = $average_rating;

	ob_start();
	?>
	
		<?php 
		/* Only show the ratings if there are indeed ratings */
		if ('0' != $rating) { ?>
		<div itemprop="reviewRating" class="reviewRating clearfix">
			<div class="edd_reviews_rating_box stars<?php echo esc_attr($rating); ?> clearfix">
				<div>Average Rating</div>
					<?php for ( $i = 1; $i <= $rating; $i++ ) : ?>
					<span class="icon-star icon-star-full"></span>
					<?php endfor; for ( $i = 0; $i < ( 5 - $rating ); $i++ ) : ?>
					<span class="icon-star icon-star-empty"></span>
					<?php endfor; ?>
			</div>
			<div style="display:none" >
				<meta itemprop="worstRating" content="1" />
				<span itemprop="ratingValue"><?php echo esc_attr($rating); ?></span>
				<span itemprop="bestRating">5</span>
			</div>
		</div>
		<?php } ?>

	<?php
	$rating_html = ob_get_clean();

	return $rating_html;
}

function dcs_edd_reviews_rating_box() {
	ob_start();
?>
<span class="edd_reviews_rating_box">
	<span class="edd_ratings">
		<a class="edd_rating" href="" data-rating="5"><i class="icon-star-empty"></i></a>
		<span class="edd_show_if_no_js"><input type="radio" name="edd_rating" id="edd_rating" value="5"/>5&nbsp;</span>

		<a class="edd_rating" href="" data-rating="4"><i class="icon-star-empty"></i></a>
		<span class="edd_show_if_no_js"><input type="radio" name="edd_rating" id="edd_rating" value="4"/>4&nbsp;</span>

		<a class="edd_rating" href="" data-rating="3"><i class="icon-star-empty"></i></a>
		<span class="edd_show_if_no_js"><input type="radio" name="edd_rating" id="edd_rating" value="3"/>3&nbsp;</span>

		<a class="edd_rating" href="" data-rating="2"><i class="icon-star-empty"></i></a>
		<span class="edd_show_if_no_js"><input type="radio" name="edd_rating" id="edd_rating" value="2"/>2&nbsp;</span>

		<a class="edd_rating" href="" data-rating="1"><i class="icon-star-empty"></i></a>
		<span class="edd_show_if_no_js"><input type="radio" name="edd_rating" id="edd_rating" value="1"/>1&nbsp;</span>
	</span>
</span>
<?php
	return ob_get_clean();
}
add_filter( 'edd_reviews_rating_box', 'dcs_edd_reviews_rating_box' );

function dcs_edd_reviews_ratings_html( $rating_html, $comment) {
	
	$rating = get_comment_meta( $comment->comment_ID, 'edd_rating', true );
	
	ob_start();
	
	?>
<span itemprop="name" class="review-title-text"><?php echo get_comment_meta( $comment->comment_ID, 'edd_review_title', true ); ?></span>

<div itemprop="reviewRating" class="reviewRating clearfix">
	<div class="edd_reviews_rating_box stars<?php echo esc_attr($rating); ?> clearfix">
		<?php for ( $i = 1; $i <= $rating; $i++ ) : ?>
		<span class="icon-star icon-star-full"></span>
		<?php endfor; for ( $i = 0; $i < ( 5 - $rating ); $i++ ) : ?>
		<span class="icon-star icon-star-empty"></span>
		<?php endfor; ?>
	</div>
	<div style="display:none" >
		<meta itemprop="worstRating" content="1" />
		<span itemprop="ratingValue"><?php echo esc_attr($rating); ?></span>
		<span itemprop="bestRating">5</span>
	</div>
</div>
<?php
	return ob_get_clean();
}
add_filter( 'edd_reviews_ratings_html', 'dcs_edd_reviews_ratings_html', 10, 2 );

/* ====================================================== EDD STUFF ====================================================== */

// filter the EDD downloads shortcode
function dcs_shortcode_atts_downloads( $atts ) {
	$atts[ 'full_content' ] = false;
	$atts[ 'buy_button' ] = false;
	$atts[ 'excerpt' ] = false;
	$atts[ 'price' ] = false;
	$atts[ 'columns' ] = 0;
	$atts[ 'number' ] = stripslashes(of_get_option('products_total'));
	
	return $atts;
} 
add_filter( 'shortcode_atts_downloads', 'dcs_shortcode_atts_downloads' );

// Set the link on pagination to move to the top of the div, not top of the page
function dcs_paginate_links( $link ) {
	return $link . '#stocky_downloads_list';
}
add_filter( 'paginate_links', 'dcs_paginate_links' );

// add stocky_downloads_list ID to downloads list
function dcs_downloads_shortcode( $display ) {
	$output = str_replace( 'class="edd_downloads_list', 'id="stocky_downloads_list" class="edd_downloads_list', $display );
	
	return $output;
}
add_filter( 'downloads_shortcode', 'dcs_downloads_shortcode' );

// Echo downloads list if EDD is active
function dcs_edd_downloads() {
	if ( function_exists('edd_get_settings') ){
		echo (do_shortcode('[downloads]'));
	}
}

// Echo the Add To Wish List button if plugin is active
function dcs_edd_wishlist() {
	if ( function_exists('EDD_Wish_Lists') ) {
		echo (do_shortcode('[edd_wish_lists_add icon="heart"]'));
	}
}

// Echo class for placement of buttons on masonry image hovers
function dcs_edd_wishlist_class() {
	if ( function_exists('EDD_Wish_Lists') ) {
		echo 'stocky_wish_list_on';
	}
}

// Set number of posts for downloads archives
function dcs_downloads_archive_number($query) {
    if ($query->is_main_query() && $query->is_post_type_archive('download') && !is_admin() || (((is_tax('download_tag')) || (is_tax('download_category')))))
        $query->set('posts_per_page', stripslashes(of_get_option('products_total')));
}
add_action('pre_get_posts', 'dcs_downloads_archive_number');

// change the size of the featured review avatar
function dcs_edd_reviews_widget_avatar_size( $size ) {
	return 120;
}
add_filter( 'edd_reviews_widget_avatar_size', 'dcs_edd_reviews_widget_avatar_size' );

/* ====================================================== COMMENTS ====================================================== */

function custom_comment($comment, $args, $depth) {
       $GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID( ); ?>">
<div class="the_comment clearfix">
<?php if(function_exists('get_avatar')) { echo get_avatar($comment, '120'); } ?>
<div class="the_comment_author">
	<?php if ('download' != get_post_type() ) { $comment_author_string = sprintf( __('<span>%1$s</span> says', 'designcrumbs'), get_comment_author_link() ); } else { $comment_author_string = sprintf( __('Review by <span>%1$s</span>', 'designcrumbs'), get_comment_author_link() ); }
	echo $comment_author_string; ?>
</div>
<?php if ($comment->comment_approved == '0') : //message if comment is held for moderation ?>
<span class="moderation"><?php _e('Your comment is awaiting moderation', 'designcrumbs'); ?>.</span>
<?php endif; ?>
<div class="the_comment_text"><?php comment_text() ?></div>
<small class="commentmetadata">
<a href="<?php comment_link() ?>" class="comment_permalink"><i class="fa fa-clock-o"></i><?php comment_date(get_option( 'date_format' )) ?> - <?php comment_date('g:i a') ?></a>
</small>
<div class="reply">
<?php edit_comment_link( '<i class="fa fa-pencil"></i>' . __('Edit', 'designcrumbs') ); ?><?php echo comment_reply_link(array('reply_text' => '<i class="fa fa-reply"></i>' . __('Reply', 'designcrumbs'), 'depth' => $depth, 'max_depth' => $args['max_depth']));  ?>
</div>
</div>
<?php } ?>
<?php function custom_pings($comment, $args, $depth) {
       $GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID( ); ?>">
<?php _e('Trackback from', 'designcrumbs'); ?> <em><?php comment_author_link() ?></em>
<div class="the_comment_text"><?php comment_text() ?></div>
<small class="commentmetadata">
<?php comment_date(get_option( 'date_format' )) ?>
</small>
<div class="clear"></div>
<?php } ?>