public static function init()
 {
     //go through each sidebar and register it
     $sidebars = ht_sidebar_generator::get_sidebars();
     if (is_array($sidebars)) {
         $z = 1;
         foreach ($sidebars as $id => $sidebar) {
             $id = sanitize_title($sidebar);
             register_sidebar(array('name' => $sidebar, 'id' => 'ht_' . $id, 'before_widget' => '<div id="%1$s" class="widget ' . $id . ' %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title"><span>', 'after_title' => '</span></h3>'));
             $z++;
         }
     }
 }
}
add_action('save_post', 'save_custom_slideshow_meta');
/* Sidebar */
/*-----------------------------------------------------------------------------------*/
if (!function_exists('add_ht_custom_sidebar_cb')) {
    function add_ht_custom_sidebar_cb()
    {
        add_meta_box('ht_custom_sidebar_cb', 'Sidebar Options', 'show_ht_custom_sidebar_cb', 'page', 'side', 'low');
        add_meta_box('ht_custom_sidebar_cb', 'Sidebar Options', 'show_ht_custom_sidebar_cb', 'post', 'side', 'low');
        add_meta_box('ht_custom_sidebar_cb', 'Sidebar Options', 'show_ht_custom_sidebar_cb', 'product', 'side', 'low');
    }
}
add_action('add_meta_boxes', 'add_ht_custom_sidebar_cb');
// Field Array
$prefix = '_';
$sidebars = ht_sidebar_generator::get_sidebars();
$sidebars_array = array('default' => array('label' => __('Select a Sidebar', 'highthemes'), 'value' => ''));
if (is_array($sidebars)) {
    foreach ($sidebars as $key => $sidebar) {
        $sidebars_array[$key]['label'] = $sidebar;
        $sidebars_array[$key]['value'] = $key;
    }
}
$custom_sidebar_fields = array(array('label' => __('Sidebar Alignment', 'highthemes'), 'desc' => '', 'id' => $prefix . 'sidebar_alignment', 'type' => 'select', 'options' => array('select' => array('label' => __('Select Sidebar Alignment', 'highthemes'), 'value' => ''), 'Right' => array('label' => __('Right Sidebar', 'highthemes'), 'value' => 'has-rightsidebar'), 'Left' => array('label' => __('Left Sidebar', 'highthemes'), 'value' => 'has-leftsidebar'))), array('label' => __('Custom Sidebar', 'highthemes'), 'desc' => '', 'id' => $prefix . 'selected_sidebar', 'type' => 'select', 'options' => $sidebars_array));
if (!function_exists('show_ht_custom_sidebar_cb')) {
    function show_ht_custom_sidebar_cb()
    {
        global $custom_sidebar_fields, $post;
        echo '<input type="hidden" name="ht_custom_sidebar_nonce" value="' . wp_create_nonce(basename(__FILE__)) . '" />';
        foreach ($custom_sidebar_fields as $field) {
            $meta = get_post_meta($post->ID, $field['id'], true);
Beispiel #3
0
function ht_add_sidebars()
{
    $hight_options['sidebar'][] = array("name" => __("Sidebar Name:", 'highthemes'), "desc" => __("Enter a name for the new sidebar.", 'highthemes'), "id" => "ht_sidebar_name", "std" => "", "type" => "text");
    $output = '<table class="form-table">
<tbody>';
    foreach ($hight_options['sidebar'] as $index => $field) {
        switch ($field['type']) {
            case 'text':
                $val = stripslashes($field['std']);
                if (get_option($field['id']) != "") {
                    $val = stripslashes(htmlspecialchars(get_option($field['id'])));
                }
                if (isset($field['options'])) {
                    $t_options = $field['options'];
                    $output .= '
					<tr valign="top">
					<th scope="row">
					<label for="' . $field['id'] . '">' . $field['name'] . '</label></th>
					<td>
					<input class="' . $t_options['class'] . '" name="' . $field['id'] . '" id="' . $field['id'] . '" type="' . $field['type'] . '" value="' . $val . '" />

					<span class="description">' . $field['desc'] . '</span>
					</td>
					</tr>
							';
                } else {
                    $output .= '
					<tr valign="top">
					<th scope="row">
					<label for="' . $field['id'] . '">' . $field['name'] . '</label></th>

					<td><input class="regular-text" name="' . $field['id'] . '" id="' . $field['id'] . '" type="' . $field['type'] . '" value="' . $val . '" />

					<br />
					<span class="description">' . $field['desc'] . '</span>
					</td>
					</tr>
						';
                }
                break;
        }
    }
    $output .= '</tbody></table>';
    echo $output;
    ?>
<table class="form-table">
<tbody>
<tr valign="top" style="">
					<th scope="row">&nbsp;
			</th>
			
			<td>
			<span >&nbsp;</span>
			</td>
			</tr>

<tr valign="top" style="background:#eee;border-bottom:1px solid #999">
					<th scope="row"><strong>
			Custom Sidebars</strong></th>
			<td>
			<span class="description"><?php 
    _e("Here's the list of available sidebars", "highthemes");
    ?>
</span>
			</td>
			</tr>   
            
<?php 
    $get_sidebar_options = ht_sidebar_generator::get_sidebars();
    $i = 0;
    if (count($get_sidebar_options) > 0 && is_array($get_sidebar_options)) {
        foreach ($get_sidebar_options as $id => $sidebar_gen) {
            ?>
			<tr valign="top">
			<th scope="row"><?php 
            echo $sidebar_gen;
            ?>
</th>
			<td>
			<span class="description"><input type="button" onClick="window.location='admin.php?page=sidebars&sn=<?php 
            echo $id;
            ?>
';"  class="button" value="<?php 
            _e("Delete", "highthemes");
            ?>
" /></span>
			</td>
			</tr>                 
            
 <?php 
            $i++;
        }
    }
    ?>
              
</tbody>
</table>
    <?php 
}