first commit

This commit is contained in:
Roman Pyrih
2023-07-24 08:30:51 +02:00
commit c2e100a763
7128 changed files with 1622619 additions and 0 deletions

View File

@@ -0,0 +1,110 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die( 'Direct access forbidden.' );
}
if ( class_exists( 'Solarify_Widget_Post_Tabs' ) ) {
return;
}
class Solarify_Widget_Post_Tabs extends WP_Widget {
/**
* @internal
*/
public function __construct() {
$widget_ops = array(
'classname' => 'widget_tabs',
'description' => esc_html__( 'Recent and Popular posts in tabs', 'solarify' ),
);
parent::__construct( false, esc_html__( 'Theme - Blog Tabs', 'solarify' ), $widget_ops );
}
/**
* @param array $args
* @param array $instance
*/
public function widget( $args, $instance ) {
extract( $args );
$number = ( (int) ( $instance['number'] ) > 0 ) ? esc_attr( $instance['number'] ) : 5;
$recent_posts = $this->fw_get_posts_with_info( array(
'sort' => 'post_date',
'items' => $number,
) );
$popular_posts = $this->fw_get_posts_with_info( array(
'sort' => 'comment_count',
'items' => $number,
) );
$filepath = SOLARIFY_THEME_PATH . '/inc/widgets/post-tabs/views/widget.php';
if ( file_exists( $filepath ) ) {
include( $filepath );
} else {
esc_html_e( 'View not found', 'solarify' );
}
}
/**
* @param array $args
*
* @return array
*/
public function fw_get_posts_with_info( $args = array() ) {
$defaults = array(
'sort' => 'recent',
'items' => 5,
'image_post' => true,
'date_post' => true,
'date_format' => 'F jS, Y',
'post_type' => 'post',
);
extract( wp_parse_args( $args, $defaults ) );
$query = new WP_Query( array(
'post_type' => $post_type,
'orderby' => $sort,
'order' => 'DESC',
'ignore_sticky_posts' => true,
'posts_per_page' => $items
) );
//wp reset query removed
return $query;
}
/**
* @param array $new_instance
* @param array $old_instance
*
* @return array
*/
public function update( $new_instance, $old_instance ) {
return $new_instance;
}
/**
* @param array $instance
*
* @return string|void
*/
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'number' => '', 'title' => '' ) );
$number = esc_attr( $instance['number'] );
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number of Blog posts', 'solarify' ); ?>
:</label>
<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" value="<?php echo esc_attr( $number ); ?>"
class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"/>
</p>
<?php
}
}

View File

@@ -0,0 +1,71 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die( 'Direct access forbidden.' );
}
/**
* @var string $before_widget
* @var string $after_widget
* @var array $recent_posts
* @var array $popular_posts
*/
$unique_id = uniqid();
echo wp_kses_post( $before_widget );
?>
<div class="tabs small-tabs">
<ul class="nav nav-tabs" role="tablist">
<li><a href="#popular_posts_<?php echo esc_attr( $unique_id ); ?>" role="tab"
data-toggle="tab"><?php esc_html_e( 'Popular', 'solarify' ); ?></a></li>
<li><a href="#recent_<?php echo esc_attr( $unique_id ); ?>" role="tab"
data-toggle="tab"><?php esc_html_e( 'Recent', 'solarify' ); ?></a></li>
</ul>
</div>
<div class="tab-content top-color-border no-border">
<div id="popular_posts_<?php echo esc_attr( $unique_id ); ?>" class="tab-pane fade">
<?php while ( $popular_posts->have_posts() ) : $popular_posts->the_post(); ?>
<div <?php post_class( 'vertical-item' ); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>">
<?php echo get_the_post_thumbnail( get_the_ID() ); ?>
</a>
<?php endif; //has_post_thumbnail ?>
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<p class="item-meta">
<?php
solarify_posted_on();
?>
<span class="pull-right">
<i class="rt-icon2-heart-outline highlight"></i>
<?php
solarify_post_like_count( get_the_ID() );
?>
</span>
</p>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
</div>
<div id="recent_<?php echo esc_attr( $unique_id ); ?>" class="tab-pane fade">
<?php while ( $recent_posts->have_posts() ) : $recent_posts->the_post(); ?>
<div <?php post_class( 'vertical-item' ); ?> id="widget-post-tabs-post-<?php the_ID(); ?>">
<?php if ( has_post_thumbnail( get_the_ID() ) ) : ?>
<a href="<?php the_permalink(); ?>">
<?php echo get_the_post_thumbnail( get_the_ID() ); ?>
</a>
<?php endif; //has_post_thumbnail ?>
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<p class="item-meta">
<?php solarify_posted_on(); ?>
<span class="pull-right">
<i class="rt-icon2-heart-outline highlight"></i>
<?php
solarify_post_like_count( get_the_ID() );
?>
</span>
</p>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
</div>
</div>
<?php echo wp_kses_post( $after_widget ); ?>