Skip to content

Instantly share code, notes, and snippets.

View dnaber-de's full-sized avatar
🏠
Working from home

David Naber dnaber-de

🏠
Working from home
View GitHub Profile
@dnaber-de
dnaber-de / bookmarklet.js
Last active November 9, 2016 13:52
A bookmarklet which brings you directly from a wordpress.org plugin page to the svn repository on plugins.svn.wordpress.org.
(function(){var b=document.location.href,a=document.createElement('a'),path=[],protocol='http';a.href=b;path=a.pathname.split('/');if('https:'==a.protocol){protocol='https'}if('wordpress.org'!=a.hostname||'undefined'==typeof path[1]||''==path[1]||'plugins'!=path[1]||'undefined'==typeof path[2]||''==path[2]){alert('It seems you are not facing a wordpress plugin page. The URL must match: worpress.org/plugins/{PLUGIN_NAME}');return}document.location.href=protocol+'://plugins.svn.wordpress.org/'+path[2]+'/trunk/'})();
@dnaber-de
dnaber-de / not-static-but-static.php
Created November 25, 2013 13:03
Shows the difference between static and dynamic class properties.
<?php
namespace Static_Or_Dynamic;
/**
* a simple property list
*
*/
class Settings_List {
@dnaber-de
dnaber-de / Class_Reflector.php
Created October 1, 2013 10:04
Example of a class reflection to make the availability of this class optional.
<?php
/**
* base reflector class to reflect plugins APIs without using
* plugin classes directly
*
*/
namespace Project\Theme\Reflector;
abstract class Class_Reflector {
@dnaber-de
dnaber-de / controller.php
Created August 23, 2013 08:55
Settings-API-Helper example
<?php
namespace Example\Theme;
class Theme_Options {
/**
* the option key
*
* @const string
@dnaber-de
dnaber-de / dna-ip-to-admin-bar.php
Last active July 13, 2017 21:28
WordPress Plugin to show the Server Address (IP) in Admin-Bar
<?php
/**
* Plugin Name: dna IP to Admin Bar
* Plugin URI: https://gist.github.com/dnaber-de/5219882
* Description: Shows the current Server IP in the Admin Bar. (Requires PHP 5.3)
* Author: David Naber
* Author URI: http://dnaber.de/
* Version: 2013.03.22
* License: MIT
@dnaber-de
dnaber-de / category.php
Last active December 12, 2015 06:49
A simple Wordpress Theme for Documentation.
<?php
get_header(); ?>
<h1>Plugin: <?php single_cat_title(); ?></h1>
<h2>Verwendet in</h2>
<ul>
<?php
while ( have_posts() ) {
the_post();
?>
@dnaber-de
dnaber-de / dna-tpl-to-admin-bar.php
Last active April 13, 2018 15:05
WordPress plugin to show the current used template file name in the admin bar.
<?php
/**
* Plugin Name: dna Template Name to Admin Bar
* Plugin URI: https://gist.github.com/4690246
* Description: Shows the current used theme template file in the admin bar. (Requires PHP 5.3)
* Author: David Naber
* Author URI: http://dnaber.de/
* Version: 2013.11.09
* License: MIT
@dnaber-de
dnaber-de / dna-save-attachment.php
Created December 5, 2012 11:57
Worpress Plugin: Calls the action 'save_post' for Attachment Post Types. Requires PHP 5.3
<?php
/**
* Plugin Name: dna Save Attachment
* Plugin URI: https://gist.github.com/4214994
* Author: David Naber
* Author URI: http://dnaber.de/
* Version: 2014.08.24
* Description: Calls the action 'save_post' for Attachment Post Types vor WordPress versions prior 4.0. Requires PHP 5.3. The plugin will have no effect in WordPress 4.0 or higher. (Getting obsolete when <a href="http://core.trac.wordpress.org/ticket/21963">#21963</a> is fixed.)
*/
namespace DNA\SaveAttachment;
@dnaber-de
dnaber-de / dna-framebreaker.php
Created November 9, 2012 13:25
Wordpress Plugin to add a framebreaker javascript to the header.
<?php
/**
* Plugin Name: dna Framebreaker
* Plugin URI: https://gist.github.com/4045656
* Description: Add a framebreaker javascript to the header. (Requires PHP 5.3)
* Version: 0.1
* Author: David Naber
* Author URI: http://dnaber.de
* License: MIT
* License URI: http://opensource.org/licenses/MIT
@dnaber-de
dnaber-de / class-Not_So_Simple_XML.php
Created August 28, 2012 17:30
This Class extends SimpleXMLElement to write CDATA-Nodes and print a formated xml-string
<?php
/**
* This Class extends SimpleXMLElement to write CDATA-Nodes and print a formated xml-string
*
* to add cdata do it like this:
* ($node is an instance of Not_So_Simple_XML)
* $node->title = NULL;
* $node->title->addCData( );
*
* @author David Naber <kontakt@dnaber.de>