Skip to content

Instantly share code, notes, and snippets.

View ericnicolaas's full-sized avatar
🎯
Focusing

Eric Daams ericnicolaas

🎯
Focusing
View GitHub Profile
@ericnicolaas
ericnicolaas / Responsive threaded comments
Last active December 18, 2015 16:29
This is a tidy little setup for responsive threaded comments. The class names here reflect a standard Wordpress comment form, but you can tailor them to your needs. The use case for this is when your comments feature the commenter's avatar on the left, which is an explicit width (in this case, 70px). On larger windows, we want the threaded comme…
/*
The baseline. This will be applied to any browser that does not
support calc, and any browser that is smaller than 800px wide
*/
.comments-list,
.comment {
width: 100%;
}
.comments-section .children {
@ericnicolaas
ericnicolaas / gist:8b9d4a632f124c319b01
Last active August 29, 2015 14:03
Register an image control in the Wordpress Customizer
/**
* Create an image control in the Customizer with an ID of 'logo_url'.
*
* This is added to the 'title_tagline' section.
*/
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'logo_url',
array(
'settings' => 'logo_url',
'section' => 'title_tagline',
'label' => __( 'Logo', 'my_theme' )
@ericnicolaas
ericnicolaas / gist:349c4550c23e90be53b7
Created July 10, 2014 23:09
Option 1: Retina image control in the Wordpress Customizer
/**
* Retina image control.
*
* Essentially, you just create two separate image controls, one of which is for the regular version of the logo,
* the other for the retina version.
*
* This is a simple solution with a few downsides:
*
* 1. It can be confusing for users who may not understand what is required for a retina version.
* 2. There is nothing enforcing the 2x sizing of the retina version.
@ericnicolaas
ericnicolaas / gist:37f8bc4ce87913e0d056
Created July 10, 2014 23:22
Option 2: Retina image control in the Wordpress Customizer
/**
* Retina image control.
*
* This solution involves creating a new control, implemented as the
* Sofa_Customizer_Retina_Image_Control class.
*
* Using this control, we get a regular image control with a simple
* checkbox underneath asking the user whether the image is retina-ready.
* This means that the user can just upload a single image and tick a box
* if it is correctly sized for retina screens (i.e. it's twice the size
@ericnicolaas
ericnicolaas / class-sofa-customizer-retina-image-control.php
Last active August 29, 2015 14:04
Wordpress Customizer Retina Image Control: Sofa_Customizer_Retina_Image_Control class
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WP_Customize_Control' ) ) return;
if ( ! class_exists( 'Sofa_Customizer_Retina_Image_Control' ) ) :
/**
@ericnicolaas
ericnicolaas / average-apache-process
Last active August 29, 2015 14:04
Print average size of Apache process (Centos 6)
ps aux | grep httpd | grep -v pts | awk '{ tot += $6; procs += 1; print $2,$6,$11 } END { print "TOTAL: ",tot,"/",procs,"=",tot/procs }'
@ericnicolaas
ericnicolaas / watch-apache
Created July 17, 2014 10:11
Keep track of the number of Apache processes and memory usage.
watch -n 1 "echo -n 'Apache Processes: ' && ps -C httpd --no-headers | wc -l && free -m"
/**
* Based on a single key, retrieve the data for a particular image, including whether it is retina and its dimensions.
*
* @param string $key
* @return false if not set, or array if set
* @access private
* @since 1.0
*/
private function get_image_data($key) {
$data = array();
/*global module:false*/
/*global require:false*/
/*jshint -W097*/
"use strict";
module.exports = function(grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
@ericnicolaas
ericnicolaas / single-campaign.php
Last active August 31, 2016 00:08
Salient campaign page template
<?php
/**
* This file should be saved as single-campaign.php, preferably in your Salient child theme.
*/
get_header(); ?>
<?php nectar_page_header($post->ID); ?>
<div class="container-wrap">