Skip to content

Instantly share code, notes, and snippets.

View mikevanwinkle's full-sized avatar

Michael Van Winkle mikevanwinkle

View GitHub Profile
@mikevanwinkle
mikevanwinkle / gist:4162741
Created November 28, 2012 17:33
redirect canonical
// tack on any additional query vars
$redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
if ( $redirect_url && !empty($redirect['query']) ) {
parse_str( $redirect['query'], $_parsed_query );
$redirect = @parse_url($redirect_url);
if ( ! empty( $_parsed_query['name'] ) && ! empty( $redirect['query'] ) ) {
parse_str( $redirect['query'], $_parsed_redirect_query );
<?php
/**
Plugin Name: WPE Debug Queries
Description: WPE Plugin for debuging query issues.
**/
if( isset( $_REQUEST['wpe_check_queries'] ) )
{
define("SAVEQUERIES",true);
add_action('wpe_filtered_output','wpe_shutdown_db');
<?php
/**
* disables a fast 404 optimization
**/
function wpewa20140105() {
header('wpengine-workaround-20140105: present');
$unhook = array(WpeCommon::instance(), 'is_404');
remove_action('template_redirect', $unhook, 100);
remove_action('bp_init', $unhook, 100);
<?php
// line 410 of modules/update/update.module
// See if the .info file is newer than the last time we checked for data,
// and if so, mark this project's data as needing to be re-fetched. Any
// time an admin upgrades their local installation, the .info file will
// be changed, so this is the only way we can be sure we're not showing
// bogus information right after they upgrade.
if ($project['info']['_info_file_ctime'] > $available[$key]['last_fetch']) {
$available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
@mikevanwinkle
mikevanwinkle / gist:c99093e3f861c9bbad64
Created November 11, 2014 22:20
Nginx redirect example
location ~ /oldlink/(.*) {
rewrite ^/oldlink/(.*)$ /newlink/$1 permanent;
}
add_action( 'wp_ajax_nopriv_ajax_pagination', 'my_ajax_pagination' );
add_action( 'wp_ajax_ajax_pagination', 'my_ajax_pagination' );
function my_ajax_pagination() {
echo get_bloginfo( 'title' );
die();
}
@mikevanwinkle
mikevanwinkle / gist:501134ce8ce83a230317
Created March 2, 2015 18:14
Insert posts on install
add_action('wp_install', function() {
global $wpdb;
$query = $wpdb->prepare("INSERT INTO %sposts", array( $wpdb->prefix ));
$wpdb->query($query);
});

Keybase proof

I hereby claim:

  • I am mikevanwinkle on github.
  • I am mikevanwinkle (https://keybase.io/mikevanwinkle) on keybase.
  • I have a public key ASAM2mkVcR4OEvlwccWaoykSeQxkgmqba0kL_W3FqptzJwo

To claim this, I am signing this object: