/**
  * Redirect single post pages
  *
  * @uses dwpb_post_types_with_tax()
  * 
  * @since 0.2.0
  * @link http://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect
  */
 public function redirect_posts()
 {
     if (is_admin() || !get_option('page_on_front')) {
         return;
     }
     // Get the front page id and url
     $page_id = get_option('page_on_front');
     $url = get_permalink($page_id);
     // Run the redirects
     if (is_singular('post')) {
         global $post;
         $redirect_url = apply_filters("dwpb_redirect_posts", $url, $post);
         $redirect_url = apply_filters("dwpb_redirect_post_{$post->ID}", $redirect_url, $post);
     } elseif (is_tag() && !dwpb_post_types_with_tax('post_tag')) {
         $redirect_url = apply_filters('dwpb_redirect_post_tag_archive', $url);
     } elseif (is_category() && !dwpb_post_types_with_tax('category')) {
         $redirect_url = apply_filters('dwpb_redirect_category_archive', $url);
     } elseif (is_post_type_archive('post')) {
         $redirect_url = apply_filters('dwpb_redirect_post_archive', $url);
     } elseif (is_home()) {
         $redirect_url = apply_filters('dwpb_redirect_blog_page', $url);
     } elseif (is_date()) {
         $redirect_url = apply_filters('dwpb_redirect_date_archive', $url);
     } else {
         $redirect_url = false;
     }
     // Get the current url and compare to the redirect, if they are the same, bail to avoid a loop
     // If there is no redirect url, then also bail.
     $protocol = stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'http://';
     $curent_url = esc_url($protocol . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
     if ($redirect_url == $curent_url || !$redirect_url) {
         return;
     }
     if (apply_filters('dwpb_redirect_front_end', true, $redirect_url)) {
         wp_redirect(esc_url($redirect_url), 301);
         exit;
     }
 }
 /**
  * Filter the widget removal & check for reasons to not remove specific widgets.
  *
  * @since 0.4.0
  *
  * @param boolean $boolean
  * @param string $widget
  *
  * @return boolean
  */
 public function filter_widget_removal($boolean, $widget)
 {
     // Remove Categories Widget
     if ('WP_Widget_Categories' == $widget && dwpb_post_types_with_tax('category')) {
         $boolean = false;
     }
     // Remove Recent Comments Widget if posts are the only type with comments
     if ('WP_Widget_Recent_Comments' == $widget && dwpb_post_types_with_feature('comments')) {
         $boolean = false;
     }
     // Remove Tag Cloud
     if ('WP_Widget_Tag_Cloud' == $widget && dwpb_post_types_with_tax('post_tag')) {
         $boolean = false;
     }
     return $boolean;
 }