Skip to content

Instantly share code, notes, and snippets.

@JPry
JPry / fix_site_name.php
Last active August 29, 2015 13:56
See https://core.trac.wordpress.org/ticket/27199. Once you use this plugin to create the Network Title, it is not necessary to keep it activated, and I recommend deactivating and removing it.
<?php
/**
* Plugin Name: Fix missing site_name setting
* Plugin URI: https://gist.github.com/JCPry/9213808
* Description: When site_name is missing from the database, there is a bug in WordPress that prevents the site_name field from being properly added. This plugin allows it to be properly added.
* Version: 1.0
* Author: Jeremy Pry
* Author URI: http://jeremypry.com/
* License: GPL2
*/
<?php
/**
* WordPress Multisite upgrade script
*
* IMPORTANT: While a simple safeguard has been added to the script,
* you'll want to add another layer that prevents this script from
* being called via the browser.
*
* Usage:
* 1) Place in the root of your install (or another place, but modify the wp-load.php path to match)
<?php
/**
* Plugin Name: Prevent Publicity
* Plugin URI: https://gist.github.com/JCPry/9377431
* Description: Ensure that the "Discourage Search Engines from indexing this site" option is always checked
* Version: 1.0
* Author: Jeremy Pry
* Author URI: http://jeremypry.com/
* License: GPL2
*/
<?php
/**
* Plugin Name: Close Comments and Pings
* Plugin URI: https://gist.github.com/JCPry/9377806
* Description: Nothing fancy, no bells or whistles, just close comments and pings (trackbacks) everywhere. Period.
* Version: 1.0
* Author: Jeremy Pry
* Author URI: http://jeremypry.com/
* License: GPL2
*/
<?php
/**
* Plugin Name: Redirect Registration
* Plugin URI: https://gist.github.com/JCPry/9468377
* Description: When registration is disabled, WordPress will simply display a message on the wp-login.php page when someone attempts to register. This plugin redirects that registration request to the home page instead.
* Version: 1.0
* Author: Jeremy Pry
* Author URI: http://jeremypry.com/
* License: GPL2
*/
<?php
// full path to customer log file
$log_file = __DIR__.'/../__admin_ajax.log';
// if it's not a POST request, just move along
if($_SERVER['REQUEST_METHOD'] != "POST") {
return(0);
}
// if you only want specific files like admin-ajax or xmlrpc, uncomment the next line

How to Version a Stylesheet in WordPress

wp_enqueue_style() is your friend

In your theme, you should be using the wp_enqueue_style() function instead of calling your stylesheet directly in your header.php file. Use something like this in your theme's functions.php file:

<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_stylesheet' );
@JPry
JPry / hhvm.md
Last active August 29, 2015 14:01 — forked from octalmage/gist:11366947
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install python-software-properties curl
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/5.5/ubuntu precise main'
sudo apt-get update
sudo echo -e "Package: *\nPin: origin ftp.osuosl.org\nPin-Priority: 1000" | tee /etc/apt/preferences.d/mariadb
sudo apt-get install mariadb-server
mysql -uroot -p 
@JPry
JPry / session1.md
Last active August 29, 2015 14:23
WordCamp Philly 2015

Taking WordPress Outside of WordPress

Zoe Rooney | Slides: http://bit.ly/take-wp-out

Plugins

Pros Cons
quick & easy potential for conflicts
someone else maintains them no one updates or maintains them
<?php
$some_var = 'something';
$func = function() use ( $some_var ) {
echo $some_var; // echos "something"
};
$func();