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 / hands-off-from-content.php
Created August 25, 2012 11:43
WP Plugin: Don't replace 'Wordpress' with 'WordPress'. Keep ' and " as they are.
<?php
/**
* Plugin Name: dna Hands off from content
* Description: Don't replace 'Wordpress' with 'WordPress'. Keep ' and " as they are.
* Plugin URI: https://gist.github.com/3464269
* Version: 2012.08.25
* Author: David Naber
* Author URI: http://dnaber.de/
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
@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 / 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 / result-page.html
Created July 10, 2012 09:37
Google custom search code
<div id="cse" style="width: 100%;">Loading</div>
<script src="http://www.google.de/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', {language : 'de'});
google.setOnLoadCallback(function() {
var customSearchOptions = {}; var customSearchControl = new google.search.CustomSearchControl(
'*****************', customSearchOptions);
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.draw('cse');
function parseParamsFromUrl() {
@dnaber-de
dnaber-de / editor_plugin.js
Created January 22, 2012 18:33
Wordpress TinyMCE Popup-Dialog. German Tutorial on http://dnaber.de/p1477
// js/editor_plugin.js
/**
* an example tinyMCE Plugin
*/
tinymce.create(
'tinymce.plugins.myPlugin',
{
/**
* @param tinymce.Editor editor
* @param string url
@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 / 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 / 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 / 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>
@dnaber-de
dnaber-de / WP_Plugins_Unit_Tests.md
Last active November 9, 2016 13:55
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: