Skip to content

Instantly share code, notes, and snippets.

@hakre
hakre / decode-input-stream-example.php
Last active August 29, 2015 14:04
Example: Decode an Input Stream with PHP filters
<?php
/**
* Example: Decode an Input Stream with PHP filters
*
* decode-input-stream-example.php
*
* @link https://gist.github.com/hakre/d34239bb237c50e728fd
* @link http://stackoverflow.com/q/25051578/367456
*/
@hakre
hakre / CurlDebug.php
Created November 2, 2014 16:14
curl debug drop-in class
<?php
/**
* Class CurlDebug
*
* drop-in class to add verbose information to curl requests and to display trouble-shooting information
*
* @author hakre <http://hakre.wordpress.com/>
* @link http://stackoverflow.com/a/14436877/367456
*/
class CurlDebug
@hakre
hakre / domblaze2.php
Created July 14, 2015 21:26
DOMBLAZE II XMLNS
<?php
/**
* DOMBLAZE II is just with XMLNS support
*
* @link http://stackoverflow.com/a/26327033/367456
*/
/* DOMBLAZE II XMLNS */ $doc->registerNodeClass("DOMElement", "DOMBLAZE");
class DOMBLAZE extends DOMElement
<?php
/**
* Example: SimpleXML tell apart a single element and a list of elements with a single element
*
* @link https://hakre.wordpress.com/2013/02/12/simplexml-type-cheatsheet/
* @libk http://stackoverflow.com/a/14829309/367456
*/
$buffer = <<<XML
<root>
<?php
/**
* Special Background Wordpress Plugin
*
* @-wp-header Plugin Name: Special Background
* @-wp-header Plugin URI: http://wordpress.stackexchange.com/questions/972/
* @-wp-header Description: Example to show how to add a special background using exiting background admin page in core.
* @-wp-header Version: 0.2
* @-wp-header Author: Mike Schinkel, hakre
* @-wp-header Author URI: http://mikeschinkel.com/custom-wordpress-plugins/
<?php
/**
* Register an Admin Page - Example
*
* NOTE: MU Plugin.
*
* @author hakre <http://hakre.wordpress.com/>
* @link http://wordpress.stackexchange.com/questions/1778/admin-config-screen-without-menu
*/
<?php
/**
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/
/**
@hakre
hakre / theme-napkin.php
Created February 8, 2011 15:32
Theme Napkin Wordpress Plugin - Safeguard unintended output generated by theme bootstrap code (functions.php).
<?php
/**
* Theme Napkin Wordpress Plugin
*
* Safeguard unintended output generated by theme bootstrap code (functions.php).
*
* Copyright 2011 by hakre <http::/hakre.wordpress.com>, some rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License