Been breaking my keyboard over this. Did a proper install, uploaded the database to a fresh MySQL and been working on using child themes properly. But there is something plaguing me I can not figure out.
On my new install (ver2.whowhatwhy.com) I intentionally left some of my widgets blank. I would expect, when reading the default-widgets.php
file in wp-includes that there would be no title element showing on that widget.
Instead, the title widget is showing because, for some reason, the value being passed by apply_filters
is a space, rather than a blank value when the $instance['title']
is blank.
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
Has anyone seen this before? The problem I have is that the original installation has no problem with this call (returns a blank value).
If you go to the site, you can see the vardumps of the different elements of the code:
function widget( $args, $instance ) {
extract($args);
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
$text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
echo $before_widget;
if ( !empty( $title ) ) { echo $before_title . '[' . $title . '] ' . $after_title; } ?>
<div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
<?php
echo $after_widget;
}
I also removed all of the widgets and then replaced the one widget on the page. This is what is in the database:
@Otto - I also looked in the database and eliminated all of the other widgets. And here is what I found:
a:2:{i:916707761;a:3:{s:5:"title";s:0:"";s:4:"text";s:1333:"<table width="297" bgcolor="#000000">
<tr>
<td width="297" bordercolor="0"><!-- BEGIN: Constant Contact Stylish Email Newsletter Form -->
<div align="center">
<div style="width:267px; background-color: #000000;">
<form name="ccoptin" action="http://visitor.r20.constantcontact.com/d.jsp" target="_blank" method="post" style="margin-bottom:3;">
<p><span class="style1" style="font-family: Arial, Helvetica, sans-serif"><font style="font-family:Arial; font-size:18px; color:#666666;"><span class="style4">Do you need the truth?</span><br>
</font><span style="font-size: 12px"><font style="font-family:Arial; font-size:14px; color:#FF0000;">Sign up for our weekly email updates and stay informed. </font></span></span></p>
<p>
<input type="text" name="ea" size="22" value="" style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:14px; border:1px solid #999999;">
<input type="submit" name="go" value="JOIN" class="submit" style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:10px;">
<input type="hidden" name="llr" value="">
<input type="hidden" name="m" value="">
<input type="hidden" name="p" value="">
</p>
</form>
</div>
</div>
</td>
</tr>
</table>
<div style="margin-bottom: 2px;"> </div>
";s:6:"filter";b:0;}s:12:"_multiwidget";i:1;}
Note where the a:3
is, you can see that the title
value is an empty string with no length.
So, why would apply_filters return a non-empty value?
apply_filters
or the value found in$title
is a space.instance($title)
which is empty/devoid of anything. For some reason the$title
assignment adds a space to the variable. Any idea why?