__( 'Blog Widget with different options', 'amazing-blog' ) ) // Args ); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base ); $post_category = ! empty( $instance['post_category'] ) ? $instance['post_category'] : 0; $post_number = ! empty( $instance['post_number'] ) ? $instance['post_number'] : 4; $custom_class = apply_filters( 'widget_custom_class', empty( $instance['custom_class'] ) ? '' : $instance['custom_class'], $instance, $this->id_base ); // Add Custom class if ( $custom_class ) { $before_widget = str_replace( 'class="', 'class="'. $custom_class . ' ', $before_widget ); } echo $before_widget; // Title if ( $title ) echo $before_title . $title . $after_title; // ?> $post_number, 'no_found_rows' => true, 'ignore_sticky_posts' => 1 ); if ( absint( $post_category ) > 0 ) { $qargs['cat'] = $post_category; } $all_posts = new WP_Query( $qargs ); ?>
have_posts() ) { while ( $all_posts->have_posts() ) { $all_posts->the_post(); ?>
'; endif ?>

'', 'post_category' => '', 'post_number' => 4, 'custom_class' => '', ) ); $title = strip_tags( $instance['title'] ); $post_category = absint( $instance['post_category'] ); $post_number = absint( $instance['post_number'] ); $custom_class = esc_attr( $instance['custom_class'] ); ?>

'name', 'hide_empty' => 0, 'taxonomy' => 'category', 'name' => $this->get_field_name('post_category'), 'id' => $this->get_field_id('post_category'), 'selected' => $post_category, 'show_option_all' => __( 'All Categories','amazing-blog' ), ); wp_dropdown_categories( $cat_args ); ?>

'', 'name' => '', 'selected' => 0, 'echo' => 1, ); $r = wp_parse_args( $args, $defaults ); $output = ''; $choices = array( '1' => sprintf( __( '%d Column','amazing-blog' ), 1 ), '2' => sprintf( __( '%d Columns','amazing-blog' ), 2 ), ); if ( ! empty( $choices ) ) { $output = "\n"; } if ( $r['echo'] ) { echo $output; } return $output; } function dropdown_image_sizes( $args ){ $defaults = array( 'id' => '', 'name' => '', 'selected' => 0, 'echo' => 1, ); $r = wp_parse_args( $args, $defaults ); $output = ''; $choices = amazing_blog_get_image_sizes_options(); if ( ! empty( $choices ) ) { $output = "\n"; } if ( $r['echo'] ) { echo $output; } return $output; } } add_action( 'widgets_init', 'amazing_blog_load_widgets' ); if ( ! function_exists( 'amazing_blog_load_widgets' ) ) : /** * Load widgets * * @since Amazing Blog 1.0.0 * */ function amazing_blog_load_widgets(){ // Latest News widget register_widget( 'Amazing_Blog_Cols_Widget' ); } endif; endif;