Support » Theme: Oenology » remove 'view/hide' from sidebar

Viewing 13 replies - 1 through 13 (of 13 total)
  • Theme Author Chip Bennett

    (@chipbennett)

    There isn’t currently a filter for that, but I can easily add one (and good suggestion; thanks!).

    Note that “show/hide” merely shows/hides the Widget content. The Widget title always shows.

    If you want the default behavior of Widget content to be shown, instead of hidden, you can change that via Dashboard -> Appearance -> Oenology Options -> General tab.

    Thread Starter jknetdesign

    (@jknetdesign)

    I knew about the Option but this site just doesn’t require that function. If this filter is not in the theme, how do I remove it?

    Theme Author Chip Bennett

    (@chipbennett)

    I just pushed these filters to the master development version:
    https://github.com/chipbennett/oenology/issues/111

    If you want to take advantage of it now, you can download the development version of functions/widgets.php, or simply make the two small changes yourself.

    Then, you can write callbacks:

    add_filter( 'oenology_showhide_widget_content_open', '__return_false' );
    add_filter( 'oenology_showhide_widget_content_close', '__return_false' );

    (This shortcut brought to you by the core __return_false() function.)

    Note: be sure that Dashboard -> Appearance -> Oenology Options -> General tab Show/Hide widget content default is set to show.

    Thread Starter jknetdesign

    (@jknetdesign)

    Can you clarify the steps for this?
    I made those changes to widgets.php
    then placed the callbacks in functions.php

    Didn’t work.
    I must be missing something.
    Thanks

    Thread Starter jknetdesign

    (@jknetdesign)

    Oh got it!
    I made the two small changes and placed the callbacks below.
    Thank you Chip!

    Theme Author Chip Bennett

    (@chipbennett)

    Oh got it!
    I made the two small changes and placed the callbacks below.

    Yes, sorry; I should have clarified: the filters may need to be hooked in at widgets_init. If you want to put it in functions.php:

    function jknetdesign_filter_widget_stuff() {
        add_filter( 'oenology_showhide_widget_content_open', '__return_false' );
        add_filter( 'oenology_showhide_widget_content_close', '__return_false' );
    }
    add_action( 'widgets_init', 'jknetdesign_filter_widget_stuff' );

    …should do the trick.

    Thread Starter jknetdesign

    (@jknetdesign)

    Yeah because i was wondering how to apply to child theme.
    So I reset the widgets.php file and
    placed that in functions and sorry but it didn’t work.

    Theme Author Chip Bennett

    (@chipbennett)

    It works for me; but I made one additional change: I moved the functions oenology_showhide_widget_content_open() and oenology_showhide_widget_content_close() out of functions/widgets.php and into functions/custom.php.

    Then, when I dropped the above add_filter() calls into functions.php to test, it worked for me.

    Just to be sure, I tested in a Child Theme, and it worked for me as well.

    I used the following, in both cases:

    add_filter( 'oenology_showhide_widget_content_open', '__return_false' );
    add_filter( 'oenology_showhide_widget_content_close', '__return_false' );

    Thread Starter jknetdesign

    (@jknetdesign)

    I’m not 100% on this. Should I:
    Leave this in functions.php?

    // Removes showhide function on sidebar
    function jknetdesign_filter_widget_stuff() {
        add_filter( 'oenology_showhide_widget_content_open', '__return_false' );
        add_filter( 'oenology_showhide_widget_content_close', '__return_false' );
    }
    add_action( 'widgets_init', 'jknetdesign_filter_widget_stuff' );

    Put widgets.php back to default?

    Then what exactly do I edit in custom.php? on what line?

    Are you saying that custom.php is left alone on theme update?
    Can I move functions/custom.php into my child theme folder?

    Thread Starter jknetdesign

    (@jknetdesign)

    Any chance of taking a look at my previous comment?
    Can you give more exact directions?

    Theme Author Chip Bennett

    (@chipbennett)

    Sorry for delayed responses for a bit; I’m incredibly swamped at the moment.

    I’m honestly unsure why it won’t work for you, but if you want to try what I did:

    1. Move the function oenology_showhide_widget_content_open(){} and function oenology_showhide_widget_content_close(), and function oenology_get_widget_args() function definitions from functions\widgets.php into functions\custom.php

    2. Add the apply_filter() calls to oenology_showhide_widget_content_open(){} and oenology_showhide_widget_content_close()

    3. In your Child Theme functions.php, add the filter callbacks:

    add_filter( 'oenology_showhide_widget_content_open', '__return_false' );
    add_filter( 'oenology_showhide_widget_content_close', '__return_false' );

    (No need to put inside another callback.)

    This worked for me, as tested in a test Child Theme.

    Note: I’m getting close to having things ready for the next release, where your add_filter() calls should work out-of-the-box.

    Thread Starter jknetdesign

    (@jknetdesign)

    It worked but what confuses me is the first step, when I cut the function from widgets.php, because what happens when an update replaces this file?

    Here’s what I have:
    This function is not in widgets.php, it’s in custom.php at the bottom — in the main theme.

    function oenology_showhide_widget_content_open() {
    	$options = oenology_get_options();
        $showhide = '<span class="showhide">';
        $showhide .= 'Click to ';
        $showhide .= '<span style="color:#5588aa;" onclick="d=this.parentElement.nextElementSibling; d.style.display==\'none\' ? d.style.display=\'block\' : d.style.display=\'none\';">view/hide</span>';
        $showhide .= '<br /></span>';
        $showhide .= '<div class="widget-inner" style="display:' . $options['widget_display_default_state'] . ';">';
    
        return apply_filters( 'oenology_showhide_widget_content_open', $showhide );
    }
    
    function oenology_showhide_widget_content_close() {
    	return apply_filters( 'oenology_showhide_widget_content_close', '</div>' );
    }

    Then I have this in the functions.php — child theme

    add_filter( 'oenology_showhide_widget_content_open', '__return_false' );
    add_filter( 'oenology_showhide_widget_content_close', '__return_false' );

    Is this correct?

    Theme Author Chip Bennett

    (@chipbennett)

    It worked but what confuses me is the first step, when I cut the function from widgets.php, because what happens when an update replaces this file?

    No worries. That’s the same change I made in the development version – meaning that, when the next version is released, that change will have been implemented.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘remove 'view/hide' from sidebar’ is closed to new replies.