### Manage Post/Page Sidebar Assignments with Meta Fields (PHP) Source: https://context7.com/studiopress/genesis-simple-sidebars/llms.txt This snippet demonstrates how to use PHP to get, set, and delete custom sidebar assignments for individual posts and pages using specific meta keys. ```php 'Primary Sidebar', '_ss_sidebar_alt' => 'Secondary Sidebar', '_ss_header' => 'Header Right Widget Area' ]; // Get sidebar assignment for a specific post $post_id = get_the_ID(); $primary_sidebar = genesis_get_custom_field( '_ss_sidebar', $post_id ); $secondary_sidebar = genesis_get_custom_field( '_ss_sidebar_alt', $post_id ); $header_sidebar = genesis_get_custom_field( '_ss_header', $post_id ); // Programmatically set sidebar for a post update_post_meta( $post_id, '_ss_sidebar', 'my-custom-sidebar' ); update_post_meta( $post_id, '_ss_sidebar_alt', 'another-sidebar' ); update_post_meta( $post_id, '_ss_header', 'header-widget-area' ); // Remove custom sidebar assignment (use default) delete_post_meta( $post_id, '_ss_sidebar' ); ``` -------------------------------- ### Get Public Taxonomies for Sidebar Assignment (PHP) Source: https://context7.com/studiopress/genesis-simple-sidebars/llms.txt The `get_public_taxonomies()` method returns an array of public taxonomies available for sidebar assignment. This list can be modified using the `genesis_simple_sidebars_taxonomies` filter to include custom taxonomies or exclude existing ones. ```php core->get_public_taxonomies(); // Default includes: category, post_tag, and other public taxonomies // Returns array of taxonomy names: ['category', 'post_tag', 'product_cat', ...] // Filter to add custom taxonomy support add_filter( 'genesis_simple_sidebars_taxonomies', function( $taxonomies ) { // Add a custom taxonomy $taxonomies[] = 'my_custom_taxonomy'; // Remove a taxonomy $taxonomies = array_diff( $taxonomies, ['post_tag'] ); return $taxonomies; }); ?> ``` -------------------------------- ### Access Genesis Simple Sidebars Plugin Instance (PHP) Source: https://context7.com/studiopress/genesis-simple-sidebars/llms.txt The `genesis_simple_sidebars()` helper function provides access to the main plugin instance. This instance allows interaction with core functionality, admin settings, and metadata components. It's essential for accessing other plugin features programmatically. ```php settings_field; // 'ss-settings' $textdomain = $plugin->plugin_textdomain; // 'genesis-simple-sidebars' // Access component objects $core = $plugin->core; // Genesis_Simple_Sidebars_Core instance $admin = $plugin->admin; // Genesis_Simple_Sidebars_Admin instance (admin only) $entry = $plugin->entry; // Genesis_Simple_Sidebars_Entry instance (admin only) $term = $plugin->term; // Genesis_Simple_Sidebars_Term instance (admin only) ?> ``` -------------------------------- ### Sidebar Output Functions (Backward Compatibility) (PHP) Source: https://context7.com/studiopress/genesis-simple-sidebars/llms.txt The plugin provides `ss_do_sidebar()` and `ss_do_sidebar_alt()` for primary and secondary sidebar output, respectively. These functions maintain backward compatibility while enabling the plugin's sidebar swapping functionality. They are automatically hooked into Genesis but can be called directly. ```php ``` -------------------------------- ### Implement Custom Sidebar Logic with Widget Swapping Filter (PHP) Source: https://context7.com/studiopress/genesis-simple-sidebars/llms.txt This PHP code demonstrates how to use the `sidebars_widgets` filter to dynamically change widget content or sidebar assignments based on specific conditions, such as page type or user login status. ```php settings_field; // 'ss-settings' // Get all sidebars directly from the database $sidebars = get_option( 'ss-settings' ); // Structure of stored sidebars: // [ // 'sidebar-id-1' => ['name' => 'Sidebar Name', 'description' => 'Description'], // 'sidebar-id-2' => ['name' => 'Another Sidebar', 'description' => 'Another description'] // ] // Programmatically add a new sidebar $sidebars = get_option( 'ss-settings', [] ); $sidebars['my-new-sidebar'] = [ 'name' => 'My New Sidebar', 'description' => 'A programmatically created sidebar' ]; update_option( 'ss-settings', $sidebars ); // Delete a sidebar programmatically unset( $sidebars['my-new-sidebar'] ); update_option( 'ss-settings', $sidebars ); ``` -------------------------------- ### Add Custom Post Type Support for Sidebars (PHP) Source: https://context7.com/studiopress/genesis-simple-sidebars/llms.txt This PHP code illustrates how to enable Genesis Simple Sidebars functionality for custom post types, either during registration or by adding support to existing types. ```php 'Products', 'public' => true, 'supports' => [ 'title', 'editor', 'thumbnail', 'genesis-simple-sidebars' // Enable sidebar selection metabox ] ]); // Or add support to an existing post type add_post_type_support( 'portfolio', 'genesis-simple-sidebars' ); // Check if a post type supports simple sidebars if ( post_type_supports( 'product', 'genesis-simple-sidebars' ) ) { echo 'Product post type has sidebar selection enabled'; } ``` -------------------------------- ### Retrieve Registered Custom Sidebars (PHP) Source: https://context7.com/studiopress/genesis-simple-sidebars/llms.txt The `get_sidebars()` method retrieves all custom sidebars created via the plugin. It returns an associative array where keys are sidebar IDs and values contain sidebar names and descriptions. An optional argument can force a refresh from the database, bypassing cache. ```php core->get_sidebars(); // Example output structure: // [ // 'custom-sidebar-1' => [ // 'name' => 'Blog Sidebar', // 'description' => 'Sidebar for blog posts' // ], // 'product-sidebar' => [ // 'name' => 'Product Sidebar', // 'description' => 'Sidebar for WooCommerce products' // ] // ] // Iterate through sidebars foreach ( $sidebars as $sidebar_id => $info ) { echo 'ID: ' . $sidebar_id . "\n"; echo 'Name: ' . $info['name'] . "\n"; echo 'Description: ' . $info['description'] . "\n"; } // Force refresh from database (bypass cache) $fresh_sidebars = genesis_simple_sidebars()->core->get_sidebars( false ); ?> ``` -------------------------------- ### Check for 3-Column Layout Support (PHP) Source: https://context7.com/studiopress/genesis-simple-sidebars/llms.txt The `has_3_column_layout()` method checks if the active Genesis theme supports any 3-column layouts. This is crucial for determining if secondary sidebar options are available and should be displayed. It returns a boolean value. ```php core->has_3_column_layout(); if ( $has_three_columns ) { // Show secondary sidebar options echo 'Three-column layouts are available'; // Valid layouts: content-sidebar-sidebar, sidebar-content-sidebar, sidebar-sidebar-content } else { // Only primary sidebar is available echo 'Only two-column layouts are enabled'; } ?> ``` -------------------------------- ### Manage Term/Taxonomy Sidebar Assignments with Meta Fields (PHP) Source: https://context7.com/studiopress/genesis-simple-sidebars/llms.txt This PHP snippet shows how to retrieve, set, and delete custom sidebar assignments for taxonomy terms (like categories or tags) using term meta functions. ```php term_id; $primary_sidebar = get_term_meta( $term_id, '_ss_sidebar', true ); $secondary_sidebar = get_term_meta( $term_id, '_ss_sidebar_alt', true ); $header_sidebar = get_term_meta( $term_id, '_ss_header', true ); // Programmatically set sidebar for a category $category_id = get_cat_ID( 'News' ); update_term_meta( $category_id, '_ss_sidebar', 'news-sidebar' ); update_term_meta( $category_id, '_ss_sidebar_alt', 'news-secondary' ); // Remove custom sidebar assignment delete_term_meta( $category_id, '_ss_sidebar' ); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.