There are several functions in the typecho_widget source code that are not very clear. Could you please tell me?

WBOY
Release: 2016-08-04 09:21:40
Original
1140 people have browsed it

I recently looked at the source code of typecho_widget. This is the parent class of all widgets. There are several methods that are not very clear. Please tell me.

<code>/**</code>
Copy after login
Copy after login
    • post event triggered
      *

    • @param boolean $condition trigger condition

    • @return mixed
      */

    1. function on($condition)
      {

      <code>   if ($condition) {
             return $this;
         } else {
             return new Typecho_Widget_Helper_Empty();
         }</code>
      Copy after login
      Copy after login

      }

    It is said that it is triggered by post, so how is it triggered? I don’t see any relevant calls. The general meaning of the function is to return the current widget if the conditions are met. I hope you can enlighten me, thank you! ! !

    Reply content:

    I recently looked at the source code of typecho_widget. This is the parent class of all widgets. There are several methods that are not very clear. Please tell me.

    <code>/**</code>
    Copy after login
    Copy after login
    • post event triggered
      *

    • @param boolean $condition trigger condition

    • @return mixed
      */

    1. function on($condition)
      {

      <code>   if ($condition) {
             return $this;
         } else {
             return new Typecho_Widget_Helper_Empty();
         }</code>
      Copy after login
      Copy after login

      }

    It is said that it is triggered by post, so how is it triggered? I don’t see any relevant calls. The general meaning of the function is to return the current widget if the conditions are met. I hope you can enlighten me, thank you! ! !

    Is there anyone who can help me with the answer

    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!