示例#1
0
/**
 * Helper function used only in this view.
 * It renders a list with sidebar-replacement details
 */
function list_sidebar_replacement($label, $list)
{
    $import = CustomSidebarsExport::get_import_data();
    $theme_sidebars = CustomSidebars::get_sidebars();
    foreach ($list as $from_id => $to_id) {
        $from = $theme_sidebars[$from_id];
        $to = array();
        if (isset($theme_sidebars[$to_id])) {
            $to = $theme_sidebars[$to_id];
        } else {
            $to = $import['sidebars'][$to_id];
        }
        ?>

		<tr>
			<th scope="row"><?php 
        echo esc_html($label);
        ?>
</th>
			<td><?php 
        echo esc_html($from['name']);
        ?>
</td>
			<td><i class="dashicons dashicons-arrow-right-alt hint"></i></td>
			<td><?php 
        echo esc_html($to['name']);
        ?>
</td>
		</tr>
		<?php 
    }
}
function inc_sidebars_free_init()
{
    // Check if the PRO plugin is present and activated.
    if (class_exists('CustomSidebars')) {
        return false;
    }
    // used for more readable i18n functions: __( 'text', CSB_LANG );
    define('CSB_LANG', 'custom-sidebars');
    $plugin_dir = dirname(__FILE__);
    $plugin_dir_rel = dirname(plugin_basename(__FILE__));
    $plugin_url = plugin_dir_url(__FILE__);
    define('CSB_PLUGIN', __FILE__);
    define('CSB_LANG_DIR', $plugin_dir_rel . '/lang/');
    define('CSB_VIEWS_DIR', $plugin_dir . '/views/');
    define('CSB_INC_DIR', $plugin_dir . '/inc/');
    define('CSB_JS_URL', $plugin_url . 'js/');
    define('CSB_CSS_URL', $plugin_url . 'css/');
    define('CSB_IMG_URL', $plugin_url . 'img/');
    // Load the actual core.
    require_once CSB_INC_DIR . 'class-custom-sidebars.php';
    // Include function library
    if (file_exists(CSB_INC_DIR . 'external/wpmu-lib/core.php')) {
        require_once CSB_INC_DIR . 'external/wpmu-lib/core.php';
    }
    // Load the text domain for the plugin
    WDev()->translate_plugin(CSB_LANG, CSB_LANG_DIR);
    // Initialize the plugin
    CustomSidebars::instance();
}
function inc_sidebars_init()
{
    if (class_exists('CustomSidebars')) {
        return false;
    }
    $plugin_dir = dirname(__FILE__);
    $plugin_dir_rel = dirname(plugin_basename(__FILE__));
    $plugin_url = plugin_dir_url(__FILE__);
    define('CSB_PLUGIN', __FILE__);
    define('CSB_IS_PRO', false);
    define('CSB_LANG_DIR', $plugin_dir_rel . '/lang/');
    define('CSB_VIEWS_DIR', $plugin_dir . '/views/');
    define('CSB_INC_DIR', $plugin_dir . '/inc/');
    define('CSB_JS_URL', $plugin_url . 'js/');
    define('CSB_CSS_URL', $plugin_url . 'css/');
    define('CSB_IMG_URL', $plugin_url . 'img/');
    // Include function library.
    $modules[] = CSB_INC_DIR . 'external/wpmu-lib/core.php';
    $modules[] = CSB_INC_DIR . 'external/wdev-frash/module.php';
    $modules[] = CSB_INC_DIR . 'class-custom-sidebars.php';
    // Free-version configuration - no drip campaign yet...
    $cta_label = false;
    $drip_param = false;
    foreach ($modules as $path) {
        if (file_exists($path)) {
            require_once $path;
        }
    }
    // Register the current plugin, for pro and free plugins!
    do_action('wdev-register-plugin', plugin_basename(__FILE__), 'CustomSidebars', '/plugins/custom-sidebars/', $cta_label, $drip_param);
    // Initialize the plugin
    CustomSidebars::instance();
}
    /**
     * Private, since it is a singleton.
     * We directly initialize sidebar options when class is created.
     */
    private function __construct()
    {
        /**
         * ID of the WP-Pointer used to introduce the plugin upon activation
         *
         * ========== Pointer ==========
         *  Internal ID:  wpmudcs1 [WPMUDev CustomSidebars 1]
         *  Point at:     #menu-appearance (Appearance menu item)
         *  Title:        Custom Sidebars
         *  Description:  Create and edit custom sidebars in your widget screen!
         * -------------------------------------------------------------------------
         */
        WDev()->pointer('wpmudcs1', '#menu-appearance', __('Custom Sidebars', CSB_LANG), sprintf(__('Now you can create and edit custom sidebars in your ' . '<a href="%1$s">Widgets screen</a>!', CSB_LANG), admin_url('widgets.php')));
        // Find out if the page is loaded in accessibility mode.
        $flag = isset($_GET['widgets-access']) ? $_GET['widgets-access'] : get_user_setting('widgets_access');
        self::$accessibility_mode = 'on' == $flag;
        // We don't support accessibility mode. Display a note to the user.
        if (true === self::$accessibility_mode) {
            WDev()->message(sprintf(__('<strong>Accessibility mode is not supported by the
						%1$s plugin.</strong><br /><a href="%2$s">Click here</a>
						to disable accessibility mode and use the %1$s plugin!', CSB_LANG), 'Custom Sidebars', admin_url('widgets.php?widgets-access=off')), 'err', 'widgets');
        } else {
            // Load javascripts/css files
            WDev()->add_ui('core', 'widgets.php');
            WDev()->add_ui('scrollbar', 'widgets.php');
            WDev()->add_ui('select', 'widgets.php');
            WDev()->add_ui(CSB_JS_URL . 'cs.min.js', 'widgets.php');
            WDev()->add_ui(CSB_CSS_URL . 'cs.css', 'widgets.php');
            // AJAX actions
            add_action('wp_ajax_cs-ajax', array($this, 'ajax_handler'));
            // Extensions use this hook to initialize themselfs.
            do_action('cs_init');
            // Display a message after import.
            if (!empty($_GET['cs-msg'])) {
                $msg = base64_decode($_GET['cs-msg']);
                // Prevent XSS attacks...
                $kses_args = array('br' => array(), 'b' => array(), 'strong' => array(), 'i' => array(), 'em' => array());
                $msg = wp_kses($msg, $kses_args);
                if (!empty($msg)) {
                    WDev()->message($msg);
                }
            }
            // Free version only
            add_action('in_widget_form', array($this, 'in_widget_form'), 10, 1);
        }
    }
 /**
  * Tell WordPress about the custom sidebars.
  */
 public function register_custom_sidebars()
 {
     $sb = self::get_custom_sidebars();
     $sb = CustomSidebars::sort_sidebars_by_name($sb);
     foreach ($sb as $sidebar) {
         /**
          * Filter sidebar options for custom sidebars.
          *
          * @since  2.0
          *
          * @param  array $sidebar Options used by WordPress to display
          *           the sidebar.
          */
         $sidebar = apply_filters('cs_sidebar_params', $sidebar);
         register_sidebar($sidebar);
     }
 }
<?php

/**
 * Contents of the Location popup in the widgets screen.
 * User can define default locations where the custom sidebar will be used.
 *
 * This file is included in widgets.php.
 */
$sidebars = CustomSidebars::get_sidebars('theme');
/**
 * Output the input fields to configure replacements for a single sidebar.
 *
 * @since  2.0
 * @param  array $sidebar Details provided by CustomSidebars::get_sidebar().
 * @param  string $prefix Category specific prefix used for input field ID/Name.
 * @param  string $cat_name Used in label: "Replace sidebar for <cat_name>".
 * @param  string $class Optinal classname added to the wrapper element.
 */
function _show_replaceable($sidebar, $prefix, $cat_name, $class = '')
{
    $base_id = 'cs-' . $prefix;
    $inp_id = $base_id . '-' . $sidebar['id'];
    $inp_name = '___cs___' . $prefix . '___' . $sidebar['id'];
    $sb_id = $sidebar['id'];
    $class = empty($class) ? '' : ' ' . $class;
    ?>
	<div
		class="cs-replaceable <?php 
    echo esc_attr($sb_id . $class);
    ?>
"
示例#7
0
?>
",
		'lbl_replaceable': "<?php 
_e('This sidebar can be replaced on certain pages', CSB_LANG);
?>
",
		'replace_tip': "<?php 
_e('Activate this option to replace the sidebar with one of your custom sidebars.', CSB_LANG);
?>
",
		'filter': "<?php 
_e('Filter...', CSB_LANG);
?>
",
		'replaceable': <?php 
echo json_encode((object) CustomSidebars::get_options('modifiable'));
?>

	};
	</script>


	<?php 
/*
============================================================================
===== TOOLBAR for custom sidebars
============================================================================
*/
?>

	<div class="cs-custom-sidebar cs-toolbar">
示例#8
0
    }
    ?>

<?php 
} else {
    ?>

	<p>
		<?php 
    _e('Here you can replace the default sidebars. Simply select what ' . 'sidebar you want to show for this post!', 'custom-sidebars');
    ?>
	</p>
<?php 
    if (!empty($sidebars)) {
        global $wp_registered_sidebars;
        $available = CustomSidebars::sort_sidebars_by_name($wp_registered_sidebars);
        foreach ($sidebars as $s) {
            ?>
			<?php 
            $sb_name = $available[$s]['name'];
            ?>
			<p>
				<label for="cs_replacement_<?php 
            echo esc_attr($s);
            ?>
">
					<b><?php 
            echo esc_html($sb_name);
            ?>
</b>:
				</label>
<?php

/**
 * Metabox inside posts/pages where user can define custom sidebars for an
 * individual post.
 *
 * Uses:
 *   $selected
 *   $wp_registered_sidebars
 *   $post_id
 */
$available = $wp_registered_sidebars;
$sidebars = CustomSidebars::get_options('modifiable');
$is_front = $post_id == get_option('page_on_front');
$is_blog = $post_id == get_option('page_for_posts');
?>

<?php 
if ($is_front || $is_blog) {
    ?>
	<p>
		<?php 
    printf(__('<strong>To change the sidebar for static Front-Page or ' . 'Posts-Page</strong>:<ul>' . '<li>Go to the <a href="%1$s">Widgets page</a></li>' . '<li>Click on "Sidebar Location"</li>' . '<li>Open the "Archive-Types" tab</li>' . '<li>Choose "Front-Page" or "Post-Index"</li></ul>', CSB_LANG), admin_url('widgets.php'));
    ?>
	</p>

	<img src="<?php 
    echo esc_url(CSB_IMG_URL . 'frontpage-info.png');
    ?>
" style="width:274px;margin:0 0 -14px -10px;" />
define('CSB_LANG_DIR', $plugin_dir_rel . '/lang/');
define('CSB_VIEWS_DIR', $plugin_dir . '/views/');
define('CSB_INC_DIR', $plugin_dir . '/inc/');
define('CSB_JS_URL', $plugin_url . 'js/');
define('CSB_CSS_URL', $plugin_url . 'css/');
define('CSB_IMG_URL', $plugin_url . 'img/');
// Load the actual core.
require_once CSB_INC_DIR . 'class-custom-sidebars.php';
// Include function library
if (file_exists(CSB_INC_DIR . 'external/wpmu-lib/core.php')) {
    require_once CSB_INC_DIR . 'external/wpmu-lib/core.php';
}
// Load the text domain for the plugin
lib2()->translate_plugin(CSB_LANG, CSB_LANG_DIR);
// Initialize the plugin
CustomSidebars::instance();
if (!class_exists('CustomSidebarsEmptyPlugin')) {
    class CustomSidebarsEmptyPlugin extends WP_Widget
    {
        public function CustomSidebarsEmptyPlugin()
        {
            parent::WP_Widget(false, $name = 'CustomSidebarsEmptyPlugin');
        }
        public function form($instance)
        {
            //Nothing, just a dummy plugin to display nothing
        }
        public function update($new_instance, $old_instance)
        {
            //Nothing, just a dummy plugin to display nothing
        }
    /**
     * Action handler for 'in_widget_form'
     *
     * @since  2.0
     */
    public function admin_widget_button($widget, $return, $instance)
    {
        static $Loaded = false;
        static $tax_list = array();
        static $type_list = array();
        static $role_list = array();
        static $membership_levels = array();
        static $pagetype_list = array();
        if (false === $Loaded) {
            $tax_list = get_taxonomies(array('public' => true), 'objects');
            $type_list = CustomSidebars::get_post_types('objects');
            $role_list = array_reverse(get_editable_roles());
            $membership_levels = $this->get_membership_levels();
            $membership2_items = $this->get_membership2_items();
            $pagetype_list = array('frontpage' => 'Front Page', 'home' => 'Post Index', 'single' => 'Single page', 'archive' => 'Archives', 'search' => 'Search results', 'e404' => 'Not found (404)', 'preview' => 'Preview', 'day' => 'Archive: Day', 'month' => 'Archive: Month', 'year' => 'Archive: Year');
            // Remove taxonomies without values.
            foreach ($tax_list as $index => $tax_item) {
                $tags = get_terms($tax_item->name, array('hide_empty' => false));
                if (empty($tags)) {
                    unset($tax_list[$index]);
                }
            }
        }
        $is_visible = '1' == @$_POST['csb_visible'] ? 1 : 0;
        $data = $this->get_widget_data($instance);
        $action_show = $data['action'] == 'show';
        $cond = $data['conditions'];
        ?>

		<div class="csb-visibility csb-visibility-<?php 
        echo esc_attr($widget->id);
        ?>
"
			data-widget="<?php 
        echo esc_attr($widget->option_name);
        ?>
"
			data-number="<?php 
        echo esc_attr(absint(@$widget->number));
        ?>
">
		<?php 
        /*
         * This input is only used to determine if the "visibility" button
         * should be displayed in the widget form.
         */
        ?>

		<input type="hidden" name="csb-visibility-button" value="0" />
		<?php 
        if (!isset($_POST['csb-visibility-button'])) {
            ?>

			<a href="#" class="button csb-visibility-button"><span class="dashicons dashicons-visibility"></span> <?php 
            _e('Visibility', CSB_LANG);
            ?>
</a>
		<?php 
        } else {
            ?>

			<script>jQuery(function() { jQuery('.csb-visibility-<?php 
            echo esc_js($widget->id);
            ?>
').closest('.widget').trigger('csb:update'); }); </script>
		<?php 
        }
        ?>


		<div class="csb-visibility-inner" <?php 
        if (!$is_visible) {
            ?>
style="display:none"<?php 
        }
        ?>
>
		<input type="hidden" name="csb_visible" class="csb-visible-flag" value="<?php 
        echo esc_attr($is_visible);
        ?>
" />

		<div class="csb-option-row csb-action">
			<label for="<?php 
        echo esc_attr($widget->id);
        ?>
-action" class="lbl-show-if toggle-action" <?php 
        if (!$action_show) {
            ?>
style="display:none"<?php 
        }
        ?>
><?php 
        _e('<b>Show</b> widget if:', CSB_LANG);
        ?>
</label>
			<label for="<?php 
        echo esc_attr($widget->id);
        ?>
-action" class="lbl-hide-if toggle-action" <?php 
        if ($action_show) {
            ?>
style="display:none"<?php 
        }
        ?>
><?php 
        _e('<b>Hide</b> widget if:', CSB_LANG);
        ?>
</label>
			<input type="hidden" id="<?php 
        echo esc_attr($widget->id);
        ?>
-action" name="csb_visibility[action]" value="<?php 
        echo esc_attr($data['action']);
        ?>
" />
			<i class="dashicons dashicons-plus choose-filters show-on-hover action"></i>
			<ul class="dropdown" style="display:none">
				<li class="csb-group"><?php 
        _e('Filters', CSB_LANG);
        ?>
</li>
				<li class="add-filter"
					data-for=".csb-date"
					style="display:none">
					<?php 
        _e('Date', CSB_LANG);
        ?>

				</li>
				<li class="add-filter"
					data-for=".csb-guest"
					<?php 
        if (!empty($cond['guest'])) {
            ?>
style="display:none"<?php 
        }
        ?>
>
					<?php 
        _e('Guests', CSB_LANG);
        ?>

				</li>
				<li class="add-filter"
					data-for=".csb-roles"
					<?php 
        if (!empty($cond['roles'])) {
            ?>
style="display:none"<?php 
        }
        ?>
>
					<?php 
        _e('Roles', CSB_LANG);
        ?>

				</li>
				<?php 
        if (false != $membership_levels) {
            ?>

					<li class="add-filter"
						data-for=".csb-membership">
						<?php 
            _e('Membership', CSB_LANG);
            ?>

					</li>
				<?php 
        }
        ?>

				<?php 
        if (false != $membership2_items) {
            ?>

					<li class="add-filter"
						data-for=".csb-membership2">
						<?php 
            _e('Membership2', CSB_LANG);
            ?>

					</li>
				<?php 
        }
        ?>

				<li class="add-filter"
					data-for=".csb-pagetypes"
					<?php 
        if (!empty($cond['pagetypes'])) {
            ?>
style="display:none"<?php 
        }
        ?>
>
					<?php 
        _e('Special pages', CSB_LANG);
        ?>

				</li>
				<li class="add-filter"
					data-for=".csb-posttypes"
					<?php 
        if (!empty($cond['posttypes'])) {
            ?>
style="display:none"<?php 
        }
        ?>
>
					<?php 
        _e('For posttype', CSB_LANG);
        ?>

				</li>
				<li class="csb-group"><?php 
        _e('Taxonomy', CSB_LANG);
        ?>
</li>
				<?php 
        foreach ($tax_list as $tax_item) {
            $row_id = 'tax-' . $tax_item->name;
            ?>

					<li class="add-filter"
						data-for=".csb-<?php 
            echo esc_attr($row_id);
            ?>
"
						<?php 
            if (!empty($cond[$row_id])) {
                ?>
style="display:none"<?php 
            }
            ?>
>
						<?php 
            echo esc_html($tax_item->labels->name);
            ?>

					</li>
					<?php 
        }
        ?>

			</ul>
		</div>

		<?php 
        $block_name = 'csb_visibility[conditions]';
        ?>


		<div class="csb-option-row csb-always" <?php 
        if (!$data['always']) {
            ?>
style="display:none"<?php 
        }
        ?>
>
			<label><?php 
        _e('Always', CSB_LANG);
        ?>
</label>
		</div>

		<?php 
        /* DATE */
        /* ?>
        		<div class="csb-option-row csb-date" style="display:none">
        			<label for="<?php echo esc_attr( $widget->id ); ?>-date">
        				<span class="csb-and" style="display:none"><?php _e( 'AND', CSB_LANG ); ?></span>
        				<?php _e( 'On these dates', CSB_LANG ); ?>
        			</label>
        			<i class="dashicons dashicons-trash clear-filter show-on-hover action"></i>
        			<input type="text"
        				id="<?php echo esc_attr( $widget->id ); ?>-date"
        				name="<?php echo esc_attr( $block_name ); ?>[date][from]"
        				value="<?php echo esc_attr( @$cond['date']['from'] ); ?>" />
        			<input type="text"
        				id="<?php echo esc_attr( $widget->id ); ?>-date-to"
        				name="<?php echo esc_attr( $block_name ); ?>[date][to]"
        				value="<?php echo esc_attr( @$cond['date']['to'] ); ?>" />
        		</div>
        		<?php */
        ?>


		<?php 
        /* GUEST */
        ?>

		<div class="csb-option-row csb-guest" <?php 
        if (empty($cond['guest'])) {
            ?>
style="display:none"<?php 
        }
        ?>
>
			<label for="<?php 
        echo esc_attr($widget->id);
        ?>
-guest1" style="padding-top:10px;margin-bottom:0">
				<input id="<?php 
        echo esc_attr($widget->id);
        ?>
-guest1" type="radio" name="<?php 
        echo esc_attr($block_name);
        ?>
[guest][]" value="guest" <?php 
        checked(in_array('guest', $cond['guest']));
        ?>
 />
				<span class="csb-and" style="display:none"><?php 
        _e('AND', CSB_LANG);
        ?>
</span>
				<?php 
        _e('User is not logged-in (Guest)', CSB_LANG);
        ?>
<br />
			</label>
			<label for="<?php 
        echo esc_attr($widget->id);
        ?>
-guest2" style="border:0;margin-bottom:0">
				<input id="<?php 
        echo esc_attr($widget->id);
        ?>
-guest2" type="radio" name="<?php 
        echo esc_attr($block_name);
        ?>
[guest][]" value="member" <?php 
        checked(in_array('member', $cond['guest']));
        ?>
  />
				<span class="csb-and" style="display:none"><?php 
        _e('AND', CSB_LANG);
        ?>
</span>
				<?php 
        _e('User is logged-in (Member)', CSB_LANG);
        ?>

			</label>
			<i class="dashicons dashicons-trash clear-filter show-on-hover action"></i>
		</div>

		<?php 
        /* ROLES */
        ?>

		<div class="csb-option-row csb-roles" <?php 
        if (empty($cond['roles'])) {
            ?>
style="display:none"<?php 
        }
        ?>
>
			<label for="<?php 
        echo esc_attr($widget->id);
        ?>
-roles">
				<span class="csb-and" style="display:none"><?php 
        _e('AND', CSB_LANG);
        ?>
</span>
				<?php 
        _e('User has role', CSB_LANG);
        ?>

			</label>
			<i class="dashicons dashicons-trash clear-filter show-on-hover action"></i>
			<select id="<?php 
        echo esc_attr($widget->id);
        ?>
-roles" name="<?php 
        echo esc_attr($block_name);
        ?>
[roles][]" multiple="multiple">
			<?php 
        foreach ($role_list as $role => $details) {
            ?>

				<?php 
            $name = translate_user_role($details['name']);
            ?>

				<?php 
            $is_selected = in_array($role, $cond['roles']);
            ?>

				<option <?php 
            selected($is_selected, true);
            ?>
 value="<?php 
            echo esc_attr($role);
            ?>
">
					<?php 
            echo esc_html($name);
            ?>

				</option>
			<?php 
        }
        ?>

			</select>
		</div>

		<?php 
        /* MEMBERSHIP */
        ?>

		<?php 
        if (is_array($membership_levels)) {
            ?>

		<div class="csb-option-row csb-membership" <?php 
            if (empty($cond['membership'])) {
                ?>
style="display:none"<?php 
            }
            ?>
>
			<label for="<?php 
            echo esc_attr($widget->id);
            ?>
-membership">
				<span class="csb-and" style="display:none"><?php 
            _e('AND', CSB_LANG);
            ?>
</span>
				<?php 
            _e('User has Membership Level', CSB_LANG);
            ?>

			</label>
			<i class="dashicons dashicons-trash clear-filter show-on-hover action"></i>
			<select id="<?php 
            echo esc_attr($widget->id);
            ?>
-membership" name="<?php 
            echo esc_attr($block_name);
            ?>
[membership][]" multiple="multiple">
			<?php 
            foreach ($membership_levels as $level) {
                ?>

				<?php 
                $is_selected = in_array($level['id'], $cond['membership']);
                ?>

				<option <?php 
                selected($is_selected);
                ?>
 value="<?php 
                echo esc_attr($level['id']);
                ?>
">
					<?php 
                echo esc_html($level['level_title']);
                ?>

					<?php 
                if (!$level['level_active']) {
                    _e('(inactive)', CSB_LANG);
                }
                ?>

				</option>
			<?php 
            }
            ?>

			</select>
		</div>
		<?php 
        }
        ?>


		<?php 
        /* MEMBERSHIP2 (PROTECTED CONTENT) */
        ?>

		<?php 
        if (is_array($membership2_items)) {
            ?>

		<div class="csb-option-row csb-membership2" <?php 
            if (empty($cond['membership2'])) {
                ?>
style="display:none"<?php 
            }
            ?>
>
			<label for="<?php 
            echo esc_attr($widget->id);
            ?>
-membership2">
				<span class="csb-and" style="display:none"><?php 
            _e('AND', CSB_LANG);
            ?>
</span>
				<?php 
            _e('User has Membership', CSB_LANG);
            ?>

			</label>
			<i class="dashicons dashicons-trash clear-filter show-on-hover action"></i>
			<select id="<?php 
            echo esc_attr($widget->id);
            ?>
-membership2" name="<?php 
            echo esc_attr($block_name);
            ?>
[membership2][]" multiple="multiple">
			<?php 
            foreach ($membership2_items as $item) {
                ?>

				<?php 
                $is_selected = in_array($item->id, $cond['membership2']);
                ?>

				<option <?php 
                selected($is_selected);
                ?>
 value="<?php 
                echo esc_attr($item->id);
                ?>
">
					<?php 
                echo esc_html($item->name);
                ?>

					<?php 
                if (!$item->active) {
                    _e('(inactive)', CSB_LANG);
                }
                ?>

				</option>
			<?php 
            }
            ?>

			</select>
		</div>
		<?php 
        }
        ?>


		<?php 
        /* PAGE TYPES */
        ?>

		<div class="csb-option-row csb-pagetypes" <?php 
        if (empty($cond['pagetypes'])) {
            ?>
style="display:none"<?php 
        }
        ?>
>
			<label for="<?php 
        echo esc_attr($widget->id);
        ?>
-pagetypes">
				<span class="csb-and" style="display:none"><?php 
        _e('AND', CSB_LANG);
        ?>
</span>
				<?php 
        _e('On these special pages', CSB_LANG);
        ?>

			</label>
			<i class="dashicons dashicons-trash clear-filter show-on-hover action"></i>
			<select id="<?php 
        echo esc_attr($widget->id);
        ?>
-pagetypes" name="<?php 
        echo esc_attr($block_name);
        ?>
[pagetypes][]" multiple="multiple">
			<?php 
        foreach ($pagetype_list as $type => $name) {
            ?>

				<?php 
            $is_selected = in_array($type, $cond['pagetypes']);
            ?>

				<option <?php 
            selected($is_selected);
            ?>
 value="<?php 
            echo esc_attr($type);
            ?>
">
					<?php 
            echo esc_html($name);
            ?>

				</option>
			<?php 
        }
        ?>

			</select>
		</div>

		<?php 
        /* POSTTYPES */
        ?>

		<div class="csb-option-row csb-posttypes"
			<?php 
        if (empty($cond['posttypes'])) {
            ?>
style="display:none"<?php 
        }
        ?>
>

			<label for="<?php 
        echo esc_attr($widget->id);
        ?>
-posttypes">
				<span class="csb-and" style="display:none"><?php 
        _e('AND', CSB_LANG);
        ?>
</span>
				<?php 
        _e('On any page of these types', CSB_LANG);
        ?>

			</label>
			<i class="dashicons dashicons-trash clear-filter show-on-hover action"></i>
			<select class="posttype"
				id="<?php 
        echo esc_attr($widget->id);
        ?>
-posttypes"
				name="<?php 
        echo esc_attr($block_name);
        ?>
[posttypes][]"
				multiple="multiple">
			<?php 
        foreach ($type_list as $type_item) {
            ?>

				<?php 
            $is_selected = in_array($type_item->name, $cond['posttypes']);
            ?>

				<option <?php 
            selected($is_selected);
            ?>
 value="<?php 
            echo esc_attr($type_item->name);
            ?>
">
					<?php 
            echo esc_html($type_item->labels->name);
            ?>

				</option>
			<?php 
        }
        ?>

			</select>

			<?php 
        /* SPECIFIC POSTS */
        ?>

			<?php 
        foreach ($type_list as $type_item) {
            $row_id = 'pt-' . $type_item->name;
            $lbl_all = sprintf(__('Only for specific %s', CSB_LANG), $type_item->labels->name);
            $lbl_single = sprintf(__('Only these %s:', CSB_LANG), $type_item->labels->name);
            $is_selected = in_array($type_item->name, $cond['posttypes']);
            $ajax_url = admin_url('admin-ajax.php?action=cs-ajax&do=visibility&posttype=' . $type_item->name);
            $sel = array();
            if (!empty($cond[$row_id])) {
                $posts = get_posts(array('post_type' => $type_item->name, 'order_by' => 'title', 'order' => 'ASC', 'numberposts' => '0', 'include' => implode(',', $cond[$row_id])));
                foreach ($posts as $post) {
                    $sel[] = $post->ID . '::' . str_replace('::', ':', $post->post_title);
                }
            }
            ?>

				<div class="csb-detail-row csb-<?php 
            echo esc_attr($row_id);
            ?>
"
					<?php 
            if (!$is_selected) {
                ?>
style="display:none"<?php 
            }
            ?>
>

					<label for="<?php 
            echo esc_attr($widget->id);
            ?>
-<?php 
            echo esc_attr($row_id);
            ?>
">
						<input type="checkbox"
							id="<?php 
            echo esc_attr($widget->id);
            ?>
-<?php 
            echo esc_attr($row_id);
            ?>
"
							<?php 
            checked(!empty($cond[$row_id]));
            ?>

							data-lbl-all="<?php 
            echo esc_attr($lbl_all);
            ?>
"
							data-lbl-single="<?php 
            echo esc_attr($lbl_single);
            ?>
" />
						<span class="lbl">
							<?php 
            echo esc_html(empty($cond[$row_id]) ? $lbl_all : $lbl_single);
            ?>

						</span>
					</label>
					<div class="detail" <?php 
            if (empty($cond[$row_id])) {
                ?>
style="display:none"<?php 
            }
            ?>
>

						<input type="hidden"
							name="<?php 
            echo esc_attr($block_name);
            ?>
[<?php 
            echo esc_attr($row_id);
            ?>
]"
							value="<?php 
            echo esc_attr(implode(',', $sel));
            ?>
"
							data-select-ajax="<?php 
            echo esc_url($ajax_url);
            ?>
" />
					</div>
				</div>
			<?php 
        }
        ?>

		</div>

		<?php 
        /* SPECIFIC TAXONOMY */
        ?>

		<?php 
        foreach ($tax_list as $tax_item) {
            $row_id = 'tax-' . $tax_item->name;
            $ajax_url = admin_url('admin-ajax.php?action=cs-ajax&do=visibility&tag=' . $tax_item->name);
            $sel = array();
            if (!empty($cond[$row_id])) {
                $tags = get_terms($tax_item->name, array('include' => implode(',', $cond[$row_id]), 'hide_empty' => false));
                foreach ($tags as $tag) {
                    $sel[] = $tag->term_id . '::' . str_replace('::', ':', $tag->name);
                }
            }
            ?>

			<div class="csb-option-row csb-<?php 
            echo esc_attr($row_id);
            ?>
"
				<?php 
            if (empty($cond[$row_id])) {
                ?>
style="display:none"<?php 
            }
            ?>
>

				<label for="<?php 
            echo esc_attr($widget->id);
            ?>
-<?php 
            echo esc_attr($row_id);
            ?>
">
					<span class="csb-and" style="display:none"><?php 
            _e('AND', CSB_LANG);
            ?>
</span>
					<?php 
            echo esc_html($tax_item->labels->name);
            ?>

					</label>
				<i class="dashicons dashicons-trash clear-filter show-on-hover action"></i>

				<input type="hidden"
					id="<?php 
            echo esc_attr($widget->id);
            ?>
-<?php 
            echo esc_attr($row_id);
            ?>
"
					name="<?php 
            echo esc_attr($block_name);
            ?>
[<?php 
            echo esc_attr($row_id);
            ?>
]"
					value="<?php 
            echo esc_attr(implode(',', $sel));
            ?>
"
					data-select-ajax="<?php 
            echo esc_url($ajax_url);
            ?>
" />
			</div>
			<?php 
        }
        ?>


		</div>
		</div>
		<?php 
    }
 /**
  * Returns a list of all sidebars available.
  * Depending on the parameter this will be either all sidebars or only
  * sidebars defined by the current theme.
  *
  * @param string $type [all|cust|theme] What kind of sidebars to return.
  */
 public static function get_sidebars($type = 'theme')
 {
     global $wp_registered_sidebars;
     $allsidebars = CustomSidebars::sort_sidebars_by_name($wp_registered_sidebars);
     $result = array();
     // Remove inactive sidebars.
     foreach ($allsidebars as $sb_id => $sidebar) {
         if (false !== strpos($sidebar['class'], 'inactive-sidebar')) {
             unset($allsidebars[$sb_id]);
         }
     }
     ksort($allsidebars);
     if ('all' == $type) {
         $result = $allsidebars;
     } elseif ('cust' == $type) {
         foreach ($allsidebars as $key => $sb) {
             // Only keep custom sidebars in the results.
             if (substr($key, 0, 3) == self::$sidebar_prefix) {
                 $result[$key] = $sb;
             }
         }
     } elseif ('theme' == $type) {
         foreach ($allsidebars as $key => $sb) {
             // Remove custom sidebars from results.
             if (substr($key, 0, 3) != self::$sidebar_prefix) {
                 $result[$key] = $sb;
             }
         }
     }
     return $result;
 }
 /**
  * Renders the Custom Sidebars form.
  *
  * @param  int $post_id The post-ID to display
  * @param  string $type Which form to display. 'metabox/quick-edit/col-sidebars'.
  */
 protected function print_sidebars_form($post_id, $type = 'metabox')
 {
     global $wp_registered_sidebars;
     $available = CustomSidebars::sort_sidebars_by_name($wp_registered_sidebars);
     $replacements = self::get_replacements($post_id);
     $sidebars = self::get_options('modifiable');
     $selected = array();
     if (!empty($sidebars)) {
         foreach ($sidebars as $s) {
             if (isset($replacements[$s])) {
                 $selected[$s] = $replacements[$s];
             } else {
                 $selected[$s] = '';
             }
         }
     }
     switch ($type) {
         case 'col-sidebars':
             include CSB_VIEWS_DIR . 'col-sidebars.php';
             break;
         case 'quick-edit':
             include CSB_VIEWS_DIR . 'quick-edit.php';
             break;
         default:
             include CSB_VIEWS_DIR . 'metabox.php';
             break;
     }
 }