Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows for the option (filter) for shortcodes to be stripped #1643

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions includes/class-wp-job-manager-post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +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, 'prepare_block_editor' ] );
add_action( 'init', [ $this, 'register_meta_fields' ] );
add_filter( 'admin_head', [ $this, 'admin_head' ] );
Expand Down Expand Up @@ -417,6 +418,36 @@ 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.36.0
*
* @param bool $do_remove_shortcodes True to remove them.
*/
if ( apply_filters( 'job_manager_strip_job_shortcodes', false ) ) {
add_filter( 'the_content', [ $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.
*/
Expand Down