function wpautop_control_filter($content)
 {
     global $post;
     // Check if a temporary $post reassignment is set. This lets the filter work on multiple content sources
     // in a single page by setting a temporary post object immediately before filters are applied. Basically
     // a complicated way to pass $post->ID with a global variable since it can't be directly passed.
     $the_post = isset($GLOBALS['wpautop_post']) ? $GLOBALS['wpautop_post'] : $post;
     // Get wpautop setting
     $remove_filter = isset($the_post) ? wpautop_disable($the_post->ID) : 0;
     // turn on/off
     if ($remove_filter) {
         remove_filter('the_content', 'wpautop');
         remove_filter('the_excerpt', 'wpautop');
     } else {
         add_filter('the_content', 'wpautop');
         add_filter('the_excerpt', 'wpautop');
     }
     // destroy temporary items
     unset($GLOBALS['wpautop_post']);
     unset($the_post);
     // return content
     return $content;
 }
 function get_content_for_layout($id, $title = false)
 {
     global $bbpress;
     if (!$id) {
         return false;
     }
     // Get the page contenet
     $page_data = get_post($id);
     $content = $page_data->post_content;
     // get the content
     if ($page_data->post_type == 'forum') {
         $forum_id = $id;
         $content = empty($bbpress['context']) ? "[bbp-single-forum id={$forum_id}]" : $bbpress['context'];
     }
     // Apply only default filters. This is the safe way, not
     // risking plugin injection/overrides of 'the_content'
     $content = wptexturize($content);
     $content = convert_smilies($content);
     $content = convert_chars($content);
     if (!wpautop_disable($id)) {
         $content = wpautop($content);
         // Add paragraph tags.
     }
     $content = shortcode_unautop($content);
     $content = prepend_attachment($content);
     $content = do_shortcode($content);
     // Get title, add to output<br />
     if ($title) {
         $content = '<h3 class="layout-block-title page-title">' . $page_data->post_title . '</h3>' . $content;
     }
     // Apply function specific
     $content = apply_filters('get_content_for_layout', $content, $id);
     return $content;
 }