2013-08-09 13:05:55 -04:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This function, hooked to display on the category/tag edit forms,
|
|
|
|
|
* adds new fields to select a sidebar. The variables $tag and $taxonomy
|
|
|
|
|
* are passed via the hook so that we can use them.
|
|
|
|
|
*/
|
2013-08-09 13:07:35 -04:00
|
|
|
function ss_term_edit_init() {
|
2013-08-09 13:11:17 -04:00
|
|
|
|
2013-08-09 13:09:21 -04:00
|
|
|
$taxonomies = ss_get_taxonomies();
|
2013-08-09 13:11:17 -04:00
|
|
|
|
|
|
|
|
if ( ! empty( $taxonomies ) && is_admin() && is_array( $taxonomies ) ) {
|
|
|
|
|
|
2013-08-09 13:07:35 -04:00
|
|
|
foreach( $taxonomies as $tax )
|
|
|
|
|
add_action( "{$tax}_edit_form", 'ss_term_sidebar', 9, 2 );
|
2013-08-09 13:11:17 -04:00
|
|
|
|
2013-08-09 13:07:35 -04:00
|
|
|
}
|
2013-08-09 13:11:17 -04:00
|
|
|
|
2013-08-09 13:07:35 -04:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 13:05:55 -04:00
|
|
|
function ss_term_sidebar($tag, $taxonomy) {
|
2013-08-09 13:11:17 -04:00
|
|
|
|
2013-08-09 13:05:55 -04:00
|
|
|
// Merge Defaults to prevent notices
|
|
|
|
|
$tag->meta = wp_parse_args( $tag->meta, array( '_ss_sidebar' => '', '_ss_sidebar_alt' => '' ) );
|
|
|
|
|
|
|
|
|
|
// Pull custom sidebars
|
|
|
|
|
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
2013-08-09 13:11:17 -04:00
|
|
|
|
2013-08-09 13:05:55 -04:00
|
|
|
?>
|
|
|
|
|
|
2013-08-09 13:35:43 -04:00
|
|
|
<h3><?php _e( 'Sidebar Options', 'ss' ); ?></h3>
|
2013-08-09 13:05:55 -04:00
|
|
|
<table class="form-table">
|
2013-08-09 13:11:17 -04:00
|
|
|
|
2013-08-09 13:05:55 -04:00
|
|
|
<tr class="form-field">
|
2013-08-09 13:35:43 -04:00
|
|
|
<th scope="row" valign="top"><label for="meta[_ss_sidebar]"><?php _e( 'Primary Sidebar', 'ss' ); ?></label></th>
|
2013-08-09 13:05:55 -04:00
|
|
|
<td>
|
|
|
|
|
<select name="meta[_ss_sidebar]" id="meta[_ss_sidebar]" style="padding-right: 10px;">
|
2013-08-09 13:35:43 -04:00
|
|
|
<option value=""><?php _e( 'Default', 'ss' ); ?></option>
|
2013-08-09 13:05:55 -04:00
|
|
|
<?php
|
2013-08-09 13:35:43 -04:00
|
|
|
foreach ( (array) $_sidebars as $id => $info ) {
|
2013-08-09 13:05:55 -04:00
|
|
|
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, $tag->meta['_ss_sidebar'] , false), esc_html( $info['name'] ) );
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
</select>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
2013-08-09 13:09:21 -04:00
|
|
|
<?php
|
|
|
|
|
// don't show the option if there are no 3 column layouts registered
|
|
|
|
|
if ( ss_has_3_column_layouts() ) {
|
2013-08-09 13:11:17 -04:00
|
|
|
?>
|
2013-08-09 13:05:55 -04:00
|
|
|
<tr class="form-field">
|
2013-08-09 13:35:43 -04:00
|
|
|
<th scope="row" valign="top"><label for="meta[_ss_sidebar_alt]"><?php _e( 'Secondary Sidebar', 'ss' ); ?></label></th>
|
2013-08-09 13:05:55 -04:00
|
|
|
<td>
|
|
|
|
|
<select name="meta[_ss_sidebar_alt]" id="meta[_ss_sidebar_alt]" style="padding-right: 10px;">
|
2013-08-09 13:35:43 -04:00
|
|
|
<option value=""><?php _e( 'Default', 'ss' ); ?></option>
|
2013-08-09 13:05:55 -04:00
|
|
|
<?php
|
2013-08-09 13:35:43 -04:00
|
|
|
foreach ( (array) $_sidebars as $id => $info ) {
|
2013-08-09 13:05:55 -04:00
|
|
|
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, $tag->meta['_ss_sidebar_alt'] , false), esc_html( $info['name'] ) );
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
</select>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
2013-08-09 13:09:21 -04:00
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
?>
|
2013-08-09 13:05:55 -04:00
|
|
|
</table>
|
2013-08-09 13:11:17 -04:00
|
|
|
|
2013-08-09 13:05:55 -04:00
|
|
|
<?php
|
2013-08-09 13:35:43 -04:00
|
|
|
}
|