Skip to content

Instantly share code, notes, and snippets.

Ralf Albert RalfAlbert

Block or report user

Report or block RalfAlbert

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@RalfAlbert
RalfAlbert / basic_datacontainer_1.php
Last active Dec 17, 2015
Example files for DataContainer
View basic_datacontainer_1.php
<?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 Dec 17, 2015
Test WordPress' is_email() and sanitize_email() functions
View mailtest.php
<?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 / gist:5372635
Created Apr 12, 2013
PHP execution shortcode for WordPress Usage: [php]<?php echo 'Hello World!'; ?>[/php]
View gist:5372635
add_shortcode(
'php',
function( $atts, $content = null ){
// un-texturize $content
$char_codes = array( '&#8216;', '&#8217;', '&#8220;', '&#8221;', '&#8242;', '&#8243;' );
$replacements = array( "'", "'", '"', '"', "'", '"' );
$content = str_replace( $char_codes, $replacements, $content );
// decode html-entities
$content = html_entity_decode( $content );
@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 / 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 / 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 / themes_functions-php.part.php
Created Dec 31, 2012
themes_functions-php.part.php
View themes_functions-php.part.php
<?php
/**
* Remove forgetmenot-checkbox on login screen
* Uses the hook 'after_theme_setup' instead of 'plugins_loaded' because
* first the theme have to be setup for get_template_directory_uri()
*
* @uses add_action()
* @hook after_setup_theme
*/
@RalfAlbert
RalfAlbert / functions-php.part.php
Last active Dec 10, 2015
Removing the Forgetmenot-checkbox on the WordPress login screen.
View functions-php.part.php
<?php
/**
* Remove forgetmenot-checkbox on login screen
* Uses the hook 'after_theme_setup' instead of 'plugins_loaded' because
* first the theme have to be setup for get_template_directory_uri()
*
* @uses add_action()
* @hook after_setup_theme
*/
You can’t perform that action at this time.