shortcode_new_to_old_params

Transforms the $atts array into a string that the old functions expected.

Description

shortcode_new_to_old_params( (Array) $params, (bool) $old_format_support = false ); 

The old way was: [shortcode a=1&b=2&c=3] or [shortcode=1] This is parsed as array( a => 1&b=2&c=3 ) and array( 0 => =1 ), which is useless

Parameters (2)

0. $params (Array)
The params.
1. $old_format_support — Optional. (bool) => false
True if [shortcode=foo] format is possible.

Usage

  1. if ( !function_exists( 'shortcode_new_to_old_params' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/shortcodes.php'; 
  3.  
  4. // The params. 
  5. $params = null; 
  6.  
  7. // true if [shortcode=foo] format is possible. 
  8. $old_format_support = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = shortcode_new_to_old_params($params, $old_format_support); 
  12.  

Defined (1)

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

/modules/shortcodes.php  
  1. function shortcode_new_to_old_params( $params, $old_format_support = false ) { 
  2. $str = ''; 
  3.  
  4. if ( $old_format_support && isset( $params[0] ) ) { 
  5. $str = ltrim( $params[0], '=' ); 
  6. } elseif ( is_array( $params ) ) { 
  7. foreach ( array_keys( $params ) as $key ) { 
  8. if ( ! is_numeric( $key ) ) 
  9. $str = $key . '=' . $params[$key]; 
  10.  
  11. return str_replace( array( '&', '&' ), '&', $str );