Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




shortcode_atts [ WordPress Function ]

shortcode_atts ( $pairs, $atts )
Parameters:
  • (array) $pairs Entire list of supported attributes and their defaults.
  • (array) $atts User defined attributes in shortcode tag.
Returns:
  • (array) Combined and filtered attribute list.
Defined at:



Combine user attributes with known attributes and fill in defaults when needed.

The pairs should be considered to be all of the attributes which are supported by the caller and given as a list. The returned attributes will only contain the attributes in the $pairs list.

If the $atts list has unsupported attributes, then they will be ignored and removed from the final returned list.

Source


<?php
function shortcode_atts($pairs$atts) {
    
$atts = (array)$atts;
    
$out = array();
    foreach(
$pairs as $name => $default) {
        if ( 
array_key_exists($name$atts) )
            
$out[$name] = $atts[$name];
        else
            
$out[$name] = $default;
    }
    return 
$out;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics