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, |
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 | |
// Redirects https://mywebsite.com/profile to current user's author URL | |
add_action('wp', 'profile_redirect'); | |
function profile_redirect() { | |
global $wp; | |
$page = trim(strtolower((string) $wp->request), '/'); | |
if ($page === 'profile') { | |
wp_safe_redirect(get_author_posts_url(get_current_user_id())); | |
} | |
} |
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 subpages to have their own unique templates (ie. /my-page/edit/ uses page-my-page-edit.php) | |
add_filter('template_include', 'get_subpage_template'); | |
function get_subpage_template($template, $page_id = null) { | |
if ($page_id === null) { | |
global $wp_query; | |
$page = $wp_query->queried_object; | |
} else { | |
$page = get_post($page_id); | |
} |
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 | |
// Clears all transients, can be ran via the function, via AJAX or by manually running: | |
// curl -d "action=hm_clear_transients" https://website.com/wordpress/wp-admin/admin-ajax.php | |
add_action('wp_ajax_hm_clear_transients', 'hm_clear_transients'); | |
add_action('wp_ajax_nopriv_hm_clear_transients', 'hm_clear_transients'); | |
function hm_clear_transients() { | |
global $wpdb; | |
$rows = $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '%_transient_%'"); | |
if (wp_doing_ajax()) wp_send_json_success($rows); | |
return $rows; |