Esempio n. 1
0
 /**
  * Creates Entities from Custom Types (static Alias)
  * @param string $what Name of custom type without "ait-" prefix
  * @param string $category Selecting custom type by specific category
  * @param int $limit Limit of returned items
  * @return array|WpLattePostEntity
  */
 public static function createCustomPostEntity($what, $category = 0, $limit = null, $order = 'menu_order', $suppress_filters = false)
 {
     if (empty($limit) or $limit === false) {
         $limit = -1;
     }
     // default, no value entered in admin or missing parameter
     $tax = array();
     if ($category !== 0 && $category !== "0" && $category !== null) {
         $tax = array(array('taxonomy' => 'ait-' . $what . '-category', 'field' => 'slug', 'terms' => $category));
     }
     $options = WpLatteFunctions::dash2camel($what) . 'Options';
     // convention over configuration
     return WpLatte::createPostEntity(new WP_Query(array('tax_query' => $tax, 'post_type' => 'ait-' . $what, 'post_status' => 'publish', 'orderby' => $order, 'order' => 'ASC', 'posts_per_page' => $limit, 'suppress_filters' => $suppress_filters)), array('meta' => @$GLOBALS[$options], 'isCustomType' => true));
 }