| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
die('-1'); |
| 5 |
} |
| 6 |
|
| 7 |
class QuadMenuItemPostType extends QuadMenuItem { |
| 8 |
|
| 9 |
protected $type = 'post_type'; |
| 10 |
|
| 11 |
function init() { |
| 12 |
|
| 13 |
if (0 < $this->depth) { |
| 14 |
|
| 15 |
$this->args->has_thumbnail = (bool) ($this->item->thumb); |
| 16 |
|
| 17 |
$this->args->has_subtitle = (bool) $this->args->has_subtitle; |
| 18 |
|
| 19 |
$this->args->has_excerpt = (bool) ($this->item->excerpt == 'on'); |
| 20 |
|
| 21 |
if ($this->args->has_thumbnail) { |
| 22 |
$this->args->has_badge = false; |
| 23 |
} |
| 24 |
|
| 25 |
if ($this->args->has_excerpt) { |
| 26 |
|
| 27 |
$this->args->has_subtitle = false; |
| 28 |
|
| 29 |
if (!$this->item->description) { |
| 30 |
|
| 31 |
$post = get_post($this->item->object_id); |
| 32 |
|
| 33 |
if (isset($post->post_excerpt)) { |
| 34 |
$this->item->description = wp_trim_words(wpautop($this->clean_item_content($post->post_excerpt ? $post->post_excerpt : $post->post_content)), 10); |
| 35 |
$this->args->has_description = true; |
| 36 |
} else { |
| 37 |
$this->args->has_excerpt = false; |
| 38 |
} |
| 39 |
} |
| 40 |
} |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
function get_start_el() { |
| 45 |
|
| 46 |
$item_output = ''; |
| 47 |
|
| 48 |
$this->add_item_classes(); |
| 49 |
|
| 50 |
$this->add_item_classes_prefix(); |
| 51 |
|
| 52 |
$this->add_item_classes_current(); |
| 53 |
|
| 54 |
$this->add_item_classes_post_type(); |
| 55 |
|
| 56 |
$this->add_item_classes_quadmenu(); |
| 57 |
|
| 58 |
$id = $this->get_item_id(); |
| 59 |
|
| 60 |
$class = $this->get_item_classes(); |
| 61 |
|
| 62 |
$item_output .= '<li' . $id . $class . '>'; |
| 63 |
|
| 64 |
$this->add_link_atts(); |
| 65 |
|
| 66 |
$this->add_link_atts_toggle(); |
| 67 |
|
| 68 |
$item_output .= $this->get_link(); |
| 69 |
|
| 70 |
return $item_output; |
| 71 |
} |
| 72 |
|
| 73 |
function add_item_classes_post_type() { |
| 74 |
$this->item_classes[] = 'quadmenu-item-type-post_type'; |
| 75 |
} |
| 76 |
|
| 77 |
} |
| 78 |
|