__( '4', 'acmephoto' ), 8 => __( '8', 'acmephoto' ), 15 => __( '12', 'acmephoto' ) ); return apply_filters( 'acmephoto_post_number', $acmephoto_post_number ); } endif; /** * Custom columns of category with various options * * @package AcmeThemes * @subpackage AcmePhoto */ if ( ! class_exists( 'acmephoto_posts_col' ) ) { /** * Class for adding widget * * @package AcmeThemes * @subpackage AcmePhoto_posts_col * @since 0.0.1 */ class acmephoto_posts_col extends WP_Widget { /*defaults values for fields*/ private $defaults = array( 'title' => '', 'acmephoto_cat_id' => '', 'post_number' => 3, 'button_url' => '' ); function __construct() { parent::__construct( /*Base ID of your widget*/ 'acmephoto_posts_col', /*Widget name will appear in UI*/ __('AT Posts Column', 'acmephoto'), /*Widget description*/ array( 'description' => __( 'Show recents post or post from category', 'acmephoto' ), ) ); } /*Widget Backend*/ public function form( $instance ) { $instance = wp_parse_args( (array) $instance, $this->defaults ); /*default values*/ $title = esc_attr( $instance[ 'title' ] ); $acmephoto_selected_cat = esc_attr( $instance[ 'acmephoto_cat_id' ] ); $post_number = absint( $instance[ 'post_number' ] ); $button_url = esc_url( $instance[ 'button_url' ] ); ?>
__('From Recent Posts','acmephoto'), 'orderby' => 'name', 'order' => 'asc', 'show_count' => 1, 'hide_empty' => 1, 'echo' => 1, 'selected' => $acmephoto_selected_cat, 'hierarchical' => 1, 'name' => $this->get_field_name('acmephoto_cat_id'), 'id' => $this->get_field_name('acmephoto_cat_id'), 'class' => 'widefat', 'taxonomy' => 'category', 'hide_if_empty' => false, ); wp_dropdown_categories($acmephoto_dropown_cat); ?>
defaults); $init_animate_title = ''; $init_animate_content = ''; if ( 'acmephoto-home' == $acmephoto_sidebar_id ){ $init_animate_title = "init-animate animated fadeInUp"; $init_animate_content = "init-animate animated fadeInLeft"; } /*default values*/ $title = apply_filters( 'widget_title', !empty( $instance['title'] ) ? $instance['title'] : '', $instance, $this->id_base ); $acmephoto_cat_id = esc_attr( $instance[ 'acmephoto_cat_id' ] ); $post_number = absint( $instance[ 'post_number' ] ); $button_url = esc_url( $instance[ 'button_url' ] ); /** * Filter the arguments for the Recent Posts widget. * * @since 0.0.1 * * @see WP_Query * */ $acmephoto_cat_post_args = array( 'posts_per_page' => $post_number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ); if( -1 != $acmephoto_cat_id ){ $acmephoto_cat_post_args['cat'] = $acmephoto_cat_id; } $the_query = new WP_Query( $acmephoto_cat_post_args ); echo $args['before_widget']; ?>