Skip to content

Instantly share code, notes, and snippets.

View JakePT's full-sized avatar

Jacob Peattie JakePT

  • Sydney, Australia
View GitHub Profile
@JakePT
JakePT / functions.php
Last active May 30, 2019 17:59
Filter to stop WordPress replacing spaces with dashes in filenames.
<?php
/**
* A copy of WordPress' sanitize_file_name function that doesn't replace
* spaces with dashes. Use on the sanitize_file_name filter to stop WordPress
* replacing filenames with dashes.
*
* ...Or don't. It's probably a bad idea.
*
* @param string $sanitized_filename The previously sanitized filename.
* @param string $filename The original unsanitized filename.
@JakePT
JakePT / get-top-terms-sample-usage.php
Last active June 30, 2017 19:44
WordPress function for getting the most used terms in a given period
<?php
// List of links for up to 10 of the most used categories in the last month.
$top_terms = prefix_get_top_terms( 'category' );
echo '<ul>';
foreach ( $top_terms as $top_term ) {
echo '<li><a href="' . get_term_link( $top_term ) . '">' . $top_term->name . '</a>';
}
echo '</ul>';
// List of links for up to 5 of the most used tags in the last 15 days.