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

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

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

调试代码如下

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

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

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;
    }

运行结构如下

{
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 语句内执}

问题是
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?

【热门文章】
【热门文章】