Skip to content

Instantly share code, notes, and snippets.

David Naber dnaber-de

Block or report user

Report or block dnaber-de

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
@dnaber-de
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
<?php
/**
* Plugin Name: Informer – disable mail queue
* Description: Deactivates the queueing of mails in <em>Informer</em>
* Author: Inpsyde GmbH
* Author URI: http://inpsyde.com
* License: MIT
* Plugin URI: https://gist.github.com/dnaber-de/550520b5cdaf13987281bb159361b56f
*/
@dnaber-de
dnaber-de / test.php
Created Feb 8, 2016
Approach on Monkey::action expects different values on consecutive calls
View test.php
<?php
Brain\Monkey::actions()
->expectFired( 'do_something' )
->twice()
->withArgs(
[
'first',
'second'
]
);
@dnaber-de
dnaber-de / wp-media-playground.js
Created Oct 21, 2015
Play around with the wp.media API
View wp-media-playground.js
myGlobalFrame = null;
/**
* @param wp wp namespace
* @param Backbone
* @param $ jQuery
*/
;( function( wp, Backbone, $ ) {
'use strict';
var myLibrary = wp.media.controller.FeaturedImage.extend(
@dnaber-de
dnaber-de / ReleaseTest.php
Last active Aug 29, 2015
Some example on a simple PHPUnit Mock. Meant as answer to this question: https://twitter.com/Rarst/status/618880034145718272
View ReleaseTest.php
<?php
class ReleaseTest \PHPUnit_Framework_TestCase {
public function testConstructor() {
$splFileInfoMock = $this->getMockBuilder( 'SplFileInfo' )
->disableOriginalConstructor()
->getMock();
@dnaber-de
dnaber-de / wp-config-sample.php
Last active Nov 13, 2017
wp-config.php template
View wp-config-sample.php
<?php
/**
* WordPress config file template
*
* @link http://wpengineer.com/2382/wordpress-constants-overview/
*/
/**
* MySQL credentials
*/
@dnaber-de
dnaber-de / attribute-entiy.php
Created Sep 29, 2014
Quick notes about some OOP structure
View attribute-entiy.php
<?php
interface EntityAttributeInterface {
public function getName();
public function setValue( AttributeValueInterface $value );
public function setUnit( AttributeUnitInterface $unit );
@dnaber-de
dnaber-de / dom-dissolve-node.php
Last active Aug 29, 2015
Dissolving a DOM Node and moving all child nodes one level up
View dom-dissolve-node.php
<?php
$html = <<<HTML
<table>
<tr>
<td>Foo with some <span>makrup</span> inside</td>
<td>Bar also <div>with <em>some</em></div> markup</td>
</tr>
</table>
HTML;
@dnaber-de
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
dnaber-de / WP_Plugins_Unit_Tests.md
Last active Nov 9, 2016
Short description on how I prepared sucessfully a unit test for wordpress plugin.
View WP_Plugins_Unit_Tests.md

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
dnaber-de / readme.md
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.
View readme.md

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>
You can’t perform that action at this time.