[ php ] 2011 september 19

PHP Code

if(post_password_required() || (!comments_open() && is_page() && $app->post->getCommentCount() < 1)) return;

Code Dissection
1. if --- Statement . Conditional Statement.
if statement - use this statement to execute some code only if a specified condition is true

2. post_password_required() --- WordPress API
post_password_required (line 558)
Whether post requires password and correct password has been provided.

return: false if a password is not required or the correct password cookie is present, true otherwise.
since: 2.7.0
bool post_password_required ([int|object  $post = null])
int|object $post: An optional post. Global $post used if not provided.

3. || --- Logical Operator. OR operator. PHP operator.
(x==5 || y==5) returns false

4. ! --- PHP/Logical/NOT operator .
!(x==y) returns true

5. comments_open --- WordPress API.
comments_open (line 772)
Whether the current post is open for comments.

return: True if the comments are open
since: 1.5.0
uses: $post
bool comments_open ([int $post_id = NULL])
int $post_id: An optional post ID to check instead of the current post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s