Skip to content

Instantly share code, notes, and snippets.

@RalfAlbert
RalfAlbert / index.php
Created August 2, 2012 23:08
Plugin Grundgeruest
<?php
/*** MOCKING ***/
function did_action( $hook ){
static $calls = 0;
return $calls++;
}
@RalfAlbert
RalfAlbert / get_constant.php
Created July 8, 2012 00:11
Get a class constant from outside of the class
<?php
class Foo
{
const BAR = 'Hallo';
const BAZ = 'Welt!';
/**
*
* Returns the value of a class constant
* @param string $const Name of the constant
@RalfAlbert
RalfAlbert / wp-query-extended.php
Created June 30, 2012 13:29
Extending WP_Query
<?php
class Custom_WP_Query extends WP_Query
{
public $time_diff = '';
public function __construct( $query = '' ){
if( ! empty( $query ) )
@RalfAlbert
RalfAlbert / filters-for-simple-cache-template.php
Created June 7, 2012 23:53
Page template for WordPress with caching
<?php
add_action( 'save_post', 'clear_many_sites_transient', 10, 1 );
add_action( 'edit_post', 'clear_many_sites_transient', 10, 1 );
function clear_many_sites_transient( $post_id ){
$post = get_post( $post_id );
if( 'page' === $post->post_type )
delete_transient( 'many_sites_in_one' );
@RalfAlbert
RalfAlbert / resize_thickbox.js
Created May 30, 2012 17:30
Groesse der Thickbox automatisch an den Inhalt anpassen. Thickbox automatically adjust the size of the content
jQuery(document).ready(
function($){
resize_thickbox_iframe();
/*
*
* some other jQuery code
*
*/
@RalfAlbert
RalfAlbert / file1.php
Created May 26, 2012 22:37
Simple-Templates: The Demo
<?php
class Template_Engine_Test
{
/**
*
* Container for the different template-engines
* @var object $template_engine
*/
public static $template_engine;
@RalfAlbert
RalfAlbert / file1.php
Created May 26, 2012 22:33
Simple-Templates: The Template-Engine
<?php
/**
*
* Abstract class WP Simple Templater creates a copy of the template-class and
* provide the templates to the template-engine
* @author Ralf Albert
*
*/
abstract class WP_Simple_Templater extends Formatter
{
@RalfAlbert
RalfAlbert / file1.php
Created May 26, 2012 17:54
Simple-Templates: The Template-Classes
<?php
/**
*
* Abstract class Wp Simple Templates define one method to retrive the defined templates
* @author Ralf Albert
*
*/
abstract class WP_Simple_Templates
{
@RalfAlbert
RalfAlbert / class-lister.php
Created March 21, 2012 09:35
Example 3 for Formatter
<?php
require_once 'class-formatter.php';
require_once 'class-templates.php';
interface Templates
{
public function get_templates();
}
class Lister extends Formatter
@RalfAlbert
RalfAlbert / file1.php
Created March 20, 2012 17:40
Example 2 for Formatter
<?php
require_once 'class-formatter.php';
class Lister extends Formatter
{
public $templates = array();
public function __construct(){
$this->templates = $this->get_templates();