Files
genesis-simple-sidebars/includes/term.php
T

70 lines
2.2 KiB
PHP
Raw Normal View History

2013-08-26 20:05:25 -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.
*/
function ss_term_edit_init() {
$taxonomies = ss_get_taxonomies();
if ( ! empty( $taxonomies ) && is_admin() && is_array( $taxonomies ) ) {
foreach( $taxonomies as $tax )
add_action( "{$tax}_edit_form", 'ss_term_sidebar', 9, 2 );
}
}
function ss_term_sidebar($tag, $taxonomy) {
2013-08-26 20:10:32 -04:00
//* Merge Defaults to prevent notices
2013-08-26 20:05:25 -04:00
$tag->meta = wp_parse_args( $tag->meta, array( '_ss_sidebar' => '', '_ss_sidebar_alt' => '' ) );
2013-08-26 20:10:32 -04:00
//* Pull custom sidebars
2013-08-26 20:05:25 -04:00
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
?>
2015-09-29 17:18:50 -04:00
<h3><?php _e( 'Sidebar Options', 'genesis-simple-sidebars' ); ?></h3>
2013-08-26 20:05:25 -04:00
<table class="form-table">
<tr class="form-field">
2015-09-29 17:18:50 -04:00
<th scope="row" valign="top"><label for="genesis-meta[_ss_sidebar]"><?php _e( 'Primary Sidebar', 'genesis-simple-sidebars' ); ?></label></th>
2013-08-26 20:05:25 -04:00
<td>
<select name="genesis-meta[_ss_sidebar]" id="genesis-meta[_ss_sidebar]" style="padding-right: 10px;">
2015-09-29 17:18:50 -04:00
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
2013-08-26 20:05:25 -04:00
<?php
foreach ( (array) $_sidebars as $id => $info ) {
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, $tag->meta['_ss_sidebar'] , false), esc_html( $info['name'] ) );
}
?>
</select>
</td>
</tr>
<?php
2013-08-26 20:10:32 -04:00
//* don't show the option if there are no 3 column layouts registered
2013-08-26 20:05:25 -04:00
if ( ss_has_3_column_layouts() ) {
?>
<tr class="form-field">
2015-09-29 17:18:50 -04:00
<th scope="row" valign="top"><label for="genesis-meta[_ss_sidebar_alt]"><?php _e( 'Secondary Sidebar', 'genesis-simple-sidebars' ); ?></label></th>
2013-08-26 20:05:25 -04:00
<td>
<select name="genesis-meta[_ss_sidebar_alt]" id="genesis-meta[_ss_sidebar_alt]" style="padding-right: 10px;">
2015-09-29 17:18:50 -04:00
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
2013-08-26 20:05:25 -04:00
<?php
foreach ( (array) $_sidebars as $id => $info ) {
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>
<?php
}
?>
</table>
<?php
}