__('Right Sidebar', 'mags') , 'id' => 'mags_right_sidebar', 'description' => __('Shows widgets at Right Side.', 'mags'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); // Registering Left Sidebar register_sidebar( array( 'name' => __('Left Sidebar', 'mags') , 'id' => 'mags_left_sidebar', 'description' => __('Shows widgets at Left Side.', 'mags'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); // Registering Front Page Template Content Section register_sidebar(array( 'name' => __('Front Page Section', 'mags') , 'id' => 'mags_front_page_content_section', 'description' => __('Shows widgets on Front Page Template Section. Suitable widget: TH: Horizontal/Vertical Posts, TH: Card/Block Posts, TH: Multiple Layout Posts and TH: Recent Posts', 'mags'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); // Registering Footer Sidebar 1 register_sidebar( array( 'name' => __('Footer - Column 1', 'mags') , 'id' => 'mags_footer_sidebar', 'description' => __('Shows widgets at Footer Column 1.', 'mags'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); // Registering Footer Sidebar 2 register_sidebar( array( 'name' => __('Footer - Column 2', 'mags'), 'id' => 'mags_footer_column2', 'description' => __('Shows widgets at Footer Column 2.', 'mags'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); // Registering Footer Sidebar 3 register_sidebar( array( 'name' => __('Footer - Column 3', 'mags'), 'id' => 'mags_footer_column3', 'description' => __('Shows widgets at Footer Column 3.', 'mags'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_widget("mags_horizontal_vertical_posts"); register_widget("mags_card_block_posts"); register_widget("mags_recent_posts"); register_widget("mags_multiple_layout_posts"); } add_action('widgets_init', 'mags_widgets_init'); /****************************************************************************************/ /** * Widget for Front Page Template. * Construct the widget. * i.e. Posts. */ class mags_horizontal_vertical_posts extends WP_Widget { function __construct() { $widget_ops = array( 'classname' => 'mags-widget-horizontal-vertical-posts', 'description' => __('Display Horizontal/Vertical Posts', 'mags') ); parent::__construct(false, $name = __('TH: Horizontal/Vertical Posts', 'mags') , $widget_ops); } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'category' => '', 'type' => 1, 'style' => 0, 'bg_image' => '', 'bg_fixed_parllax' => 1, 'spacing' => 0, ) ); $title = isset( $instance['title'] ) ? $instance['title'] : ''; $type = ( isset($instance['type']) && is_numeric($instance['type']) ) ? (int) $instance['type'] : 1; $bg_fixed_parllax = ( isset($instance['bg_fixed_parllax']) && is_numeric($instance['bg_fixed_parllax']) ) ? (int) $instance['bg_fixed_parllax'] : 1; ?>

/>



>
>

' ', 'name' => $this->get_field_name('category') , 'selected' => $instance['category'] ) ); ?>


>
>

0 && $new_instance['type'] < 3 ) ? (int) $new_instance['type'] : 1; $instance['bg_image'] = esc_url_raw($new_instance['bg_image']); $instance['bg_fixed_parllax'] = ( isset($new_instance['bg_fixed_parllax']) && $new_instance['bg_fixed_parllax'] > 0 && $new_instance['bg_fixed_parllax'] < 3 ) ? (int) $new_instance['bg_fixed_parllax'] : 1; $instance['spacing'] = ( isset($new_instance['spacing']) && $new_instance['spacing'] > 0 && $new_instance['spacing'] <= 50 ) ? (int) $new_instance['spacing'] : 0; return $instance; } function widget($args, $instance) { $category = isset($instance['category']) ? $instance['category'] : ''; $style = empty($instance['style']) ? 0 : $instance['style']; $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $type = ( isset($instance['type']) && is_numeric($instance['type']) ) ? (int) $instance['type'] : 1; $bg_image = isset($instance['bg_image']) ? $instance['bg_image'] : ''; $bg_fixed_parllax = ( isset($instance['bg_fixed_parllax']) && is_numeric($instance['bg_fixed_parllax']) ) ? (int) $instance['bg_fixed_parllax'] : 1; $spacing = empty($instance['spacing']) ? 0 : $instance['spacing']; global $post; $post_type = array( 'posts_per_page' => 5, 'post_type' => array('post'), 'post__not_in' => get_option('sticky_posts'), ); if ( $type == 2 ) { $post_type['category__in'] = $category; } $get_featured_posts = new WP_Query($post_type); echo $args['before_widget']; if (!empty($bg_image)) { ?>
have_posts()):$get_featured_posts->the_post(); ?>
', '' ); ?>
', '' ); ?>
' : '' ; echo $args['after_widget'] . ''; } } /****************************************************************************************/ /** * Widget for Front Page Template. * Construct the widget. * i.e. Posts. */ class mags_card_block_posts extends WP_Widget { function __construct() { $widget_ops = array( 'classname' => 'mags-widget-card-block-posts', 'description' => __('Display Card/Block Posts', 'mags') ); parent::__construct(false, $name = __('TH: Card/Block Posts', 'mags') , $widget_ops); } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'category' => '', 'type' => 1, 'style' => 0, 'bg_image' => '', 'bg_fixed_parllax' => 1, 'spacing' => 0, ) ); $title = isset( $instance['title'] ) ? $instance['title'] : ''; $type = ( isset($instance['type']) && is_numeric($instance['type']) ) ? (int) $instance['type'] : 1; $bg_fixed_parllax = ( isset($instance['bg_fixed_parllax']) && is_numeric($instance['bg_fixed_parllax']) ) ? (int) $instance['bg_fixed_parllax'] : 1; ?>

/>



>
>

' ', 'name' => $this->get_field_name('category') , 'selected' => $instance['category'] ) ); ?>


