jetpack_lytro_shortcode_url_to_atts

Lytro Shortcode URL to Shortcode Attributes.

Description

jetpack_lytro_shortcode_url_to_atts( $url ); 

This helper function parses a Lytro.com URL and returns an attributes array.

Parameters (1)

0. $url
The url.

Usage

  1. if ( !function_exists( 'jetpack_lytro_shortcode_url_to_atts' ) ) { 
  2. require_once '/modules/shortcodes/lytro.php'; 
  3.  
  4. // The url. 
  5. $url = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = jetpack_lytro_shortcode_url_to_atts($url); 
  9.  

Defined (1)

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

/modules/shortcodes/lytro.php  
  1. function jetpack_lytro_shortcode_url_to_atts( $url ) { 
  2. $attributes = jetpack_lytro_shortcode_attributes(); 
  3. $atts = array(); 
  4.  
  5. $url = str_replace( '&', '&', $url ); 
  6.  
  7. if ( preg_match( '#^https?://(www\.)?lytro\.com/living-pictures/([0-9]+)/?#i', $url, $matches ) ) { 
  8. $atts['photo'] = $matches[2]; 
  9. } elseif ( preg_match( '#^https?://(www\.)?pictures\.lytro\.com/([^/]+)/pictures/([0-9]+)/?#i', $url, $matches ) ) { 
  10. $atts['username'] = $matches[2]; 
  11. $atts['photo'] = $matches[3]; 
  12.  
  13. $url = parse_url( $url ); 
  14. if ( isset( $url['query'] ) ) { 
  15. parse_str( $url['query'], $qargs ); 
  16.  
  17. // Get the attributes with query_args and fill in the $atts array 
  18. foreach ( $attributes as $key => $attribute ) { 
  19. if ( isset( $attribute['query_arg'] ) && in_array( $attribute['query_arg'], array_keys( $qargs ) ) ) { 
  20. $atts[$key] = $qargs[$attribute['query_arg']]; 
  21.  
  22. return $atts;