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 / automatic_activate_plugin.php
Created Dec 4, 2011
automatic activate a plugin after install
View automatic_activate_plugin.php
add_filter( 'upgrader_post_install', 'autoactivate_plugin_after_install', 10, 3 );
function autoactivate_plugin_after_install( $value, $hook_extra, $result ){
$p_tmp = get_plugins('/' . $result['destination_name']);
$p_key = array_keys( $p_tmp );
$pre = ! empty( $result['destination_name'] ) ? $result['destination_name'] . '/' : '';
$plugin = $pre . $p_key[0];
$plugins = get_option('active_plugins');
@RalfAlbert
RalfAlbert / show_comment_numbers.php
Created Dec 5, 2011
WordPress - Show comment-numbers in a comment-thread
View show_comment_numbers.php
<?php
/**
* Plugin Name: Show Comment Number
* Plugin URI: http://neun12.de
* Text Domain:
* Domain Path:
* Description: Dieses Plugin zeigt die laufende Kommentar-Nummer in einem Kommentar-Thread an.
* Author: Ralf Albert
* Version: 0.1
* Author URI: http://neun12.de/
@RalfAlbert
RalfAlbert / do_not_nag_non-admins_on_updates.php
Created Dec 11, 2011
Removing update notifications for non-admins
View do_not_nag_non-admins_on_updates.php
/* put this function in your functions.php. You can use it very often */
function __return_null(){
return NULL;
}
/* stop informing non-admins */
global $current_user;
if( ! current_user_can( 'update_core' ) ){
# 2.8 to 3.0:
remove_action( 'wp_version_check', 'wp_version_check' );
View some_foobar_controller.php
<?php
function get_some_foo(){
return array( 'foo_one', 'foo_two', 'foo_three' );
}
function get_some_bar(){
return array( 'bar_one', 'bar_two', 'bar_three' );
}
function some_view( $the_array ){
@RalfAlbert
RalfAlbert / file1.php
Created Dec 18, 2011
Selector with classes
View file1.php
<?php
/* Plugin Name Some Code */
class PluginInit
{
/**
* mocking code
*/
CONST WP_VERSION = '3.3';
private function get_wp_version(){ return '3.3' ; }
private function get_wp_network() { return false; }
@RalfAlbert
RalfAlbert / selector.php
Created Dec 18, 2011
Selector with Namespaces
View selector.php
<?php
/* Plugin Name Some Code */
namespace PluginInit
{
/**
* mocking code
*/
CONST WP_VERSION = '3.3';
function get_wp_version(){ return '3.3' ; }
@RalfAlbert
RalfAlbert / example.php
Created Dec 23, 2011 — forked from eteubert/activate.php
WordPress: Find Users by Last Login Activity
View example.php
<?php
/*
Plugin Name: User Activity
Plugin URI:
Description: Provides means to query users by last login activity.
Version: 1.0
Author: Eric Teubert, Ralf Albert
Author URI: ericteubert@googlemail.com, neun12@googlemail.com
License: MIT
*/
@RalfAlbert
RalfAlbert / sortable_posts_column.php
Created Dec 26, 2011
WordPress - Make posts column sortable
View sortable_posts_column.php
<?php
/*
Plugin Name: Sortable post column
Description: Make posts column on users screen sortable
Version: 0.0.1
Author: Ralf Albert
Author URI: http://yoda.neun12.de
*/
// make posts-column sortable
@RalfAlbert
RalfAlbert / quicklogin.php
Created Dec 28, 2011
WordPress Quicklogin
View quicklogin.php
<?php
require( dirname(__FILE__) . '/wp-load.php' );
is_wp_error(
wp_signon(
array(
'user_login'=>'YourLoginName',
'user_password'=>'YoUrAw3s0M3P455W0rD'
)
)
) ? die('Mooo... :(') : wp_safe_redirect( admin_url() );
@RalfAlbert
RalfAlbert / file1.php
Created Jan 8, 2012
Simple DataContainer with overwrite protection
View file1.php
<?php
class DataContainer
{
private static $data = array();
public static function __set( $name, $value ){
if( ! isset( self::$data[$name] ) )
self::$data[$name] = $value;
else
return FALSE;
You can’t perform that action at this time.