__( 'Right Sidebar', 'colormag' ),
'id' => 'colormag_right_sidebar',
'description' => __( 'Shows widgets at Right side.', 'colormag' ),
'before_widget' => '',
'before_title' => '
'
) );
// Registering main left sidebar
register_sidebar( array(
'name' => __( 'Left Sidebar', 'colormag' ),
'id' => 'colormag_left_sidebar',
'description' => __( 'Shows widgets at Left side.', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering Header sidebar
register_sidebar( array(
'name' => __( 'Header Sidebar', 'colormag' ),
'id' => 'colormag_header_sidebar',
'description' => __( 'Shows widgets in header section just above the main navigation menu.', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// registering the Front Page: Slider Area Sidebar
register_sidebar( array(
'name' => __( 'Front Page: Slider Area', 'colormag' ),
'id' => 'colormag_front_page_slider_area',
'description' => __( 'Show widget just below menu. Suitable for TG: Featured Cat Slider.', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// registering the Front Page: Area beside slider Sidebar
register_sidebar( array(
'name' => __( 'Front Page: Area beside slider', 'colormag' ),
'id' => 'colormag_front_page_area_beside_slider',
'description' => __( 'Show widget beside the slider. Suitable for TG: Highlighted Posts.', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// registering the Front Page: Content Top Section Sidebar
register_sidebar( array(
'name' => __( 'Front Page: Content Top Section', 'colormag' ),
'id' => 'colormag_front_page_content_top_section',
'description' => __( 'Content Top Section', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// registering the Front Page: Content Middle Left Section Sidebar
register_sidebar( array(
'name' => __( 'Front Page: Content Middle Left Section', 'colormag' ),
'id' => 'colormag_front_page_content_middle_left_section',
'description' => __( 'Content Middle Left Section', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// registering the Front Page: Content Middle Right Section Sidebar
register_sidebar( array(
'name' => __( 'Front Page: Content Middle Right Section', 'colormag' ),
'id' => 'colormag_front_page_content_middle_right_section',
'description' => __( 'Content Middle Right Section', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// registering the Front Page: Content Bottom Section Sidebar
register_sidebar( array(
'name' => __( 'Front Page: Content Bottom Section', 'colormag' ),
'id' => 'colormag_front_page_content_bottom_section',
'description' => __( 'Content Middle Bottom Section', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering contact Page sidebar
register_sidebar( array(
'name' => __( 'Contact Page Sidebar', 'colormag' ),
'id' => 'colormag_contact_page_sidebar',
'description' => __( 'Shows widgets on Contact Page Template.', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering Error 404 Page sidebar
register_sidebar( array(
'name' => __( 'Error 404 Page Sidebar', 'colormag' ),
'id' => 'colormag_error_404_page_sidebar',
'description' => __( 'Shows widgets on Error 404 page.', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering advertisement above footer sidebar
register_sidebar( array(
'name' => __( 'Advertisement Above The Footer', 'colormag' ),
'id' => 'colormag_advertisement_above_the_footer_sidebar',
'description' => __( 'Shows widgets Just Above The Footer, suitable for TG: 728x90 widget.', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering footer sidebar one
register_sidebar( array(
'name' => __( 'Footer Sidebar One', 'colormag' ),
'id' => 'colormag_footer_sidebar_one',
'description' => __( 'Shows widgets at footer sidebar one.', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering footer sidebar two
register_sidebar( array(
'name' => __( 'Footer Sidebar Two', 'colormag' ),
'id' => 'colormag_footer_sidebar_two',
'description' => __( 'Shows widgets at footer sidebar two.', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering footer sidebar three
register_sidebar( array(
'name' => __( 'Footer Sidebar Three', 'colormag' ),
'id' => 'colormag_footer_sidebar_three',
'description' => __( 'Shows widgets at footer sidebar three.', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
// Registering footer sidebar three
register_sidebar( array(
'name' => __( 'Footer Sidebar Four', 'colormag' ),
'id' => 'colormag_footer_sidebar_four',
'description' => __( 'Shows widgets at footer sidebar four.', 'colormag' ),
'before_widget' => '',
'before_title' => ''
) );
register_widget( "colormag_featured_posts_slider_widget" );
register_widget( "colormag_highlighted_posts_widget" );
register_widget( "colormag_featured_posts_widget" );
register_widget( "colormag_featured_posts_vertical_widget" );
register_widget( "colormag_728x90_advertisement_widget" );
register_widget( "colormag_300x250_advertisement_widget" );
register_widget( "colormag_125x125_advertisement_widget" );
register_widget( "colormag_video_widget" );
}
/****************************************************************************************/
/**
* Featured Posts widget
*/
class colormag_featured_posts_slider_widget extends WP_Widget {
function colormag_featured_posts_slider_widget() {
$widget_ops = array( 'classname' => 'widget_featured_slider widget_featured_meta', 'description' => __( 'Display latest posts or posts of specific category', 'colormag') );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false,$name= __( 'TG: Featured Cat Slider', 'colormag' ),$widget_ops);
}
function form( $instance ) {
$tg_defaults['number'] = 4;
$tg_defaults['type'] = 'latest';
$tg_defaults['category'] = '';
$instance = wp_parse_args( (array) $instance, $tg_defaults );
$number = $instance['number'];
$type = $instance['type'];
$category = $instance['category'];
?>
id="get_field_id( 'type' ); ?>" name="get_field_name( 'type' ); ?>" value="latest"/>
id="get_field_id( 'type' ); ?>" name="get_field_name( 'type' ); ?>" value="category"/>
' ','name' => $this->get_field_name( 'category' ), 'selected' => $category ) ); ?>
$number,
'post_type' => 'post',
'ignore_sticky_posts' => true
) );
}
else {
$get_featured_posts = new WP_Query( array(
'posts_per_page' => $number,
'post_type' => 'post',
'category__in' => $category
) );
}
echo $before_widget;
?>
'widget_highlighted_posts widget_featured_meta', 'description' => __( 'Display latest posts or posts of specific category', 'colormag') );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false,$name= __( 'TG: Highligted Posts', 'colormag' ),$widget_ops);
}
function form( $instance ) {
$tg_defaults['number'] = 4;
$tg_defaults['type'] = 'latest';
$tg_defaults['category'] = '';
$instance = wp_parse_args( (array) $instance, $tg_defaults );
$number = $instance['number'];
$type = $instance['type'];
$category = $instance['category'];
?>
id="get_field_id( 'type' ); ?>" name="get_field_name( 'type' ); ?>" value="latest"/>
id="get_field_id( 'type' ); ?>" name="get_field_name( 'type' ); ?>" value="category"/>
' ','name' => $this->get_field_name( 'category' ), 'selected' => $category ) ); ?>
$number,
'post_type' => 'post',
'ignore_sticky_posts' => true
) );
}
else {
$get_featured_posts = new WP_Query( array(
'posts_per_page' => $number,
'post_type' => 'post',
'category__in' => $category
) );
}
echo $before_widget;
?>
'widget_featured_posts widget_featured_meta', 'description' => __( 'Display latest posts or posts of specific category', 'colormag') );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false,$name= __( 'TG: Featured Posts', 'colormag' ),$widget_ops);
}
function form( $instance ) {
$tg_defaults['title'] = '';
$tg_defaults['text'] = '';
$tg_defaults['number'] = 4;
$tg_defaults['type'] = 'latest';
$tg_defaults['category'] = '';
$instance = wp_parse_args( (array) $instance, $tg_defaults );
$title = esc_attr( $instance[ 'title' ] );
$text = esc_textarea($instance['text']);
$number = $instance['number'];
$type = $instance['type'];
$category = $instance['category'];
?>
id="get_field_id( 'type' ); ?>" name="get_field_name( 'type' ); ?>" value="latest"/>
id="get_field_id( 'type' ); ?>" name="get_field_name( 'type' ); ?>" value="category"/>
' ','name' => $this->get_field_name( 'category' ), 'selected' => $category ) ); ?>
$number,
'post_type' => 'post',
'ignore_sticky_posts' => true
) );
}
else {
$get_featured_posts = new WP_Query( array(
'posts_per_page' => $number,
'post_type' => 'post',
'category__in' => $category
) );
}
echo $before_widget;
?>
'. esc_html( $title ) .''; }
if( !empty( $text ) ) { ?>
have_posts() ):$get_featured_posts->the_post();
?>
'; } elseif ( $i == 2 ) { echo ''; } ?>
ID );
$image .= '
';
echo $image;
}
?>
%2$s';
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
);
printf( __( '
%3$s', 'colormag' ),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
$time_string
);
?>
'; } ?>
2 ) { echo '
'; }
// Reset Post Data
wp_reset_query();
?>
'widget_featured_posts widget_featured_posts_vertical widget_featured_meta', 'description' => __( 'Display latest posts or posts of specific category', 'colormag') );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false,$name= __( 'TG: Featured Posts Vertical', 'colormag' ),$widget_ops);
}
function form( $instance ) {
$tg_defaults['title'] = '';
$tg_defaults['text'] = '';
$tg_defaults['number'] = 4;
$tg_defaults['type'] = 'latest';
$tg_defaults['category'] = '';
$instance = wp_parse_args( (array) $instance, $tg_defaults );
$title = esc_attr( $instance[ 'title' ] );
$text = esc_textarea($instance['text']);
$number = $instance['number'];
$type = $instance['type'];
$category = $instance['category'];
?>
id="get_field_id( 'type' ); ?>" name="get_field_name( 'type' ); ?>" value="latest"/>
id="get_field_id( 'type' ); ?>" name="get_field_name( 'type' ); ?>" value="category"/>
' ','name' => $this->get_field_name( 'category' ), 'selected' => $category ) ); ?>
$number,
'post_type' => 'post',
'ignore_sticky_posts' => true
) );
}
else {
$get_featured_posts = new WP_Query( array(
'posts_per_page' => $number,
'post_type' => 'post',
'category__in' => $category
) );
}
echo $before_widget;
?>
'. esc_html( $title ) .''; }
if( !empty( $text ) ) { ?>
have_posts() ):$get_featured_posts->the_post();
?>
'; } elseif ( $i == 2 ) { echo ''; } ?>
ID );
$image .= '
';
echo $image;
}
?>
%2$s';
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
);
printf( __( '
%3$s', 'colormag' ),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
$time_string
);
?>
'; } ?>
2 ) { echo '
'; }
// Reset Post Data
wp_reset_query();
?>
'widget_300x250_advertisement', 'description' => __( 'Add your 300x250 Advertisement here', 'colormag') );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false,$name= __( 'TG: 300x250 Advertisement', 'colormag' ),$widget_ops);
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', '300x250_image_url' => '', '300x250_image_link' => '') );
$title = esc_attr( $instance[ 'title' ] );
$image_link = '300x250_image_link';
$image_url = '300x250_image_url';
$instance[ $image_link ] = esc_url( $instance[ $image_link ] );
$instance[ $image_url ] = esc_url( $instance[ $image_url ] );
?>
get_field_id( $instance[ $image_url ] . 'preview') . '"src="' . $instance[ $image_url ] . '"style="max-width:250px;" />
';
endif;
?>
';
if ( !empty( $image_link ) ) {
$output .= '
';
} else {
$output .= '
';
}
$output .= '
';
echo $output;
} ?>
'widget_728x90_advertisement', 'description' => __( 'Add your 728x90 Advertisement here', 'colormag') );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false,$name= __( 'TG: 728x90 Advertisement', 'colormag' ),$widget_ops);
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', '728x90_image_url' => '', '728x90_image_link' => '') );
$title = esc_attr( $instance[ 'title' ] );
$image_link = '728x90_image_link';
$image_url = '728x90_image_url';
$instance[ $image_link ] = esc_url( $instance[ $image_link ] );
$instance[ $image_url ] = esc_url( $instance[ $image_url ] );
?>
get_field_id( $instance[ $image_url ] . 'preview') . '"src="' . $instance[ $image_url ] . '"style="max-width:250px;" />
';
endif;
?>
';
if ( !empty( $image_link ) ) {
$output .= '
';
} else {
$output .= '
';
}
$output .= '
';
echo $output;
} ?>
'widget_125x125_advertisement', 'description' => __( 'Add your 125x125 Advertisement here', 'colormag') );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false,$name= __( 'TG: 125x125 Advertisement', 'colormag' ),$widget_ops);
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', '125x125_image_url_1' => '', '125x125_image_url_2' => '', '125x125_image_url_3' => '', '125x125_image_url_4' => '', '125x125_image_url_5' => '', '125x125_image_url_6' => '', '125x125_image_link_1' => '', '125x125_image_link_2' => '', '125x125_image_link_3' => '', '125x125_image_link_4' => '', '125x125_image_link_5' => '', '125x125_image_link_6' => '') );
$title = esc_attr( $instance[ 'title' ] );
for ( $i = 1; $i < 7; $i++ ) {
$image_link = '125x125_image_link_'.$i;
$image_url = '125x125_image_url_'.$i;
$instance[ $image_link ] = esc_url( $instance[ $image_link ] );
$instance[ $image_url ] = esc_url( $instance[ $image_url ] );
}
?>
get_field_id( $instance[$image_url] . 'preview') . '"src="' . $instance[$image_url] . '"style="max-width:250px;" />
';
endif;
?>
';
for ( $i = 1; $i < 7; $i++ ) {
$j = $i - 1;
if( !empty( $image_array[$j] ) ) {
if ( !empty( $link_array[$j] ) ) {
$output .= '
';
} else {
$output .= '
';
}
}
}
$output .= '
';
echo $output;
} ?>
'widget_video_colormag', 'description' => __( 'Add the videos here', 'colormag') );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::WP_Widget( false,$name= __( 'TG: Videos', 'colormag' ),$widget_ops);
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'link' => '' ) );
$title = esc_attr( $instance[ 'title' ] );
$link = 'link';
$instance[ $link ] = strip_tags( $instance[ $link ] );
?>