Skip to content

Instantly share code, notes, and snippets.

<?php
/*
* Since PHP5 there is no need to pass an reference of $this
*
* @see http://php.net/manual/en/language.oop5.references.php
* [...] As of PHP 5, an object variable doesn't contain the object itself as value anymore [...]
*/
add_action( 'load-upload.php', array( $this, 'custom_bulk_action' ) );
@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 / class-custom_import.php
Created February 9, 2013 04:13
A custoim importer for WordPress
<?php
/*
Plugin Name: Custom Importer
Plugin URI:
Description: Import posts or not
Author: Ralf Albert
Author URI: http://yoda.neun12.de
Version: 0.1
Text Domain: custom-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@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 / 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 / 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>
@RalfAlbert
RalfAlbert / membersince.php
Created January 1, 2013 13:35
WordPress: Show date of registration in user profile
<?php
namespace ShowMemberSince;
add_action( 'plugins_loaded', 'ShowMemberSince\init' );
/**
* Adding needed action hooks
*/
function init(){
<?php
/**
* WordPress-Plugin Simple Facebook Avatar
*
* PHP version 5.3
*
* @category PHP
* @package WordPress
* @subpackage Simple Facebook Avatar
* @author Ralf Albert <me@neun12.de>