研究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_itemend function do_itemget_dataget_dataget_dataif 語句內執}{do_itemend function do_itemget_dataget_dataget_dataif 語句內執}{do_itemend function do_itemget_dataget_dataget_dataif 語句內執}
問題是
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指令碼
調試代碼如下
` 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_itemend function do_itemget_dataget_dataget_dataif 語句內執}{do_itemend function do_itemget_dataget_dataget_dataif 語句內執}{do_itemend function do_itemget_dataget_dataget_dataif 語句內執}
問題是
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?