Skip to content

Instantly share code, notes, and snippets.

/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
// Enable WP_DEBUG mode
define('WP_DEBUG', true);
@troutacular
troutacular / attributes
Created July 12, 2015 19:26
CSS Attribute Selectors
/* From Chis Coyier: https://css-tricks.com/attribute-selectors/ */
/*
Attribute exactly equals certain value
<h1 rel="external">Attribute Equals</h1>
*/
h1[rel="external"] { color: red; }
/*
Attribute contains certain value somewhere
@troutacular
troutacular / gist:048767800182a6caf0bb
Created July 12, 2015 19:13
PNG with SVG Alpha Transparency
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@troutacular
troutacular / gist:536c2633a3bf4bb55009
Created July 12, 2015 18:47
WordPress Archives by Year/Month
<?php
global $wpdb;
$limit = 0;
$year_prev = null;
$months = $wpdb->get_results("SELECT DISTINCT MONTH( post_date ) AS month , YEAR( post_date ) AS year, COUNT( id ) as post_count FROM $wpdb->posts WHERE post_status = 'publish' and post_date <= now( ) and post_type = 'post' GROUP BY month , year ORDER BY post_date DESC");
foreach($months as $month) :
$year_current = $month->year;
if ($year_current != $year_prev){
if ($year_prev != null){?>
@troutacular
troutacular / is_localhost
Created May 30, 2015 00:02
PHP - Check if localhost
// Check if we are in a local environment
function is_localhost() {
// set the array for testing the local environment
$whitelist = array( '127.0.0.1', '::1' );
// check if the server is in the array
if ( in_array( $_SERVER['REMOTE_ADDR'], $whitelist ) ) {