Skip to content

Instantly share code, notes, and snippets.

@efuller
efuller / notes.md
Last active March 1, 2017 18:05 — forked from kellenmace/output-buffering-example.php
Template tags and Output Buffering at WDS

Information

This exploded into a big discussion about the creation of template tags and why you don’t have to always create a get and a do.

Example, in a loop you run do_my_thing(), the function do_my_thing() does not need to buffer the output if you’re just going to echo it out in the loop, so ob_start is not needed!

If, later, you find you need to get that string you can write a simple getter: https://gist.github.com/cd948f2b9f83625e09518c531d272d1c#file-output-buffering-example-php

Usually a template tag is wrote as a do first, and then a get later when it’s needed, but either way write your do and get when you need them, don’t build a get for the future unless it will be needed in the future