'easy_commerce_widget_social', 'description' => esc_html__( 'Displays social icons.', 'easy-commerce' ), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => esc_html__( 'Title:', 'easy-commerce' ), 'type' => 'text', 'class' => 'widefat', ), 'subtitle' => array( 'label' => esc_html__( 'Subtitle:', 'easy-commerce' ), '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.', 'easy-commerce' ), 'type' => 'message', 'class' => 'widefat', ); } parent::__construct( 'easy-commerce-social', esc_html__( 'EC: Social', 'easy-commerce' ), $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']; } if ( ! empty( $params['subtitle'] ) ) { echo '

' . esc_html( $params['subtitle'] ) . '

'; } if ( has_nav_menu( 'social' ) ) { wp_nav_menu( array( 'theme_location' => 'social', 'container' => false, 'depth' => 1, 'link_before' => '', 'link_after' => '', ) ); } echo $args['after_widget']; } } endif; if ( ! class_exists( 'Easy_Commerce_Featured_Page_Widget' ) ) : /** * Featured page widget Class. * * @since 1.0.0 */ class Easy_Commerce_Featured_Page_Widget extends Easy_Commerce_Widget_Base { /** * Sets up a new widget instance. * * @since 1.0.0 */ function __construct() { $opts = array( 'classname' => 'easy_commerce_widget_featured_page', 'description' => esc_html__( 'Displays single featured Page or Post.', 'easy-commerce' ), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => esc_html__( 'Title:', 'easy-commerce' ), 'type' => 'text', 'class' => 'widefat', ), 'subtitle' => array( 'label' => esc_html__( 'Subtitle:', 'easy-commerce' ), 'type' => 'text', 'class' => 'widefat', ), 'use_page_title' => array( 'label' => esc_html__( 'Use Page/Post Title as Widget Title', 'easy-commerce' ), 'type' => 'checkbox', 'default' => true, ), 'featured_page' => array( 'label' => esc_html__( 'Select Page:', 'easy-commerce' ), 'type' => 'dropdown-pages', 'show_option_none' => esc_html__( '— Select —', 'easy-commerce' ), ), 'id_message' => array( 'label' => '' . _x( 'OR', 'Featured Page Widget', 'easy-commerce' ) . '', 'type' => 'message', ), 'featured_post' => array( 'label' => esc_html__( 'Post ID:', 'easy-commerce' ), 'placeholder' => esc_html__( 'Eg: 1234', 'easy-commerce' ), 'type' => 'text', 'sanitize_callback' => 'easy_commerce_widget_sanitize_post_id', ), 'content_type' => array( 'label' => esc_html__( 'Show Content:', 'easy-commerce' ), 'type' => 'select', 'default' => 'full', 'options' => array( 'excerpt' => esc_html__( 'Excerpt', 'easy-commerce' ), 'full' => esc_html__( 'Full', 'easy-commerce' ), ), ), 'excerpt_length' => array( 'label' => esc_html__( 'Excerpt Length:', 'easy-commerce' ), 'description' => esc_html__( 'Applies when Excerpt is selected in Content option.', 'easy-commerce' ), 'type' => 'number', 'css' => 'max-width:60px;', 'default' => 40, 'min' => 1, 'max' => 400, ), 'featured_image' => array( 'label' => esc_html__( 'Featured Image:', 'easy-commerce' ), 'type' => 'select', 'options' => easy_commerce_get_image_sizes_options(), ), 'featured_image_alignment' => array( 'label' => esc_html__( 'Image Alignment:', 'easy-commerce' ), 'type' => 'select', 'default' => 'center', 'options' => easy_commerce_get_image_alignment_options(), ), ); parent::__construct( 'easy-commerce-featured-page', esc_html__( 'EC: Featured Page', 'easy-commerce' ), $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']; $our_id = ''; if ( absint( $params['featured_post'] ) > 0 ) { $our_id = absint( $params['featured_post'] ); } if ( absint( $params['featured_page'] ) > 0 ) { $our_id = absint( $params['featured_page'] ); } if ( absint( $our_id ) > 0 ) { $qargs = array( 'p' => absint( $our_id ), 'post_type' => 'any', 'no_found_rows' => true, ); $the_query = new WP_Query( $qargs ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); echo '
'; if ( 'disable' != $params['featured_image'] && has_post_thumbnail() ) { the_post_thumbnail( esc_attr( $params['featured_image'] ), array( 'class' => 'align' . esc_attr( $params['featured_image_alignment'] ) ) ); } echo ''; echo '
'; } wp_reset_postdata(); } } echo $args['after_widget']; } } endif; if ( ! class_exists( 'Easy_Commerce_Recent_Posts_Widget' ) ) : /** * Recent posts widget Class. * * @since 1.0.0 */ class Easy_Commerce_Recent_Posts_Widget extends Easy_Commerce_Widget_Base { /** * Sets up a new widget instance. * * @since 1.0.0 */ function __construct() { $opts = array( 'classname' => 'easy_commerce_widget_recent_posts', 'description' => esc_html__( 'Displays recent posts.', 'easy-commerce' ), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => esc_html__( 'Title:', 'easy-commerce' ), 'type' => 'text', 'class' => 'widefat', ), 'subtitle' => array( 'label' => esc_html__( 'Subtitle:', 'easy-commerce' ), 'type' => 'text', 'class' => 'widefat', ), 'post_category' => array( 'label' => esc_html__( 'Select Category:', 'easy-commerce' ), 'type' => 'dropdown-taxonomies', 'show_option_all' => esc_html__( 'All Categories', 'easy-commerce' ), ), 'post_number' => array( 'label' => esc_html__( 'Number of Posts:', 'easy-commerce' ), 'type' => 'number', 'default' => 4, 'css' => 'max-width:60px;', 'min' => 1, 'max' => 100, ), 'featured_image' => array( 'label' => esc_html__( 'Featured Image:', 'easy-commerce' ), 'type' => 'select', 'default' => 'thumbnail', 'options' => easy_commerce_get_image_sizes_options( true, array( 'disable', 'thumbnail' ), false ), ), 'image_width' => array( 'label' => esc_html__( 'Image Width:', 'easy-commerce' ), 'type' => 'number', 'description' => esc_html__( 'px', 'easy-commerce' ), 'css' => 'max-width:60px;', 'adjacent' => true, 'default' => 65, 'min' => 1, 'max' => 150, ), 'disable_date' => array( 'label' => esc_html__( 'Disable Date', 'easy-commerce' ), 'type' => 'checkbox', 'default' => false, ), ); parent::__construct( 'easy-commerce-recent-posts', esc_html__( 'EC: Recent Posts', 'easy-commerce' ), $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']; } if ( ! empty( $params['subtitle'] ) ) { echo '

' . esc_html( $params['subtitle'] ) . '

'; } $qargs = array( 'posts_per_page' => esc_attr( $params['post_number'] ), 'no_found_rows' => true, ); if ( absint( $params['post_category'] ) > 0 ) { $qargs['cat'] = absint( $params['post_category'] ); } $all_posts = get_posts( $qargs ); ?>
$post ) : ?>