Skip to content

Instantly share code, notes, and snippets.

View michaeldozark's full-sized avatar

Michael Dozark michaeldozark

View GitHub Profile
@michaeldozark
michaeldozark / wp-debug
Last active December 23, 2015 09:39
Better WordPress Debugging: Use WP_DEBUG flag, but only output errors to error log. Goes in wp-config.php. Thanks to ZippyKid for the idea.
define('WP_DEBUG', true); // false
if (WP_DEBUG) {
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);
}
@michaeldozark
michaeldozark / cPanel Mime Types
Created January 24, 2014 17:21
Mime types list for cPanel GZIP compression
text/html text/plain text/xml text/css text/javascript application/javascript application/xhtml+xml application/xml application/rss+xml application/atom_xml application/x-javascript application/x-httpd-php application/x-httpd-fastphp application/x-httpd-eruby image/svg+xml
AddType image/x-icon .ico
<IfModule mod_headers.c>
# YEAR
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf)$">
Header set Cache-Control "max-age=29030400"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|swf)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
@michaeldozark
michaeldozark / slimline-wp-list-pages.php
Last active August 29, 2015 13:56
Wrapper function for wp_list_pages() that accepts more than one ID in exclude_tree and adds an include_tree parameter
<?php
/**
* slimline_wp_list_pages function
*
* Builds include and exclude parameters from a tree before calling
* a standard wp_list_pages call. All parameters are the same as the
* wp_list_pages functions with one exception listed below.
*
* @param string $args[ 'include_tree' ] Define a comma-separated list of Parent IDs to be included
*/
@michaeldozark
michaeldozark / slimline-random-orderby.php
Last active August 29, 2015 13:57
Edit SQL ORDER BY statement to randomly order posts after other orders are accounted for.
<?php
/**
* slimline_random_orderby function
*
* Edit SQL ORDER BY statement to randomly order posts after other orders are accounted for.
*
* @param string $orderby The ORDER BY statement generated by get_posts()
* @return string $orderby ORDER BY statement with RAND() set as an additional clause
*/
@michaeldozark
michaeldozark / gforms-google-analytics.php
Last active August 29, 2015 14:01
Adds Google Analytics Tracking for Gravity Forms.
<?php
add_filter( "gform_submit_button", "slimline_gform_google_analytics", 10, 2 ); // add Google Analytics tracking to form submits
/**
* slimline_gform_google_analytics function
*
* Adds Google Analytics Tracking for Gravity Forms.
*
* @global object $wp The WordPress global object. Used for capturing the current request URI {@see http://kovshenin.com/2012/current-url-in-wordpress/}
@michaeldozark
michaeldozark / get-terms-custom-order.php
Last active August 29, 2015 14:03
Filters get terms in the order the term_ids are listed in the `include` parameter of get_terms.
<?php
add_filter( 'get_terms_args', 'slimline_get_terms_args', 0 ); // allow extra filtering of terms arguments
/**
* slimline_get_terms_args filter
*
* Adds additional filtering to get_terms as needed.
*
* @param array $args An array of arguments passed from the get_terms() function
@michaeldozark
michaeldozark / login.php
Last active July 29, 2016 19:37
Style the login screen. Make sure to read my comment below as well.
<?php
/**
* Login Functions
*
* Functions and filters that run only on the WordPress login screen.
*
* @package Slimline
* @subpackage Login
*/
@michaeldozark
michaeldozark / get_terms_orderby_name_as_number
Created September 12, 2014 19:35
Order terms by name cast as a number. Originally used for retrieving WooCommerce attributes. To use, set the 'orderby' argument in your `get_terms` call to 'name_as_number'.
add_filter( 'get_terms_orderby', 'slimline_get_terms_orderby_name_as_number', 10, 2 );
/**
* slimline_get_terms_orderby_name_as_number function
*
* @param string $orderby The orderby string created from the initial arguments passed through `get_terms`
* @param array $args `get_terms` arguments
* @return string $orderby Name cast as a number if `orderby` is 'name_as_number', otherwise unchanged
*/
function slimline_get_terms_orderby_name_as_number( $orderby, $args ) {
@michaeldozark
michaeldozark / slimline_wp_vars
Last active August 29, 2015 14:15
Javascript conversion of WordPress vars.php needed for when I am using page caching, but still need browser-based body classes, etc.
/**
* Slimline WordPress Globals
*
* Javascript conversion of WordPress vars.php needed for when I am using page caching, but still need browser-based body classes, etc.
*
* @link https://gist.github.com/michaeldozark/17412e3eeda6b391ae8c
* @version 0.1.0
*/
/**