Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / git-archive.sh
Created June 7, 2016 18:57
Archive git branches
#!/bin/sh -x
# Exit if any error is encountered:
set -o errexit
# git name-rev is fail
# Get the branch name and replace the string from an array of values for instance "feature/" with "archive/"
CURRENT=`git branch | grep '\*' | awk ' {print $2}'`
ARCHIVE=`git branch | grep '\*' | awk ' {print $2}' | sed 's,.*[a-z]/,,g' | sed 's,^,archive/,g'`
#Check if we are on master or develop since we don't want to tag those
if [ $CURRENT = 'master' ]
@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 / index.html
Created January 27, 2016 21:29
Google Plus Comments
<script src="https://apis.google.com/js/plusone.js"></script>
<script>
gapi.comments.render('comments', {
href: window.location,
width: '760',
first_party_property: 'BLOGGER',
view_type: 'FILTERED_POSTMOD'
});
</script>
<html>
@joshlevinson
joshlevinson / eight-day-week-filters.php
Created November 6, 2015 15:10
Sample Eight Day Week filters for the Observer
<?php
add_filter( 'Eight_Day_Week\Plugins\Article_Export\xml_outer_elements', function( $elements, $article ) {
$elements['subHeadline'] = get_post_meta( $article->ID, 'nyo_dek', true );
return $elements;
}, 10, 2 );
add_filter( 'Eight_Day_Week\Plugins\Article_Export\xml_outer_elements', function( $elements, $article ) {
if( function_exists( '\Eight_Day_Week\Plugins\Article_Byline\get_article_byline' ) ) {
$elements['byline'] = \Eight_Day_Week\Plugins\Article_Byline\get_article_byline( $article );
@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,
] );
@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;