__( 'Right Sidebar', 'spacious' ),
'id' => 'spacious_right_sidebar',
'description' => __( 'Shows widgets at Right side.', 'spacious' ),
'before_widget' => '',
'before_title' => '
'
) );
// Registering main left sidebar
register_sidebar( array(
'name' => __( 'Left Sidebar', 'spacious' ),
'id' => 'spacious_left_sidebar',
'description' => __( 'Shows widgets at Left side.', 'spacious' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering Header sidebar
register_sidebar( array(
'name' => __( 'Header Sidebar', 'spacious' ),
'id' => 'spacious_header_sidebar',
'description' => __( 'Shows widgets in header section just above the main navigation menu.', 'spacious' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering Business Page template top section sidebar
register_sidebar( array(
'name' => __( 'Business Top Sidebar', 'spacious' ),
'id' => 'spacious_business_page_top_section_sidebar',
'description' => __( 'Shows widgets on Business Page Template Top Section.', 'spacious' ).' '.__( 'Suitable widget: TG: Services, TG: Call To Action Widget, TG: Featured Widget', 'spacious' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering Business Page template middle section left half sidebar
register_sidebar( array(
'name' => __( 'Business Middle Left Sidebar', 'spacious' ),
'id' => 'spacious_business_page_middle_section_left_half_sidebar',
'description' => __( 'Shows widgets on Business Page Template Middle Section Left Half.', 'spacious' ).' '.__( 'Suitable widget: TG: Testimonial, TG: Featured Single Page', 'spacious' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering Business Page template middle section right half sidebar
register_sidebar( array(
'name' => __( 'Business Middle Right Sidebar', 'spacious' ),
'id' => 'spacious_business_page_middle_section_right_half_sidebar',
'description' => __( 'Shows widgets on Business Page Template Middle Section Right Half.', 'spacious' ).' '.__( 'Suitable widget: TG: Testimonial, TG: Featured Single Page', 'spacious' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering Business Page template bottom section sidebar
register_sidebar( array(
'name' => __( 'Business Bottom Sidebar', 'spacious' ),
'id' => 'spacious_business_page_bottom_section_sidebar',
'description' => __( 'Shows widgets on Business Page Template Bottom Section.', 'spacious' ).' '.__( 'Suitable widget: TG: Services, TG: Call To Action Widget, TG: Featured Widget', 'spacious' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering contact Page sidebar
register_sidebar( array(
'name' => __( 'Contact Page Sidebar', 'spacious' ),
'id' => 'spacious_contact_page_sidebar',
'description' => __( 'Shows widgets on Contact Page Template.', 'spacious' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering Error 404 Page sidebar
register_sidebar( array(
'name' => __( 'Error 404 Page Sidebar', 'spacious' ),
'id' => 'spacious_error_404_page_sidebar',
'description' => __( 'Shows widgets on Error 404 page.', 'spacious' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering footer sidebar one
register_sidebar( array(
'name' => __( 'Footer Sidebar One', 'spacious' ),
'id' => 'spacious_footer_sidebar_one',
'description' => __( 'Shows widgets at footer sidebar one.', 'spacious' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering footer sidebar two
register_sidebar( array(
'name' => __( 'Footer Sidebar Two', 'spacious' ),
'id' => 'spacious_footer_sidebar_two',
'description' => __( 'Shows widgets at footer sidebar two.', 'spacious' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering footer sidebar three
register_sidebar( array(
'name' => __( 'Footer Sidebar Three', 'spacious' ),
'id' => 'spacious_footer_sidebar_three',
'description' => __( 'Shows widgets at footer sidebar three.', 'spacious' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering footer sidebar four
register_sidebar( array(
'name' => __( 'Footer Sidebar Four', 'spacious' ),
'id' => 'spacious_footer_sidebar_four',
'description' => __( 'Shows widgets at footer sidebar four.', 'spacious' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering widgets
register_widget( "spacious_featured_single_page_widget" );
register_widget( "spacious_service_widget" );
register_widget( "spacious_call_to_action_widget" );
register_widget( "spacious_testimonial_widget" );
register_widget( "spacious_recent_work_widget" );
}
/****************************************************************************************/
/**
* Featured Single page widget.
*
*/
class spacious_featured_single_page_widget extends WP_Widget {
function spacious_featured_single_page_widget() {
$widget_ops = array( 'classname' => 'widget_featured_single_post', 'description' => __( 'Display Featured Single Page', 'spacious' ) );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false, $name='TG: Featured Single Page', $widget_ops, $control_ops);
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'page_id' => '', 'title' => '', 'disable_feature_image' => 0, 'image_position' => 'above' ) );
$title = esc_attr( $instance[ 'title' ] );
$page_id = absint( $instance[ 'page_id' ] );
$disable_feature_image = $instance['disable_feature_image'] ? 'checked="checked"' : '';
$image_position = $instance[ 'image_position' ];
_e( 'Suitable for Home Top Sidebar, Home Bottom Left Sidebar and Side Sidbar.', 'spacious' );
?>
$this->get_field_name( 'page_id' ), 'selected' => $instance['page_id'] ) ); ?>
id="get_field_id('disable_feature_image'); ?>" name="get_field_name('disable_feature_image'); ?>" />
have_posts() ):$the_query->the_post();
$page_name = get_the_title();
$output = $before_widget;
if( $image_position == "below" ) {
if( $title ): $output .= $before_title.''. $title .''.$after_title;
else: $output .= $before_title.''. $page_name .''.$after_title;
endif;
}
if( has_post_thumbnail() && $disable_feature_image != "true" ) {
$output.= ''.get_the_post_thumbnail( $post->ID, 'featured', array( 'title' => esc_attr( $page_name ), 'alt' => esc_attr( $page_name ) ) ).'
';
}
if( $image_position == "above" ) {
if( $title ): $output .= $before_title.''. $title .''.$after_title;
else: $output .= $before_title.''. $page_name .''.$after_title;
endif;
}
$output .= ''.get_the_excerpt().'...'.'
';
$output .= ''.__( 'Read more', 'spacious' ).'';
$output .= $after_widget;
endwhile;
// Reset Post Data
wp_reset_postdata();
echo $output;
}
}
}
/****************************************************************************************/
/**
* Featured service widget to show pages.
*/
class spacious_service_widget extends WP_Widget {
function spacious_service_widget() {
$widget_ops = array( 'classname' => 'widget_service_block', 'description' => __( 'Display some pages as services. Best for Business Top or Bottom sidebar.', 'spacious' ) );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false, $name = __( 'TG: Services', 'spacious' ), $widget_ops, $control_ops);
}
function form( $instance ) {
for ( $i=0; $i<6; $i++ ) {
$var = 'page_id'.$i;
$defaults[$var] = '';
}
$instance = wp_parse_args( (array) $instance, $defaults );
for ( $i=0; $i<6; $i++ ) {
$var = 'page_id'.$i;
$var = absint( $instance[ $var ] );
}
?>
' ','name' => $this->get_field_name( key($defaults) ), 'selected' => $instance[key($defaults)] ) ); ?>
-1,
'post_type' => array( 'page' ),
'post__in' => $page_array,
'orderby' => 'post__in'
) );
echo $before_widget; ?>
have_posts() ):$get_featured_pages->the_post();
$page_title = get_the_title();
if( $j % 2 == 1 && $j > 1 ) {
$service_class = "tg-one-third tg-after-two-blocks-clearfix";
}
elseif ( $j % 3 == 1 && $j > 1 ) {
$service_class = "tg-one-third tg-after-three-blocks-clearfix";
}
else {
$service_class = "tg-one-third";
}
if( $j % 2 == 0 ) { $service_class = $service_class.' tg-service-right'; }
else { $service_class = $service_class.' tg-service-left'; }
?>
'.get_the_post_thumbnail( $post->ID, 'featured' ).'
';
}
?>
'widget_call_to_action', 'description' => __( 'Use this widget to show the call to action section.', 'spacious' ) );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false, $name = __( 'TG: Call To Action Widget', 'spacious' ), $widget_ops, $control_ops);
}
function form( $instance ) {
$spacious_defaults[ 'text_main' ] = '';
$spacious_defaults[ 'text_additional' ] = '';
$spacious_defaults[ 'button_text' ] = '';
$spacious_defaults[ 'button_url' ] = '';
$instance = wp_parse_args( (array) $instance, $spacious_defaults );
$text_main = esc_textarea( $instance[ 'text_main' ] );
$text_additional = esc_textarea( $instance[ 'text_additional' ] );
$button_text = esc_attr( $instance[ 'button_text' ] );
$button_url = esc_url( $instance[ 'button_url' ] );
?>
'widget_testimonial', 'description' => __( 'Display Testimonial', 'spacious' ) );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false, $name = __( 'TG: Testimonial', 'spacious' ), $widget_ops, $control_ops);
}
function widget( $args, $instance ) {
extract($args);
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
$text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
$name = apply_filters( 'widget_name', empty( $instance['name'] ) ? '' : $instance['name'], $instance, $this->id_base );
$byline = apply_filters( 'widget_byline', empty( $instance['byline'] ) ? '' : $instance['byline'], $instance, $this->id_base );
echo $before_widget;
if ( !empty( $title ) ) { echo $before_title. esc_html( $title ) . $after_title; } ?>
'.esc_textarea( $text ).''; ?>
'', 'text' => '', 'name' =>'', 'byline'=>'' ) );
$title = strip_tags($instance['title']);
$name = strip_tags($instance['name']);
$byline = strip_tags($instance['byline']);
$text = esc_textarea($instance['text']);
?>
'widget_recent_work', 'description' => __( 'Show your some pages as recent work. Best for Business Top or Bottom sidebar.', 'spacious' ) );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false, $name = __( 'TG: Featured Widget', 'spacious' ), $widget_ops, $control_ops);
}
function form( $instance ) {
for ( $i=0; $i<3; $i++ ) {
$var = 'page_id'.$i;
$defaults[$var] = '';
}
$att_defaults = $defaults;
$att_defaults['title'] = '';
$att_defaults['text'] = '';
$instance = wp_parse_args( (array) $instance, $att_defaults );
for ( $i=0; $i<3; $i++ ) {
$var = 'page_id'.$i;
$var = absint( $instance[ $var ] );
}
$title = esc_attr( $instance[ 'title' ] );
$text = esc_textarea($instance['text']);
?>
' ','name' => $this->get_field_name( key($defaults) ), 'selected' => $instance[key($defaults)] ) ); ?>
-1,
'post_type' => array( 'page' ),
'post__in' => $page_array,
'orderby' => 'post__in'
) );
echo $before_widget;
?>
have_posts() ):$get_featured_pages->the_post();
if ( $i % 4 == 0 ) { $class = 'tg-one-fourth tg-one-fourth-last'.' tg-column-'.$i; }
elseif( $i % 3 == 0 ) { $class= 'tg-one-fourth tg-after-two-blocks-clearfix'.' tg-column-'.$i; }
else { $class = 'tg-one-fourth'.' tg-column-'.$i; }
$page_title = get_the_title();
?>
';
}
?>