<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                激活和停用掛鉤提供了在插件激活或停用時執行操作的方法。 在激活時,插件可以運行例程來添加重寫規則,添加自定義數據庫表或設置默認選項值。 在停用時,插件可以運行例程來刪除臨時數據,如緩存和臨時文件和目錄。 >[danger] 警報:停用掛鉤有時與卸載掛鉤混淆。 卸載鉤子最適合永久刪除所有數據,例如刪除插件選項和自定義表等。 ## 啟用 要設置激活鉤子,請使用register_activation_hook()函數: ``` register_activation_hook( __FILE__, 'pluginprefix_function_to_run' ); ``` ## 停用 要設置停用掛鉤,請使用register_deactivation_hook()函數: ``` register_deactivation_hook( __FILE__, 'pluginprefix_function_to_run' ); ``` 每個這些函數中的第一個參數是指您的主插件文件,這是您已經放置插件標題注釋的文件。 通常這兩個函數將從主插件文件中觸發; 但是,如果函數放在任何其他文件中,則必須更新第一個參數以正確指向主插件文件。 ##示例 激活鉤子最常見的用途之一是當插件注冊自定義帖子類型時刷新WordPress的固定鏈接。 這擺脫了糟糕的404錯誤。 我們來看一下如何做到這一點的例子: ``` function pluginprefix_setup_post_types() { // register the "book" custom post type register_post_type( 'book', ['public' => 'true'] ); } add_action( 'init', 'pluginprefix_setup_post_type' ); function pluginprefix_install() { // trigger our function that registers the custom post type pluginprefix_setup_post_type(); // clear the permalinks after the post type has been registered flush_rewrite_rules(); } register_activation_hook( __FILE__, 'pluginprefix_install' ); ``` 如果您不熟悉注冊自定義帖子類型,請不要擔心 - 稍后將會介紹。 這個例子很簡單,因為它很常見。 使用上面的示例,以下是如何反轉此過程并停用插件: ``` function pluginprefix_deactivation() { // our post type will be automatically removed, so no need to unregister it // clear the permalinks to remove our post type's rules flush_rewrite_rules(); } register_deactivation_hook( __FILE__, 'pluginprefix_deactivation' ); ``` 有關激活和停用掛鉤的更多信息,以下是一些優秀的資源: - register_activation_hook() 在WordPress的功能參考。 - register_deactivation_hook() 在WordPress的功能參考。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看