Skip to content

Instantly share code, notes, and snippets.

View RadGH's full-sized avatar

Radley Sustaire RadGH

View GitHub Profile
@RadGH
RadGH / block-editor.js
Last active October 25, 2023 09:04
WordPress Block Editor - Custom SVG icon using javascript filter
// Result: https://radleysustaire.com/s3/d87fe5/chrome
// Enqueue this script in PHP during the action "enqueue_block_editor_assets":
// $deps = array('wp-element', 'wp-hooks');
// wp_register_script( 'rs-download-block-editor', RSD_URL . '/assets/block-editor.js', $deps );
// This filter replaces the icon of any block with the prefix "rs-downloads/" using a custom SVG icon
wp.hooks.addFilter(
'blocks.registerBlockType',
'rs-downloads/modify_icon',
@RadGH
RadGH / aa-process-all-users-once-daily.php
Last active June 5, 2020 15:19
WordPress Plugin: Loops through all users on your site, spread out throughout the day for efficiency. Provides a hook to do any sort of maintenance on those users. Does not actually modify any users, this just an API of sorts.
<?php
/*
Plugin Name: RS Process Users Daily
Description: Provides an API action for developers which iterates all users once per day, based on cofigurable settings. Usage: <code class="code">add_action( 'aa_process_all_users_daily/user', 'example_process_user' );</code>
Author: Radley Sustaire
Version: 1.1.0
*/
/*
// EXAMPLE
@RadGH
RadGH / rs_upload_from_url.php
Last active May 4, 2024 02:49
Upload a file from a URL to the WordPress media gallery. Supports images, PDFs, and other file types.
<?php
/**
* This function uploads a file from a URL to the media library, designed to be placed in your own theme or plugin.
* Metadata will be generated and images will generate thumbnails automatically.
*
* HOW TO USE:
* 1. Add the function below to your theme or plugin
* 2. Call the function and provide the URL to an image or other file.
* 3. If successful, the attachment ID will be returned.
@mommaroodles
mommaroodles / functions.php
Created February 2, 2014 00:16
Woocommerce: Remove Company Input Field in Checkout Page
<?php
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_company']);
return $fields;
}
?>