baden03 / collapse-o-matic

Collapse-O-Matic is a WordPress plugin that removes clutter and saves space. Display and hide additional content in a SEO friendly way by wrapping content in an [expand] shortcode.
GNU General Public License v2.0
6 stars 7 forks source link

add 'expand' as third argument in shortcode_atts (enables filtering) #3

Closed jerclarke closed 8 years ago

jerclarke commented 8 years ago

shortcode_atts() merges the passed-in values and the defaults for the shortcode. It's third argument is $shortcode, which is supposed to be the slug of the shortcode. It's optional, but if it's missing then no one can filter the arguments with the "shortcodeatts{$shortcode}" filter.

This patch just adds the third argument so I can set a bunch of defaults for the [expand] shortcode on my site.

jerclarke commented 8 years ago

Thank you for considering this patch!

Here is a very simple example of the kind of filter it enables (my actual use is much more elaborate):

function gv_expand_shortcode_filter_atts( $out, $pairs, $atts, $shortcode) {

    // Disable the title= attribute
    $out['notitle'] = true;

    return $out;
}
add_filter('shortcode_atts_expand', 'gv_expand_shortcode_filter_atts', 10, 4);
jerclarke commented 8 years ago

Thanks baden!