I'll see what this code means, guys.

Source: Internet
Author: User
Everybody php master help me to see what this piece of code means


function Apply_filters ($tag, $value) {
Global $WP _filter, $merged _filters, $WP _current_filter;

$args = Array ();

if (isset ($wp _filter[' all ')) {
$WP _current_filter[] = $tag;
$args = Func_get_args ();
_wp_call_all_hook ($args);
}

if (!isset ($wp _filter[$tag])) {
if (isset ($wp _filter[' all '))
Array_pop ($wp _current_filter);
return $value;
}

if (!isset ($wp _filter[' all '))
$WP _current_filter[] = $tag;

if (!isset ($merged _filters[$tag])) {
Ksort ($WP _filter[$tag]);
$merged _filters[$tag] = true;
}

Reset ($wp _filter[$tag]);

if (empty ($args))
$args = Func_get_args ();

do {
foreach (array) current ($WP _filter[$tag]) as $the _)
if (!is_null ($the _[' function ')) {
$args [1] = $value;
$value = Call_user_func_array ($the _[' function '], Array_slice ($args, 1, (int) $the _[' Accepted_args '));
}

} while (Next ($wp _filter[$tag])!== false);

Array_pop ($wp _current_filter);

return $value;
}



function The_permalink () {
echo apply_filters (' The_permalink ', Get_permalink ());
}

Share to:


------Solution--------------------
Common function-apply_filters ()
Description
Call the function added to the filter hook. View a list of filter hooks on the plugin API.
By calling this function, you can invoke a callback function attached to the filter hook $tag. Call this function with the name of the new hook specified by the $tag parameter to create a new filter hook.
Usage

Parameters
$tag
(string) (required) name of the filter hook
Default value: None
$value
(mixed) (required) a value that may be modified by a filter connected to the $tag
Default value: None
The value returned
(mixed) After all the join functions have been applied to the function, the result of $value is returned.
Note: The type of the return value should be the same as the $value type, such as a string or an array.
How to use:

$tag: You can customize any value
$value: You can customize any value

------Solution--------------------
References:
Quote: References:

Common function-apply_filters ()
Description
Call the function added to the filter hook. View a list of filter hooks on the plugin API.
By calling this function, you can invoke a callback function attached to the filter hook $tag. Call this function with the name of the new hook specified by the $tag parameter to create a new filter hook.
Usage

Parameters
$tag
(string) (required) name of the filter hook
Default value: None
$value
(mixed) (required) a value that may be modified by a filter connected to the $tag
Default value: None
The value returned
(mixed) After all the join functions have been applied to the function, the result of $value is returned.
Note: The type of the return value should be the same as the $value type, such as a string or an array.
How to use:

$tag: You can customize any value
$value: You can customize any value


Filter hooks? What the hell is that?
I choose to use WordPress to make a blog, first display all the posts in the blog.php page (pagination), and then click on the title to enter the full blog content.
Why when I click on the title of the post, I jump to the index.php page, if it is someone else to write the template, in the index.php display all the blog post, click on the title after the index.php show the full post, why change a page can not? The code might look like this:
 
!--? php if (have_posts ()):?-->//Check for logs
!--? php while (have_posts ()): The_post ( );?-->//loop
"title="!--? php the_title (),?--"class=",
  • " in the case of a blog post with a log
  • 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.