[wp-trac] [WordPress Trac] #4832: In comments_popup_link(), why bomb out when on a page or single post?

WordPress Trac wp-trac at lists.automattic.com
Tue Aug 28 03:42:46 GMT 2007


#4832: In comments_popup_link(), why bomb out when on a page or single post?
--------------------------+-------------------------------------------------
 Reporter:  JeremyVisser  |       Owner:  anonymous 
     Type:  defect        |      Status:  new       
 Priority:  normal        |   Milestone:  2.4 (next)
Component:  Template      |     Version:            
 Severity:  normal        |    Keywords:            
--------------------------+-------------------------------------------------
 In the {{{comments_popup_link()}}} function in {{{wp-includes/comment-
 template.php}}}, the first two lines of code make the function return if
 it is being called from a page or single post.

 {{{
 if ( is_single() || is_page() )
         return;
 }}}

 So, the following template tag that you'd normally use in a post loop when
 displaying, say, the home page:

 {{{
 <?php comments_popup_link('No responses (be the first!)', '(One
 response)', '(% responses)'); ?>
 }}}

 ...would show up as blank if you used it on a page or single post, because
 of the aforementioned code.

 Now, I'm working on a mockup theme, which only uses comments in the
 comment popup (I insert the {{{comments_popup_script()}}} into the header,
 making {{{comments_popup_link()}}} bring up a popup window instead of
 linking to {{{get_the_permalink() . '#comments'}}}), and bringing the
 comment popup works great form the index page.

 However, I also want to be able to launch the popup window from the
 permalink (I don't want any comments directly printed on the single post),
 but this code:

 {{{
 if ( is_single() || is_page() )
         return;
 }}}

 ...is preventing me.

 So, I worked around it by adding a {{{force_comments_popup_link()}}}
 function in {{{functions.php}}} of my theme, which is exactly the same as
 {{{comments_popup_link()}}}, but doesn't contain the {{{( is_single() ||
 is_page() )}}} jurgle. And guess what -- it works great.

 So, is that code really necessary? Could it be removed? Or, could a
 {{{$force = false}}} be added to the parameter list?

 (The latter might be desirable, as I think some themes depend on the
 functionality of {{{comments_popup_link()}}} being blank at times.)

 === Environment ===

  * !WordPress 2.2.2
  * !WordPress trunk (r5954)

-- 
Ticket URL: <http://trac.wordpress.org/ticket/4832>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list