Home  >  Article  >  Backend Development  >  web - wordpress blog系统的class.wp-dependencies.php 文件 do_items 执行问题

web - wordpress blog系统的class.wp-dependencies.php 文件 do_items 执行问题

WBOY
WBOYOriginal
2016-06-06 20:10:371475browse

研究wordpress 碰到js加载跟着代码走读到wp-includes/class.wp-dependencies.php文件的do_items
发现该函数调用$this->do_item( $handle, $group ) 后打印输出js脚本

调试代码如下

<code>` echo "{"; ob_flush();
            if ($this->do_item( $handle, $group )){
                echo "if 语句内执";ob_flush();
                $this->done[] = $handle;
            }
            echo "}";`
</code>

我在do_item函数添加和get_data 添加代码表示被调用

<code>public function get_data( $handle, $key ) {
        echo "\n",__FUNCTION__,"\n"; 
        if ( !isset( $this->registered[$handle] ) )
            return false;
        if ( !isset( $this->registered[$handle]->extra[$key] ) )
            return false;
        return $this->registered[$handle]->extra[$key];
    }

public function do_item($handle) {
        echo "\n",__FUNCTION__,"\n";
        $temp=isset($this->registered[$handle]);
        echo "end function do_item";
        return $temp;
    }</code>

运行结构如下

<code>{
do_item
end function do_item
get_data

get_data

get_data
<script type="text/javascript" src="http://www.hweijie.com/wp-content/themes/dux/js/libs/bootstrap.min.js?ver=1.4"></script>
if 语句内执}{
do_item
end function do_item
get_data

get_data

get_data
<script type="text/javascript" src="http://www.hweijie.com/wp-content/themes/dux/js/loader.js?ver=1.4"></script>
if 语句内执}{
do_item
end function do_item
get_data

get_data

get_data
<script type="text/javascript" src="http://www.hweijie.com/wp-includes/js/wp-embed.min.js?ver=4.5.1"></script>
if 语句内执}</code>

问题是
get_data 函数是如何被调用的,而js脚本输出有时那个函数被输出的

以下是我提供的代码环境
http://pan.baidu.com/s/1hrZaBsC
这是一个干净的wordpress 模板 dux. 也可以自己下载,安装到本地的wordpress 模板目录里面即可......

回复内容:

研究wordpress 碰到js加载跟着代码走读到wp-includes/class.wp-dependencies.php文件的do_items
发现该函数调用$this->do_item( $handle, $group ) 后打印输出js脚本

调试代码如下

<code>` echo "{"; ob_flush();
            if ($this->do_item( $handle, $group )){
                echo "if 语句内执";ob_flush();
                $this->done[] = $handle;
            }
            echo "}";`
</code>

我在do_item函数添加和get_data 添加代码表示被调用

<code>public function get_data( $handle, $key ) {
        echo "\n",__FUNCTION__,"\n"; 
        if ( !isset( $this->registered[$handle] ) )
            return false;
        if ( !isset( $this->registered[$handle]->extra[$key] ) )
            return false;
        return $this->registered[$handle]->extra[$key];
    }

public function do_item($handle) {
        echo "\n",__FUNCTION__,"\n";
        $temp=isset($this->registered[$handle]);
        echo "end function do_item";
        return $temp;
    }</code>

运行结构如下

<code>{
do_item
end function do_item
get_data

get_data

get_data
<script type="text/javascript" src="http://www.hweijie.com/wp-content/themes/dux/js/libs/bootstrap.min.js?ver=1.4"></script>
if 语句内执}{
do_item
end function do_item
get_data

get_data

get_data
<script type="text/javascript" src="http://www.hweijie.com/wp-content/themes/dux/js/loader.js?ver=1.4"></script>
if 语句内执}{
do_item
end function do_item
get_data

get_data

get_data
<script type="text/javascript" src="http://www.hweijie.com/wp-includes/js/wp-embed.min.js?ver=4.5.1"></script>
if 语句内执}</code>

问题是
get_data 函数是如何被调用的,而js脚本输出有时那个函数被输出的

以下是我提供的代码环境
http://pan.baidu.com/s/1hrZaBsC
这是一个干净的wordpress 模板 dux. 也可以自己下载,安装到本地的wordpress 模板目录里面即可......

唉,你怎么就没试试看echo get_class($this)呢?
class WP_Scripts extends WP_Dependencies
class WP_Styles extends WP_Dependencies
所以,你确定你运行的是 new WP_Dependencies 而不是 new WP_Scripts或者new WP_Styles?

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