How to change default values for specific attributes

Code in this article requires PHP version 5.3 or higher.

The following snippet will set custom default values for the note_color and radius attributes of the [su_note] shortcode. Just paste the snippet into the functions.php file of your active theme:

add_filter( 'shortcode_atts_note', function( $out, $pairs, $atts, $shortcode ) {

		if ( ! isset( $atts['note_color'] ) ) {
			$out['note_color'] = '#f5f5f5';
		}

		if ( ! isset( $atts['radius'] ) ) {
			$out['radius'] = 0;
		}

		return $out;

	}, 10, 4 );

add_filter( 'su/data/shortcodes', function( $shortcodes ) {

	$shortcodes['note']['atts']['note_color']['default'] = '#f5f5f5';
	$shortcodes['note']['atts']['radius']['default'] = 0;

	return $shortcodes;

}, 10, 1 );

Using this snippet you will be able to use the default shortcode (with no attributes set) to display a gray-colored note with border-radius equal to 0.

Example:

[su_note] A gray-colored note [/su_note]