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