Skip to content

Instantly share code, notes, and snippets.

Hugh Lashbrooke hlashbrooke

Block or report user

Report or block hlashbrooke

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hlashbrooke
hlashbrooke / wordpress.sql
Created Dec 13, 2018
Change site URLs in WordPress database - covers all areas where the URLs appear, except for seralised strings, like customiser and widget options. Those will need to be updated manually or by using WP-CLI.
View wordpress.sql
UPDATE wp_options SET option_value = replace(option_value, 'OLDURL', 'NEWURL') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'OLDURL','NEWURL');
UPDATE wp_posts SET post_content = replace(post_content, 'OLDURL', 'NEWURL');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'OLDURL','NEWURL');
@hlashbrooke
hlashbrooke / functions.php
Created Oct 12, 2018
Filtering items available in media library - taken from v1 of the WooCommerce Product Vendors extension.
View functions.php
/**
* Only show current vendor's media in the media library
* @param array $request Default request arguments
* @return array Modified request arguments
*/
add_filter( 'request', 'pv_restrict_media_library', 10, 1 );
function pv_restrict_media_library( $request = array() ) {
if( ! is_admin() ) {
return $request;
@hlashbrooke
hlashbrooke / functions.php
Last active Mar 8, 2019
Seriously Simple Speakers: Rename the 'Speakers' label to something else. In this example I have renamed the 'Speakers' to 'Guests' in both the plural and singular instances - you can make those labels anything you want by editing this code and adding it to your theme's functions.php file or a functionality plugin.
View functions.php
<?php
add_filter( 'ssp_speakers_plural_label', 'ssp_speakers_plural_label_custom' );
function ssp_speakers_plural_label_custom ( $label ) {
return 'Guests';
}
add_filter( 'ssp_speakers_single_label', 'ssp_speakers_single_label_custom' );
function ssp_speakers_single_label_custom ( $label ) {
return 'Guest';
}
@hlashbrooke
hlashbrooke / functions.php
Last active Mar 22, 2019
WordPress: Create a custom metabox that works in exactly the same way as the existing 'Featured Image' box on the post edit screen. In this case the image is called 'Listing Image' (with all the function and variable names correlating to that), but you can change the strings to whatever you need them to be.
View functions.php
<?php
add_action( 'add_meta_boxes', 'listing_image_add_metabox' );
function listing_image_add_metabox () {
add_meta_box( 'listingimagediv', __( 'Listing Image', 'text-domain' ), 'listing_image_metabox', 'post', 'side', 'low');
}
function listing_image_metabox ( $post ) {
global $content_width, $_wp_additional_image_sizes;
$image_id = get_post_meta( $post->ID, '_listing_image_id', true );
@hlashbrooke
hlashbrooke / seriously-simple-podcasting.conf
Created Nov 11, 2015
Seriously Simple Podcasting: Fix for Nginx servers where the podcast downloads and audio player are not working and/or returning a 404 error.
View seriously-simple-podcasting.conf
location ~* ^/podcast-download/ {
try_files $uri $uri/
fastcgi_index /index.php;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
location ~* ^/podcast-player/ {
try_files $uri $uri/
fastcgi_index /index.php;
@hlashbrooke
hlashbrooke / functions.php
Created Nov 7, 2015
Seriously Simple Podcasting: Hide the episode audio player
View functions.php
add_filter( 'ssp_show_audio_player', '__return_false' );
@hlashbrooke
hlashbrooke / functions.php
Created Nov 7, 2015
Seriously Simple Podcasting: Add episodes series to episode meta data
View functions.php
add_filter( 'ssp_episode_meta_details', 'ssp_series_title_in_meta', 10, 3 );
function ssp_series_title_in_meta ( $meta, $episode_id, $context ) {
$series_title = get_the_term_list( $episode_id, 'series', 'Series: ', ', ' );
$meta['series'] = $series_title;
return $meta;
}
@hlashbrooke
hlashbrooke / functions.php
Created Nov 7, 2015
Seriously Simple Podcasting: Remove 'Download file' link from episode meta data
View functions.php
add_filter( 'ssp_episode_meta_details', 'ssp_remove_download_link', 10, 3 );
function ssp_remove_download_link ( $meta, $episode_id, $context ) {
unset( $meta['link'] );
return $meta;
}
@hlashbrooke
hlashbrooke / functions.php
Created Oct 27, 2015
Seriously Simple Podcasting: Use raw audio file URL instead of custom rewrite
View functions.php
add_filter( 'ssp_episode_download_link', 'ssp_use_raw_audio_file_url', 10, 3 );
function ssp_use_raw_audio_file_url ( $url, $episode_id, $file ) {
return $file;
}
@hlashbrooke
hlashbrooke / .htaccess
Created Oct 8, 2015
Seriously Simple Podcasting: .htaccess line for FastCGI servers to enable password protection for feeds. This line to be added above the WordPress rules in the .htaccess file.
View .htaccess
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
You can’t perform that action at this time.