esc_html__( 'Wocommerce Sidebar', 'blog-personal-plus' ),
'id' => 'woocommerce-widget',
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
endif;
}
add_action( 'widgets_init', 'blog_personal_plus_widgets_init' );
if ( ! function_exists( 'blog_personal_plus_enqueue_styles' ) ) :
/**
* Load assets.
*
* @since 1.0.0
*/
function blog_personal_plus_enqueue_styles() {
wp_enqueue_style( 'blog-personal-parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'blog-personal-plus', get_stylesheet_uri(), array( 'blog-personal-parent-style' ), '1.0.0' );
}
endif;
add_action( 'wp_enqueue_scripts', 'blog_personal_plus_enqueue_styles');
function Blog_Personal_Plus_Featured_Action() {
register_widget( 'Blog_Personal_Plus_Featured' );
}
add_action( 'widgets_init', 'Blog_Personal_Plus_Featured_Action' );
/**
*
* Featured Post Widget
*
**/
class Blog_Personal_Plus_Featured extends WP_Widget {
function __construct() {
global $control_ops;
$widget_ops = array(
'classname' => 'featured-post',
'description' => esc_html__( 'Displays latest posts or posts from a choosen category.', 'blog-personal-plus' ),
);
parent::__construct( 'Blog_Personal_Plus_Featured',esc_html__( 'Blog: Featured Post', 'blog-personal-plus' ), $widget_ops, $control_ops );
}
function form( $instance ) {
$defaults[ 'title' ] = '';
$defaults[ 'show_post_meta' ] = true;
$defaults[ 'category' ] = '';
$instance = wp_parse_args( (array) $instance, $defaults );
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 3;
$title = ( ! empty( $instance['title'] ) ) ? esc_html($instance['title']) : '';
$category = isset( $instance['category'] ) ? absint( $instance['category'] ) : 0;
$show_post_meta = isset( $instance['show_post_meta'] ) ? (bool) $instance['show_post_meta'] : true;
?>
id="get_field_id( 'show_post_meta' )); ?>" name="get_field_name( 'show_post_meta' )); ?>" />
'name',
'hide_empty' => 0,
'class' => 'widefat',
'show_option_none' => '',
'show_option_all' => esc_html__('— Select —','blog-personal-plus'),
'name' => esc_attr($this->get_field_name( 'category' )),
'selected' => absint( $category ),
) );
?>
absint( $number ),
'post_type' => 'post',
'post_status' => 'publish',
'post__not_in' => get_option( 'sticky_posts' ),
);
if ( absint( $category ) > 0 ) {
$slider_args['cat'] = absint( $category );
}
$the_query = new WP_Query( $slider_args );
if ($the_query->have_posts()) : ?>
have_posts() ) : $the_query->the_post(); ?>