Skip to content

Instantly share code, notes, and snippets.

View gist:3483773
<?php
$expert_parents = array( array( "parent_entry_id" => "1758" ), array( "parent_entry_id" => "151" ), );
$topic_parents = array( array( "parent_entry_id" => "151" ),
array( "parent_entry_id" => "1815" ),
array( "parent_entry_id" => "2548" ),
array( "parent_entry_id" => "2550" ), );
function find_matches( $val1, $val2 ) {
return ( intval( $val1["parent_entry_id"] ) - intval( $val2["parent_entry_id"] ) );
@MZAWeb
MZAWeb / PHP version
Created Aug 30, 2012
Eurler 2 (not tested)
View PHP version
<?php
$a = 1;
$b = 2;
$sum = 0;
$response = 0;
for ( $i=0; $a<4000000; $i++ ) {
$sum = $a + $b;
$a = $b;
View gist:3549198
<?php
class A {
protected function nonstatic() {
echo "nonstaticA\n";
var_dump($this);
}
}
class B extends A {}
@MZAWeb
MZAWeb / gist:3625950
Created Sep 4, 2012
2nd pass at hidden category
View gist:3625950
<?php
/*
Plugin Name: Private Events
Plugin URI: http://tri.be
Description: This plugin allows you to have a private event category only visible to viewers who have logged in to your site.
Version: 1.0
Author: Daniel - Coder / Phil - Plugin typer upper
Author URI: http://tri.be
License: A "Slug" license name e.g. GPL2
*/
View 2.php
<?php
/**
* User Details
*
* @package bbPress
* @subpackage Theme
*/
?>
View gist:3717480
add_filter( 'pre_get_posts', 'tribe_pre_get_posts' );
function tribe_pre_get_posts( $query ) {
if ( $query->query_vars["post_type"] === TribeEvents::POSTTYPE ) {
$query = apply_filters( 'tribe_pre_get_posts', $query );
}
View gist:3717426
<?php
add_filter( 'pre_get_posts', 'tribe_filters_query' );
function tribe_filters_query( $query ) {
if ( is_main_query() && the_user_just_made_a_search_in_the_filter_view() ) {
$query = apply_filters( 'tribe_filters_query_args', $query );
View gist:4136893
<?php
add_action( 'plugins_loaded', 'my_pre_my_ostrichcized_plugins', 1 );
add_action( 'wp', 'dd_test_notice' );
add_action( 'wp', 'dd_test_warning' );
add_action( 'wp', 'dd_test_fatal' );
function dd_test_notice() {
$error = NOT_DEFINED_CONSTANT;
}
@MZAWeb
MZAWeb / gist:4590550
Created Jan 21, 2013
Maybe use current directory as a taskwarrior project filter
View gist:4590550
function t() {
project=$(basename `pwd`);
tp=( $(task _projects | grep $project) );
if [[ -n $tp ]]; then
task "$@" project:$project;
else
task "$@"
fi
}
@MZAWeb
MZAWeb / gist:5122874
Last active Dec 14, 2015
Remove breadcrums for bbPress shortcodes
View gist:5122874
<?php
add_filter( 'the_content', 'remove_breadcrum', 0 );
add_filter( 'the_content', 'add_breadcrum', 1000 );
function remove_breadcrum( $content ) {
add_filter( 'bbp_no_breadcrumb', '__return_true' );
return $content;
}
function add_breadcrum( $content ) {