WordPress.org

Ready to get started?Download WordPress

Forums

Oenology
[resolved] remove 'view/hide' from sidebar (14 posts)

  1. jknetdesign
    Member
    Posted 1 year ago #

    Do you have a filter to remove the 'Click to view/hide' function from the 2 column layout?

    I'm using a plugin called Spots so I want the title to stay put.

    http://growersice.com/services/

    Most appreciated.

  2. Chip Bennett
    Theme Review Admin
    Theme Author

    Posted 1 year ago #

    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.

  3. jknetdesign
    Member
    Posted 1 year ago #

    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?

  4. Chip Bennett
    Theme Review Admin
    Theme Author

    Posted 1 year ago #

    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.

  5. jknetdesign
    Member
    Posted 1 year ago #

    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

  6. jknetdesign
    Member
    Posted 1 year ago #

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

  7. Chip Bennett
    Theme Review Admin
    Theme Author

    Posted 1 year ago #

    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.

  8. jknetdesign
    Member
    Posted 1 year ago #

    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.

  9. Chip Bennett
    Theme Review Admin
    Theme Author

    Posted 1 year ago #

    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' );
  10. jknetdesign
    Member
    Posted 1 year ago #

    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?

  11. jknetdesign
    Member
    Posted 1 year ago #

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

  12. Chip Bennett
    Theme Review Admin
    Theme Author

    Posted 1 year ago #

    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.

  13. jknetdesign
    Member
    Posted 1 year ago #

    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?

  14. Chip Bennett
    Theme Review Admin
    Theme Author

    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic