From d0b20079fe0abe6f8df47c34f5c3e65ff9bec0cf Mon Sep 17 00:00:00 2001 From: Jake Oehler Morrison Date: Tue, 11 Dec 2018 16:53:29 +0000 Subject: [PATCH 1/2] Allows for the option (filter) for shortcodes to be stripped --- includes/class-wp-job-manager-post-types.php | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/includes/class-wp-job-manager-post-types.php b/includes/class-wp-job-manager-post-types.php index 3c42095cf..c0c98006d 100644 --- a/includes/class-wp-job-manager-post-types.php +++ b/includes/class-wp-job-manager-post-types.php @@ -34,6 +34,7 @@ public static function instance() { */ public function __construct() { add_action( 'init', array( $this, 'register_post_types' ), 0 ); + add_action( 'init', array( $this, 'add_content_filters' ) ); add_filter( 'admin_head', array( $this, 'admin_head' ) ); add_action( 'job_manager_check_for_expired_jobs', array( $this, 'check_for_expired_jobs' ) ); add_action( 'job_manager_delete_old_previews', array( $this, 'delete_old_previews' ) ); @@ -343,6 +344,35 @@ public function register_post_types() { ); } + /** + * Adds content filters for job listings. + */ + public function add_content_filters() { + /** + * If enabled, this removes the shortcodes from job listing content. + * + * @since 1.32.0 + * + * @param bool $do_remove_shortcodes True to remove them. + */ + if ( apply_filters( 'job_manager_strip_job_shortcodes', false ) ) { + add_filter( 'the_content', array( $this, 'strip_shortcodes' ) ); + } + } + + /** + * Strip shortcodes from content. + * + * @param string $content Post content to filter. + * @return string + */ + public function strip_shortcodes( $content ) { + if ( 'job_listing' !== get_post_type() ) { + return $content; + } + return strip_shortcodes( $content ); + } + /** * Change label for admin menu item to show number of Job Listing items pending approval. */ From ac6d0868b6123124d9bf9542178f21712e664c8e Mon Sep 17 00:00:00 2001 From: Jake Oehler Morrison Date: Wed, 27 Jan 2021 12:24:00 +0000 Subject: [PATCH 2/2] Fix formatting issue from merge --- includes/class-wp-job-manager-post-types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wp-job-manager-post-types.php b/includes/class-wp-job-manager-post-types.php index 8ed8f62fd..b50180ed8 100644 --- a/includes/class-wp-job-manager-post-types.php +++ b/includes/class-wp-job-manager-post-types.php @@ -52,7 +52,7 @@ public static function instance() { */ public function __construct() { add_action( 'init', [ $this, 'register_post_types' ], 0 ); - add_action( 'init', [ $this, 'add_content_filters' ] ); + add_action( 'init', [ $this, 'add_content_filters' ] ); add_action( 'init', [ $this, 'prepare_block_editor' ] ); add_action( 'init', [ $this, 'register_meta_fields' ] ); add_filter( 'admin_head', [ $this, 'admin_head' ] );