/**
  * The class constructor
  */
 public function __construct()
 {
     add_action('save_post', array($this, 'save_post'));
     foreach (Custom_Sidebars::get_post_types() as $post_type) {
         add_action("add_meta_boxes_{$post_type}", array($this, 'add_meta_boxes'));
     }
 }
 /**
  * The WP admin_init action callback
  *
  * Get all pages and posts and add sidebars for each individual post
  */
 public function init()
 {
     $posts = array();
     if (!($posts = wp_cache_get('sidebars', 'custom_sidebars'))) {
         $args = array('post_type' => Custom_Sidebars::get_post_types(), 'meta_query' => array(array('key' => '_custom_sidebar', 'value' => true)));
         $query = new WP_Query($args);
         if ($query->have_posts()) {
             $posts = $query->posts;
         }
         wp_cache_set('sidebars', 'custom_sidebars');
     }
     foreach ($posts as $post) {
         $args = apply_filters('custom_sidebar_args', array('name' => sprintf(__('Sidebar: %s', 'custom_sidebars'), $post->post_title), 'id' => $this->get_sidebar_id($post->ID), 'description' => sprintf(__('This sidebar will appear on the %s single page.', 'cd-sidebar'), $post->post_title), 'class' => '', 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>'));
         register_sidebar($args);
     }
 }