PluginProbe ʕ •ᴥ•ʔ
Presto Player / 2.2.3-beta1
Presto Player v2.2.3-beta1
4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.4 4.2.3 4.2.2 4.2.0 4.2.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.12.0 1.13.0 1.14.0 1.14.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3-beta1 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.0-beta1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
presto-player / inc / Services / ReusableVideos.php
presto-player / inc / Services Last commit date
API 2 years ago Blocks 5 years ago License 5 years ago AdminNotice.php 5 years ago AdminNotices.php 4 years ago AjaxActions.php 2 years ago Blocks.php 5 years ago Compatibility.php 4 years ago Menu.php 3 years ago Migrations.php 5 years ago Player.php 2 years ago ProCompatibility.php 2 years ago ReusableVideos.php 4 years ago Scripts.php 2 years ago Settings.php 4 years ago Shortcodes.php 2 years ago Streamer.php 4 years ago Translation.php 2 years ago VideoPostType.php 4 years ago
ReusableVideos.php
146 lines
1 <?php
2
3 namespace PrestoPlayer\Services;
4
5 use PrestoPlayer\Services\Scripts;
6
7
8 class ReusableVideos
9 {
10 /**
11 * Register shortcode
12 *
13 * @return void
14 */
15 public function register()
16 {
17 add_action('admin_notices', [$this, 'notice']);
18 add_action('admin_init', [$this, 'dismissNotice']);
19 }
20
21 public function notice()
22 {
23 global $typenow, $current_screen;
24
25 if (!($typenow === 'pp_video_block' && $current_screen->base === 'edit')) {
26 return;
27 }
28
29 $notice_name = 'presto_player_reusable_notice';
30 if (AdminNotices::isDismissed($notice_name)) {
31 return;
32 }
33 ?>
34 <div class="notice" style="border-left-color: #7c3aed;">
35 <p><strong><?php _e('What is the media hub?', 'presto-player'); ?></strong></p>
36 <p><?php _e('The media hub is a more flexible way to add media to your site. It allows you to save audio and videos which you can later use in any post or page on your site - either through the Block Editor, a page builder, or by using a shortcode or php function.', 'presto-player'); ?></p>
37 <p><a href="<?php echo esc_url(add_query_arg(array('presto_action' => 'dismiss_notices', 'presto_notice' => $notice_name))); ?>"><?php _e('Dismiss Notice', 'presto-player'); ?></a></p>
38 </div>
39 <?php
40 }
41
42 public function dismissNotice()
43 {
44 // permissions check
45 if (!current_user_can('update_options')) {
46 return;
47 }
48
49 // not our notices, bail
50 if (!isset($_GET['presto_action']) || 'dismiss_notice' !== $_GET['presto_action']) {
51 return;
52 }
53
54 $notice = !empty($_GET['presto_notice']) ? sanitize_text_field($_GET['presto_notice']) : '';
55
56 if (!$notice) {
57 return;
58 }
59
60 // notice is dismissed
61 update_option("presto_player_dismissed_notice_" . sanitize_text_field($notice), 1);
62 }
63
64 /**
65 * Get reusable video block function.
66 *
67 * @param mixed $id The ID of the reusable block.
68 * @return $content The content of the block.
69 */
70 public static function get($id)
71 {
72 $content_post = get_post($id);
73 $content = $content_post->post_content;
74 return $content;
75 }
76
77 public static function getBlock($id)
78 {
79 $blocks = parse_blocks(self::get($id));
80 $out = '';
81 if(is_feed()) {
82 foreach ($blocks as $block) {
83 foreach ($block['innerBlocks'] as $innerblock) {
84 $out .= self::getFeedHtml( $innerblock );
85 }
86 }
87 return $out;
88 }
89
90 foreach ($blocks as $block) {
91 $out .= render_block($block);
92 }
93
94 return $out;
95 }
96
97 /**
98 * Display block function.
99 *
100 * @param mixed $id The ID of the reusable block.
101 */
102 public static function display($id)
103 {
104 echo self::getBlock($id);
105 }
106
107 /**
108 * Return fallback html for feeds.
109 *
110 * @param array $block array of block attributes.
111 */
112 public static function getFeedHtml( $block ) {
113
114 $html = '';
115 if( $block['blockName'] === 'presto-player/vimeo') {
116 ob_start();
117 ?>
118 <div class="presto-iframe-fallback-container" >
119 <iframe style="width: 100%" class="presto-fallback-iframe" id="presto-iframe-fallback-<?php echo (int) $block['attrs']['id']; ?>" src="<?php echo esc_attr($block['attrs']['src']); ?>" ></iframe>
120 </div>
121 <?php
122 $html = ob_get_clean();
123 }
124 elseif( $block['blockName'] === 'presto-player/youtube') {
125 ob_start();
126 ?>
127 <div class="presto-iframe-fallback-container" >
128 <iframe style="width: 100%" class="presto-fallback-iframe" id="presto-iframe-fallback-<?php echo (int) $block['attrs']['id']; ?>" src="<?php echo esc_attr($block['attrs']['src']); ?>"></iframe>
129 </div>
130 <?php
131 $html = ob_get_clean();
132 }
133 else {
134 ob_start();
135 ?>
136 <video controls preload="none" >
137 <source src="<?php echo esc_attr( $block['attrs']['src'] ); ?>" />
138 </video>
139 <?php
140 $html = ob_get_clean();
141 }
142 return $html;
143
144 }
145 }
146