shortcodes = array( 'ustudio' ); // This adds support for pulling video metadata from a featured video. $this->meta_keys[] = '_ustudio_featured_video_shortcode'; } } /** * Analyse a video shortcode from the plugin for usable video information. * * @param string $full_shortcode Full shortcode as found in the post content. * @param string $sc Shortcode found. * @param array $atts Shortcode attributes - already decoded if needed. * @param string $content The shortcode content, i.e. the bit between [sc]content[/sc]. * * @return array An array with the usable information found or else an empty array */ public function get_info_from_shortcode( $full_shortcode, $sc, $atts = array(), $content = '' ) { return $this->get_vid_from_atts( $atts ); } /** * Analyse a specific post meta field for usable video information. * * @param string $meta_value The value to analyse. * @param string $meta_key The associated meta key. * @param int $post_id The id of the post this meta value applies to. * * @return array An array with the usable information found or else an empty array */ public function get_info_from_post_meta( $meta_value, $meta_key, $post_id ) { if ( $meta_key === '_ustudio_featured_video_shortcode' ) { $atts = shortcode_parse_atts( $meta_value ); return $this->get_vid_from_atts( $atts ); } } /** * Centralized code for generating video info from shortcode attributes. * * @param array $atts Shortcode attributes. */ public function get_vid_from_atts( $atts ) { $vid = array(); if ( isset( $atts['destination'] ) && isset( $atts['video'] ) ) { $vid['id'] = $atts['destination'] . '/' . $atts['video']; $vid['type'] = 'ustudio'; } return $vid; } } }