Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Wilkinson wpmark

View GitHub Profile
@wpmark
wpmark / wp-email-tweaks.php
Created Oct 12, 2021
Easily customise the name and email address of WordPress emails
View wp-email-tweaks.php
<?php
/**
* Used to filter email from 'address'
*/
function hd_email_send_wp_mail_address( $input ) {
// return a new from email address.
return 'no-reply@highrise.digital';
}
@wpmark
wpmark / alignment-options.js
Last active Oct 14, 2021
Add alignment options for WordPress core blocks.
View alignment-options.js
// set alignment options for cover, video, and paragraph blocks.
wp.hooks.addFilter(
'blocks.registerBlockType',
'hd-theme/hd-theme',
function( settings, name ) {
if ( name === 'core/cover' || name === 'core/video' || name === 'core/paragraph' || name === 'core/list' ) {
return lodash.assign( {}, settings, {
supports: lodash.assign( {}, settings.supports, {
// allow support for full and wide alignment.
align: ['full', 'wide'],
@wpmark
wpmark / readme.md
Last active Nov 5, 2021
An example of caching data using a WordPress transient
View readme.md

Caching WordPress data using Transients - Example

In this simple example we create a function for obtaining data from an external source and caching it for 24 hours. You can use the function hd_get_external_data() to get the data and work with it in your site.

If you want to force a refresh of the cache, you can pass a value of true into the function.

You can place the code into your themes functions.php file or better still in a plugin. If you are placing it in a plugin, remember to use function_exists() when using this. This ensures that the code will fail correctly if the plugin is not active.

@wpmark
wpmark / post-type-support.php
Created Oct 8, 2021
Add post type support for the post excerpt
View post-type-support.php
<?php
/**
* Add support for the excerpt on pages.
*/
function hd_add_custom_post_type_excerpt_support() {
// add post type support for pages.
add_post_type_support( 'page', 'excerpt' );
// add post type support for case studies.
@wpmark
wpmark / hd-just-in-time-css.php
Created Aug 13, 2021
A plugin to provide Just in Time CSS for WordPress blocks
View hd-just-in-time-css.php
<?php
/*
Plugin Name: Just in Time CSS
Plugin URI: https://highrise.digital/
Description: A plugin from Highrise Digital to provide just in time CSS functionality.
Version: 1.0
License: GPL-2.0+
Author: Highrise Digital Ltd
Author URI: https://highrise.digital/
Text domain: hd-just-in-time-css
@wpmark
wpmark / hd-user-categories.php
Created Jun 11, 2021
A WordPress plugin that adds categories to users. It allows you to assign categories to users which you could then use elsewhere in your site.
View hd-user-categories.php
<?php
/*
Plugin Name: User Categories
Plugin URI: https://highrise.digital/
Description: Adds categories to users. It allows you to assign categories to users which you could then use elsewhere in your site.
Version: 1.0
License: GPL-2.0+
Author: Highrise Digital Ltd
Author URI: https://highrise.digital/
Text domain: hd-user-categories
@wpmark
wpmark / highrise-auto-updater.php
Created Mar 31, 2021
Allow WordPress to auto update eveything.
View highrise-auto-updater.php
<?php
/*
Plugin Name: Highrise Digital Auto Updater
Plugin URI: https://highrise.digital/
Description: A plugin to set WordPress to auto update everything.
Version: 1.0
License: GPL-2.0+
Author: Highrise Digital
Author URI: https://highrise.digital/
Text domain: highrise-auto-updater
@wpmark
wpmark / wp-dev-env-body-class.php
Created Oct 15, 2020
Output a body class based on the WP development environment
View wp-dev-env-body-class.php
<?php
/**
* Adds a body class for the environment.
*
* @param array $classes The current array of body classes.
* @return array The new array of body classes.
*/
function hd_env_body_class( $classes ) {
// if WP environment function exists.
@wpmark
wpmark / extensible-changes.php
Created Oct 6, 2020
HD Extensible Social Profiles Widget
View extensible-changes.php
<?php
/**
* Edit the social profiles available.
*
* @param array $profiles The current array of registered social profiles.
* @return array The modified array of registered social profiles.
*/
function hd_test_edit_social_profile( $profiles ) {
// if we have a linkedin profile.
@wpmark
wpmark / readme.txt
Created Jan 17, 2020
Altering the meta compare value of the WP Broadbean Search salary field.
View readme.txt
This function will change the behaviour of the salary field in the WP Broadbean Search form. By default the salary search only searches for values greater than whatever the user enters.
The code above changes the behaviour of this to return jobs that have salary values greater than AND equal to the value entered.
Place this code either in your themes functions.php file, your own plugin, or a file in the mu-plugins folder inside the wp-content folder.