What is the use of WordPress comments-popup.php files?

Source: Internet
Author: User

There is a comments. php file in WP theme, which is a comment template file. But another name-related comments-popup.php file has never known what it is. Even deleting it has not seen any abnormality in the system.

In fact, it is useful, that is, click "comment" of the article to pop up the page and enter a comment in it. However, because the "pop-up comment page" function is disabled by default, many people do not know about it. To enable the function of the pop-up comment page, edit the header. php file and see row 21st (wp2.9.1 ):

<? PHP // comments_popup_script (); // off by default?>

Here is the switch. Remove the comments of the sentence. Refresh the blog homepage and you will see the JS script added to the head part of the Code:

<SCRIPT type = 'text/JavaScript '>
Function wpopen (macagna)
{
Window. Open (macagna, '_ blank', 'width = 400, Height = 400, scrollbars = Yes, status = Yes ');
}
</SCRIPT>

The script for the comment link is changed:

<Div class = "feedback">
<A href = "http ://.../? Comments_popup = 230 "onclick =" wpopen (this. href); Return false "Title ="... "> comment (0) </a>
</Div>

Note that the JS script onclick = "wpopen (this. href); Return false "is cleverly written. When the link structure is not changed, The onclick event function is added to change the Link Opening behavior. Instead of writing:

<A href = "#" onclick = "wpopen ('HTTP ://.../? Comments_popup = 230 '); Return false "Title ="... "> comment (0) </a>

I found this skill and referred to an article by a foreigner:
(Address: http://playworkplay.com/blog/understanding-comments-popupphp)

Understanding comments-popup.php

282.161.2008

I have a confession to make.

Up until now, I didn't have any idea how comments-popup.php works. oh, it's not like I haven't done any research. the Codex's theme development page, for instance, explains this file:

The popup comments template. If not present, comments-popup.php from the "default" theme is used.

And it doesn't link to any specific page explaining more about it. On another page, using themes, the information is even more sparse:

Popup comments template = comments-popup.php

For quite a long time, my understanding is that this file is used if, somewhere within WordPress, the option to display comments as a popup is activated. when that magic switch is on, people who click the comment link will get a popup window with the comment area inside it. the question is, where on earth do I find that option?

Oh, don't ask me how to handle hours I 've spent looking around for it. i'm even tempted to enter the famous konami code inside the WP admin area just to see if a secret page will open and show me the magic "display comment as popup" option-It' s really that hard to find!

And no wonder. I just got the revelation today, and it turns out there's never been such option within the admin area. Nope. I was digging in the wrong place.

The option to use comments-popup.php, ladies and gentlemen, depends solely on the presence of a single PHP line inside a theme's header file. go open the header. PHP of the classic theme (available in any default install of WordPress), line 21 you will see:

View sourceprint? 1. <? PHP // comments_popup_script (); // off by default?> Yes! That's the magic switch. The Holy Grail of popup commenting. I uncommented that and, bam, the very first WordPress Comment popup appared before my very eyes. Try it.

By searching for that PHP function into the codex, I found this small but complete explanation about popup comments, which I wished I 've found before.

Anyways, it's also interesting to note that week, too themes out there have comments-popup.php inside them but no comments_popup_script () function, making it practically useless. it's not even available within Kubrick, WordPress's current default theme.

I'm not sure why comments_popup_script () function is not supported ded within the default theme (not even in commented form like the one inside the classic theme); to me and other others, kubrick is the first theme we tear apart and learn in the process. perhaps the usage of popup window is discouraged?

I'm not sure. but in my case, I'm very likely to leave out the comments-popup.php like I often do. I used to do it out of the fact that I don't know what it does, and because sandbox theme-another good theme I learn a lot from-does not have it. but now, after some thinking, I'll just leave it out for one more reason:

I 've never ever visit a WP-powered blog with popup comments (have you ?). I'm sure that's what most users experience as well-we're already accustomed to the open-New-page-for-Comments behavior.

Better not mess with that.

Author: Zhang Qing (mesh) 2010-4-6
From mesh horizon: http://blog.why100000.com
Why 100,000 computer learning networks: http://www.why100000.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.