{"id":438,"date":"2014-01-20T20:11:26","date_gmt":"2014-01-21T05:11:26","guid":{"rendered":"http:\/\/jayjennings.com\/?p=438"},"modified":"2014-01-20T20:11:26","modified_gmt":"2014-01-21T05:11:26","slug":"wp-admin-notes-quick-bit-of-code","status":"publish","type":"post","link":"https:\/\/jayjennings.com\/blog\/2014\/01\/20\/wp-admin-notes-quick-bit-of-code\/","title":{"rendered":"WP Admin Notes &#8211; Quick Bit of Code"},"content":{"rendered":"<p>I just added a feature to one of my sites that allows me to write a &#8220;note to the admin&#8221; (me) that doesn&#8217;t show up on the site. Here&#8217;s a look at one of the widgets in my admin area:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"http:\/\/jayjennings.com\/wp-content\/uploads\/2014\/01\/wp-trr-notes.png\" alt=\"Wp trr notes\" title=\"wp-trr-notes.png\" border=\"1\" width=\"446\" height=\"141\" \/><\/p>\n<p>I really don&#8217;t want a title for that widget, but I also don&#8217;t want to have to open every text widget to remember what it is (many of my text widgets are without titles). By creating that shortcode I can surround any bits of text that is a note to myself, but it won&#8217;t appear on the site.<\/p>\n<p>Creating a shortcode is really easy &#8212; and this one was especially easy because nothing is really happening. WP passes me the text that&#8217;s surrounded by the shortcode and I don&#8217;t do anything with it &#8212; just pass WP back an empty string.<\/p>\n<p>I put this code inside the functions.php of my current theme:<\/p>\n<pre lang=\"php\">\nfunction trr_note( $atts, $content = null ) {\n\treturn '';\n}\nadd_shortcode( 'trr_note', 'trr_note' );\n<\/pre>\n<p>Because of the way shortcodes work I can also call it like this:<\/p>\n<pre lang=\"php\">\n[trr_note foo=\"This is my note for my eyes only!\"]\n<\/pre>\n<p>The variable named foo can be named anything &#8212; since I&#8217;m doing nothing with that it doesn&#8217;t matter what it&#8217;s called.<\/p>\n<p>The only other thing I had to do was tell WP to process shortcodes inside widget titles and text &#8212; apparently that&#8217;s not standard (which seems weird to me). I added these lines of code to the functions.php file:<\/p>\n<pre lang=\"php\">\nadd_filter('widget_text', 'do_shortcode');\nadd_filter('widget_title', 'do_shortcode');\n<\/pre>\n<p>It&#8217;s not rocket science, but it makes my admin duties easier since I can tell at a glance what specific widgets are for. I can also use it to &#8220;comment out&#8221; text on pages that I want to save for later.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just added a feature to one of my sites that allows me to write a &#8220;note to the admin&#8221; (me) that doesn&#8217;t show up on the site. Here&#8217;s a look at one of the widgets in my admin area: I really don&#8217;t want a title for that widget, but I also don&#8217;t want to have to open every text &#8230; <a href=\"https:\/\/jayjennings.com\/blog\/2014\/01\/20\/wp-admin-notes-quick-bit-of-code\/\" class=\"more-link\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[18],"tags":[54],"class_list":["post-438","post","type-post","status-publish","format-standard","hentry","category-programming","tag-wordpress","no-post-thumbnail"],"jetpack_featured_media_url":"","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/jayjennings.com\/blog\/wp-json\/wp\/v2\/posts\/438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jayjennings.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jayjennings.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jayjennings.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jayjennings.com\/blog\/wp-json\/wp\/v2\/comments?post=438"}],"version-history":[{"count":0,"href":"https:\/\/jayjennings.com\/blog\/wp-json\/wp\/v2\/posts\/438\/revisions"}],"wp:attachment":[{"href":"https:\/\/jayjennings.com\/blog\/wp-json\/wp\/v2\/media?parent=438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jayjennings.com\/blog\/wp-json\/wp\/v2\/categories?post=438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jayjennings.com\/blog\/wp-json\/wp\/v2\/tags?post=438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}