Skip to content

Instantly share code, notes, and snippets.

View taricco's full-sized avatar

Tim in Seattle taricco

  • Seattle, WA
View GitHub Profile
/*** Block Editor Notices (Single Page)
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/
add_action('enqueue_block_editor_assets', function () {
if ( ! is_admin() ) return;
$screen = function_exists('get_current_screen') ? get_current_screen() : null;
if ( ! $screen || empty($screen->post_type) || $screen->post_type !== 'page' ) return;
$post_id = isset($_GET['post']) ? (int) $_GET['post'] : 0;
$allowed_ids = [8588]; // <-- Insert Post ID(s)
/** Force-enqueue "Orbital" theme GF assets for ALL forms on all single posts/pages/CPTs **/
add_action('wp', function () {
if ( is_admin() ) return; // front-end only
if ( ! is_singular() || is_attachment() ) return; // any single post/page/CPT, skip attachments
// Ensure GF is available
if ( ! function_exists('gravity_form_enqueue_scripts') || ! class_exists('GFAPI') ) return;
$uses_ajax = apply_filters('wsv_gf_force_enqueue_ajax', false); // flip to true if you use AJAX sitewide
/** Populate Gravity Forms form hidden field with ACF field "resource_type" data
NOTE: In the Gravity Forms hidden field, enter "resource_type" as the dynamic population parameter. **/
// Populate GF hidden field with parameter name: resource_type
add_filter('gform_field_value_resource_type', function ($value) {
// Bail if ACF isn't loaded
if ( ! function_exists('get_field') ) {
return $value;
}
// Get a reliable post ID even when the form is injected via hooks/Elements
/*** Add "Reading Time" to Posts
Display with dyanmic template tag {{fn.wsv_read_time_badge}} - https://snippetclub.com/dynamic-template-tags/
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/
function wsv_calc_read_time($post_id = 0) {
$post_id = $post_id ?: get_the_ID();
$wpm = (int) apply_filters('wsv_read_time_wpm', 225);
if ($wpm < 100) $wpm = 100;
$content = get_post_field('post_content', $post_id);
/*** Add Tags to CPTs
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/
// 1) Make these CPTs support post_tag
add_action( 'init', function () {
$post_types = [ 'reports', 'webinars', 'ebooks', 'guidebooks', 'solutions' ];
foreach ( $post_types as $pt ) {
register_taxonomy_for_object_type( 'post_tag', $pt );
}
}, 11 ); // run after CPTs are registered
https://wordpress.org/plugins/gravity-forms-email-blacklist/
Settings:
- Please use a business email address. Personal email domains (e.g., Gmail, Hotmail) are not accepted.
- 027168.com, 0815.su, 0sg.net, 10mail.org, 10minutemail.co.za, 11mail.com, 123.com, 123box.net, 123india.com, 123mail.cl, 123mail.org, 123qwe.co.uk, 126.com, 139.com, 150mail.com, 150ml.com, 15meg4free.com, 163.com, 16mail.com, 188.com, 189.cn, 1ce.us, 1chuan.com, 1coolplace.com, 1freeemail.com, 1funplace.com, 1internetdrive.com, 1mail.ml, 1mail.net, 1me.net, 1mum.com, 1musicrow.com, 1netdrive.com, 1nsyncfan.com, 1pad.de, 1under.com, 1webave.com, 1webhighway.com, 1zhuan.com, 2-mail.com, 20email.eu, 20mail.in, 20mail.it, 212.com, 21cn.com, 24horas.com, 2911.net, 2980.com, 2bmail.co.uk, 2d2i.com, 2die4.com, 2trom.com, 3000.it, 30minutesmail.com, 3126.com, 321media.com, 33mail.com, 37.com, 3ammagazine.com, 3dmail.com, 3email.com, 3g.ua, 3mail.ga, 3xl.net, 444.net, 4email.com, 4email.net, 4mg.com, 4newyork.com, 4warding.net, 4warding.org,
//This code comes from https://snippetnest.com/snippet/remove-clutter-from-block-editor/
// Exclude specific blocks and namespaces
// Reorder block categories in the block inserter
// Exclude specific blocks and namespaces by User Role
// Exclude specific blocks and namespaces by Post Type
// Exclude specific blocks and namespaces
add_filter('allowed_block_types_all', function($allowed_blocks, $editor_context) {
/**
* Register custom dynamic tags for GenerateBlocks from WooCommerce.
*/
add_action('init', 'register_woocommerce_dynamic_tags');
function register_woocommerce_dynamic_tags() {
if (class_exists('GenerateBlocks_Register_Dynamic_Tag')) {
// 1. Label Sale
new GenerateBlocks_Register_Dynamic_Tag(
/*** IMPORTANT: The plugin Admin and Site Enhancements (ASE) hides the notices. ***/
/*** Posts Alert Message
Notes: notice-error #d63638, notice-warning #dba617, notice-success #00a32a, notice-info #72aee6.
ChatGPT Generated
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/
function posts_admin_notice() {
global $pagenow;