Skip to content

Instantly share code, notes, and snippets.

@salcode
salcode / remove-header-right-widget-area.php
Created August 26, 2015 19:55
Genesis remove Header Right Widget Area (a.k.a. sidebar)
<?php
unregister_sidebar( 'header-right' );
remove_action( 'genesis_header', 'genesis_do_header' );
@salcode
salcode / wp-overlay-dev.php
Last active June 27, 2016 18:05
WordPress code to overlay an image on the webpage I'm working on. This should only be used on a development site. This can be used as an mu-plugin
<?php
/*
* Plugin Name: Overlay Dev
* Description: Overlay an image on the website to assist with development. Please add overlay-dev.png to the same directory as this file. This works as an mu-plugin.
* Version: 1.0.0
* Author: Sal Ferrarello
* Author URI: http://salferrarello.com/
*
* This file can be copied from the gist with
* curl -O https://gist.githubusercontent.com/salcode/f286c301663edad4e4a3/raw/wp-overlay-dev.php
@salcode
salcode / bsg-customizer-navbar-logo.php
Created August 6, 2015 20:46
Bootstrap Genesis - add the logo in the nav to the customizer. This file can be dropped into the wp-content/mu-plugins/ directory (note: you may need to create the mu-plugins folder within wp-content if it does not already exist)
<?php
// add customizer controls
add_action( 'customize_register', 'bsg_navbar_brand_logo_customize_register' );
function bsg_navbar_brand_logo_customize_register( $wp_customize ) {
$wp_customize->add_setting( 'brand_logo',
array(
'default' => '',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
@salcode
salcode / original-filename
Created July 21, 2015 14:17
Redirect with the meta Refresh tag. This file was useful to me when redirecting an Amazon S3 file where the bucket was not setup to act as a website.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Refresh" content="0; URL=http://www.example.com/target/">
<title>Redirect</title>
</head>
<body>
<a href="http://www.example.com/target/">http://www.example.com/target/</a>
@salcode
salcode / genesis-last-updated-post-info.php
Created July 4, 2015 16:18
Update Genesis Post Info with Last Updated date in place of Publish Date. This code can be added to the end of functions.php or you can create this file genesis-last-updated-post-info.php in wp-content/mu-plugins/
// filter post_info to use 'Last updated' date
add_filter( 'genesis_post_info', 'fe_genesis_post_info_add_last_mod' );
/**
* Change Genesis Post Info date to last modified date
*
* @since 0.1.0
*
* @param string $post_info, string (with shortcodes) for post info
* @return string Genesis default post info with modified instead of publish date
@salcode
salcode / deltadb.php
Last active August 29, 2015 14:23
#wcphilly contributors #unittests
<?php
/**
* Test dbDelta()
*
* @group upgrade
* @group dbdelta
*/
class Tests_dbDelta extends WP_UnitTestCase {
@salcode
salcode / install-composer.sh
Created June 11, 2015 13:28
composer command line install
curl -sS https://getcomposer.org/installer | php;\
mkdir -p /usr/local/bin;\
mv composer.phar /usr/local/bin/composer
@salcode
salcode / fe-disable-comments-until-4.2.1.php
Last active August 29, 2015 14:20
Disable comments on WordPress website until the WordPress version is greater than 4.2.
<?php
global $wp_version;
if ( version_compare( $wp_version, '4.2', '<=' ) ) {
add_filter( 'comments_open', '__return_false' );
}
@salcode
salcode / composer.json
Created April 23, 2015 02:07
Attempting to use branch name in place of version. Error: "Your requirements could not be resolved to an installable set of packages. Problem 1 - The requested package webdevstudios/hash-link-scroll-offset could not be found in any version, there may be a typo in the package name. Potential causes: - A typo in the package name - The package is n…
{
"repositories":[
{
"type":"composer",
"url":"http://wpackagist.org"
},
{
"type": "package",
"package": {
"name": "WebDevStudios/Hash-Link-Scroll-Offset",
@salcode
salcode / composer.json
Created April 22, 2015 19:42
Throws the error [Composer\Repository\InvalidRepositoryException] No valid composer.json was found in any branch or tag of https://github.com/WebDevStudios/Hash-Link-Scroll-Offset, could not load a package from it.
{
"repositories":[
{
"type":"composer",
"url":"http://wpackagist.org"
},
{
"type": "vcs",
"url": "https://github.com/WebDevStudios/Hash-Link-Scroll-Offset"
}