dailymotion_shortcode

DailyMotion shortcode.

Description

(string) dailymotion_shortcode( (array) $atts ); 

The documented shortcode is: [dailymotion id=x8oma9]

Possibilities, according to the old parsing regexp: [dailymotion x8oma9] [dailymotion=x8oma9]

Hypothetical option, according to the old shortcode function is [dailymotion id=1&title=2&user=3&video=4]

The new style is now: [dailymotion id=x8oma9 title=2 user=3 video=4]

Returns (string)

html

Parameters (1)

0. $atts (array)
The atts.

Usage

  1. if ( !function_exists( 'dailymotion_shortcode' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/shortcodes/dailymotion.php'; 
  3.  
  4. // The atts. 
  5. $atts = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = dailymotion_shortcode($atts); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/shortcodes/dailymotion.php  
  1. function dailymotion_shortcode( $atts ) { 
  2. global $content_width; 
  3.  
  4. if ( isset( $atts[0] ) ) { 
  5. $id = ltrim( $atts[0], '=' ); 
  6. $atts['id'] = $id; 
  7.  
  8. } else { 
  9. $params = shortcode_new_to_old_params( $atts ); 
  10. parse_str( $params, $atts_new ); 
  11.  
  12. foreach( $atts_new as $k => $v ) { 
  13. $atts[ $k ] = $v; 
  14.  
  15. if ( isset( $atts['id'] ) ) { 
  16. $id = $atts['id']; 
  17. } else { 
  18. return '<!--Dailymotionerror bad or missing ID-->'; 
  19.  
  20. if ( ! empty( $content_width ) ) { 
  21. $width = min( 425, intval( $content_width ) ); 
  22. } else { 
  23. $width = 425; 
  24.  
  25. $height = ( 425 == $width ) ? 334 : ( $width / 425 ) * 334; 
  26. $id = urlencode( $id ); 
  27.  
  28. if ( preg_match( '/^[A-Za-z0-9]+$/', $id ) ) { 
  29. $output = '<iframe width="' . $width . '" height="' . $height . '" src="' . esc_url( '//www.dailymotion.com/embed/video/' . $id ) . '" frameborder="0"></iframe>'; 
  30. $after = ''; 
  31.  
  32. if ( array_key_exists( 'video', $atts ) && $video = preg_replace( '/[^-a-z0-9_]/i', '', $atts['video'] ) && array_key_exists( 'title', $atts ) && $title = wp_kses( $atts['title'], array() ) ) { 
  33. $after .= '<br /><strong><a href="' . esc_url( 'http://www.dailymotion.com/video/' . $video ) . '">' . esc_html( $title ) . '</a></strong>'; 
  34.  
  35. if ( array_key_exists( 'user', $atts ) && $user = preg_replace( '/[^-a-z0-9_]/i', '', $atts['user'] ) ) { 
  36. $after .= '<br /><em>Uploaded by <a href="' . esc_url( 'http://www.dailymotion.com/' . $user ) . '">' . esc_html( $user ) . '</a></em>'; 
  37.  
  38. return $output . $after;