'blogism_widget_social', 'description' => esc_html__( 'Displays social icons.', 'blogism' ), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => esc_html__( 'Title:', 'blogism' ), 'type' => 'text', 'class' => 'widefat', ), ); if ( false === has_nav_menu( 'social' ) ) { $fields['message'] = array( 'label' => esc_html__( 'Social menu is not set. Please create menu and assign it to Social Menu.', 'blogism' ), 'type' => 'message', 'class' => 'widefat', ); } parent::__construct( 'blogism-social', esc_html__( 'Blogism: Social', 'blogism' ), $opts, array(), $fields ); } /** * Outputs the content for the current widget instance. * * @since 1.0.0 * * @param array $args Display arguments. * @param array $instance Settings for the current widget instance. */ function widget( $args, $instance ) { $params = $this->get_params( $instance ); echo $args['before_widget']; if ( ! empty( $params['title'] ) ) { echo $args['before_title'] . esc_html( $params['title'] ) . $args['after_title']; } if ( has_nav_menu( 'social' ) ) { echo ''; } echo $args['after_widget']; } } endif; if ( ! class_exists( 'Blogism_Recent_Posts_Widget' ) ) : /** * Recent posts widget Class. * * @since 1.0.0 */ class Blogism_Recent_Posts_Widget extends Blogism_Widget_Base { /** * Sets up a new widget instance. * * @since 1.0.0 */ function __construct() { $opts = array( 'classname' => 'blogism_widget_recent_posts', 'description' => esc_html__( 'Displays recent posts.', 'blogism' ), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => esc_html__( 'Title:', 'blogism' ), 'type' => 'text', 'class' => 'widefat', ), 'post_category' => array( 'label' => esc_html__( 'Select Category:', 'blogism' ), 'type' => 'dropdown-taxonomies', 'show_option_all' => esc_html__( 'All Categories', 'blogism' ), ), 'post_number' => array( 'label' => esc_html__( 'Number of Posts:', 'blogism' ), 'type' => 'number', 'default' => 4, 'css' => 'max-width:60px;', 'min' => 1, 'max' => 100, ), 'featured_image' => array( 'label' => esc_html__( 'Featured Image:', 'blogism' ), 'type' => 'select', 'default' => 'thumbnail', 'options' => blogism_get_image_sizes_options( true, array( 'disable', 'thumbnail' ), false ), ), 'image_width' => array( 'label' => esc_html__( 'Image Width:', 'blogism' ), 'type' => 'number', 'description' => esc_html__( 'px', 'blogism' ), 'css' => 'max-width:60px;', 'adjacent' => true, 'default' => 90, 'min' => 1, 'max' => 150, ), 'disable_date' => array( 'label' => esc_html__( 'Disable Date', 'blogism' ), 'type' => 'checkbox', 'default' => false, ), ); parent::__construct( 'blogism-recent-posts', esc_html__( 'Blogism: Recent Posts', 'blogism' ), $opts, array(), $fields ); } /** * Outputs the content for the current widget instance. * * @since 1.0.0 * * @param array $args Display arguments. * @param array $instance Settings for the current widget instance. */ function widget( $args, $instance ) { $params = $this->get_params( $instance ); echo $args['before_widget']; if ( ! empty( $params['title'] ) ) { echo $args['before_title'] . $params['title'] . $args['after_title']; } $qargs = array( 'posts_per_page' => esc_attr( $params['post_number'] ), 'no_found_rows' => true, ); if ( absint( $params['post_category'] ) > 0 ) { $qargs['cat'] = $params['post_category']; } $all_posts = get_posts( $qargs ); ?>