Skip to content

Instantly share code, notes, and snippets.

View hlashbrooke's full-sized avatar
🎲

Hugh Lashbrooke hlashbrooke

🎲
View GitHub Profile
@hlashbrooke
hlashbrooke / style.css
Last active September 5, 2023 01:35
CSS for a responsive 2-column layout in the TTRPG Roll Tables WordPress plugin: https://hlashbrooke.itch.io/ttrpg-roll-tables-wordpress-plugin
#rolltable-data-tables, .rolltable_tables {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
gap: 0.5em;
}
.rolltable_data_block {
flex: 0 0 45%;
min-width: 450px;
@hlashbrooke
hlashbrooke / functions.php
Last active October 27, 2019 16:14
Modify the URL used by Bible Readings for Seriously Simple Podcasting
<?php
add_filter( 'ssp_bible_readings_url', 'my_bible_reading_url', 10, 4 );
function my_bible_reading_url ( $url, $episode_id, $bible_reading, $version ) {
// Include logic here to modify the URL
return $url;
}
@hlashbrooke
hlashbrooke / functions.php
Last active March 28, 2020 03:56
Modify Bible version used by Bible Readings for Seriously Simple Podcasting
<?php
add_filter( 'ssp_bible_readings_version', 'my_bible_version', 10, 2 );
function my_bible_version ( $version, $episode_id ) {
$version = 'NKJV'; // All available versions are listed here: https://www.biblegateway.com/versions/
return $version;
}
?>
@hlashbrooke
hlashbrooke / wordpress.sql
Created December 13, 2018 11:56
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.
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 October 12, 2018 12:52
Filtering items available in media library - taken from v1 of the WooCommerce Product Vendors extension.
/**
* 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 January 25, 2020 19:20
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.
<?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 May 26, 2020 01:03
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.
<?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 November 11, 2015 19:27
Seriously Simple Podcasting: Fix for Nginx servers where the podcast downloads and audio player are not working and/or returning a 404 error.
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 November 7, 2015 11:50
Seriously Simple Podcasting: Hide the episode audio player
add_filter( 'ssp_show_audio_player', '__return_false' );
@hlashbrooke
hlashbrooke / functions.php
Created November 7, 2015 05:16
Seriously Simple Podcasting: Add episodes series to episode meta data
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;
}