Allow Unfiltered HTML by Role in Multisite

/** * Enable unfiltered_html capability for role. * * @param array $caps The user’s capabilities. * @param string $cap Capability name. * @param int $user_id The user ID. * @return array $caps The user’s capabilities, with ‘unfiltered_html’ potentially added. */…Continue reading

Set the ranges for Calendar View | Display Eventbrite Events

/** * Set the valid range for the calendar view. */ add_filter( ‘wfea_cal_options’ , function( $options ) { $options[‘fullcalendar’][‘validRange’] = array( ‘start’ => date( ‘Y-m-d’, strtotime( ‘-5 months’ ) ), // 5 months ago ‘end’ => date( ‘Y-m-d’, strtotime( ‘+5…Continue reading

Disable, Add, and Enable Thumbnail Sizes

// disable generated image sizes //function tps_disable_image_sizes($sizes) { // unset($sizes[‘thumbnail’]); // disable thumbnail size // unset($sizes[‘medium’]); // disable medium size // unset($sizes[‘large’]); // disable large size //unset($sizes[‘medium_large’]); // disable medium-large size //unset($sizes[‘1536×1536’]); // disable 2x medium-large size //unset($sizes[‘2048×2048’]); // disable…Continue reading

Dequeue / Enqueue Scripts and Styles (Reference)

add_action( ‘wp_enqueue_scripts’, function() { wp_dequeue_script( ‘generate-classlist’ ); wp_dequeue_style( ‘classic-theme-styles’ ); wp_dequeue_style( ‘wp-block-library’ ); wp_dequeue_style( ‘global-styles’ ); //wp_deregister_style( ‘popup-maker-site’ ); //wp_dequeue_style( ‘popup-maker-site’ ); //wp_deregister_script( ‘popup-maker-site’ ); //wp_dequeue_script( ‘popup-maker-site’ ); //wp_deregister_script( ‘pum-stp’ ); //wp_dequeue_script( ‘pum-stp’ ); //wp_register_script( ‘popup-maker-site’, ‘/wp-content/plugins/popup-maker/assets/js/site.min.js’, array( ‘jquery’, ‘jquery-ui-core’,…Continue reading

Shortcode in Nav Menu, Widgets, Sidebar

/** * Enable shortcodes for menu navigation. */ if ( ! has_filter( ‘wp_nav_menu’, ‘do_shortcode’ ) ) { add_filter( ‘wp_nav_menu’, ‘shortcode_unautop’ ); add_filter( ‘wp_nav_menu’, ‘do_shortcode’, 11 ); } /** * Enable shortcodes for widgets (footer, sidebar…). */ if ( ! has_filter(…Continue reading

Image Upload Size Restrictions (reference)

/* * Plugin Name: Image Upload Restrictions * Description: Prevents the upload of images too big, narrow, wide, tall, or short * Version: 1.2 * Author: Titus and Jeff * Author URI: https://titus-design.com */ //if (!defined(‘ABSPATH’)) die(‘Restricted Area’); add_filter(‘wp_handle_upload_prefilter’,’tps_validate_image_size’); function…Continue reading

Per User Upload Prefilter

add_filter(‘wp_handle_upload_prefilter’, ‘per_user_upload_prefilter’); function per_user_upload_prefilter($errors) { if( ( isset( $_REQUEST[‘action’] ) && ( “um_resize_image” == $_REQUEST[‘action’] || “um_imageupload” == $_REQUEST[‘action’] ) ) || isset( $_REQUEST[‘um_action’] ) ){ return $errors; } // in this filter we add a WP filter that alters…Continue reading

ACF Image Upload Size Restrictions

//add_filter(‘wp_handle_upload_prefilter’,’tps_validate_image_size’); add_filter(‘acf/validate_attachment/name=gallery_post_featured_image’, ‘tps_validate_gallery_image_size’, 10, 5); function tps_validate_gallery_image_size( $errors, $file, $attachment, $field, $context ){ $image_type = $file[‘type’]; $image_filesize = $file[‘size’]; $image_width = $file[‘width’]; $image_height = $file[‘height’]; if ( ( $image_type != ‘jpg’ ) && ( $image_type != ‘jpeg’ ) && (…Continue reading

Change srcset Sizes

function tps_change_srcset_sizes( $sizes ) { return ‘(min-width: 769px) calc( ( ( 100vw – 80px ) * .7 ) – 40px ), calc(100vw – 60px)’; } add_filter( ‘wp_calculate_image_sizes’, ‘tps_change_srcset_sizes’ );Continue reading