コード例 #1
0
 function __construct($atts = array(), $params = array())
 {
     $atts['skin'] = isset($atts['skin']) && $atts['skin'] ? $atts['skin'] : 'default';
     $atts['hide_filters'] = isset($atts['hide_filters']) && $atts['hide_filters'] ? 1 : 0;
     $atts['orderby'] = isset($atts['orderby']) && $atts['orderby'] ? $atts['orderby'] : 'menu_order';
     $atts['order'] = isset($atts['order']) && $atts['order'] ? $atts['order'] : 'ASC';
     $atts['maxposts'] = isset($atts['maxposts']) && $atts['maxposts'] ? $atts['maxposts'] : 20;
     $this->ID = isset($atts['id']) && $atts['id'] ? $atts['id'] : uniqid("np-");
     $this->items = null;
     $this->atts = $atts;
     $this->skin = $atts['skin'];
     $this->skinObj = apply_filters("nimble_portfolio_skin_get_{$this->skin}", null);
     // set Post Type
     if (isset($params['post_type']) && $params['post_type']) {
         $this->postType = $params['post_type'];
     } else {
         $this->postType = isset($atts['post_type']) && $atts['post_type'] ? $atts['post_type'] : NimblePortfolioPlugin::getPostType();
     }
     //set Taxonomy
     if (isset($params['taxonomy']) && $params['taxonomy']) {
         $this->taxonomy = $params['taxonomy'];
     } else {
         $this->taxonomy = isset($atts['taxonomy']) ? $atts['taxonomy'] : NimblePortfolioPlugin::getTaxonomy();
     }
     // construct WP_Query
     $this->items_ids = array();
     $args = array();
     $args['post_type'] = $this->postType;
     $args['posts_per_page'] = -1;
     $args['fields'] = 'ids';
     $args['orderby'] = $atts['orderby'];
     $args['order'] = $atts['order'];
     $args['post_status'] = 'publish';
     if (isset($atts['showposts']) && $atts['showposts']) {
         $args['showposts'] = $atts['showposts'];
     }
     $args = apply_filters('nimble_portfolio_query_args', $args, $this);
     $this->queryObj = new WP_Query($args);
     if ($this->queryObj->have_posts()) {
         $this->items_ids = $this->queryObj->get_posts();
     }
     wp_reset_postdata();
 }