remove 'view/hide' from sidebar
-
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.
https://growersice.com/services/
Most appreciated.
-
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
.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?
I just pushed these filters to the master development version:
https://github.com/chipbennett/oenology/issues/111If 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.Can you clarify the steps for this?
I made those changes to widgets.php
then placed the callbacks in functions.phpDidn’t work.
I must be missing something.
ThanksOh got it!
I made the two small changes and placed the callbacks below.
Thank you Chip!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 infunctions.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.
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.It works for me; but I made one additional change: I moved the functions
oenology_showhide_widget_content_open()
andoenology_showhide_widget_content_close()
out offunctions/widgets.php
and intofunctions/custom.php
.Then, when I dropped the above
add_filter()
calls intofunctions.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' );
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?Any chance of taking a look at my previous comment?
Can you give more exact directions?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(){}
andfunction oenology_showhide_widget_content_close()
, andfunction oenology_get_widget_args()
function definitions fromfunctions\widgets.php
intofunctions\custom.php
2. Add the
apply_filter()
calls tooenology_showhide_widget_content_open(){}
andoenology_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.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?
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.
- The topic ‘remove 'view/hide' from sidebar’ is closed to new replies.