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 / informer-disable-queue.php
Last active May 24, 2016 08:09
Disable mail queue of Informer (WP Plugin) to send all emails at once.
<?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 February 8, 2016 15:44
Approach on Monkey::action expects different values on consecutive calls
<?php
Brain\Monkey::actions()
->expectFired( 'do_something' )
->twice()
->withArgs(
[
'first',
'second'
]
);
@dnaber-de
dnaber-de / wp-media-playground.js
Created October 21, 2015 17:05
Play around with the wp.media API
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 August 29, 2015 14:24
Some example on a simple PHPUnit Mock. Meant as answer to this question: https://twitter.com/Rarst/status/618880034145718272
<?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 November 13, 2017 18:05
wp-config.php template
<?php
/**
* WordPress config file template
*
* @link http://wpengineer.com/2382/wordpress-constants-overview/
*/
/**
* MySQL credentials
*/
@dnaber-de
dnaber-de / attribute-entiy.php
Created September 29, 2014 08:42
Quick notes about some OOP structure
<?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 December 6, 2021 01:26
Dissolving a DOM Node and moving all child nodes one level up
<?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 August 20, 2014 09:36
How to copy a table in MySQL
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 September 5, 2024 01:48
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
dnaber-de / readme.md
Last active August 29, 2015 13:56
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>