Skip to content

Instantly share code, notes, and snippets.

Ralf Albert RalfAlbert

View GitHub Profile
View custom_bulk_actions_on_upload.php
<?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 Dec 14, 2015
Just a testcase
View snarfer.php
<?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 Mar 3, 2013
WordPress Remove "external" and "nofollow" from rel-attribute in comment author link
View remove_external_nofollow_from_comment_author_link.php
@RalfAlbert
RalfAlbert / category_widget.php
Created Feb 24, 2013
WordPress: Display a widget with tabs. The tab contents depends on the current category
View category_widget.php
<?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 Feb 9, 2013
A custoim importer for WordPress
View class-custom_import.php
<?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 Jan 29, 2013
simplexml und xpath example
View data.xml
<?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 Jan 29, 2013
PHP XMLReader class example
View data.xml
<?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 Jan 1, 2013
Simple GPlus Avatar Exchange the Gravatar avatar with the GooglePlus avatar if an user provide a link to his GooglePlus profile.
View index.php
<?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 Jan 1, 2013
WordPress: Show date of registration in user profile
View membersince.php
<?php
namespace ShowMemberSince;
add_action( 'plugins_loaded', 'ShowMemberSince\init' );
/**
* Adding needed action hooks
*/
function init(){
View index.php
<?php
/**
* WordPress-Plugin Simple Facebook Avatar
*
* PHP version 5.3
*
* @category PHP
* @package WordPress
* @subpackage Simple Facebook Avatar
* @author Ralf Albert <me@neun12.de>
You can’t perform that action at this time.