Skip to content

Instantly share code, notes, and snippets.

<?php
class swDFPBaseModule
{
private function parent_or_child($tax, $query_key)
{
$slug = $wp_query->query_vars[$query_key]
$s = get_term_by('slug', $slug, $tax);
return ($s->parent>0) ?
'get_on_'.$tax.'_page' : 'get_on_child_'.$tax.'_page';
@beezee
beezee / php-cs-fixer-pre-commit.php
Created September 8, 2012 16:04 — forked from mardix/php-cs-fixer-pre-commit.php
A pre-commit hook to make PHP code PSR-2 compliant, check for syntax error
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*
@beezee
beezee / param_call.php
Created July 1, 2012 18:55 — forked from maxpert/param_call.php
PHP named parameter calling
<?php
$x = function($bar, $foo="9") {
echo $foo, $bar, "\n";
};
class MissingArgumentException extends Exception {
}
function call_user_func_named_array($method, $arr){