first commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Posts
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Posts extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Posts', 'powerkit' );
|
||||
$this->desc = esc_html__( 'Display a list of posts in your sidebar, including post meta and preview image in multiple available layouts.', 'powerkit' );
|
||||
$this->slug = 'posts';
|
||||
$this->type = 'default';
|
||||
$this->category = 'content';
|
||||
$this->priority = 150;
|
||||
$this->public = true;
|
||||
$this->enabled = true;
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/posts/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
// Helpers Functions for the module.
|
||||
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-posts.php';
|
||||
|
||||
// The classes responsible for defining all actions.
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-posts-widget.php';
|
||||
|
||||
// Admin and public area.
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-posts-public.php';
|
||||
|
||||
new Powerkit_Posts_Public( $this->slug );
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Posts();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Helpers Posts
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Helper
|
||||
*/
|
||||
|
||||
/**
|
||||
* Widget template handler
|
||||
*
|
||||
* @param string $name Specific template.
|
||||
* @param array $posts Array of posts.
|
||||
* @param array $params Array of params.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
function powerkit_widget_featured_posts_handler( $name, $posts, $params, $instance ) {
|
||||
$templates = apply_filters( 'powerkit_featured_posts_templates', array() );
|
||||
|
||||
if ( isset( $templates[ $name ] ) && function_exists( $templates[ $name ]['func'] ) ) {
|
||||
call_user_func( $templates[ $name ]['func'], $posts, $params, $instance );
|
||||
} else {
|
||||
call_user_func( 'powerkit_widget_featured_posts_template', $posts, $params, $instance );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* The public-facing functionality of the module.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* The public-facing functionality of the module.
|
||||
*/
|
||||
class Powerkit_Posts_Public extends Powerkit_Module_Public {
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_filter( 'powerkit_pinit_exclude_selectors', array( $this, 'pinit_disable' ) );
|
||||
add_action( 'init', array( $this, 'register_templates' ) );
|
||||
add_filter( 'powerkit_featured_posts_templates', array( $this, 'list_templates' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* PinIt disable
|
||||
*
|
||||
* @param string $selectors List selectors.
|
||||
*/
|
||||
public function pinit_disable( $selectors ) {
|
||||
$selectors[] = '.pk-block-posts';
|
||||
|
||||
return $selectors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Templates
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*
|
||||
* @param array $templates List of Templates.
|
||||
*/
|
||||
public function register_templates( $templates = array() ) {
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/posts-template.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Register Templates
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*
|
||||
* @param array $templates List of Templates.
|
||||
*/
|
||||
public function list_templates( $templates = array() ) {
|
||||
$templates = array(
|
||||
'list' => array(
|
||||
'name' => esc_html__( 'Simple List', 'powerkit' ),
|
||||
'func' => 'powerkit_featured_posts_default_template',
|
||||
),
|
||||
'numbered' => array(
|
||||
'name' => esc_html__( 'Numbered List', 'powerkit' ),
|
||||
'func' => 'powerkit_featured_posts_default_template',
|
||||
),
|
||||
'large' => array(
|
||||
'name' => esc_html__( 'Large Thumbnails', 'powerkit' ),
|
||||
'func' => 'powerkit_featured_posts_default_template',
|
||||
),
|
||||
);
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
wp_enqueue_style( 'powerkit-widget-posts', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-widget-posts.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'powerkit-widget-posts', 'rtl', 'replace' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
/**
|
||||
* Widget Featured Posts
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Powerkit/widgets
|
||||
*/
|
||||
|
||||
/**
|
||||
* Widget Featured Posts
|
||||
*/
|
||||
class Powerkit_Featured_Posts_Widget extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Sets up a new widget instance.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->default_settings = apply_filters(
|
||||
'powerkit_widget_posts_settings', array(
|
||||
'title' => '',
|
||||
'template' => 'list',
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => 5,
|
||||
'orderby' => 'date',
|
||||
'order' => 'desc',
|
||||
'time_frame' => '',
|
||||
'category' => false,
|
||||
'post_meta' => array( 'date' ),
|
||||
'post_meta_compact' => false,
|
||||
'avoid_duplicate' => false,
|
||||
)
|
||||
);
|
||||
|
||||
$widget_details = array(
|
||||
'classname' => 'powerkit_widget_posts',
|
||||
'description' => esc_html__( 'Display a list of your featured posts.', 'powerkit' ),
|
||||
);
|
||||
parent::__construct( 'powerkit_widget_posts', esc_html__( 'Featured Posts', 'powerkit' ), $widget_details );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the content for the current widget instance.
|
||||
*
|
||||
* @param array $args Display arguments including 'before_title', 'after_title',
|
||||
* 'before_widget', and 'after_widget'.
|
||||
* @param array $instance Settings for the current widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
global $pk_posts;
|
||||
global $wp_query;
|
||||
|
||||
if ( ! $pk_posts ) {
|
||||
$pk_posts = array();
|
||||
}
|
||||
|
||||
$params = array_merge( $this->default_settings, $instance );
|
||||
|
||||
if ( in_array( 'category', $params['post_meta'], true ) ) {
|
||||
$params['post_meta_category'] = true;
|
||||
} else {
|
||||
$params['post_meta_category'] = false;
|
||||
}
|
||||
|
||||
$posts_args = array(
|
||||
'post_type' => $params['post_type'],
|
||||
'posts_per_page' => $params['posts_per_page'],
|
||||
'order' => $params['order'],
|
||||
'no_found_rows' => true,
|
||||
'post_status' => 'publish',
|
||||
'ignore_sticky_posts' => true,
|
||||
);
|
||||
|
||||
if ( $params['category'] ) {
|
||||
$category = $params['category'];
|
||||
$posts_args['cat'] = $category;
|
||||
}
|
||||
|
||||
// Avoid Duplicate.
|
||||
if ( $params['avoid_duplicate'] ) {
|
||||
$main_posts = array();
|
||||
|
||||
if ( isset( $wp_query->posts ) && $wp_query->posts ) {
|
||||
$main_posts = wp_list_pluck( $wp_query->posts, 'ID' );
|
||||
}
|
||||
|
||||
if ( $main_posts ) {
|
||||
$posts_args['post__not_in'] = array_merge( $main_posts, $pk_posts );
|
||||
} else {
|
||||
$posts_args['post__not_in'] = $pk_posts;
|
||||
}
|
||||
}
|
||||
|
||||
// Post order.
|
||||
$posts_args['orderby'] = $params['orderby'];
|
||||
|
||||
$type_post_views = powerkit_post_views_enabled();
|
||||
|
||||
if ( $type_post_views && ( 'views' === $params['orderby'] || 'post_views' === $params['orderby'] ) ) {
|
||||
$posts_args['orderby'] = $type_post_views;
|
||||
// Don't hide posts without views.
|
||||
$posts_args['views_query']['hide_empty'] = false;
|
||||
}
|
||||
|
||||
if ( $params['time_frame'] ) {
|
||||
$posts_args['date_query'] = array(
|
||||
array(
|
||||
'column' => 'post_date_gmt',
|
||||
'after' => $params['time_frame'] . ' ago',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$posts = new WP_Query( apply_filters_ref_array( 'powerkit_widget_featured_posts_args', array( $posts_args, & $params ) ) );
|
||||
|
||||
if ( $posts->have_posts() ) {
|
||||
|
||||
// Before Widget.
|
||||
echo $args['before_widget']; // XSS.
|
||||
|
||||
// Title.
|
||||
if ( $params['title'] ) {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', wp_kses( $params['title'], 'pk-title' ), $instance, $this->id_base ) . $args['after_title']; // XSS.
|
||||
}
|
||||
|
||||
// Template.
|
||||
if ( in_array( $params['template'], array( 'list', 'numbered', 'large' ), true ) ) {
|
||||
$class = sprintf( 'pk-widget-posts-template-default pk-widget-posts-template-%s', $params['template'] );
|
||||
} else {
|
||||
$class = sprintf( 'pk-widget-posts-template-%s', $params['template'] );
|
||||
}
|
||||
|
||||
// Number of Posts.
|
||||
$class .= sprintf( ' posts-per-page-%s', (int) $params['posts_per_page'] );
|
||||
?>
|
||||
|
||||
<div class="widget-body pk-widget-posts <?php echo esc_html( $class ); ?>">
|
||||
<ul>
|
||||
<?php
|
||||
while ( $posts->have_posts() ) :
|
||||
$posts->the_post();
|
||||
|
||||
$pk_posts[] = get_the_ID();
|
||||
?>
|
||||
<li class="pk-post-item">
|
||||
<?php powerkit_widget_featured_posts_handler( $params['template'], $posts, $params, $instance ); ?>
|
||||
</li>
|
||||
<?php endwhile; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
// After Widget.
|
||||
echo $args['after_widget']; // XSS.
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles updating settings for the current widget instance.
|
||||
*
|
||||
* @param array $new_instance New settings for this instance as input by the user via
|
||||
* WP_Widget::form().
|
||||
* @param array $old_instance Old settings for this instance.
|
||||
* @return array Settings to save or bool false to cancel saving.
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
$instance = $new_instance;
|
||||
|
||||
// Post Meta.
|
||||
if ( ! isset( $instance['post_meta'] ) ) {
|
||||
$instance['post_meta'] = array();
|
||||
}
|
||||
|
||||
// Compact Post Meta.
|
||||
if ( ! isset( $instance['post_meta_compact'] ) ) {
|
||||
$instance['post_meta_compact'] = false;
|
||||
}
|
||||
|
||||
// Avoid duplicate posts.
|
||||
if ( ! isset( $instance['avoid_duplicate'] ) ) {
|
||||
$instance['avoid_duplicate'] = false;
|
||||
}
|
||||
|
||||
return apply_filters( 'powerkit_widget_posts_update', $instance );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the widget settings form.
|
||||
*
|
||||
* @param array $instance Current settings.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
$params = array_merge( $this->default_settings, $instance );
|
||||
|
||||
$templates = apply_filters( 'powerkit_featured_posts_templates', array() );
|
||||
?>
|
||||
<!-- Title -->
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'powerkit' ); ?></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( $params['title'] ); ?>" /></p>
|
||||
|
||||
<?php do_action( 'powerkit_widget_posts_form_before', $this, $params, $instance ); ?>
|
||||
|
||||
<!-- Template -->
|
||||
<?php if ( $templates ) { ?>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>"><?php esc_html_e( 'Template:', 'powerkit' ); ?></label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'template' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>" class="widefat">
|
||||
<?php
|
||||
foreach ( $templates as $slug => $template ) {
|
||||
$name = isset( $template['name'] ) ? $template['name'] : $slug;
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $slug ); ?>" <?php selected( $params['template'], $slug ); ?>><?php echo esc_html( $name ); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Post Type -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'post_type' ) ); ?>"><?php esc_html_e( 'Post Type', 'powerkit' ); ?>:</label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'post_type' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'post_type' ) ); ?>" class="widefat">
|
||||
<?php
|
||||
$post_types = get_post_types( array(
|
||||
'publicly_queryable' => 1,
|
||||
), 'objects' );
|
||||
|
||||
foreach ( $post_types as $name => $post_type ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $name ); ?>" <?php selected( $params['post_type'], $name ); ?>><?php echo esc_html( $post_type->labels->name ); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Number of Posts -->
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'posts_per_page' ) ); ?>"><?php esc_html_e( 'Number of posts:', 'powerkit' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'posts_per_page' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'posts_per_page' ) ); ?>" type="number" value="<?php echo esc_attr( $params['posts_per_page'] ); ?>" /></p>
|
||||
|
||||
<!-- Order by -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php esc_html_e( 'Order by:', 'powerkit' ); ?></label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" class="widefat">
|
||||
<option value="date" <?php selected( $params['orderby'], 'date' ); ?>><?php esc_html_e( 'Date', 'powerkit' ); ?></option>
|
||||
<option value="comment_count" <?php selected( $params['orderby'], 'comment_count' ); ?>><?php esc_html_e( 'Comments', 'powerkit' ); ?></option>
|
||||
<option value="rand" <?php selected( $params['orderby'], 'rand' ); ?>><?php esc_html_e( 'Random', 'powerkit' ); ?></option>
|
||||
|
||||
<?php if ( powerkit_post_views_enabled() ) { ?>
|
||||
<option value="post_views" <?php selected( $params['orderby'], 'post_views' ); ?>><?php esc_html_e( 'Views', 'powerkit' ); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Order -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"><?php esc_html_e( 'Order', 'powerkit' ); ?>:</label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>" class="widefat">
|
||||
<option value="desc" <?php selected( $params['order'], 'desc' ); ?>><?php esc_html_e( 'Descending', 'powerkit' ); ?></option>
|
||||
<option value="asc" <?php selected( $params['order'], 'asc' ); ?>><?php esc_html_e( 'Ascending', 'powerkit' ); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Time Frame -->
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'time_frame' ) ); ?>"><?php esc_html_e( 'Time frame:', 'powerkit' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'time_frame' ) ); ?>" placeholder="<?php esc_html_e( '3 months', 'powerkit' ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'time_frame' ) ); ?>" type="text" value="<?php echo esc_attr( $params['time_frame'] ); ?>" /></p>
|
||||
|
||||
<!-- Category -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>"><?php esc_html_e( 'Category:', 'powerkit' ); ?></label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>[]" id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" class="widefat" style="height: auto !important;" multiple="multiple" size="8">
|
||||
<?php
|
||||
$cat_args = array(
|
||||
'hide_empty' => 0,
|
||||
'hierarchical' => 1,
|
||||
'selected' => (array) $params['category'],
|
||||
'walker' => new Powerkit_Add_Posts_Categories_Tree_Walker(),
|
||||
);
|
||||
|
||||
$allowed_html = array(
|
||||
'option' => array(
|
||||
'class' => true,
|
||||
'value' => true,
|
||||
'selected' => true,
|
||||
),
|
||||
);
|
||||
|
||||
echo wp_kses( walk_category_dropdown_tree( get_categories( $cat_args ), 0, $cat_args ), $allowed_html );
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Post meta -->
|
||||
<h4><?php esc_html_e( 'Post meta:', 'powerkit' ); ?></h4>
|
||||
|
||||
<?php
|
||||
$allowed_post_meta = powerkit_allowed_post_meta();
|
||||
|
||||
foreach ( $allowed_post_meta as $key => $caption ) {
|
||||
?>
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'post_meta' ) ); ?>-<?php echo esc_attr( $key ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'post_meta' ) ); ?>[]" type="checkbox" value="<?php echo esc_attr( $key ); ?>" <?php checked( in_array( $key, (array) $params['post_meta'], true ) ? true : false ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'post_meta' ) ); ?>-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $caption ); ?></label></p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Compact Post Meta -->
|
||||
<h4><?php esc_html_e( 'Compact post meta:', 'powerkit' ); ?></h4>
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'post_meta_compact' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'post_meta_compact' ) ); ?>" type="checkbox" <?php checked( (bool) $params['post_meta_compact'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'post_meta_compact' ) ); ?>"><?php esc_html_e( 'Display compact post meta', 'powerkit' ); ?></label></p>
|
||||
|
||||
<!-- Avoid duplicate posts -->
|
||||
<h4><?php esc_html_e( 'Avoid duplicate posts:', 'powerkit' ); ?></h4>
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'avoid_duplicate' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'avoid_duplicate' ) ); ?>" type="checkbox" <?php checked( (bool) $params['avoid_duplicate'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'avoid_duplicate' ) ); ?>"><?php esc_html_e( 'Exclude duplicate posts', 'powerkit' ); ?></label></p>
|
||||
|
||||
<?php do_action( 'powerkit_widget_posts_form_after', $this, $params, $instance ); ?>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create HTML dropdown list of Categories.
|
||||
*/
|
||||
class Powerkit_Add_Posts_Categories_Tree_Walker extends Walker_CategoryDropdown {
|
||||
|
||||
/**
|
||||
* Starts the element output.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @access public
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $category Category data object.
|
||||
* @param int $depth Depth of category. Used for padding.
|
||||
* @param array $args Uses 'selected', 'show_count', and 'value_field' keys, if they exist.
|
||||
* See wp_dropdown_categories().
|
||||
* @param int $id Optional. ID of the current category. Default 0 (unused).
|
||||
*/
|
||||
public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
|
||||
$pad = $depth > 0 ? '- ' . str_repeat( ' ', $depth * 3 ) : '';
|
||||
$selected = array_map( 'intval', $args['selected'] );
|
||||
$cat_name = apply_filters( 'list_cats', $category->name, $category );
|
||||
|
||||
$output .= sprintf(
|
||||
'<option class="level-%1$s" value="%2$s" %4$s>%3$s</option>',
|
||||
esc_attr( $depth ),
|
||||
esc_attr( $category->term_id ),
|
||||
esc_html( $pad . $cat_name ),
|
||||
selected( in_array( $category->term_id, $selected, true ), true )
|
||||
);
|
||||
$output .= "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Widget
|
||||
*/
|
||||
function powerkit_widget_init_featured_posts() {
|
||||
register_widget( 'Powerkit_Featured_Posts_Widget' );
|
||||
}
|
||||
add_action( 'widgets_init', 'powerkit_widget_init_featured_posts' );
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-widget-posts {
|
||||
--pk-posts-thumbnail-width: 80px;
|
||||
--pk-posts-thumbnail-border-radius: 100%;
|
||||
--pk-posts-thumbnail-gutter: 2rem;
|
||||
--pk-posts-number-color: #FFFFFF;
|
||||
--pk-posts-number-font-size: 80%;
|
||||
--pk-posts-number-top: 0;
|
||||
--pk-posts-number-right: 0;
|
||||
--pk-posts-number-left: initial;
|
||||
--pk-posts-number-bottom: initial;
|
||||
--pk-posts-number-width: 30px;
|
||||
--pk-posts-number-height: 30px;
|
||||
--pk-posts-number-line-height: 30px;
|
||||
--pk-posts-number-border-radius: 100%;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-widget-posts .pk-post-item:not(:first-child) {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-outer {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-thumbnail {
|
||||
position: relative;
|
||||
flex: 0 0 var(--pk-posts-thumbnail-width);
|
||||
margin-left: var(--pk-posts-thumbnail-gutter);
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-thumbnail img {
|
||||
width: var(--pk-posts-thumbnail-width);
|
||||
height: var(--pk-posts-thumbnail-width);
|
||||
border-radius: var(--pk-posts-thumbnail-border-radius);
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
font-family: 'object-fit: cover;';
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-data {
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-number {
|
||||
position: absolute;
|
||||
top: var(--pk-posts-number-top);
|
||||
right: var(--pk-posts-number-left);
|
||||
left: var(--pk-posts-number-right);
|
||||
bottom: var(--pk-posts-number-bottom);
|
||||
width: var(--pk-posts-number-width);
|
||||
height: var(--pk-posts-number-height);
|
||||
line-height: var(--pk-posts-number-line-height);
|
||||
color: var(--pk-posts-number-color);
|
||||
text-align: center;
|
||||
border-radius: var(--pk-posts-number-border-radius);
|
||||
font-size: var(--pk-posts-number-font-size);
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-data .meta-category {
|
||||
display: inline-block;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-data .entry-title {
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-meta .sep {
|
||||
display: inline-block;
|
||||
padding: 0 0.5rem;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-meta-hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-widget-posts-template-large .pk-post-item:not(:first-child) {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.pk-widget-posts-template-large .pk-post-outer {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.pk-widget-posts-template-large .pk-post-thumbnail {
|
||||
margin-left: 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.pk-widget-posts-template-large .pk-post-thumbnail img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
border-radius: 0;
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-widget-posts {
|
||||
--pk-posts-thumbnail-width: 80px;
|
||||
--pk-posts-thumbnail-border-radius: 100%;
|
||||
--pk-posts-thumbnail-gutter: 2rem;
|
||||
--pk-posts-number-color: #FFFFFF;
|
||||
--pk-posts-number-font-size: 80%;
|
||||
--pk-posts-number-top: 0;
|
||||
--pk-posts-number-left: 0;
|
||||
--pk-posts-number-right: initial;
|
||||
--pk-posts-number-bottom: initial;
|
||||
--pk-posts-number-width: 30px;
|
||||
--pk-posts-number-height: 30px;
|
||||
--pk-posts-number-line-height: 30px;
|
||||
--pk-posts-number-border-radius: 100%;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-widget-posts .pk-post-item:not(:first-child) {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-outer {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-thumbnail {
|
||||
position: relative;
|
||||
flex: 0 0 var(--pk-posts-thumbnail-width);
|
||||
margin-right: var(--pk-posts-thumbnail-gutter);
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-thumbnail img {
|
||||
width: var(--pk-posts-thumbnail-width);
|
||||
height: var(--pk-posts-thumbnail-width);
|
||||
border-radius: var(--pk-posts-thumbnail-border-radius);
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
font-family: 'object-fit: cover;';
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-data {
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-number {
|
||||
position: absolute;
|
||||
top: var(--pk-posts-number-top);
|
||||
left: var(--pk-posts-number-left);
|
||||
right: var(--pk-posts-number-right);
|
||||
bottom: var(--pk-posts-number-bottom);
|
||||
width: var(--pk-posts-number-width);
|
||||
height: var(--pk-posts-number-height);
|
||||
line-height: var(--pk-posts-number-line-height);
|
||||
color: var(--pk-posts-number-color);
|
||||
text-align: center;
|
||||
border-radius: var(--pk-posts-number-border-radius);
|
||||
font-size: var(--pk-posts-number-font-size);
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-data .meta-category {
|
||||
display: inline-block;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-data .entry-title {
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-meta .sep {
|
||||
display: inline-block;
|
||||
padding: 0 0.5rem;
|
||||
}
|
||||
|
||||
.pk-widget-posts .pk-post-meta-hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-widget-posts-template-large .pk-post-item:not(:first-child) {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.pk-widget-posts-template-large .pk-post-outer {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.pk-widget-posts-template-large .pk-post-thumbnail {
|
||||
margin-right: 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.pk-widget-posts-template-large .pk-post-thumbnail img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
border-radius: 0;
|
||||
}
|
||||
@@ -0,0 +1,366 @@
|
||||
/*!
|
||||
* Colcade v0.2.0
|
||||
* Lightweight masonry layout
|
||||
* by David DeSandro
|
||||
* MIT license
|
||||
*/
|
||||
|
||||
/*jshint browser: true, undef: true, unused: true */
|
||||
|
||||
( function( window, factory ) {
|
||||
// universal module definition
|
||||
/*jshint strict: false */
|
||||
/*global define: false, module: false */
|
||||
if ( typeof define == 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( factory );
|
||||
} else if ( typeof module == 'object' && module.exports ) {
|
||||
// CommonJS
|
||||
module.exports = factory();
|
||||
} else {
|
||||
// browser global
|
||||
window.Colcade = factory();
|
||||
}
|
||||
|
||||
}( window, function factory() {
|
||||
|
||||
// -------------------------- Colcade -------------------------- //
|
||||
|
||||
function Colcade( element, options ) {
|
||||
element = getQueryElement( element );
|
||||
|
||||
// do not initialize twice on same element
|
||||
if ( element && element.colcadeGUID ) {
|
||||
var instance = instances[ element.colcadeGUID ];
|
||||
instance.option( options );
|
||||
return instance;
|
||||
}
|
||||
|
||||
this.element = element;
|
||||
// options
|
||||
this.options = {};
|
||||
this.option( options );
|
||||
// kick things off
|
||||
this.create();
|
||||
}
|
||||
|
||||
var proto = Colcade.prototype;
|
||||
|
||||
proto.option = function( options ) {
|
||||
this.options = extend( this.options, options );
|
||||
};
|
||||
|
||||
// globally unique identifiers
|
||||
var GUID = 0;
|
||||
// internal store of all Colcade intances
|
||||
var instances = {};
|
||||
|
||||
proto.create = function() {
|
||||
this.errorCheck();
|
||||
// add guid for Colcade.data
|
||||
var guid = this.guid = ++GUID;
|
||||
this.element.colcadeGUID = guid;
|
||||
instances[ guid ] = this; // associate via id
|
||||
// update initial properties & layout
|
||||
this.reload();
|
||||
// events
|
||||
this._windowResizeHandler = this.onWindowResize.bind( this );
|
||||
this._loadHandler = this.onLoad.bind( this );
|
||||
window.addEventListener( 'resize', this._windowResizeHandler );
|
||||
this.element.addEventListener( 'load', this._loadHandler, true );
|
||||
};
|
||||
|
||||
proto.errorCheck = function() {
|
||||
var errors = [];
|
||||
if ( !this.element ) {
|
||||
errors.push( 'Bad element: ' + this.element );
|
||||
}
|
||||
if ( !this.options.columns ) {
|
||||
errors.push( 'columns option required: ' + this.options.columns );
|
||||
}
|
||||
if ( !this.options.items ) {
|
||||
errors.push( 'items option required: ' + this.options.items );
|
||||
}
|
||||
|
||||
if ( errors.length ) {
|
||||
throw new Error( '[Colcade error] ' + errors.join('. ') );
|
||||
}
|
||||
};
|
||||
|
||||
// update properties and do layout
|
||||
proto.reload = function() {
|
||||
this.updateColumns();
|
||||
this.updateItems();
|
||||
this.layout();
|
||||
};
|
||||
|
||||
proto.updateColumns = function() {
|
||||
this.columns = querySelect( this.options.columns, this.element );
|
||||
};
|
||||
|
||||
proto.updateItems = function() {
|
||||
this.items = querySelect( this.options.items, this.element );
|
||||
};
|
||||
|
||||
proto.getActiveColumns = function() {
|
||||
return this.columns.filter( function( column ) {
|
||||
var style = getComputedStyle( column );
|
||||
return style.display != 'none';
|
||||
});
|
||||
};
|
||||
|
||||
// ----- layout ----- //
|
||||
|
||||
// public, updates activeColumns
|
||||
proto.layout = function() {
|
||||
this.activeColumns = this.getActiveColumns();
|
||||
this._layout();
|
||||
};
|
||||
|
||||
// private, does not update activeColumns
|
||||
proto._layout = function() {
|
||||
// reset column heights
|
||||
this.columnHeights = this.activeColumns.map( function() {
|
||||
return 0;
|
||||
});
|
||||
// layout all items
|
||||
this.layoutItems( this.items );
|
||||
};
|
||||
|
||||
proto.layoutItems = function( items ) {
|
||||
items.forEach( this.layoutItem, this );
|
||||
};
|
||||
|
||||
proto.layoutItem = function( item ) {
|
||||
// layout item by appending to column
|
||||
var minHeight = Math.min.apply( Math, this.columnHeights );
|
||||
var index = this.columnHeights.indexOf( minHeight );
|
||||
this.activeColumns[ index ].appendChild( item );
|
||||
// at least 1px, if item hasn't loaded
|
||||
// Not exactly accurate, but it's cool
|
||||
this.columnHeights[ index ] += item.offsetHeight || 1;
|
||||
};
|
||||
|
||||
// ----- adding items ----- //
|
||||
|
||||
proto.append = function( elems ) {
|
||||
var items = this.getQueryItems( elems );
|
||||
// add items to collection
|
||||
this.items = this.items.concat( items );
|
||||
// lay them out
|
||||
this.layoutItems( items );
|
||||
};
|
||||
|
||||
proto.prepend = function( elems ) {
|
||||
var items = this.getQueryItems( elems );
|
||||
// add items to collection
|
||||
this.items = items.concat( this.items );
|
||||
// lay out everything
|
||||
this._layout();
|
||||
};
|
||||
|
||||
proto.getQueryItems = function( elems ) {
|
||||
elems = makeArray( elems );
|
||||
var fragment = document.createDocumentFragment();
|
||||
elems.forEach( function( elem ) {
|
||||
fragment.appendChild( elem );
|
||||
});
|
||||
return querySelect( this.options.items, fragment );
|
||||
};
|
||||
|
||||
// ----- measure column height ----- //
|
||||
|
||||
proto.measureColumnHeight = function( elem ) {
|
||||
var boundingRect = this.element.getBoundingClientRect();
|
||||
this.activeColumns.forEach( function( column, i ) {
|
||||
// if elem, measure only that column
|
||||
// if no elem, measure all columns
|
||||
if ( !elem || column.contains( elem ) ) {
|
||||
var lastChildRect = column.lastElementChild.getBoundingClientRect();
|
||||
// not an exact calculation as it includes top border, and excludes item bottom margin
|
||||
this.columnHeights[ i ] = lastChildRect.bottom - boundingRect.top;
|
||||
}
|
||||
}, this );
|
||||
};
|
||||
|
||||
// ----- events ----- //
|
||||
|
||||
proto.onWindowResize = function() {
|
||||
clearTimeout( this.resizeTimeout );
|
||||
this.resizeTimeout = setTimeout( function() {
|
||||
this.onDebouncedResize();
|
||||
}.bind( this ), 100 );
|
||||
};
|
||||
|
||||
proto.onDebouncedResize = function() {
|
||||
var activeColumns = this.getActiveColumns();
|
||||
// check if columns changed
|
||||
var isSameLength = activeColumns.length == this.activeColumns.length;
|
||||
var isSameColumns = true;
|
||||
this.activeColumns.forEach( function( column, i ) {
|
||||
isSameColumns = isSameColumns && column == activeColumns[i];
|
||||
});
|
||||
if ( isSameLength && isSameColumns ) {
|
||||
return;
|
||||
}
|
||||
// activeColumns changed
|
||||
this.activeColumns = activeColumns;
|
||||
this._layout();
|
||||
};
|
||||
|
||||
proto.onLoad = function( event ) {
|
||||
this.measureColumnHeight( event.target );
|
||||
};
|
||||
|
||||
// ----- destroy ----- //
|
||||
|
||||
proto.destroy = function() {
|
||||
// move items back to container
|
||||
this.items.forEach( function( item ) {
|
||||
this.element.appendChild( item );
|
||||
}, this );
|
||||
// remove events
|
||||
window.removeEventListener( 'resize', this._windowResizeHandler );
|
||||
this.element.removeEventListener( 'load', this._loadHandler, true );
|
||||
// remove data
|
||||
delete this.element.colcadeGUID;
|
||||
delete instances[ this.guid ];
|
||||
};
|
||||
|
||||
// -------------------------- HTML init -------------------------- //
|
||||
|
||||
docReady( function() {
|
||||
var dataElems = querySelect('[data-colcade]');
|
||||
dataElems.forEach( htmlInit );
|
||||
});
|
||||
|
||||
function htmlInit( elem ) {
|
||||
// convert attribute "foo: bar, qux: baz" into object
|
||||
var attr = elem.getAttribute('data-colcade');
|
||||
var attrParts = attr.split(',');
|
||||
var options = {};
|
||||
attrParts.forEach( function( part ) {
|
||||
var pair = part.split(':');
|
||||
var key = pair[0].trim();
|
||||
var value = pair[1].trim();
|
||||
options[ key ] = value;
|
||||
});
|
||||
|
||||
new Colcade( elem, options );
|
||||
}
|
||||
|
||||
Colcade.data = function( elem ) {
|
||||
elem = getQueryElement( elem );
|
||||
var id = elem && elem.colcadeGUID;
|
||||
return id && instances[ id ];
|
||||
};
|
||||
|
||||
// -------------------------- jQuery -------------------------- //
|
||||
|
||||
Colcade.makeJQueryPlugin = function( $ ) {
|
||||
$ = $ || window.jQuery;
|
||||
if ( !$ ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.fn.colcade = function( arg0 /*, arg1 */) {
|
||||
// method call $().colcade( 'method', { options } )
|
||||
if ( typeof arg0 == 'string' ) {
|
||||
// shift arguments by 1
|
||||
var args = Array.prototype.slice.call( arguments, 1 );
|
||||
return methodCall( this, arg0, args );
|
||||
}
|
||||
// just $().colcade({ options })
|
||||
plainCall( this, arg0 );
|
||||
return this;
|
||||
};
|
||||
|
||||
function methodCall( $elems, methodName, args ) {
|
||||
var returnValue;
|
||||
$elems.each( function( i, elem ) {
|
||||
// get instance
|
||||
var colcade = $.data( elem, 'colcade' );
|
||||
if ( !colcade ) {
|
||||
return;
|
||||
}
|
||||
// apply method, get return value
|
||||
var value = colcade[ methodName ].apply( colcade, args );
|
||||
// set return value if value is returned, use only first value
|
||||
returnValue = returnValue === undefined ? value : returnValue;
|
||||
});
|
||||
return returnValue !== undefined ? returnValue : $elems;
|
||||
}
|
||||
|
||||
function plainCall( $elems, options ) {
|
||||
$elems.each( function( i, elem ) {
|
||||
var colcade = $.data( elem, 'colcade' );
|
||||
if ( colcade ) {
|
||||
// set options & init
|
||||
colcade.option( options );
|
||||
colcade.layout();
|
||||
} else {
|
||||
// initialize new instance
|
||||
colcade = new Colcade( elem, options );
|
||||
$.data( elem, 'colcade', colcade );
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// try making plugin
|
||||
Colcade.makeJQueryPlugin();
|
||||
|
||||
// -------------------------- utils -------------------------- //
|
||||
|
||||
function extend( a, b ) {
|
||||
for ( var prop in b ) {
|
||||
a[ prop ] = b[ prop ];
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
// turn element or nodeList into an array
|
||||
function makeArray( obj ) {
|
||||
var ary = [];
|
||||
if ( Array.isArray( obj ) ) {
|
||||
// use object if already an array
|
||||
ary = obj;
|
||||
} else if ( obj && typeof obj.length == 'number' ) {
|
||||
// convert nodeList to array
|
||||
for ( var i=0; i < obj.length; i++ ) {
|
||||
ary.push( obj[i] );
|
||||
}
|
||||
} else {
|
||||
// array of single index
|
||||
ary.push( obj );
|
||||
}
|
||||
return ary;
|
||||
}
|
||||
|
||||
// get array of elements
|
||||
function querySelect( selector, elem ) {
|
||||
elem = elem || document;
|
||||
var elems = elem.querySelectorAll( selector );
|
||||
return makeArray( elems );
|
||||
}
|
||||
|
||||
function getQueryElement( elem ) {
|
||||
if ( typeof elem == 'string' ) {
|
||||
elem = document.querySelector( elem );
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
|
||||
function docReady( onReady ) {
|
||||
if ( document.readyState == 'complete' ) {
|
||||
onReady();
|
||||
return;
|
||||
}
|
||||
document.addEventListener( 'DOMContentLoaded', onReady );
|
||||
}
|
||||
|
||||
// -------------------------- end -------------------------- //
|
||||
|
||||
return Colcade;
|
||||
|
||||
}));
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Posts
|
||||
*/
|
||||
( function( $ ) {
|
||||
|
||||
function powerkitInitPostsMasonry() {
|
||||
$( '.pk-block-posts-layout-masonry:not(.pk-block-posts-layout-masonry-colcade-ready)' )
|
||||
.addClass( 'pk-block-posts-layout-masonry-colcade-ready' )
|
||||
.each( function() {
|
||||
new Colcade( this, {
|
||||
columns: '.pk-block-post-grid-col',
|
||||
items: '.pk-block-post-grid-item'
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
$( document ).ready( function() {
|
||||
powerkitInitPostsMasonry();
|
||||
$( document.body ).on( 'post-load', function() {
|
||||
powerkitInitPostsMasonry();
|
||||
} );
|
||||
} );
|
||||
|
||||
} )( jQuery );
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Posts Template
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/templates
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default Template
|
||||
*
|
||||
* @param array $posts Array of posts.
|
||||
* @param array $params Array of params.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
function powerkit_widget_featured_posts_template( $posts, $params, $instance ) {
|
||||
?>
|
||||
<article <?php post_class(); ?>>
|
||||
<div class="pk-post-outer">
|
||||
<?php
|
||||
$thumbnail_size = ( 'large' === $params['template'] ) ? 'pk-thumbnail' : 'pk-small';
|
||||
|
||||
$thumbnail_size = apply_filters( 'powerkit_widget_featured_posts_size', $thumbnail_size, $params, $instance );
|
||||
?>
|
||||
<?php if ( has_post_thumbnail() ) { ?>
|
||||
<div class="pk-post-inner pk-post-thumbnail">
|
||||
<a href="<?php the_permalink(); ?>" class="post-thumbnail">
|
||||
<?php the_post_thumbnail( $thumbnail_size ); ?>
|
||||
|
||||
<?php if ( 'numbered' === $params['template'] ) : ?>
|
||||
<span class="pk-post-number pk-bg-primary">
|
||||
<?php echo esc_html( $posts->current_post + 1 ); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="pk-post-inner pk-post-data">
|
||||
<?php
|
||||
powerkit_get_post_meta( 'category', (bool) $params['post_meta_compact'], true, $params['post_meta'] );
|
||||
?>
|
||||
|
||||
<?php
|
||||
$tag = ( 'large' === $params['template'] ) ? 'h5' : 'h6';
|
||||
|
||||
$tag = apply_filters( 'powerkit_widget_featured_posts_title_tag', $tag, $params, $instance );
|
||||
?>
|
||||
|
||||
<<?php echo esc_html( $tag ); ?> class="entry-title">
|
||||
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
|
||||
</<?php echo esc_html( $tag ); ?>>
|
||||
|
||||
<?php
|
||||
powerkit_get_post_meta( powerkit_allowed_post_meta( true, 'category' ), (bool) $params['post_meta_compact'], true, $params['post_meta'] );
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<?php
|
||||
}
|
||||
Reference in New Issue
Block a user