Skip to content

Commit

Permalink
Merge pull request #6151 from Automattic/fix/undefined-variable-remov…
Browse files Browse the repository at this point in the history
…ing-shortcodes

Sync: Fix undefined variable when processing shortcodes
  • Loading branch information
gravityrail authored Jan 23, 2017
2 parents 1bc9bba + baf97d3 commit 56cb6f1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sync/class.jetpack-sync-module-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,22 @@ function filter_post_content_and_add_links( $post_object ) {
* @param array of shortcode tags to remove.
*/
$shortcodes_to_remove = apply_filters( 'jetpack_sync_do_not_expand_shortcodes', array( 'gallery', 'slideshow' ) );
$removed_shortcode_callbacks = array();
foreach ( $shortcodes_to_remove as $shortcode ) {
if ( isset ( $shortcode_tags[ $shortcode ] ) ) {
$shortcodes_and_callbacks_to_remove[ $shortcode ] = $shortcode_tags[ $shortcode ];
$removed_shortcode_callbacks[ $shortcode ] = $shortcode_tags[ $shortcode ];
}
}

array_map( 'remove_shortcode' , array_keys( $shortcodes_and_callbacks_to_remove ) );
array_map( 'remove_shortcode' , array_keys( $removed_shortcode_callbacks ) );

/** This filter is already documented in core. wp-includes/post-template.php */
if ( Jetpack_Sync_Settings::get_setting( 'render_filtered_content' ) && $post_type->public ) {
$post->post_content_filtered = apply_filters( 'the_content', $post->post_content );
$post->post_excerpt_filtered = apply_filters( 'the_excerpt', $post->post_excerpt );
}

foreach ( $shortcodes_and_callbacks_to_remove as $shortcode => $callback ) {
foreach ( $removed_shortcode_callbacks as $shortcode => $callback ) {
add_shortcode( $shortcode, $callback );
}

Expand Down

0 comments on commit 56cb6f1

Please sign in to comment.