Skip to content

Instantly share code, notes, and snippets.

Working from home

David Naber dnaber-de

Working from home
View GitHub Profile
dnaber-de / informer-disable-queue.php
Last active May 24, 2016
Disable mail queue of Informer (WP Plugin) to send all emails at once.
View informer-disable-queue.php
* Plugin Name: Informer – disable mail queue
* Description: Deactivates the queueing of mails in <em>Informer</em>
* Author: Inpsyde GmbH
* Author URI:
* License: MIT
* Plugin URI:
dnaber-de / test.php
Created Feb 8, 2016
Approach on Monkey::action expects different values on consecutive calls
View test.php
->expectFired( 'do_something' )
dnaber-de / wp-media-playground.js
Created Oct 21, 2015
Play around with the API
View wp-media-playground.js
myGlobalFrame = null;
* @param wp wp namespace
* @param Backbone
* @param $ jQuery
;( function( wp, Backbone, $ ) {
'use strict';
var myLibrary =
dnaber-de / ReleaseTest.php
Last active Aug 29, 2015
Some example on a simple PHPUnit Mock. Meant as answer to this question:
View ReleaseTest.php
class ReleaseTest \PHPUnit_Framework_TestCase {
public function testConstructor() {
$splFileInfoMock = $this->getMockBuilder( 'SplFileInfo' )
dnaber-de / wp-config-sample.php
Last active Nov 13, 2017
wp-config.php template
View wp-config-sample.php
* WordPress config file template
* @link
* MySQL credentials
dnaber-de / attribute-entiy.php
Created Sep 29, 2014
Quick notes about some OOP structure
View attribute-entiy.php
interface EntityAttributeInterface {
public function getName();
public function setValue( AttributeValueInterface $value );
public function setUnit( AttributeUnitInterface $unit );
dnaber-de / dom-dissolve-node.php
Last active Dec 6, 2021
Dissolving a DOM Node and moving all child nodes one level up
View dom-dissolve-node.php
$html = <<<HTML
<td>Foo with some <span>makrup</span> inside</td>
<td>Bar also <div>with <em>some</em></div> markup</td>
dnaber-de / copy_table.sql
Created Aug 20, 2014
How to copy a table in MySQL
View copy_table.sql
CREATE TABLE IF NOT EXISTS dbname.new_tablename LIKE dbname.old_tablename;
ALTER TABLE dbname.new_tablename DISABLE KEYS;
TRUNCATE TABLE dbname.new_tablename;
INSERT INTO dbname.new_tablename SELECT * FROM dbname.old_tablename;
ALTER TABLE dbname.new_tablename ENABLE KEYS;
dnaber-de /
Last active Nov 9, 2016
Short description on how I prepared sucessfully a unit test for wordpress plugin.

Plugin UnitTest – How To

Assuming you have a separate WordPress installation for your project (eg. /var/www/my-project ) with your plugin you want to test in /var/www/my-project/wp-content/plugins/my-plugin. PHPUnit and SVN needs also to be installed on your system.

1. Get the WordPress test environment

Get the WordPress test environment as described here in step 1 and 2. You may want to use a separate directory for those stuff like ( ~/tmp/wordpress-test).

The repository looks like:

dnaber-de /
Last active Aug 29, 2015
Hotfix Plugin for WP Colored Coding to disable the early shortcode handling, which can lead into trouble with some other plugins.

WP Colored Coding – Disable early shortcode

Issue #8 of WP Colored Coding describes a interoperability problem with another plugin which parses the_content and didn't expect the occurrence of source code in the text.

This can be fixed by handling the WP-CC Shortcode after the_content which is the normal way.

But this drops the support for in-text codes using the enclosing shortcode:

[cc lang="html"]
<strong>This will not longer be possible</strong>