Tagged: x
-
AuthorPosts
-
April 30, 2016 at 2:24 pm #907158
cwallaceParticipantHi guys,
Kind of an advanced question, but here goes. I need to add a bit of code that will either allow or disallow the display of the sidebar based on role. I know how to do that, so that’s not the question. 😀 The question is, would wp-sidebar.php be the most appropriate place add that code? Here’s why: the code in wp-sidebar.php is short and sweet, as follows:
<?php if ( x_get_content_layout() != ‘full-width’ ) : ?>
<aside class=”<?php x_sidebar_class(); ?>” role=”complementary”>
<?php if ( get_option( ‘ups_sidebars’ ) != array() ) : ?>
<?php dynamic_sidebar( apply_filters( ‘ups_sidebar’, ‘sidebar-main’ ) ); ?>
<?php else : ?>
<?php dynamic_sidebar( ‘sidebar-main’ ); ?> <<<<– ADD MY CODE HERE?
<?php endif; ?>
</aside><?php endif; ?>
Rather than muck about in the dynamic_sidebar routine, I can add my conditional right above the call to it, which as far as I can tell, would work just fine. If there’s a better way, however, please enlighten me. 🙂
Thanks!
ChrisMay 1, 2016 at 5:44 am #907687
ChristianModeratorHey Chris,
Yes, that is the correct place.
Thanks.
May 1, 2016 at 1:02 pm #908109
cwallaceParticipantThanks. Anyone needing to disable the sidebar on pages/posts where the user/role has to have permission can use the following. It’s in wp-sidebar.php in x/framework/views/integrity. Save the changed version of the file to x-child/framework/views/integrity.
<?php if ( x_get_content_layout() != 'full-width' ) : ?> <aside class="<?php x_sidebar_class(); ?>" role="complementary"> <?php if ( get_option( 'ups_sidebars' ) != array() ) : ?> <?php if ( current_user_can( 'edit_posts' ) ) : ?> <?php dynamic_sidebar( apply_filters( 'ups_sidebar', 'sidebar-main' ) ); ?> <?php endif; ?> <?php else : ?> <?php if ( current_user_can( 'edit_posts' ) ) : ?> <?php dynamic_sidebar( 'sidebar-main' ); ?> <?php endif; ?> <?php endif; ?> </aside> <?php endif; ?>May 1, 2016 at 9:41 pm #908455
NicoModeratorHi There,
Thank you so much for sharing. We really appreciate it.
Feel free to share and to let us know if you need anything else.
Thanks.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-907158 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
