• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

php 搞代码 3年前 (2022-01-25) 14次浏览 已收录 0个评论
文章目录[隐藏]

研究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_itemend function do_itemget_dataget_dataget_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_itemend function do_itemget_dataget_dataget_data<script type='text/javascript' src='http://www.hweijie.com/wp-content/themes/dux/js/loader.js?ver=1.4'></script>if 语句内执}{do_itemend function do_itemget_dataget_dataget_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. 也可以自己下载,安装到本地的wor·本2文来源gaodai$ma#com搞$代*码网2搞gaodaima代码dpress 模板目录里面即可……

回复内容:

研究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_itemend function do_itemget_dataget_dataget_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_itemend function do_itemget_dataget_dataget_data<script type='text/javascript' src='http://www.hweijie.com/wp-content/themes/dux/js/loader.js?ver=1.4'></script>if 语句内执}{do_itemend function do_itemget_dataget_dataget_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?


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:web – wordpress blog系统的class.wp-dependencies.php 文件 do_items 执行问题

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址