/** * 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); } } }
/** * Checks to see if simple sidebar exists * * @return string/boolean String of sidebar key OR false if none found */ function wsm_child_has_ss_sidebar($sidebar_key = '_ss_sidebar') { static $taxonomies = null; if (is_singular() && ($sidebar_key = genesis_get_custom_field($sidebar_key))) { return $sidebar_key; } if (is_category()) { $term = get_term(get_query_var('cat'), 'category'); if (isset($term->meta[$sidebar_key])) { return $term->meta[$sidebar_key]; } } if (is_tag()) { $term = get_term(get_query_var('tag_id'), 'post_tag'); if (isset($term->meta[$sidebar_key])) { return $term->meta[$sidebar_key]; } } if (is_tax()) { if (function_exists('ss_do_sidebar')) { if (null === $taxonomies) { $taxonomies = ss_get_taxonomies(); } foreach ($taxonomies as $tax) { if ('post_tag' == $tax || 'category' == $tax) { continue; } if (is_tax($tax)) { $obj = get_queried_object(); $term = get_term($obj->term_id, $tax); if (isset($term->meta[$sidebar_key])) { return $term->meta[$sidebar_key]; } break; } } } } return false; }
/** * Create a Genesis Simple Sidebars conditional tag which * allows content to be conditionally placed on pages and posts * that have specific simple sidebars assigned to them. * * @since 1.2 */ function dynamik_is_ss($sidebar_id = 'sb-id') { if (!defined('SS_SETTINGS_FIELD')) { return false; } static $taxonomies = null; if (is_singular()) { if ($sidebar_id == genesis_get_custom_field('_ss_sidebar')) { return true; } } if (is_category()) { $term = get_term(get_query_var('cat'), 'category'); if (isset($term->meta['_ss_sidebar']) && $sidebar_id == $term->meta['_ss_sidebar']) { return true; } } if (is_tag()) { $term = get_term(get_query_var('tag_id'), 'post_tag'); if (isset($term->meta['_ss_sidebar']) && $sidebar_id == $term->meta['_ss_sidebar']) { return true; } } if (is_tax()) { if (null === $taxonomies) { $taxonomies = ss_get_taxonomies(); } foreach ($taxonomies as $tax) { if ('post_tag' == $tax || 'category' == $tax) { continue; } if (is_tax($tax)) { $obj = get_queried_object(); $term = get_term($obj->term_id, $tax); if (isset($term->meta['_ss_sidebar']) && $sidebar_id == $term->meta['_ss_sidebar']) { return true; } break; } } } return false; }