web - wordpress blog系統的class.wp-dependencies.php 檔案 do_items 執行問題

來源:互聯網
上載者:User
關鍵字 php wordpress web
研究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?

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.