Skip to content

Instantly share code, notes, and snippets.

@boogah
boogah / WordPress_Unicode_Fix.sql
Last active October 14, 2016 08:11
Run this when you see weird crap in your posts/comments after moving your WordPress install.
update wp_posts set post_content = replace(post_content,'’','\'');
update wp_posts set post_title = replace(post_title,'’','\'');
update wp_comments set comment_content = replace(comment_content,'’','\'');
update wp_postmeta set meta_value = replace(meta_value,'’','\'');
update wp_posts set post_excerpt = replace(post_excerpt,'’','\'');
update wp_posts set post_content = replace(post_content,'…','...');
update wp_posts set post_title = replace(post_title,'…','...');
update wp_comments set comment_content = replace(comment_content,'…','...');
update wp_postmeta set meta_value = replace(meta_value,'…','...');
@luetkemj
luetkemj / wp-query-ref.php
Last active February 3, 2025 10:58
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
@JPry
JPry / remove-wpe-info.php
Last active January 19, 2022 20:52
Remove WP Engine info from WP Dashboard
<?php
// Remove all evidence of WP Engine from the Dashboard, unless the logged in user is "wpengine"
$user = wp_get_current_user();
if ( $user->user_login != 'wpengine' ) {
add_action( 'admin_init', 'jpry_remove_menu_pages' );
add_action( 'admin_bar_menu', 'jpry_remove_admin_bar_links', 999 );
}
/**
@JPry
JPry / gist:2399833
Last active October 3, 2015 05:27
If Statement sample
<?php
if ( $user->user_login == 'johnsmith' ) {
add_action( 'admin_init', 'jpry_remove_menu_pages' );
add_action( 'admin_bar_menu', 'jpry_remove_admin_bar_links', 999 );
}
?>
@JPry
JPry / stylesheetversion.php
Created June 25, 2012 20:52
Version your stylesheet when using Genesis theme
<?php
remove_action( 'genesis_meta', 'genesis_load_stylesheet' );
add_action( 'genesis_meta', 'jpry_load_stylesheet' );
function jpry_load_stylesheet() {
$theme_info = wp_get_theme();
wp_enqueue_style( 'jpry-style', get_stylesheet_uri(), array(), $theme_info->Version, 'screen' );
}
?>
@rodw
rodw / backup-github.sh
Last active January 12, 2025 07:11
A simple script to backup an organization's GitHub repositories, wikis and issues.
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
#-------------------------------------------------------------------------------
# NOTES:
#-------------------------------------------------------------------------------
# * Under the heading "CONFIG" below you'll find a number of configuration
# parameters that must be personalized for your GitHub account and org.
# Replace the `<CHANGE-ME>` strings with the value described in the comments
# (or overwrite those values at run-time by providing environment variables).

Whitelist IPs

Add whitelisted IPs to the Limit Login Attempts plugin.There are 3 different versions: One with a simple array list, the second uses a loop to build up an array instead of hand-coding every IP address in the list, and the third allows for a CIDR range. Adjust to your own needs.

Usage

Coming soon...

@JPry
JPry / redirect-files.php
Last active December 13, 2015 19:38
Convert CSV of HTML paths to PHP redirects
<?php
error_reporting( E_ALL );
ini_set( "auto_detect_line_endings", true );
//---------- SETUP OPTIONS FOR SCRIPT ---------------//
// Primary folder containing the redirects
$base_path = dirname( __FILE__ ) . '/_redirects';
// The file name to grab redirects from
@JPry
JPry / fix-limit-login-textdomain.php
Created February 25, 2013 18:05
For WordPress users who don't speak English as their primary language, fix the text domain for the Limit Login Attempts plugin so that it can be translated properly.
<?php
/**
* Plugin Name: Fix MU Text Domain
* Description: <strong>For use on WPEngine</strong> Since WP Engine includes the plugin "Limit Login Attempts" in the /wp-content/mu-plugins folder instead of the normal /wp-content/plugins folder, the text domain (for translation) is broken. This plugin fixes the text domain issue.
* Version: 1.0
* Author: Jeremy Pry <[email protected]>
* Author URI: http://jeremypry.com
* License GPL3
*/
@boogah
boogah / wp_mysql_optimizations.sql
Last active April 20, 2017 20:32
Common database optimizations for WordPress sites.
/* Delete revisions */
DELETE FROM wp_posts WHERE post_type = "revision";
/* Only use this if you no longer care about any of your current revisions! */
/* Delete trashed posts */
DELETE FROM wp_posts WHERE post_type = "trash";
/* Delete Jetpack Feedback Spam */
SELECT * FROM wp_posts WHERE wp_posts.post_type = "feedback" AND wp_posts.post_status= "spam";