| 1958 | * Builds the Track shortcode output. |
| 1959 | * |
| 1960 | * This implements the functionality of the Track Shortcode for displaying |
| 1961 | * time triggered text to the viewer. |
| 1962 | * |
| 1963 | * @since 3.6.0 |
| 1964 | * |
| 1965 | * @param array $attr { |
| 1966 | * Attributes of the shortcode. |
| 1967 | * |
| 1968 | * @type string $kind Type of track (subtitles, captions, chapters, descriptgions, or metadata). |
| 1969 | * @type string $src URL to the source of the vtt file. Default empty. |
| 1970 | * @type string $srclang The two-letter code (valid BCP 47 language tag) for the language of the text track, for example "en" for English. |
| 1971 | * @type int $label The label for the track that will be show to the user, for example in a menu that list the different languages available for subtitles. |
| 1972 | * @type int $default The default attribute can be used to have a track default to showing. Otherwise the viewer would need to select their language from the captions or subtitles menu. NOTE: For chapters, default is required if you want the chapters menu to show. |
| 1973 | * } |
| 1974 | * @param string $track Shortcode content. |
| 1975 | * @return string|void HTML content to display track. |
| 1976 | */ |
| 1977 | function track_shortcode( $atts, $content = null ) { |
| 1978 | extract( shortcode_atts( array( |
| 1979 | 'kind' => '', |
| 1980 | 'src' => '', |
| 1981 | 'srclang' => '', |
| 1982 | 'label' => '', |
| 1983 | 'default' => '' |
| 1984 | ), $atts ) ); |
| 1985 | |
| 1986 | if ( $kind ) |
| 1987 | $kind = " kind='" . $kind . "'"; |
| 1988 | |
| 1989 | if ( $src ) |
| 1990 | $src = " src='" . $src . "'"; |
| 1991 | |
| 1992 | if ( $srclang ) |
| 1993 | $srclang = " srclang='" . $srclang . "'"; |
| 1994 | |
| 1995 | if ( $label ) |
| 1996 | $label = " label='" . $label . "'"; |
| 1997 | |
| 1998 | if ( "true" == $default || "default" == $default ) |
| 1999 | $default = " default"; |
| 2000 | else |
| 2001 | $default = ""; |
| 2002 | |
| 2003 | $track = " |
| 2004 | <track" . $kind . $src . $srclang . $label . $default . " /> |
| 2005 | "; |
| 2006 | |
| 2007 | return $track; |
| 2008 | } |
| 2009 | add_shortcode( 'track', 'track_shortcode' ); |
| 2010 | |
| 2011 | /** |