Skip to content

Instantly share code, notes, and snippets.

@stevegrunwell
stevegrunwell / gist:11c3e9d370127fa97898
Last active May 13, 2021 22:44
Bulk-upgrade WordPress plugins using WP-CLI, committing each upgrade to Git as we go
#! /bin/bash
# Find available updates for WordPress plugins via WP-CLI, then upgrade theme one at a time.
# After each upgrade, commit the changed files to Git.
#
# Requires that WP-CLI be installed and in your path: http://wp-cli.org/
#
# Currently, it will only work when run from the root of the WordPress installation, and has
# a hard-coded path for wp-content/plugins.
#
@norcross
norcross / yoast-ga-menu-move.php
Last active August 29, 2015 14:06
move Yoast Google Analytics top-level nav to a sub menu
/**
* move the main settings page for Yoast Google Analytics
* from it's own parent menu into a submenu page in either
* the Yoast SEO menu or in the general settings
*
* @return null
*/
function rkv_yoast_ga_menu() {
// check for the Yoast GA class in the event the plugin
@GaryJones
GaryJones / gist:cfe0f917f144da8c908e
Last active August 29, 2015 14:06
Gamajo Accessible Menu plugin
/**
* Gamajo Accessible Menu.
*
* Improves menu accessibility in two ways:
* * Adds a delay to submenus disappearing when moving the mouse away.
* * Makes submenus appear when tabbing through menu items with the keyboard.
*
* Kudos to Rian Rietveld for the code on which this plugin is based.
*
* After enqueueing this file (or concatenating it with your theme JS file),
@chuckreynolds
chuckreynolds / wordpress-terms-checkboxes-keep-nested.php
Created August 19, 2014 01:42
Remove the default WordPress behavior of displaying checked categories all at the top. This will keep the nested structure even when checked.
add_filter( 'wp_terms_checklist_args', 'ryno_wp_terms_checklist_args', 1, 2 );
function ryno_wp_terms_checklist_args( $args, $post_id ) {
$args[ 'checked_ontop' ] = false;
return $args;
}
@jjeaton
jjeaton / wp-config.php
Last active November 5, 2020 13:27
WP_DEBUG in wp-config.php using debug.log
<?php
define( 'WP_DEBUG', true );
if ( WP_DEBUG ) {
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'SAVEQUERIES', true );
define( 'SCRIPT_DEBUG', true );
@ini_set( 'display_errors', 0 );
if ( function_exists( 'xdebug_disable' ) ) {
@hdragomir
hdragomir / sm-annotated.html
Last active March 5, 2024 08:57
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
<?php
/**
* Primary Nav using Dropdown Walker
*
* @param array $args
* @return array
*/
function be_primary_nav_dropdown( $args ) {
if( 'primary' !== $args['theme_location'] || !class_exists( 'Walker_Nav_Menu_Dropdown' ) )
if ( $query->is_home() && $query->is_main_query() ) {
$posts_per_page = 8;
$page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 0;
$query->set( 'offset', 5 + $posts_per_page * $page );
$query->set( 'posts_per_page', $posts_per_page );
}