Skip to content

Instantly share code, notes, and snippets.

@kurtpayne
kurtpayne / install.php
Created February 21, 2012 00:55
W3TC Autoconfigurator
<?php
// Activate W3 Total Cache
if ( file_exists( WP_PLUGIN_DIR . '/w3-total-cache/w3-total-cache.php' ) )
activate_plugin( WP_PLUGIN_DIR . '/w3-total-cache/w3-total-cache.php' , admin_url() );
// Load host specific W3TC config
if ( defined( 'W3TC_CONFIG_PATH' ) ) {
// Set the configuration path based on the platform's abilities
<?php
if ( !defined('P3_PATH') )
die( 'Forbidden ');
/**
* Performance Profile Reader
*
* @author GoDaddy.com
* @version 1.0
* @package P3_Profiler
@kurtpayne
kurtpayne / wp_remote_get.diff
Created March 10, 2012 03:17
Use wp_remote_get instead of curl
Index: github_gist_wordpress_plugin.php
===================================================================
--- github_gist_wordpress_plugin.php (revision 517091)
+++ github_gist_wordpress_plugin.php (working copy)
@@ -46,13 +46,12 @@
}
function get_content_from_url($url) {
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL,$url);
@kurtpayne
kurtpayne / memoization.php
Created March 20, 2012 19:04
PHP Memoization
<?php
function args_to_key($args) {
$tmp = array();
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($args));
foreach($it as $v) {
if (is_object($v)) {
$tmp[] = spl_object_hash($v);
} elseif (is_scalar($v)) {
$tmp[] = $v;
@kurtpayne
kurtpayne / make_clickable.patch
Created March 20, 2012 20:38
Patch make_clickable
Index: W:/wordpress-unit-tests/wordpress/wp-includes/formatting.php
===================================================================
--- W:/wordpress-unit-tests/wordpress/wp-includes/formatting.php (revision 20220)
+++ W:/wordpress-unit-tests/wordpress/wp-includes/formatting.php (working copy)
@@ -1484,7 +1484,7 @@
$ret = " $ret "; // Pad with whitespace to simplify the regexes
$url_clickable = '~
- ([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation
+ ([\\s(<>.,;:!?]) # 1: Leading whitespace, or punctuation
@kurtpayne
kurtpayne / my-plugin.php
Created March 21, 2012 18:56
Test dbDelta
<?php
/*
Plugin Name: My Plugin
Description: Test dbDelta
Version: 0.1
*/
// Upgrade when the admin loads
add_action( 'admin_init', 'myplugin_upgrade' );
@kurtpayne
kurtpayne / ZendFramework.spec
Created April 4, 2012 20:38
Zend Framework RPM spec
%define source0 ZendFramework-1.11.5.tar.gz
%define name ZendFramework
%define version 1.11.5
Name: ZendFramework
Summary: ZendFramework %{version} for PHP
Version: %{version}
Release: 1
Group: GoDaddy
License: BSD
@kurtpayne
kurtpayne / test_admin_ajax_dim_comments.php.patch
Created April 12, 2012 16:52
Ajax exception timestamp assertions
Index: wp-testcase/test-ajax-actions/test_admin_ajax_dim_comments.php
===================================================================
--- wp-testcase/test-ajax-actions/test_admin_ajax_dim_comments.php (revision 676)
+++ wp-testcase/test-ajax-actions/test_admin_ajax_dim_comments.php (working copy)
@@ -188,9 +188,14 @@
$_POST['_page'] = 1;
$_POST['_url'] = admin_url( 'edit-comments.php' );
- // Make the request
- $this->setExpectedException( 'WPAjaxDieException', (string) time() );
@kurtpayne
kurtpayne / private_var.php
Created May 1, 2012 18:04
Stupid PHP Tricks - Access a Private Var
<?php
class Foo {
private $_bar = '';
public function __construct( $bar ) {
$this->_bar = $bar;
}
public function getBaz( $foo ) {
return $foo->_bar;
}
@kurtpayne
kurtpayne / override_host_wpt.txt
Created May 11, 2012 23:37
Override the DNS and host header in WebPageTest
setDnsName www.example.com 1.2.3.4
overrideHost 1.2.3.4 www.example.com
setDnsName example.com 1.2.3.4
overrideHost 1.2.3.4 example.com
navigate http://www.example.com/