| 1 |
<div |
| 2 |
<?php echo $wrapper_attr; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- contains attriutes and values together which are required here ?>> |
| 3 |
<?php |
| 4 |
$section_tag = betterdocs()->template_helper->is_valid_tag( $faq_section_title_tag ); |
| 5 |
echo wp_kses_post( '<' . $section_tag . ' class="' . esc_attr( $faq_heading_class ) . ' betterdocs-faq-section-title">' . esc_html( $faq_heading ) . '</' . $section_tag . '>' ); |
| 6 |
?> |
| 7 |
|
| 8 |
<div class="betterdocs-faq-inner-wrapper"> |
| 9 |
<?php |
| 10 |
$terms = get_terms( $terms_query_args ); |
| 11 |
$faq_json = ''; |
| 12 |
|
| 13 |
if ( ! is_wp_error( $terms ) ) { |
| 14 |
$GLOBALS['betterdocs_faq_schema'] = []; |
| 15 |
if ( $faq_schema ) { |
| 16 |
$faq_json = [ |
| 17 |
'@context' => 'https://schema.org', |
| 18 |
'@type' => 'FAQPage', |
| 19 |
'mainEntity' => [] |
| 20 |
]; |
| 21 |
|
| 22 |
$GLOBALS['betterdocs_faq_schema_main_entity'] = $faq_json['mainEntity']; |
| 23 |
} |
| 24 |
|
| 25 |
foreach ( $terms as $term ) { |
| 26 |
if ( $term->count <= 0 ) { |
| 27 |
continue; |
| 28 |
} |
| 29 |
|
| 30 |
// title |
| 31 |
$view_object->get( |
| 32 |
'shortcode-parts/faq-term-title', |
| 33 |
[ |
| 34 |
'title' => $term->name |
| 35 |
] |
| 36 |
); |
| 37 |
|
| 38 |
// faq list |
| 39 |
$view_object->get( |
| 40 |
'shortcode-parts/faq-list', |
| 41 |
[ |
| 42 |
'term' => $term, |
| 43 |
'faq_schema' => $faq_schema, |
| 44 |
'faq_json' => $faq_schema ? $faq_json['mainEntity'] : '' |
| 45 |
] |
| 46 |
); |
| 47 |
} |
| 48 |
|
| 49 |
if ( $faq_schema ) { |
| 50 |
$faq_json['mainEntity'] = $GLOBALS['betterdocs_faq_schema_main_entity']; |
| 51 |
echo '<script type="application/ld+json">' . wp_json_encode( $faq_json ) . '</script>'; |
| 52 |
} |
| 53 |
} |
| 54 |
?> |
| 55 |
</div> |
| 56 |
</div> |
| 57 |
|