1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function epl_shortcode_listing_meta_doc_callback( $atts ) {
$atts = shortcode_atts(
array(
'post_type' => '',
),
$atts
);
$meta_boxes = epl_get_meta_boxes();
ob_start();
?>
<style>
ul.striped-list {
list-style-type: none;
margin: 0;
padding: 0;
}
ul.striped-list > li:nth-of-type(odd) {
background-color: rgba(78, 168, 234, 0.1) ;
}
ul.striped-list > li {
border-bottom: 1px solid rgb(221,221,221);
padding: 6px;
}
ul.striped-list > li:last-child {
border-bottom: none;
}
.epl-meta-opt-list {
margin-left: 35px !important;
}
</style>
<?php
if ( ! empty( $meta_boxes ) ) {
foreach ( $meta_boxes as $epl_meta_box ) {
$epl_meta_box['post_type'] = (array) $epl_meta_box['post_type'];
if ( ! empty( $atts['post_type'] ) && ! in_array( $atts['post_type'], $epl_meta_box['post_type'], true ) ) {
continue;
}
echo '<h4>' . esc_html( $epl_meta_box['label'] ) . '</h4>';
if ( ! empty( $epl_meta_box['groups'] ) ) {
foreach ( $epl_meta_box['groups'] as $group ) {
echo '<div class="epl-meta-group-wrap">';
if ( ! empty( $group['label'] ) ) {
echo '<h4>' . esc_html( $group['label'] ) . '</h4>';
}
$fields = $group['fields'];
$fields = array_filter( $fields );
if ( ! empty( $fields ) ) {
echo '<ul class="striped-list epl-meta-fields-list">';
foreach ( $fields as $field ) {
if ( isset( $field['exclude'] ) && ! empty( $field['exclude'] ) ) {
if ( ! empty( $atts['post_type'] ) && in_array( $atts['post_type'], $field['exclude'], true ) ) {
continue;
}
}
if ( isset( $field['include'] ) && ! empty( $field['include'] ) ) {
if ( ! empty( $atts['post_type'] ) && ! in_array( $atts['post_type'], $field['include'], true ) ) {
continue;
}
}
echo '<li class="epl-meta-field-item">';
switch ( $field['type'] ) {
case 'text':
echo '<strong>' . esc_attr( $field['name'] ) . '</strong><span class="epl-meta-sep"> :: </span>' . esc_attr( $field['type'] );
break;
case 'checkbox_single':
echo '<strong>' . esc_attr( $field['name'] ) . '</strong><span class="epl-meta-sep"> :: </span> "yes" or "no"';
break;
case 'select':
echo '<strong>' . esc_attr( $field['name'] ) . '</strong><span class="epl-meta-sep"> :: </span>' . esc_attr( $field['type'] ) . ' (drop down options) ';
echo '<ul class="epl-meta-opt-list">';
foreach ( $field['opts'] as $opt_key => $opt_label ) {
$label = is_array( $opt_label ) ? $opt_label['label'] : $opt_label;
echo '<li class="epl-meta-opt-item">';
echo esc_attr( $label );
echo '</li>';
}
echo '</ul>';
break;
default:
echo '<strong>' . esc_attr( $field['name'] ) . '</strong><span class="epl-meta-sep"> :: </span>' . esc_attr( $field['type'] );
break;
}
echo '</li>';
}
echo '</ul>';
}
echo '</div><hr>';
}
}
}
}
return ob_get_clean();
}
add_shortcode( 'listing_meta_doc', 'epl_shortcode_listing_meta_doc_callback' );