| 1 |
<?php |
| 2 |
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical. |
| 3 |
|
| 4 |
/** |
| 5 |
* The single-doc meta row. |
| 6 |
* |
| 7 |
* Sits between the title and the article body: reading time and the Listen pill |
| 8 |
* on the leading edge, AI Actions on the trailing edge. All three are |
| 9 |
* independently switchable, so the wrapper itself is conditional — if nothing has |
| 10 |
* anything to show, no empty row is emitted and no vertical space is consumed. |
| 11 |
* |
| 12 |
* Included by views/templates/contents/layout-1.php and layout-2.php, which |
| 13 |
* between them serve every single-doc layout in Free (1, 4, 5, 8, 9, 10) and in |
| 14 |
* Pro (2, 3, 6, 7). |
| 15 |
* |
| 16 |
* @var string $reading_time Rendered reading-time markup, or ''. |
| 17 |
*/ |
| 18 |
|
| 19 |
if ( ! defined( 'ABSPATH' ) ) { |
| 20 |
exit; |
| 21 |
} |
| 22 |
|
| 23 |
$reading_time = isset( $reading_time ) ? (string) $reading_time : ''; |
| 24 |
|
| 25 |
ob_start(); |
| 26 |
// Beside the reading-time pill, which is where the design puts it: the two are |
| 27 |
// both facts about the article, where AI Actions on the far edge is a thing you |
| 28 |
// do to it. No per-instance overrides here — the classic templates render |
| 29 |
// whatever the global settings say — so this needs no context handoff. |
| 30 |
if ( isset( betterdocs()->listen ) && betterdocs()->listen->has_listen( get_the_ID() ) ) { |
| 31 |
echo do_shortcode( '[betterdocs_listen]' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- rendered template parts, escaped at source. |
| 32 |
} |
| 33 |
/** |
| 34 |
* Extra content on the leading edge of the doc meta row, after reading time and |
| 35 |
* the Listen pill. |
| 36 |
* |
| 37 |
* @since 4.8.0 |
| 38 |
*/ |
| 39 |
do_action( 'betterdocs_doc_meta_start' ); |
| 40 |
$meta_start = ob_get_clean(); |
| 41 |
|
| 42 |
ob_start(); |
| 43 |
if ( isset( betterdocs()->ai_actions ) && betterdocs()->ai_actions->has_actions() ) { |
| 44 |
// No per-instance overrides here — the classic templates render whatever the |
| 45 |
// global settings say — so this needs no context handoff. |
| 46 |
echo do_shortcode( '[betterdocs_ai_actions]' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- rendered template parts, escaped at source. |
| 47 |
} |
| 48 |
/** |
| 49 |
* Extra content on the trailing edge of the doc meta row, after AI Actions. |
| 50 |
* |
| 51 |
* @since 4.8.0 |
| 52 |
*/ |
| 53 |
do_action( 'betterdocs_doc_meta_end' ); |
| 54 |
$meta_end = ob_get_clean(); |
| 55 |
|
| 56 |
$leading = $reading_time . $meta_start; |
| 57 |
$trailing = $meta_end; |
| 58 |
|
| 59 |
// Nothing on either side: emit no wrapper at all rather than an empty flex row. |
| 60 |
if ( '' === trim( $leading ) && '' === trim( $trailing ) ) { |
| 61 |
return; |
| 62 |
} |
| 63 |
?> |
| 64 |
<div class="betterdocs-doc-meta"> |
| 65 |
<?php if ( '' !== trim( $leading ) ) : ?> |
| 66 |
<div class="betterdocs-doc-meta-start"> |
| 67 |
<?php echo $leading; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- rendered template parts, escaped at source. ?> |
| 68 |
</div> |
| 69 |
<?php endif; ?> |
| 70 |
|
| 71 |
<?php if ( '' !== trim( $trailing ) ) : ?> |
| 72 |
<div class="betterdocs-doc-meta-end"> |
| 73 |
<?php echo $trailing; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- rendered template parts, escaped at source. ?> |
| 74 |
</div> |
| 75 |
<?php endif; ?> |
| 76 |
</div> |
| 77 |
|