HEX
Server: Apache/2
System: Linux localhost 5.4.0-131-generic #147-Ubuntu SMP Fri Oct 14 17:07:22 UTC 2022 x86_64
User: rasad (1007)
PHP: 7.4.33
Disabled: shell_exec,system,passthru,exec,popen,ini_restore,socket_create,socket_create_listen,socket_create_pair,socket_listen,socket_bind,symlink,link,pfsockopen,ini_alter,dl,pcntl_exec,pcntl_fork,proc_close,proc_open,proc_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_uname,show_source,getfile,mkfifo
Upload Files
File: /home/rasad/public_html/wp-content/themes/ofogh/widget/cat-video.php
<?php
class theme_wg_news_video_post extends WP_Widget {
	
	function __construct() {
		parent::__construct( false, 'ofogh - ویدئوها' );
	}
	
	function widget( $args, $instance ) {
		extract($args, EXTR_SKIP);
		echo $before_widget;
		echo $before_title;
		//Display title as stored in this instance of the widget
		echo esc_html($instance['news_title']); 
		echo $after_title;
		print_theme_wg_news_video_post($instance);
		echo $after_widget;
	}
	
	function update( $new_instance, $old_instance ) {
		$instance = $old_instance;
		$instance['news_title'] = $new_instance['news_title'];
		$instance['select_news'] = $new_instance['select_news'];
		$instance['news_cat'] = $new_instance['news_cat'];
		$instance['news_count'] = $new_instance['news_count'];
		return $instance;
	}

	function form( $instance ) {
		$defaults = array(
			'news_title' => 'ویدئو ها',
			'news_count' => '6',
		);
		$instance = wp_parse_args( (array) $instance, $defaults );
		?>
<p>
<label style="width:100%;" for="<?php echo $this->get_field_id('news_title'); ?>">عنوان</label>
<input style="width:100%;" type="text" id="<?php echo $this->get_field_id( 'news_title' ); ?>" name="<?php echo $this->get_field_name( 'news_title' ); ?>" value="<?php echo $instance['news_title']; ?>" />
</p>
<p>					
<label style="width:100%;" for="<?php echo $this->get_field_id('select_news'); ?>">نوع نمايش </label>
<select style="width:100%;" class="select-type" id="<?php echo $this->get_field_id('select_news'); ?>" name="<?php echo $this->get_field_name('select_news'); ?>" type="text">
	<option value="1">آخرین</option>
	<option value="2">تصادفی</option>
</select>
</p>
<p>
<label style="width:100%;" for="<?php echo $this->get_field_id('news_count'); ?>">تعداد نوشته</label>
<input style="width:100%;" type="number" step="1" min="1" id="<?php echo $this->get_field_id( 'news_count' ); ?>" name="<?php echo $this->get_field_name( 'news_count' ); ?>" value="<?php echo $instance['news_count']; ?>" />
</p>
		<?php
		
		echo '<script>';
		echo 'document.getElementById("'. $this->get_field_id( 'select_news' ) .'").value = "' . $instance['select_news'] . '";';
		echo 'document.getElementById("'. $this->get_field_id( 'news_title' ) .'").value = "' . $instance['news_title'] . '";';
		echo 'document.getElementById("'. $this->get_field_id( 'news_count' ) .'").value = "' . $instance['news_count'] . '";';
		echo '
			jQuery(function($) {
				$("#'. $this->get_field_id('select_news'). '").change(function(){
					if($("#'. $this->get_field_id('select_news'). '").val() == "3") {
						$(".select-cat").show(); 
					} else {
						$(".select-cat").hide(); 
					} 
				});
			});
		</script>';
	}
	
}
function theme_wg_news_video_post_register() {
	register_widget( 'theme_wg_news_video_post' );
}
add_action( 'widgets_init', 'theme_wg_news_video_post_register' );

function print_theme_wg_news_video_post($options) { ?>
<ul class="widget_img_small">
				<?php
					if($options['select_news']==1){
						$big_query = new WP_Query(array(
						'post_status' =>'publish',
						'post_type' => array('video'),
						'posts_per_page' => $options['news_count']));
						
					} elseif ($options['select_news']==2) {
						
						$big_query = new WP_Query(array(
						'post_status' =>'publish',
						'post_type' => array('video'),
						'orderby' => 'rand',
						'posts_per_page' => $options['news_count']));
						
					}
					if($big_query->have_posts()) : while($big_query->have_posts()) : $big_query->the_post();
					?>
<li>
<div class="thumb">
<?php if(has_post_thumbnail()){?>
<a href="<?php the_permalink(); ?>"><img src="<?php the_post_thumbnail_url('medium'); ?>" alt="<?php the_title(); ?>"></a>
<?php }else{ ?>
<img src="<?php bloginfo("template_url"); ?>/img/none.png">
<?php } ?>
<a class="iicon" href="<?php the_permalink(); ?>"><i class="fa fa-play"></i></a>
 </div>
 <div class="det">
 <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
 <?php if(get_post_meta( get_the_ID(), 'video-time', true )!=null){ ?>
<div class="ttime"><?php echo get_post_meta( get_the_ID(), 'video-time', true ); ?></div>
<?php } ?>
</div>
</li>				
<?php endwhile; endif; wp_reset_query(); ?>
</ul>
<?php
}
?>