Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Shortcode to go along with my Option Tree
* helper functions. See those here:
* https://gist.github.com/2627998
*
* <samp>[theme_option name="home_text"]</samp>
*
* @param array Array of attributes passed from the shortcode.
* @return string|null
@joshlevinson
joshlevinson / gist:d92b0a3d2c63ecd62d85
Created October 4, 2014 03:10
Roots Sidebar Display
<?php
/*
* Allows manual override on a per page/post basis
* for the display of the Roots Sidebar
*
* Allows for filtering the post types that show the metabox
*
*/
@joshlevinson
joshlevinson / httpd-vhosts.conf
Last active August 3, 2019 01:54
My xampp config
# xampp/apache/conf/extra/httpd-vhosts.conf
# You can replace the contents or append this
NameVirtualHost *:80
UseCanonicalName Off
#
# My {sites-directory} is C:\xampp\htdocs\domains\ (full path)
# In the domains dir, I create a new dir for a new site
@joshlevinson
joshlevinson / ra-export.php
Created October 7, 2014 04:45
Modified Advanced Export for WP & WPMU to Export by Tag
<?php
/*
Plugin Name: Advanced Export
Plugin URI: http://wpmututorials.com/plugins/advanced-export/
Description: Adds an Advanced Export to the Tools menu which allows selective exporting of pages, posts, specific categories and/or post statuses by date.
Version: 2.9
Author: Ron Rennick
Author URI: http://ronandandrea.com/
*/
/* jshint esnext: true */
import Ember from 'ember';
// When mixed into an Ember.Component class, actions can be explicitly or implicitly delegated to the parent.
// In general this makes the most sense for an app-level component, where actions are not mututated as they bubble
// up to higher levels.
export default Ember.Mixin.create({
// When true, all actions will be implicitly passed on to the parent
@joshlevinson
joshlevinson / .bash_profile
Last active April 21, 2023 12:04
WP CLI + Xdebug
# Add this to /config/bash_profile
function wpd {
export XDEBUG_CONFIG="idekey=VVVDEBUG remote_connect_back=1"
wp "$@"
unset XDEBUG_CONFIG
};
# Run these commands:
# vagrant ssh
# sudo cp /srv/config/bash_profile /home/vagrant/.bash_profile
# source ~/.bash_profile
@joshlevinson
joshlevinson / fixed-block.js
Created September 2, 2015 20:35
Sticky js script found on http://www.9news.com.au/
(function () {
define('redesign/ninemsn/portal/news/stickyElementController',['jquery', 'redesign/ninemsn/portal/news/helper'], function ($, helper) {
var bufferY = 56; // Offset for fixed positioning
var windowTop,
startY,
blockY,
stopY,
offset;
@joshlevinson
joshlevinson / To create a new site
Last active April 14, 2016 17:00
Creating a VVV site with no down time
vagrant ssh
cd /srv/www/
mkdir site-name && cd site-name && mkdir htdocs && cd htdocs
wp core download
wp core config --dbname=site-name --dbuser=root --dbpass=root
# Before you install the site, you'll need to create the DB. I just pull up phpMyAdmin and create it there.
wp core install --url=site-name.dev --title=Site --admin_user=admin --admin_pass=password --admin_email=admin@example.dev
# Create the files "vvv-hosts" and "vvv-nginx.conf"
@joshlevinson
joshlevinson / WP CLI commands.sh
Last active December 30, 2016 13:54
Create new VVV sites with WP CLI + wildcard hosts
vagrant ssh
cd /srv/www/
mkdir site-name && cd site-name && mkdir htdocs && cd htdocs
wp core download
wp core config --dbname=site-name --dbuser=root --dbpass=root
wp db create
wp core install --url=site-name.dev --title=Site --admin_user=admin --admin_pass=password --admin_email=admin@example.dev
@joshlevinson
joshlevinson / query.php
Created November 3, 2015 15:33
Better -1 posts_per_page for WP Query
<?php
$posts_per_page = 100;
$page = 1;
do {
$posts = get_posts( [
'posts_per_page' => $posts_per_page,
'paged' => $page,
] );