'nature_bliss_widget_social', 'description' => __( 'Displays social icons.', 'nature-bliss' ), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => __( 'Title:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'subtitle' => array( 'label' => __( 'Subtitle:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), ); if ( false === has_nav_menu( 'social' ) ) { $fields['message'] = array( 'label' => __( 'Social menu is not set. Please create menu and assign it to Social Menu.', 'nature-bliss' ), 'type' => 'message', 'class' => 'widefat', ); } parent::__construct( 'nature-bliss-social', __( 'NB: Social', 'nature-bliss' ), $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( 'Nature_Bliss_Featured_Page_Widget' ) ) : /** * Featured page widget Class. * * @since 1.0.0 */ class Nature_Bliss_Featured_Page_Widget extends Nature_Bliss_Widget_Base { /** * Sets up a new widget instance. * * @since 1.0.0 */ function __construct() { $opts = array( 'classname' => 'nature_bliss_widget_featured_page', 'description' => __( 'Displays single featured Page or Post.', 'nature-bliss' ), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => __( 'Title:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'use_page_title' => array( 'label' => __( 'Use Page/Post Title as Widget Title', 'nature-bliss' ), 'type' => 'checkbox', 'default' => true, ), 'subtitle' => array( 'label' => __( 'Subtitle:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'featured_page' => array( 'label' => __( 'Select Page:', 'nature-bliss' ), 'type' => 'dropdown-pages', 'show_option_none' => __( '— Select —', 'nature-bliss' ), ), 'id_message' => array( 'label' => '' . _x( 'OR', 'Featured Page Widget', 'nature-bliss' ) . '', 'type' => 'message', ), 'featured_post' => array( 'label' => __( 'Post ID:', 'nature-bliss' ), 'placeholder' => __( 'Eg: 1234', 'nature-bliss' ), 'type' => 'text', 'sanitize_callback' => 'nature_bliss_widget_sanitize_post_id', ), 'content_type' => array( 'label' => __( 'Show Content:', 'nature-bliss' ), 'type' => 'select', 'default' => 'full', 'options' => array( 'excerpt' => __( 'Excerpt', 'nature-bliss' ), 'full' => __( 'Full', 'nature-bliss' ), ), ), 'excerpt_length' => array( 'label' => __( 'Excerpt Length:', 'nature-bliss' ), 'description' => __( 'Applies when Excerpt is selected in Content option.', 'nature-bliss' ), 'type' => 'number', 'css' => 'max-width:60px;', 'default' => 100, 'min' => 1, 'max' => 400, ), 'featured_image' => array( 'label' => __( 'Featured Image:', 'nature-bliss' ), 'type' => 'select', 'options' => nature_bliss_get_image_sizes_options(), ), 'featured_image_alignment' => array( 'label' => __( 'Image Alignment:', 'nature-bliss' ), 'type' => 'select', 'default' => 'center', 'options' => nature_bliss_get_image_alignment_options(), ), ); parent::__construct( 'nature-bliss-featured-page', __( 'NB: Featured Page', 'nature-bliss' ), $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'] ) ); } echo ''; echo '
'; } wp_reset_postdata(); } } echo $args['after_widget']; } } endif; if ( ! class_exists( 'Nature_Bliss_Latest_News_Widget' ) ) : /** * Latest news widget Class. * * @since 1.0.0 */ class Nature_Bliss_Latest_News_Widget extends Nature_Bliss_Widget_Base { /** * Sets up a new widget instance. * * @since 1.0.0 */ function __construct() { $opts = array( 'classname' => 'nature_bliss_widget_latest_news', 'description' => __( 'Displays latest posts in grid.', 'nature-bliss' ), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => __( 'Title:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'subtitle' => array( 'label' => __( 'Subtitle:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'post_category' => array( 'label' => __( 'Select Category:', 'nature-bliss' ), 'type' => 'dropdown-taxonomies', 'show_option_all' => __( 'All Categories', 'nature-bliss' ), ), 'post_number' => array( 'label' => __( 'Number of Posts:', 'nature-bliss' ), 'type' => 'number', 'default' => 3, 'css' => 'max-width:60px;', 'min' => 1, 'max' => 100, ), 'post_column' => array( 'label' => __( 'Number of Columns:', 'nature-bliss' ), 'type' => 'select', 'default' => 3, 'options' => nature_bliss_get_numbers_dropdown_options( 1, 4 ), ), 'featured_image' => array( 'label' => __( 'Featured Image:', 'nature-bliss' ), 'type' => 'select', 'default' => 'nature-bliss-thumb', 'options' => nature_bliss_get_image_sizes_options(), ), 'excerpt_length' => array( 'label' => __( 'Excerpt Length:', 'nature-bliss' ), 'description' => __( 'in words', 'nature-bliss' ), 'type' => 'number', 'css' => 'max-width:60px;', 'default' => 15, 'min' => 1, 'max' => 400, 'adjacent' => true, ), 'more_text' => array( 'label' => __( 'More Text:', 'nature-bliss' ), 'type' => 'text', 'default' => __( 'Know More', 'nature-bliss' ), ), 'disable_date' => array( 'label' => __( 'Disable Date', 'nature-bliss' ), 'type' => 'checkbox', 'default' => false, ), 'disable_excerpt' => array( 'label' => __( 'Disable Excerpt', 'nature-bliss' ), 'type' => 'checkbox', 'default' => false, ), 'disable_more_text' => array( 'label' => __( 'Disable More Text', 'nature-bliss' ), 'type' => 'checkbox', 'default' => false, ), ); parent::__construct( 'nature-bliss-latest-news', __( 'NB: Latest News', 'nature-bliss' ), $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 ) : ?>
'nature_bliss_widget_call_to_action', 'description' => __( 'Call To Action Widget.', 'nature-bliss' ), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => __( 'Title:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'description' => array( 'label' => __( 'Description:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'primary_button_text' => array( 'label' => __( 'Primary Button Text:', 'nature-bliss' ), 'default' => __( 'Learn more', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'primary_button_url' => array( 'label' => __( 'Primary Button URL:', 'nature-bliss' ), 'type' => 'url', 'class' => 'widefat', ), 'secondary_button_text' => array( 'label' => __( 'Secondary Button Text:', 'nature-bliss' ), 'default' => '', 'type' => 'text', 'class' => 'widefat', ), 'secondary_button_url' => array( 'label' => __( 'Secondary Button URL:', 'nature-bliss' ), 'type' => 'url', 'class' => 'widefat', ), 'background_image' => array( 'label' => __( 'Background Image:', 'nature-bliss' ), 'type' => 'image', 'default' => '', ), 'enable_background_overlay' => array( 'label' => __( 'Enable Background Overlay', 'nature-bliss' ), 'type' => 'checkbox', 'default' => true, ), ); parent::__construct( 'nature-bliss-call-to-action', __( 'NB: Call To Action', 'nature-bliss' ), $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 ); // Add background image. if ( ! empty( $params['background_image'] ) ) { $background_style = ''; $background_style .= ' style="background-image:url(' . esc_url( $params['background_image'] ) . ');" '; $args['before_widget'] = implode( $background_style . ' ' . 'class="', explode( 'class="', $args['before_widget'], 2 ) ); } // Add overlay class. $overlay_class = ( true === $params['enable_background_overlay'] ) ? 'overlay-enabled' : 'overlay-disabled' ; $args['before_widget'] = implode( 'class="' . $overlay_class . ' ', explode( 'class="', $args['before_widget'], 2 ) ); echo $args['before_widget']; if ( ! empty( $params['title'] ) ) { echo $args['before_title'] . $params['title'] . $args['after_title']; } ?>
'nature_bliss_widget_services', 'description' => __( 'Show your services with icon and read more link.', 'nature-bliss' ), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => __( 'Title:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'subtitle' => array( 'label' => __( 'Subtitle:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'excerpt_length' => array( 'label' => __( 'Excerpt Length:', 'nature-bliss' ), 'description' => __( 'in words', 'nature-bliss' ), 'type' => 'number', 'css' => 'max-width:60px;', 'default' => 15, 'min' => 1, 'max' => 400, 'adjacent' => true, ), 'disable_excerpt' => array( 'label' => __( 'Disable Excerpt', 'nature-bliss' ), 'type' => 'checkbox', 'default' => false, ), 'more_text' => array( 'label' => __( 'Read More Text:', 'nature-bliss' ), 'type' => 'text', 'default' => __( 'Know More', 'nature-bliss' ), ), 'disable_more_text' => array( 'label' => __( 'Disable Read More', 'nature-bliss' ), 'type' => 'checkbox', 'default' => false, ), ); for( $i = 1; $i <= 6; $i++ ) { $fields[ 'block_heading_' . $i ] = array( 'label' => __( 'Block', 'nature-bliss' ) . ' #' . $i, 'type' => 'heading', 'class' => 'widefat', ); $fields[ 'block_page_' . $i ] = array( 'label' => __( 'Select Page:', 'nature-bliss' ), 'type' => 'dropdown-pages', 'show_option_none' => __( '— Select —', 'nature-bliss' ), ); $fields[ 'block_icon_' . $i ] = array( 'label' => __( 'Icon:', 'nature-bliss' ), 'description' => __( 'Eg: fa-cogs', 'nature-bliss' ), 'type' => 'text', 'default' => 'fa-cogs', ); } parent::__construct( 'nature-bliss-services', __( 'NB: Services', 'nature-bliss' ), $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'] ) . '

'; } $service_arr = array(); for ( $i = 0; $i < 6 ; $i++ ) { $block = ( $i + 1 ); $service_arr[ $i ] = array( 'page' => $params[ 'block_page_' . $block ], 'icon' => $params[ 'block_icon_' . $block ], ); } $refined_arr = array(); if ( ! empty( $service_arr ) ) { foreach ( $service_arr as $item ) { if ( ! empty( $item['page'] ) ) { $refined_arr[ $item['page'] ] = $item; } } } if ( ! empty( $refined_arr ) ) { $this->render_widget_content( $refined_arr, $params ); } echo $args['after_widget']; } /** * Render services content. * * @since 1.0.0 * * @param array $service_arr Services array. * @param array $params Parameters array. */ function render_widget_content( $service_arr, $params ) { $column = count( $service_arr ); $page_ids = array_keys( $service_arr ); $qargs = array( 'posts_per_page' => count( $page_ids ), 'post__in' => $page_ids, 'post_type' => 'page', 'orderby' => 'post__in', 'no_found_rows' => true, ); $all_posts = get_posts( $qargs ); ?>
ID ]['icon'] ) && ! empty( $service_arr[ $post->ID ]['icon'] ) ) : ?>
'nature_bliss_widget_recent_posts', 'description' => __( 'Displays recent posts.', 'nature-bliss' ), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => __( 'Title:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'subtitle' => array( 'label' => __( 'Subtitle:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'post_category' => array( 'label' => __( 'Select Category:', 'nature-bliss' ), 'type' => 'dropdown-taxonomies', 'show_option_all' => __( 'All Categories', 'nature-bliss' ), ), 'post_number' => array( 'label' => __( 'Number of Posts:', 'nature-bliss' ), 'type' => 'number', 'default' => 4, 'css' => 'max-width:60px;', 'min' => 1, 'max' => 100, ), 'featured_image' => array( 'label' => __( 'Featured Image:', 'nature-bliss' ), 'type' => 'select', 'default' => 'thumbnail', 'options' => nature_bliss_get_image_sizes_options( true, array( 'disable', 'thumbnail' ), false ), ), 'image_width' => array( 'label' => __( 'Image Width:', 'nature-bliss' ), 'type' => 'number', 'description' => __( 'px', 'nature-bliss' ), 'css' => 'max-width:60px;', 'adjacent' => true, 'default' => 70, 'min' => 1, 'max' => 150, ), 'disable_date' => array( 'label' => __( 'Disable Date', 'nature-bliss' ), 'type' => 'checkbox', 'default' => false, ), ); parent::__construct( 'nature-bliss-recent-posts', __( 'NB: Recent Posts', 'nature-bliss' ), $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'] = $params['post_category']; } $all_posts = get_posts( $qargs ); ?>
$post ) : ?>

'nature_bliss_widget_features', 'description' => __( 'Displays features.', 'nature-bliss' ), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => __( 'Title:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'subtitle' => array( 'label' => __( 'Subtitle:', 'nature-bliss' ), 'type' => 'text', 'class' => 'widefat', ), 'main_image' => array( 'label' => __( 'Main Image:', 'nature-bliss' ), 'description' => __( 'Square image is recommended.', 'nature-bliss' ), 'type' => 'image', ), ); for( $i = 1; $i <= 4; $i++ ) { $fields[ 'block_heading_' . $i ] = array( 'label' => __( 'Block', 'nature-bliss' ) . ' #' . $i, 'type' => 'heading', 'class' => 'widefat', ); $fields[ 'block_page_' . $i ] = array( 'label' => __( 'Select Page:', 'nature-bliss' ), 'type' => 'dropdown-pages', 'show_option_none' => __( '— Select —', 'nature-bliss' ), ); $fields[ 'block_icon_' . $i ] = array( 'label' => __( 'Icon:', 'nature-bliss' ), 'description' => __( 'Eg: fa-cogs', 'nature-bliss' ), 'type' => 'text', 'default' => 'fa-cogs', ); } parent::__construct( 'nature-bliss-features', __( 'NB: Features', 'nature-bliss' ), $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'] ) . '

'; } $feature_arr = array(); for ( $i = 0; $i < 4 ; $i++ ) { $block = ( $i + 1 ); $feature_arr[ $i ] = array( 'page' => $params[ 'block_page_' . $block ], 'icon' => $params[ 'block_icon_' . $block ], ); } $refined_arr = array(); if ( ! empty( $feature_arr ) ) { foreach ( $feature_arr as $item ) { if ( ! empty( $item['page'] ) ) { $refined_arr[] = $item; } } } if ( ! empty( $refined_arr ) ) { $this->render_widget_content( $refined_arr, $params ); } echo $args['after_widget']; } function get_details( $items ) { $output = array(); $page_ids = wp_list_pluck( $items, 'page' ); $qargs = array( 'post__in' => $page_ids, 'post_type' => 'page', 'orderby' => 'post__in', 'no_found_rows' => true, ); $all_posts = get_posts( $qargs ); if ( ! empty( $all_posts ) ) { $cnt = 0; foreach ( $all_posts as $post ) { $item = array(); $item['title'] = apply_filters( 'the_title', $post->post_title ); $item['url'] = get_permalink( $post->ID ); $item['excerpt'] = nature_bliss_the_excerpt( 15, $post ); $item['icon'] = ''; if ( isset( $items[ $cnt ]['icon'] ) ) { $item['icon'] = $items[ $cnt ]['icon']; } $output[] = $item; $cnt++; } } return $output; } /** * Render feature content. * * @since 1.0.0 * * @param array $feature_arr Features array. * @param array $params Parameters array. */ function render_widget_content( $feature_arr, $params ) { $item_details = $this->get_details( $feature_arr ); if ( empty( $item_details ) ) { return; } $first_part = array(); $second_part = array(); $first_part = array_slice( $item_details, 0, 2 ); $second_part = array_slice( $item_details, 2, 2 ); ?>