Skip to content

Instantly share code, notes, and snippets.

@RalfAlbert
RalfAlbert / data.xml
Created January 29, 2013 03:16
PHP XMLReader class example
<?xml version="1.0" encoding="UTF-8"?>
<products>
<last_updated>2009-11-30 13:52:40</last_updated>
<product tax="19" name="luxus">
<element>foo</element>
</product>
<product tax="7" name="brot">
<element>bar</element>
</product>
</products>
@RalfAlbert
RalfAlbert / tutorial_testfile.php
Created December 21, 2013 13:18
tutorial_testfile.php
<?php
/**
* Plugin Name: 000 Tutorial TestFile
* Description: Simple testfile for writing tutorials
*/
namespace TutorialTestFile;
add_action(
'plugins_loaded',
@RalfAlbert
RalfAlbert / gist:7732687
Created December 1, 2013 11:53
Custom events with jQuery
<h1>jQuery Testseite</h1>
<p id="test">Hello World!</p>
<p><a href="#" id="clickit">Click it!</a></p>
<script type="text/javascript">
$(document).ready(
function() {
$('#test').bind(
@RalfAlbert
RalfAlbert / basic_datacontainer_1.php
Last active December 17, 2015 22:49
Example files for DataContainer
<?php
class DataContainer
{
public static $data = array();
public function __set( $name, $value ) {
self::$data[$name] = $value;
}
public function __get( $name ) {
@RalfAlbert
RalfAlbert / mailtest.php
Last active December 17, 2015 11:39
Test WordPress' is_email() and sanitize_email() functions
<?php
// require wordpress
/**
* @see http://en.wikipedia.org/wiki/Email_address
*/
$email = array();
$email[] = 'john.smith(commentedemail)@example.com';
$email[] = '(commentedemail)john.smith@example.com';
$email[] = 'john.smith@(commentedemail)example.com';
$email[] = 'john.smith@example.com(commentedemail)';
@RalfAlbert
RalfAlbert / snarfer.php
Last active December 14, 2015 13:09
Just a testcase
<?php
/*
Template Name: Snarfer
*/
global $wp_query;
$old_query = $wp_query;
query_posts('author=1');
echo '<ul>';
@RalfAlbert
RalfAlbert / remove_external_nofollow_from_comment_author_link.php
Created March 3, 2013 22:08
WordPress Remove "external" and "nofollow" from rel-attribute in comment author link
@RalfAlbert
RalfAlbert / category_widget.php
Created February 24, 2013 13:18
WordPress: Display a widget with tabs. The tab contents depends on the current category
<?php
class Category_Widget extends WP_Widget {
public function __construct() {
$widget_ops = array(
'classname' => __CLASS__,
'description' => 'Displaying content depending on the current category',
);
@RalfAlbert
RalfAlbert / data.xml
Created January 29, 2013 09:32
simplexml und xpath example
<?xml version="1.0" encoding="UTF-8"?>
<products>
<product tax="19" status="luxus">
<element>Benzin</element>
</product>
<product tax="7" status="grundnahrung">
<element>Brot</element>
</product>
</products>
@RalfAlbert
RalfAlbert / index.php
Created January 1, 2013 21:30
Simple GPlus Avatar Exchange the Gravatar avatar with the GooglePlus avatar if an user provide a link to his GooglePlus profile.
<?php
/**
* WordPress-Plugin Simple GPlus Avatar
*
* PHP version 5.3
*
* @category PHP
* @package WordPress
* @subpackage Simple GPlus Avatar
* @author Ralf Albert <me@neun12.de>