{"id":33890,"date":"2019-03-01T13:12:53","date_gmt":"2019-03-01T13:12:53","guid":{"rendered":"http:\/\/getshortcodes.com\/?post_type=docs&#038;p=33890"},"modified":"2019-03-12T07:04:41","modified_gmt":"2019-03-12T07:04:41","slug":"changing-default-values-for-specific-attributes","status":"publish","type":"docs","link":"https:\/\/getshortcodes.com\/docs\/changing-default-values-for-specific-attributes\/","title":{"rendered":"Changing default values for specific attributes"},"content":{"rendered":"\n<p class=\"has-text-color has-background has-black-color has-yellow-background-color\">Code in this article requires PHP version 5.3 or higher.<\/p>\n\n\n\n<p>The following snippet will set custom default values for\u00a0the <em>note_color<\/em> and <em>radius<\/em> attributes of the\u00a0<em><div class=\"su-note\"  style=\"border-color:#e5e54c;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFFF66;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><\/em>\u00a0shortcode. Just paste the snippet into the functions.php file of your active theme:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">add_filter( 'shortcode_atts_note', function( $out, $pairs, $atts, $shortcode ) {<br><br>  if ( ! isset( $atts['note_color'] ) ) {<br>    $out['note_color'] = '#f5f5f5';<br>  }<br><br>  if ( ! isset( $atts['radius'] ) ) {<br>    $out['radius'] = 0;<br>  }<br><br>  return $out;<br><br>}, 10, 4 );<br><br>add_filter( 'su\/data\/shortcodes', function( $shortcodes ) {<br><br>  $shortcodes['note']['atts']['note_color']['default'] = '#f5f5f5';<br>  $shortcodes['note']['atts']['radius']['default'] = 0;<br><br>  return $shortcodes;<br><br>}, 10, 1 );<\/pre>\n\n\n\n<p>Using this snippet you will be able to use the default&nbsp;shortcode&nbsp;(with no attributes set) to display a gray-colored note with border-radius equal to 0.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><div class=\"su-note\"  style=\"border-color:#e5e54c;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFFF66;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><\/div><\/div> A gray-colored note <\/div><\/div><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"594\" height=\"81\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-EHzab6rTBT.png\" alt=\"\" class=\"wp-image-33891\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-EHzab6rTBT.png 594w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-EHzab6rTBT-512x70.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-EHzab6rTBT-128x17.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-EHzab6rTBT-80x11.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-EHzab6rTBT-24x3.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-EHzab6rTBT-280x38.png 280w\" sizes=\"auto, (max-width: 594px) 100vw, 594px\" \/><\/figure>\n","protected":false},"featured_media":0,"template":"","docs_category":[24],"class_list":["post-33890","docs","type-docs","status-publish","hentry","docs_category-api"],"_links":{"self":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs\/33890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/types\/docs"}],"wp:attachment":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/media?parent=33890"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs_category?post=33890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}