'bizroot_widget_social',
'description' => __( 'Displays social icons.', 'bizroot' ),
'customize_selective_refresh' => true,
);
$fields = array(
'title' => array(
'label' => __( 'Title:', 'bizroot' ),
'type' => 'text',
'class' => 'widefat',
),
'subtitle' => array(
'label' => __( 'Subtitle:', 'bizroot' ),
'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.', 'bizroot' ),
'type' => 'message',
'class' => 'widefat',
);
}
parent::__construct( 'bizroot-social', __( 'Bizroot: Social', 'bizroot' ), $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'] ) . '
';
}
$nav_menu_locations = get_nav_menu_locations();
$menu_id = 0;
if ( isset( $nav_menu_locations['social'] ) && absint( $nav_menu_locations['social'] ) > 0 ) {
$menu_id = absint( $nav_menu_locations['social'] );
}
if ( $menu_id > 0 ) {
$menu_items = wp_get_nav_menu_items( $menu_id );
if ( ! empty( $menu_items ) ) {
echo '';
}
}
echo $args['after_widget'];
}
}
endif;
if ( ! class_exists( 'Bizroot_Latest_News_Widget' ) ) :
/**
* Latest news widget Class.
*
* @since 1.0.0
*/
class Bizroot_Latest_News_Widget extends Bizroot_Widget_Base {
/**
* Sets up a new widget instance.
*
* @since 1.0.0
*/
function __construct() {
$opts = array(
'classname' => 'bizroot_widget_latest_news',
'description' => __( 'Displays latest posts in grid.', 'bizroot' ),
'customize_selective_refresh' => true,
);
$fields = array(
'title' => array(
'label' => __( 'Title:', 'bizroot' ),
'type' => 'text',
'class' => 'widefat',
),
'subtitle' => array(
'label' => __( 'Subtitle:', 'bizroot' ),
'type' => 'text',
'class' => 'widefat',
),
'post_category' => array(
'label' => __( 'Select Category:', 'bizroot' ),
'type' => 'dropdown-taxonomies',
'show_option_all' => __( 'All Categories', 'bizroot' ),
),
'post_number' => array(
'label' => __( 'Number of Posts:', 'bizroot' ),
'type' => 'number',
'default' => 3,
'css' => 'max-width:60px;',
'min' => 1,
'max' => 100,
),
'post_column' => array(
'label' => __( 'Number of Columns:', 'bizroot' ),
'type' => 'select',
'default' => 3,
'options' => bizroot_get_numbers_dropdown_options( 1, 4 ),
),
'featured_image' => array(
'label' => __( 'Featured Image:', 'bizroot' ),
'type' => 'select',
'default' => 'bizroot-thumb',
'options' => bizroot_get_image_sizes_options(),
),
'excerpt_length' => array(
'label' => __( 'Excerpt Length:', 'bizroot' ),
'description' => __( 'in words', 'bizroot' ),
'type' => 'number',
'css' => 'max-width:60px;',
'default' => 15,
'min' => 1,
'max' => 400,
'adjacent' => true,
),
'more_text' => array(
'label' => __( 'More Text:', 'bizroot' ),
'type' => 'text',
'default' => __( 'Read more', 'bizroot' ),
),
'disable_date' => array(
'label' => __( 'Disable Date', 'bizroot' ),
'type' => 'checkbox',
'default' => false,
),
'disable_excerpt' => array(
'label' => __( 'Disable Excerpt', 'bizroot' ),
'type' => 'checkbox',
'default' => false,
),
'disable_more_text' => array(
'label' => __( 'Disable More Text', 'bizroot' ),
'type' => 'checkbox',
'default' => false,
),
);
parent::__construct( 'bizroot-latest-news', __( 'Bizroot: Latest News', 'bizroot' ), $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['category'] = absint( $params['post_category'] );
}
$all_posts = get_posts( $qargs );
?>
'bizroot_widget_call_to_action',
'description' => __( 'Call To Action Widget.', 'bizroot' ),
'customize_selective_refresh' => true,
);
$fields = array(
'title' => array(
'label' => __( 'Title:', 'bizroot' ),
'type' => 'text',
'class' => 'widefat',
),
'description' => array(
'label' => __( 'Description:', 'bizroot' ),
'type' => 'textarea',
'class' => 'widefat',
),
'primary_button_text' => array(
'label' => __( 'Button Text:', 'bizroot' ),
'default' => __( 'Learn more', 'bizroot' ),
'type' => 'text',
'class' => 'widefat',
),
'primary_button_url' => array(
'label' => __( 'Button URL:', 'bizroot' ),
'type' => 'url',
'class' => 'widefat',
),
);
parent::__construct( 'bizroot-call-to-action', __( 'Bizroot: Call To Action', 'bizroot' ), $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'];
}
?>
'bizroot_widget_services',
'description' => __( 'Show your services with icon and read more link.', 'bizroot' ),
'customize_selective_refresh' => true,
);
$fields = array(
'title' => array(
'label' => __( 'Title:', 'bizroot' ),
'type' => 'text',
'class' => 'widefat',
),
'subtitle' => array(
'label' => __( 'Subtitle:', 'bizroot' ),
'type' => 'text',
'class' => 'widefat',
),
'excerpt_length' => array(
'label' => __( 'Excerpt Length:', 'bizroot' ),
'description' => __( 'in words', 'bizroot' ),
'type' => 'number',
'css' => 'max-width:60px;',
'default' => 15,
'min' => 1,
'max' => 400,
'adjacent' => true,
),
'disable_excerpt' => array(
'label' => __( 'Disable Excerpt', 'bizroot' ),
'type' => 'checkbox',
'default' => false,
),
'more_text' => array(
'label' => __( 'Read More Text:', 'bizroot' ),
'type' => 'text',
'default' => __( 'Read more', 'bizroot' ),
),
'disable_more_text' => array(
'label' => __( 'Disable Read More', 'bizroot' ),
'type' => 'checkbox',
'default' => false,
),
);
for( $i = 1; $i <= 4; $i++ ) {
$fields[ 'block_heading_' . $i ] = array(
'label' => __( 'Block', 'bizroot' ) . ' #' . $i,
'type' => 'heading',
'class' => 'widefat',
);
$fields[ 'block_page_' . $i ] = array(
'label' => __( 'Select Page:', 'bizroot' ),
'type' => 'dropdown-pages',
'show_option_none' => __( '— Select —', 'bizroot' ),
);
$fields[ 'block_icon_' . $i ] = array(
'label' => __( 'Icon:', 'bizroot' ),
'description' => __( 'Eg: fa-cogs', 'bizroot' ),
'type' => 'text',
'default' => 'fa-cogs',
);
}
parent::__construct( 'bizroot-services', __( 'Bizroot: Services', 'bizroot' ), $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 < 4 ; $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(
'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'] ) ) : ?>
'bizroot_widget_contact',
'description' => __( 'Displays contact form.', 'bizroot' ),
'customize_selective_refresh' => true,
);
$fields = array(
'title' => array(
'label' => __( 'Title:', 'bizroot' ),
'type' => 'text',
'class' => 'widefat',
),
'subtitle' => array(
'label' => __( 'Subtitle:', 'bizroot' ),
'type' => 'text',
'class' => 'widefat',
),
'form_id' => array(
'label' => __( 'Select Contact Form:', 'bizroot' ),
'type' => 'select',
'options' => bizroot_get_contact_form_options(),
),
'form_message' => array(
'label' => _x( 'OR', 'Bizroot Contact', 'bizroot' ),
'type' => 'heading',
),
'form_shortcode' => array(
'label' => __( 'Enter Form Shortcode:', 'bizroot' ),
'type' => 'textarea',
'class' => 'widefat',
),
);
parent::__construct( 'bizroot-contact', __( 'Bizroot: Contact', 'bizroot' ), $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'] ) . '
';
}
$shortcode_text = null;
if ( ! empty( $params['form_id'] ) && absint( $params['form_id'] ) > 0 && defined( 'WPCF7_VERSION' ) ) {
$shortcode_text = '[contact-form-7 id="' . absint( $params['form_id'] ) . '"]';
}
if ( empty( $shortcode_text ) ) {
$shortcode_text = wp_kses_data( $params['form_shortcode'] );
}
if ( ! empty( $shortcode_text ) ) {
echo do_shortcode( $shortcode_text );
}
echo $args['after_widget'];
}
}
endif;