This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// underscore template in a php file that is meant to be included on the page so that it becomes an "inline template" | |
<script id="template-composite-view" type="text/template"> | |
<h1>I am a Template With Child View</h1> | |
<h2>Here they are.</h2> | |
<% if( children.length ) { %> | |
<% _.each(children, function(child){ %> | |
<div id="<%= child.cid %>" class="child-view"></div> | |
<% }); %> | |
<% } %> | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based very heavily on http://ianstormtaylor.com/rendering-views-in-backbonejs-isnt-always-simple/ | |
CompositeView = Backbone.View.extend({ | |
// assuming an inline underscrore template | |
template: _.template(jQuery('#template-composite-view').html()) | |
initialize: function(){ | |
this.children = []; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'posts_request', 'tbcorr_posts_request', 10, 2 ); | |
function tbcorr_posts_request( $request, $query ){ | |
$is_admin = $query->query_vars['is_admin']; | |
$is_search = $query->query_vars['is_search']; | |
$is_main_query = $query->query_vars['is_main_query']; | |
if( $is_admin ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MultipleConstructors { | |
private $prop_one; // string | |
private $prop_two; // int | |
private function __construct(){ | |
$this->set_prop_one(""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class LazyInstantiation { | |
// we can only access this static property | |
// through the public static getter since | |
// the property is private | |
private static $expensive_to_compute; | |
// public static getter |