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

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

WBOY
WBOYOriginal
2016-08-04 09:21:401135browse

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>
    • 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>

      }

    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>
    • 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>

      }

    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

    Statement:
    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