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 / 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(){
@RalfAlbert
RalfAlbert / file_upload.php
Last active May 18, 2018
WordPress: Simple class to handle file uploads to the wp-content directory and creating an attachment post
View file_upload.php
<?php
class File_Upload
{
/**
* Index key from upload form
* @var string
*/
public $index_key = '';
/**
@RalfAlbert
RalfAlbert / autoimporter.php
Created Apr 27, 2013
WordPress: Class to allow automatically import posts/pages
View autoimporter.php
<?php
/** Display verbose errors */
define( 'IMPORT_DEBUG', false );
// Load Importer API
require_once ABSPATH . 'wp-admin/includes/import.php';
if ( ! class_exists( 'WP_Importer' ) ) {
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
if ( file_exists( $class_wp_importer ) )
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' ) );
View onetime_nonce.php
<?php
function create_onetime_nonce( $action = -1 ) {
$time = time();
$nonce = wp_create_nonce( $time . $action );
set_transient( '_nonce_' . $time, 1, 60*60 ); // adjust the lifetime of the transient
return $nonce . '-' . $time;
}
function verify_onetime_nonce( $_nonce, $action = -1 ) {
@list( $nonce, $time ) = explode( '-', $_nonce );
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>
@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
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>
View 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 Dec 1, 2013
Custom events with jQuery
View gist:7732687
<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(
You can’t perform that action at this time.