Changeset 2651431
- Timestamp:
- 12/31/2021 06:17:42 PM (4 years ago)
- Location:
- video-metabox-aoc/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (1 diff)
-
video-metabox-aoc.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
video-metabox-aoc/trunk/readme.txt
r2651422 r2651431 33 33 == Changelog == 34 34 35 = 1.1 = 36 * Add shortcode `aoc_video_box` 37 38 = 1.0 = 39 * Bugfix - return video URL instead of video ID 40 35 41 = 0.1 = 36 42 * First stable version -
video-metabox-aoc/trunk/video-metabox-aoc.php
r2651426 r2651431 7 7 * Plugin name: Video Metabox AOC 8 8 * Description: This plugin allows you to upload video as a custom field for a post/page. 9 * Version: 1. 09 * Version: 1.1 10 10 */ 11 11 function aoc_vid_register_meta_boxes() … … 30 30 <source src="<?= esc_url(wp_get_attachment_url(intval($aoc_vid_video))) ?>"> 31 31 Your browser does not support the video tag. 32 </video><input type="hidden" name="aoc_vid_video" id="aoc_vid_vid_input" value="<?= intval($aoc_vid_video) ?>"><button data-vid-id="<?= intval($aoc_vid_video) ?>" class="aoc-del-vid" type="button">X</button></div> 32 </video> 33 <input type="hidden" name="aoc_vid_video" id="aoc_vid_vid_input" value="<?= intval($aoc_vid_video) ?>"> 34 <button data-vid-id="<?= intval($aoc_vid_video) ?>" class="aoc-del-vid" type="button">X</button> 35 </div> 33 36 <?php 34 37 endif; … … 71 74 return wp_get_attachment_url($vid); 72 75 } 76 77 add_action('init', 'aoc_init_shortcode'); 78 function aoc_init_shortcode() 79 { 80 add_shortcode('aoc_video_box', 'aoc_video_box'); 81 } 82 83 function aoc_video_box($atts) 84 { 85 $id = get_queried_object_id(); 86 $video = get_post_meta($id, 'aoc_vid_video', true); 87 88 if (!$video) { 89 return ''; 90 } 91 $video_url = wp_get_attachment_url($video); 92 if (!$video_url) { 93 return; 94 } 95 $attributes = ''; 96 if ($atts && is_array($atts)) { 97 foreach ($atts as $key => $value) { 98 $attributes .= $key . '= "' . $value . '" '; 99 } 100 if (isset($atts['controls']) && $atts['controls']) { 101 $attributes .= ' controls="true"'; 102 } 103 } 104 return '<video ' . $attributes . '> 105 <source src="' . $video_url . '"> 106 Your browser does not support the video tag. 107 </video>'; 108 };
Note: See TracChangeset
for help on using the changeset viewer.