PluginProbe
BeyondWords – AI audio for publishers / 6.0.3
BeyondWords – AI audio for publishers v6.0.3
7.1.0 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.7.0 All 43 releases
speechkit / src / Core / Player / Renderer / Amp.php

Amp.php in BeyondWords – AI audio for publishers 6.0.3, at src/Core/Player/Renderer/Amp.php

67 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Beyondwords\Wordpress\Core\Player\Renderer;
4
5 use Beyondwords\Wordpress\Component\Post\PostMetaUtils;
6 use Beyondwords\Wordpress\Core\CoreUtils;
7 use Beyondwords\Wordpress\Core\Environment;
8
9 /**
10 * Class Amp
11 *
12 * Renders the AMP-compatible BeyondWords player.
13 */
14 class Amp extends Base
15 {
16 /**
17 * Check whether we should use the AMP player for the current post.
18 *
19 * @param \WP_Post $post WordPress post object.
20 *
21 * @return bool True if AMP player should be used.
22 */
23 public static function check(\WP_Post $post): bool
24 {
25 if (! CoreUtils::isAmp()) {
26 return false;
27 }
28
29 return parent::check($post);
30 }
31
32 /**
33 * Render AMP player HTML.
34 *
35 *
36 * @return string HTML markup for AMP player.
37 */
38 public static function render(\WP_Post $post): string
39 {
40 $projectId = PostMetaUtils::getProjectId($post->ID);
41 $contentId = PostMetaUtils::getContentId($post->ID, true); // Fallback to Post ID if Content ID is not set
42
43 $src = sprintf(Environment::getAmpPlayerUrl(), $projectId, $contentId);
44
45 ob_start();
46 ?>
47 <amp-iframe
48 frameborder="0"
49 height="43"
50 layout="responsive"
51 sandbox="allow-scripts allow-same-origin allow-popups"
52 scrolling="no"
53 src="<?php echo esc_url($src); ?>"
54 width="295"
55 >
56 <amp-img
57 height="150"
58 layout="responsive"
59 placeholder
60 src="<?php echo esc_url(Environment::getAmpImgUrl()); ?>"
61 width="643"
62 ></amp-img>
63 </amp-iframe>
64 <?php
65 return ob_get_clean();
66 }
67 }