Disable Openverse

add_filter( ‘block_editor_settings_all’, function( $settings, $context ) { $settings[‘enableOpenverseMediaCategory’] = false; return $settings; }, 10, 2 );Continue reading

Disable Template Editor

add_action( ‘current_screen’, function () { $screen = get_current_screen(); // Add other custom post types here as needed. if ( in_array( $screen->id, array( ‘post’, ‘page’ ) ) ) { remove_theme_support( ‘block-templates’ ); } } );Continue reading

Heartbeat Setting

// Add a new setting in wp-admin > Settings > General add_action( ‘admin_init’, function() { register_setting( ‘general’, ‘custom_heartbeat_interval’, ‘intval’ ); add_settings_field( ‘custom_heartbeat_interval’, ‘Heartbeat Interval’, function() { $interval = get_option( ‘custom_heartbeat_interval’, 120 ); echo “ seconds”; }, ‘general’ ); }); add_filter(…Continue reading

Storing User’s Uncached IP Address in Hidden Field

/** * Do not store the cached IP address in a hidden field * * @link https://wpforms.com/developers/how-to-store-the-non-cached-ip-address-into-a-hidden-field/ */ function wpf_hidden_ip_avoid_cache( $fields, $entry, $form_data ){ // Only run on the form with ID 727 if( $form_data[ ‘id’ ] == 727 )…Continue reading

Unattached Media Cleanup

// Schedule the event if it is not already scheduled function schedule_unattached_media_cleanup() { if (!wp_next_scheduled(‘delete_unattached_media_event’)) { wp_schedule_event(time(), ‘daily’, ‘delete_unattached_media_event’); } } add_action(‘wp’, ‘schedule_unattached_media_cleanup’); // Hook the function to the scheduled event add_action(‘delete_unattached_media_event’, ‘delete_unattached_media’); // Function to delete unattached media function…Continue reading

Sending Numerical Values Through Webhooks

/** * Send the numerical values through webhooks. * * @link https://wpforms.com/developers/how-to-send-the-numerical-values-through-webhooks/ */ function wpf_dev_webhooks_numeric_value( $filled_params, $params, $process ) { // Request Body params which values should be numeric. // List each variable that you want as a number and…Continue reading

Remove Query Strings From Static Files

function wpcode_snippet_remove_query_strings_split( $src ) { $output = preg_split( “/(&ver|\?ver)/”, $src ); return $output ? $output[0] : ”; } add_action( ‘init’, function () { if ( ! is_admin() ) { add_filter( ‘script_loader_src’, ‘wpcode_snippet_remove_query_strings_split’, 15 ); add_filter( ‘style_loader_src’, ‘wpcode_snippet_remove_query_strings_split’, 15 ); }…Continue reading

Sending Geolocation Data Through Webhooks

/** * Send geolocation through webhooks. * * @link https://wpforms.com/developers/how-to-send-geolocation-through-webhooks */ function wpf_dev_geolocation_webhook( $options, $webhook_data, $fields, $form_data, $entry_id ) { // Optional, you can limit to specific forms. Below, we restrict output to // form #1899. if ( absint( $form_data[…Continue reading

Processing Smart Tags in HTML Field

/** * Process Smart Tags inside HTML / Code Block form fields. * * @link https://wpforms.com/developers/how-to-process-smart-tags-in-html-fields/ */ function wpf_dev_html_process_smarttags( $properties, $field, $form_data ) { $properties[ ‘inputs’ ][ ‘primary’ ][ ‘code’ ] = apply_filters( ‘wpforms_process_smart_tags’, $properties[ ‘inputs’ ][ ‘primary’ ][ ‘code’…Continue reading