>
>

0 && $new_instance['type'] < 3 ) ? (int) $new_instance['type'] : 1; $instance['bg_image'] = esc_url_raw($new_instance['bg_image']); $instance['bg_fixed_parllax'] = ( isset($new_instance['bg_fixed_parllax']) && $new_instance['bg_fixed_parllax'] > 0 && $new_instance['bg_fixed_parllax'] < 3 ) ? (int) $new_instance['bg_fixed_parllax'] : 1; $instance['spacing'] = ( isset($new_instance['spacing']) && $new_instance['spacing'] > 0 && $new_instance['spacing'] <= 50 ) ? (int) $new_instance['spacing'] : 0; return $instance; } function widget($args, $instance) { $category = isset($instance['category']) ? $instance['category'] : ''; $style = empty($instance['style']) ? 0 : $instance['style']; $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $type = ( isset($instance['type']) && is_numeric($instance['type']) ) ? (int) $instance['type'] : 1; $bg_image = isset($instance['bg_image']) ? $instance['bg_image'] : ''; $bg_fixed_parllax = ( isset($instance['bg_fixed_parllax']) && is_numeric($instance['bg_fixed_parllax']) ) ? (int) $instance['bg_fixed_parllax'] : 1; $spacing = empty($instance['spacing']) ? 0 : $instance['spacing']; global $post; $post_type = array( 'posts_per_page' => 6, 'post_type' => array('post'), 'post__not_in' => get_option('sticky_posts'), ); if ( $type == 2 ) { $post_type['category__in'] = $category; } $get_featured_posts = new WP_Query($post_type); echo $args['before_widget']; if (!empty($bg_image)) { ?>
have_posts()):$get_featured_posts->the_post(); ?>
', '' ); ?>
style="background-image: url('');" >
', '' ); ?>
' : '' ; echo $args['after_widget'] . ''; } } /****************************************************************************************/ /** * Widget for Any Sidebars. * Construct the widget. * i.e. Name and posts. */ class mags_recent_posts extends WP_Widget { function __construct() { $widget_ops = array( 'classname' => 'mags-widget-recent-posts', 'description' => __('Display Recent Posts', 'mags') ); parent::__construct(false, $name = __('TH: Recent Posts', 'mags') , $widget_ops); } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'number' => '6', 'title' => '', 'bg_image' => '', 'bg_fixed_parllax' => 1, 'spacing' => 0, ) ); $title = isset( $instance['title'] ) ? $instance['title'] : ''; $bg_fixed_parllax = ( isset($instance['bg_fixed_parllax']) && is_numeric($instance['bg_fixed_parllax']) ) ? (int) $instance['bg_fixed_parllax'] : 1; ?>



>
>

0 && $new_instance['number'] < 51 ) ? (int) $new_instance['number'] : 6; $instance['title'] = sanitize_text_field($new_instance['title']); $instance['bg_image'] = esc_url_raw($new_instance['bg_image']); $instance['bg_fixed_parllax'] = ( isset($new_instance['bg_fixed_parllax']) && $new_instance['bg_fixed_parllax'] > 0 && $new_instance['bg_fixed_parllax'] < 3 ) ? (int) $new_instance['bg_fixed_parllax'] : 1; $instance['spacing'] = ( isset($new_instance['spacing']) && $new_instance['spacing'] > 0 && $new_instance['spacing'] <= 50 ) ? (int) $new_instance['spacing'] : 0; return $instance; } function widget($args, $instance) { $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $number = empty($instance['number']) ? 6 : $instance['number']; $bg_image = isset($instance['bg_image']) ? $instance['bg_image'] : ''; $bg_fixed_parllax = ( isset($instance['bg_fixed_parllax']) && is_numeric($instance['bg_fixed_parllax']) ) ? (int) $instance['bg_fixed_parllax'] : 1; $spacing = empty($instance['spacing']) ? 0 : $instance['spacing']; global $post; $get_featured_posts = new WP_Query( array( 'posts_per_page' => $number, 'post_type' => array('post'), 'post__not_in' => get_option('sticky_posts'), ) ); echo $args['before_widget']; if (!empty($bg_image)) { ?>
0) { $i = 0; while ($get_featured_posts->have_posts()):$get_featured_posts->the_post(); ?>
', '' ); ?>
' : '' ; echo $args['after_widget'] . ''; } } /****************************************************************************************/ /** * Widget for Front Page Template. * Construct the widget. * i.e. Posts. */ class mags_multiple_layout_posts extends WP_Widget { function __construct() { $widget_ops = array( 'classname' => 'mags-widget-multiple-layouts', 'description' => __('Display Multiple Layout Posts', 'mags') ); parent::__construct(false, $name = __('TH: Multiple Layout Posts', 'mags') , $widget_ops); } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'category' => '', 'type' => 1, 'style' => 1, 'bg_image' => '', 'bg_fixed_parllax' => 1, 'spacing' => 0, ) ); $title = isset( $instance['title'] ) ? $instance['title'] : ''; $type = ( isset($instance['type']) && is_numeric($instance['type']) ) ? (int) $instance['type'] : 1; $style = ( isset($instance['style']) && is_numeric($instance['style']) ) ? (int) $instance['style'] : 1; $bg_fixed_parllax = ( isset($instance['bg_fixed_parllax']) && is_numeric($instance['bg_fixed_parllax']) ) ? (int) $instance['bg_fixed_parllax'] : 1; ?>


>
>



>
>

' ', 'name' => $this->get_field_name('category') , 'selected' => $instance['category'] ) ); ?>


