From 488892a9356be432f493c3a58ddf2e48ca580580 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Fri, 25 Oct 2024 18:16:07 -0700 Subject: [PATCH] Don't change priority of autop filters Wordpress adds these filters by default, in the correct order to make sure that rendered shortcodes don't get unwanted tags added to them. Note that the "content" of shortcodes isn't excluded and will still get these tags where appropriate. --- inc/filters.php | 5 ----- inc/shortcodes/class.accordion-shortcode.php | 8 -------- inc/shortcodes/class.blockquote-shortcode.php | 5 ----- inc/shortcodes/class.tabs-tours-shortcode.php | 5 ----- inc/shortcodes/class.tile-box-shortcode.php | 5 ----- 5 files changed, 28 deletions(-) diff --git a/inc/filters.php b/inc/filters.php index 6f527e1..a4b0062 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -21,11 +21,6 @@ function __construct() { add_filter( 'excerpt_more', '__return_false' ); add_filter( 'the_excerpt', array( $this, 'excerpt_more_override' ) ); - //remove auto-paragraphs from shortcodes and keep it for content - remove_filter( 'the_content', 'wpautop' ); - add_filter( 'the_content', 'wpautop', 99 ); - add_filter( 'the_content', 'shortcode_unautop', 100 ); - // Add PDF filter to media library add_filter( 'post_mime_types', array( $this, 'modify_post_mime_types' ) ); diff --git a/inc/shortcodes/class.accordion-shortcode.php b/inc/shortcodes/class.accordion-shortcode.php index 6b91625..a7f6c22 100644 --- a/inc/shortcodes/class.accordion-shortcode.php +++ b/inc/shortcodes/class.accordion-shortcode.php @@ -10,18 +10,10 @@ * [/accordion] */ class UW_Accordion { - const PRIORITY = 12; - /** * Accordion constructor. */ public function __construct() { - remove_filter( 'the_content', 'wpautop' ); - add_filter( 'the_content', 'wpautop', self::PRIORITY ); - - remove_filter( 'the_excerpt', 'wpautop' ); - add_filter( 'the_excerpt', 'wpautop', self::PRIORITY ); - add_shortcode( 'accordion', array( $this, 'accordion_handler' ) ); add_shortcode( 'section', array( $this, 'section_handler' ) ); add_shortcode( 'subsection', array( $this, 'subsection_handler' ) ); diff --git a/inc/shortcodes/class.blockquote-shortcode.php b/inc/shortcodes/class.blockquote-shortcode.php index 5abd382..8df735c 100644 --- a/inc/shortcodes/class.blockquote-shortcode.php +++ b/inc/shortcodes/class.blockquote-shortcode.php @@ -6,15 +6,10 @@ * [blockquote style="" align="" name="Dubs Husky" title="Official Live Mascot"] blockquote text [/blockquote] */ class UW_Blockquote { - const PRIORITY = 12; - /** * Blockquote constructor. */ public function __construct() { - remove_filter( 'the_content', 'wpautop' ); - add_filter( 'the_content', 'wpautop', self::PRIORITY ); - add_shortcode( 'blockquote', array( $this, 'blockquote_handler' ) ); } diff --git a/inc/shortcodes/class.tabs-tours-shortcode.php b/inc/shortcodes/class.tabs-tours-shortcode.php index d3b6a48..02ac293 100644 --- a/inc/shortcodes/class.tabs-tours-shortcode.php +++ b/inc/shortcodes/class.tabs-tours-shortcode.php @@ -10,15 +10,10 @@ * [/uw_tabs] */ class UW_Tabs_Tours { - const PRIORITY = 12; - /** * Tabs constructor. */ public function __construct() { - remove_filter( 'the_content', 'wpautop' ); - add_filter( 'the_content', 'wpautop', self::PRIORITY ); - add_shortcode( 'uw_tabs', array( $this, 'tabs_tours_handler' ) ); add_shortcode( 'tabs_section', array( $this, 'tabs_section_handler' ) ); diff --git a/inc/shortcodes/class.tile-box-shortcode.php b/inc/shortcodes/class.tile-box-shortcode.php index eab4858..85a3756 100644 --- a/inc/shortcodes/class.tile-box-shortcode.php +++ b/inc/shortcodes/class.tile-box-shortcode.php @@ -10,16 +10,11 @@ class UW_TileBox { const MAXTILES = 12; - const PRIORITY = 11; private $count = 0; private $NumbersArray = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve'); //arrays can't be constants in PHP. Privates at least can't be changed function __construct() { - remove_filter( 'the_content', 'wpautop' ); - add_filter( 'the_content', 'wpautop' , self::PRIORITY ); - remove_filter( 'the_excerpt', 'wpautop' ); - add_filter( 'the_excerpt', 'wpautop' , self::PRIORITY ); add_shortcode( 'box', array( $this, 'box_handler' ) ); add_shortcode( 'tile', array( $this, 'tile_handler' ) ); }