| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* |
| 8 |
*/ |
| 9 |
abstract class CJT_Models_Block_Assignmentpanel_Postbase |
| 10 |
extends CJT_Models_Block_Assignmentpanel_Wordpress { |
| 11 |
|
| 12 |
/** |
| 13 |
* put your comment there... |
| 14 |
* |
| 15 |
* @var mixed |
| 16 |
*/ |
| 17 |
protected $args = array( |
| 18 |
'order' => 'ASC', |
| 19 |
'orderby' => 'title', |
| 20 |
'suppress_filters' => true, |
| 21 |
'update_post_term_cache' => false, |
| 22 |
'update_post_meta_cache' => false |
| 23 |
); |
| 24 |
|
| 25 |
/** |
| 26 |
* put your comment there... |
| 27 |
* |
| 28 |
* @param mixed $key |
| 29 |
* @param mixed $item |
| 30 |
*/ |
| 31 |
protected function prepareItem($key, & $item) { |
| 32 |
// Initialize. |
| 33 |
$typeParams =& $this->getTypeParams(); |
| 34 |
// Get only 'ID' and 'Title', 'parent' fields. |
| 35 |
$preItem['id'] = $item->ID; |
| 36 |
$preItem['title'] = $item->post_title; |
| 37 |
$preItem['parent'] = $item->post_parent; |
| 38 |
// Get permalink. |
| 39 |
$preItem['link'] = get_permalink($preItem['id']); |
| 40 |
/// Flag if term has child terms! |
| 41 |
// Query childs. |
| 42 |
$args = $this->args; |
| 43 |
$args['post_parent'] = $preItem['id']; |
| 44 |
$args['post_type'] = $typeParams['type']; |
| 45 |
$args['numberposts'] = 1; |
| 46 |
$childPosts = get_posts($args); |
| 47 |
// Flag it! |
| 48 |
$preItem['hasChilds'] = !empty($childPosts); |
| 49 |
// Re-Reference. |
| 50 |
$item = $preItem; |
| 51 |
} |
| 52 |
|
| 53 |
} // End class. |
| 54 |
|