>
>

0 && $new_instance['style'] <= 2 ) ? (int) $new_instance['style'] : 1; $instance['title'] = sanitize_text_field($new_instance['title']); $instance['type'] = ( isset($new_instance['type']) && $new_instance['type'] > 0 && $new_instance['type'] < 3 ) ? (int) $new_instance['type'] : 1; $instance['bg_image'] = esc_url_raw($new_instance['bg_image']); $instance['bg_fixed_parllax'] = ( isset($new_instance['bg_fixed_parllax']) && $new_instance['bg_fixed_parllax'] > 0 && $new_instance['bg_fixed_parllax'] < 3 ) ? (int) $new_instance['bg_fixed_parllax'] : 1; $instance['spacing'] = ( isset($new_instance['spacing']) && $new_instance['spacing'] > 0 && $new_instance['spacing'] <= 50 ) ? (int) $new_instance['spacing'] : 0; return $instance; } function widget($args, $instance) { $category = isset($instance['category']) ? $instance['category'] : ''; $style = ( isset($instance['style']) && is_numeric($instance['style']) ) ? (int) $instance['style'] : 1; $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $type = ( isset($instance['type']) && is_numeric($instance['type']) ) ? (int) $instance['type'] : 1; $bg_image = isset($instance['bg_image']) ? $instance['bg_image'] : ''; $bg_fixed_parllax = ( isset($instance['bg_fixed_parllax']) && is_numeric($instance['bg_fixed_parllax']) ) ? (int) $instance['bg_fixed_parllax'] : 1; $spacing = empty($instance['spacing']) ? 0 : $instance['spacing']; global $post; $post_type = array( 'posts_per_page' => 10, 'post_type' => array('post'), 'post__not_in' => get_option('sticky_posts'), ); if ( $type == 2 ) { $post_type['category__in'] = $category; } $get_featured_posts = new WP_Query($post_type); $featured_post_count = $get_featured_posts->post_count; echo $args['before_widget']; if (!empty($bg_image)) { ?>
have_posts()):$get_featured_posts->the_post(); ?>
= 2) { if ( $i == 2 ) { ?>
', '' ); ?>
= 4 && $i <= 10 ) { if ( $i == 4 ) { ?>
', '' ); ?>
' : '' ; echo $args['after_widget'] . ''; } }