This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get information about available image sizes | |
function get_image_sizes($size = null) { | |
$sizes = array(); | |
$size_data = wp_get_additional_image_sizes(); | |
$size_names = get_intermediate_image_sizes(); | |
$default_sizes = array_diff($size_names, array_keys($size_data)); | |
if ($size) $size_names = array($size); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin grid($cols: 4, $gap: 2rem, $item: '> *') { | |
&:after { | |
clear: left; | |
content: ''; | |
display: block; | |
} | |
#{$item} { | |
box-sizing: border-box; | |
float: left; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Gets user data in the form of an array with user meta attached that has empty results filtered, | |
// and optionally single results collapsed into a single value and/or only single values returned. | |
function get_account_info($user_id = null, $collapse = true, $single = false) { | |
if (!$user_id) $user_id = get_current_user_id(); | |
$user = get_userdata($user_id); | |
if (!$user) return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Stops any emails from sending and instead prints the email message out on the page | |
add_filter('wp_mail', 'preview_emails', 1, 99); | |
function preview_emails($args) { | |
echo $args['message']; | |
die(); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Takes an array with a term taxonomy as the item keys and term ids as their values and | |
// returns the same array but with the values set as term ids that have posts associated | |
// with the term combination. (PHP7 and above only) | |
function get_term_filter_options($taxonomies, $query_args = array()) { | |
array_walk($taxonomies, function(&$value, $taxonomy) use($taxonomies, $query_args) { | |
$posts = null; | |
$others = array_filter($taxonomies, function($value, $key) use($taxonomy) { | |
return $key !== $taxonomy && !empty($value); | |
}, ARRAY_FILTER_USE_BOTH); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$arr = array( | |
array( | |
'id' => 123, | |
'amount' => 39 | |
), | |
array( | |
'id' => 789, | |
'amount' => 27 | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Allows for a custom post detail page | |
add_action('init', 'hm_alternative_post_page'); | |
function alternative_post_page() { | |
add_rewrite_rule('story/([^/]+)/?$', 'index.php?page_id=13317&child_post_name=$matches[1]', 'top'); | |
} | |
// Setup our custom `child_post_slug` query var for custom post detail pages | |
add_filter('query_vars', 'alternative_post_page_var'); | |
function hm_alternative_post_page_var($vars) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Set HTTP Request Timeout | |
add_filter('http_request_args', 'my_http_request_args', 100, 1); | |
function my_http_request_args($r) { | |
$r['timeout'] = 30; | |
return $r; | |
} | |
// Set HTTP Request Timeout | |
add_filter('http_request_timeout', 'my_custom_http_request_timeout', 101); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this on a MySQL server and it will echo out a command for you to copy, paste, and run to kill all currently running MySQL processes | |
SELECT GROUP_CONCAT(CONCAT('KILL ',id,';') SEPARATOR ' ') 'Paste the following query to kill all processes' FROM information_schema.processlist WHERE user<>'system user'\G |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This makes it possible to use `/page/` URLs with non-archive pages such as single pages | |
add_action('init', 'add_pagination_to_pages'); | |
function add_pagination_to_pages() { | |
$pages = array( | |
'flex/assessments' => 220460, | |
'flex/collections' => 215682, | |
'flex/lesson-plans' => 215685, | |
'flex/my-standards' => 220768, | |
'flex/resources' => 220383, |