Skip to content

Instantly share code, notes, and snippets.

@JPry
JPry / add-editor-style.php
Last active August 29, 2015 14:27 — forked from jtsternberg/add-editor-style.php
add editor style (works for front-end editors as well)
<?php
add_filter( 'mce_css', 'jpry_add_editor_styles' );
/**
* Filter the TinyMCE styles.
*
* @param string $styles The comma-separated list of stylesheets to be loaded by TinyMCE.
*
* @return string The updated comma-separated list of stylesheets to be loaded by TinyMCE.
*/
@JPry
JPry / shortcode.php
Last active September 14, 2020 09:26
Template part shortcode example
<?php
/**
* Register a template_part shortcode handler.
*
* @param array $atts The array of attributes the user entered into the shortcode.
*/
function template_part_shortcode( $atts ) {
$defaults = array(
'main_part' => 'loop',
<?php
add_filter( 'pre_get_posts', 'sample_pre_get_posts' );
function sample_pre_get_posts( $query ) {
// Possibly check to make sure this is the query we want to modify
if ( $query->is_main_query() && ! $query->is_admin() ) {
$query->set( 'post_status', array(
'draft',
'publish',
'pending',
<?php
$some_var = 'something';
$func = function() use ( $some_var ) {
echo $some_var; // echos "something"
};
$func();
@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
@JPry
JPry / heartbeat_allowed.php
Last active April 13, 2023 16:48
Note that you must change "plugins.php" to match whatever page you want to allow.
<?php
/**
* Plugin Name: Allow Heartbeat on more pages
* Plugin URI: https://gist.github.com/JPry/b1f6c55a5d5337557f97
* Description: Allow the Heartbeat API on more pages in the Dashboard
* Version: 1.0
* Author: Jeremy Pry
* Author URI: http://jeremypry.com/
* License: GPL2
*/
@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 

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' );
<?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