{"id":2433,"date":"2007-12-27T04:54:16","date_gmt":"2007-12-27T11:54:16","guid":{"rendered":"http:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/?p=2433"},"modified":"2008-01-04T23:21:29","modified_gmt":"2008-01-05T06:21:29","slug":"speaking-in-tongues-presentable-php-in-wordpress","status":"publish","type":"post","link":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/2433\/speaking-in-tongues-presentable-php-in-wordpress\/","title":{"rendered":"Speaking in tongues: Presentable PHP in WordPress"},"content":{"rendered":"<p>In the coming days, I plan to take up the idea of PHP for non-programmers, helping you tap the power of PHP&#8217;s dynamic text processing without learning (much) actual coding.<\/p>\n<p>The problem is that illustrating HTML or PHP in WordPress is always a problem. Why? Because WordPress eats code for breakfast. Properly-formatted coding looks to WordPress like&#8230; properly-formatted coding. Instead of a code example, you get the executed code itself.<\/p>\n<p>There are ways around this. I&#8217;ve used pictures in the past, or done elaborate searches to suss WordPress into showing the code sample as a code sample. But because I&#8217;m going to be showing a lot of code, and because I want for you to be able to copy and paste my examples into your own files, I built a tool (in PHP) to render PHP and HTML in a form that looks to WordPress like mere text, not code to be executed, but which will work just fine when you copy and paste it into your own files.<\/p>\n<p>Like this, as a very simple example:<\/p>\n<pre>&lt;html&gt;\r\n&lt;body&gt;\r\n&lt;p&gt;Hello, World!&lt;\/p&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>I&#8217;ve made <a href=\"http:\/\/bloodhoundrealty.com\/BloodhoundBlog\/SlashProc.php\" target=\"_blank\">my little toy available to you<\/a>, if you want to play with it. You can use it to show coded examples to your own readers. It&#8217;s not doing any kind of error-trapping, but it&#8217;s not doing very much of anything. Let me know if you can break it.<\/p>\n<p>Building this was actually easier than talking about it, but there is a caveat. WordPress won&#8217;t love you if you try to go back and edit a published post that has one of these encoded examples in it. The second time through the WordPress parser, it will try to execute the code. The solution is either to write in and edit in an off-line editor like Ecto or to create your posts using coded examples in a text editor, editing your original files, rather than the published post. The point, either way, is to make sure that WordPress parses the coded examples only once before displaying them.<\/p>\n<p>I&#8217;ll have more shortly, but if you want to get a jump on things, do this: Copy the example code above and paste <a href=\"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/2433\/speaking-in-tongues-presentable-php-in-wordpress\/#more-2433\" class=\"more-link\">Read more<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the coming days, I plan to take up the idea of PHP for non-programmers, helping you tap the power of PHP&#8217;s dynamic text processing without learning (much) actual coding. The problem is that illustrating HTML or PHP in WordPress is always a problem. Why? Because WordPress eats code for breakfast. Properly-formatted coding looks to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,6,5,19],"tags":[],"class_list":{"0":"post-2433","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-blogging","7":"category-marketing","8":"category-real-estate","9":"category-technology","11":"no-featured-image"},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2465,"url":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/2465\/speaking-in-tongues-for-morgan-brown-a-quick-and-dirty-contributors-blogroll\/","url_meta":{"origin":2433,"position":0},"title":"Speaking in tongues for Morgan Brown: A quick and dirty contributors&#8217; blogroll","author":"Greg Swann","date":"January 3, 2008","format":false,"excerpt":"I know I promised to do nothing but \"includes,\" and we'll come back to those soon, but here is a real PHP routine, doing an actual real world job. What does it do? For a multi-author weblog like BloodhoundBlog, it produces a blogroll of the contributors' weblogs or web sites.\u2026","rel":"","context":"In &quot;Blogging&quot;","block_context":{"text":"Blogging","link":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/category\/blogging\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2438,"url":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/2438\/speaking-in-tongues-dynamically-updated-lists-of-links-in-php\/","url_meta":{"origin":2433,"position":1},"title":"Speaking in tongues: Dynamically updated lists of links in PHP","author":"Greg Swann","date":"December 28, 2007","format":false,"excerpt":"Let's get dynamic, shall we? There are a lot of things you can say about PHP -- and some of them are even safe for work. But, at bottom, PHP is a working stiff's programming language for producing dynamic web pages. What's a dynamic web page? It's a page that\u2026","rel":"","context":"In &quot;Blogging&quot;","block_context":{"text":"Blogging","link":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/category\/blogging\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":174,"url":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/174\/how-to-make-fast-flexible-web-pages\/","url_meta":{"origin":2433,"position":2},"title":"How to make fast, flexible web pages . . .","author":"Greg Swann","date":"August 4, 2006","format":false,"excerpt":"Sellsius\u00b0 has a big bag of how-to's but I'm from Missouri. I like how-to articles that tell exactly how to do something. One from me: How to make fast, flexible web pages. This is Realtor 2.0 stuff: Full-service Realtors who plan to compete need to learn how to punch out\u2026","rel":"","context":"In &quot;Blogging&quot;","block_context":{"text":"Blogging","link":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/category\/blogging\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3248,"url":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/3248\/speaking-in-tongues-parsing-structured-data-on-the-fly\/","url_meta":{"origin":2433,"position":3},"title":"Speaking in tongues: Parsing structured data on the fly","author":"Greg Swann","date":"June 19, 2008","format":false,"excerpt":"This is not ProjectBloodhound material, at least not first semester stuff. But if you find yourself running into highly structured data -- such as the reports from a spreadsheet or a database application -- you have the ability to easily manipulate that data in PHP. This is a simple example,\u2026","rel":"","context":"In &quot;Marketing&quot;","block_context":{"text":"Marketing","link":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/category\/marketing\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5959,"url":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/5959\/speaking-in-tongues-revising-my-universal-contact-form-for-real-estate-weblogs-e-paging-support-and-friendlier-coding\/","url_meta":{"origin":2433,"position":4},"title":"Speaking in tongues: Revising my universal contact form for real estate weblogs &#8212; e-paging support and friendlier coding","author":"Greg Swann","date":"December 5, 2008","format":false,"excerpt":"About eleven months ago, I built a universal contact form for real estate webloggers. Just lately, I've revisited that code to add support for e-paging and other kinds of hyper-brief email-based messaging. Getting a form emailed to the office is a nice thing -- unless you're out previewing or inspecting\u2026","rel":"","context":"In &quot;Blogging&quot;","block_context":{"text":"Blogging","link":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/category\/blogging\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1298,"url":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/1298\/real-estate-weblogging-101-our-story-so-far\/","url_meta":{"origin":2433,"position":5},"title":"Real Estate Weblogging 101: Our story so far","author":"Greg Swann","date":"April 13, 2007","format":false,"excerpt":"Here's a true fact of weblogging: Sometimes you decide you want to do something that requires you to go back and edit 30 or 40 posts. As an example, imagine that you decided you wanted to add a new category. You would have to go back and re-categorize all the\u2026","rel":"","context":"In &quot;Blogging&quot;","block_context":{"text":"Blogging","link":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/category\/blogging\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/wp-json\/wp\/v2\/posts\/2433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/wp-json\/wp\/v2\/comments?post=2433"}],"version-history":[{"count":0,"href":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/wp-json\/wp\/v2\/posts\/2433\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/wp-json\/wp\/v2\/media?parent=2433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/wp-json\/wp\/v2\/categories?post=2433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bloodhoundrealty.com\/BloodhoundBlog\/wp-json\/wp\/v2\/tags?post=2433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}