Home > Forum

Support Forum

Blank title handling

Discussions related to the HTML Javascript Adder WordPress plugin.

Blank title handling

Postby The1stImmortal » Wed Jul 27, 2011 12:06 am

Hi all,

Not sure if this is the correct way to handle this, but...

Most of the built-in WordPress widgets handle the case of a blank title by not rendering a title block in the widget at all. We ran into this with a client recently - they were using the widget for an advertisement block and wanted to minimze the "fluff" around the icon.

I made a small patch to html-javascript-adder.php to check for a title string, and not include any title block if it's null. This is listed below (or, in case the forum mangles the patch, at http://pastebin.com/JPCgN3Mv )

Code: Select all
--- html-javascript-adder.php.orig      2011-07-27 09:17:13.000000000 +1000
+++ html-javascript-adder.php   2011-07-27 09:56:40.000000000 +1000
@@ -118,7 +118,11 @@
        ## Display the Widget
        function widget($args, $instance){
                extract($args);
-               $hja_title = apply_filters('widget_title', empty($instance['hja_title']) ? '' : $instance['hja_title'], $instance, $this->id_base);
+               $hja_title_block = "";
+               if ( $title ) {
+                       $hja_title = apply_filters('widget_title', empty($instance['hja_title']) ? '' : $instance['hja_title'], $instance, $this->id_base);
+                       $hja_title_block = $before_title . $hja_title . $after_title;
+               }

                if(empty($instance['hja_content'])){
                        $hja_content = '';
@@ -134,9 +138,7 @@
                ## Output
                $hja_output_content =
                        $before_widget . "\n\n<!-- Start - HTML Javascript Adder plugin v" . HJA_VERSION . " -->\n" .
-                       $before_title .
-                       $hja_title .
-                       $after_title .
+                       $hja_title_block .
                        $hja_before_content .
                        $hja_content .
                        $this->hja_link_back() .


Thanks,

The1stImmortal
The1stImmortal
 
Posts: 1
Joined: Tue Jul 26, 2011 11:49 pm

Re: Blank title handling

Postby vaakash » Wed Jul 27, 2011 11:43 am

Thanks for your patch The1stImmortal, this will be soon coded in the next version.
User avatar
vaakash
Site Admin
 
Posts: 672
Joined: Sun Jan 17, 2010 11:15 am
Location: India


Return to HTML Javascript Adder

cron


phpBB SEO