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

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                在WP 4.2之前,具有相同s in(例如,標簽和分享s lug“”a a a a a a a a in in in in in in。。。。。。。。)))))。。。。 從WordPress 4.2開始,當這些共享術語中的一個更新時,它將被拆分:更新的術語將被分配一個新的術語ID。 在絕大多數情況下,這種更新將是無縫和平靜的。 然而,一些插件和主題在選項,后期元數據,用戶元數據或其他地方存儲術語ID。 WP 4.2將包括兩種不同的工具來幫助這些插件和主題的作者過渡。 ##'split_shared_term'動作 當共享術語被分配一個新的術語ID時,會觸發一個新的“split_shared_term”操作。 存儲術語ID的插件和主題應掛接到此操作以執行必要的遷移。 掛鉤的文檔如下: ``` /** * Fires after a previously shared taxonomy term is split into two separate terms. * * @since 4.2.0 * * @param int $term_id ID of the formerly shared term. * @param int $new_term_id ID of the new term created for the $term_taxonomy_id. * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split. * @param string $taxonomy Taxonomy for the split term. */ ``` 以下是插件和主題作者如何利用此操作確保存儲的術語ID更新的幾個示例。 ##更新存儲在選項中的術語ID 假設你的插件存儲一個名為“featured_tags”的選項,它包含一個術語ID數組(update_option('featured_tags',array(4,6,10)))。 在這個例子中,你將鉤住'split_shared_term',檢查更新后的術語ID是否在數組中,如有必要,進行更新。 ``` /** * Update featured tags when a term gets split. * * @param int $term_id ID of the formerly shared term. * @param int $new_term_id ID of the new term created for the $term_taxonomy_id. * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split. * @param string $taxonomy Taxonomy for the split term. */ function my_featured_tags_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { // We only care about tags, so we'll first verify that the term is a tag. if ( 'post_tag' == $taxonomy ) { // Get the current featured tags. $featured_tags = get_option( 'featured_tags' ); // If the updated term is in the array, note the array key. $found_term = array_search( $term_id, $featured_tags ); if ( false !== $found_term ) { // The updated term is a featured tag! Replace it in the array, and resave. $featured_tags[ $found_term ] = $new_term_id; update_option( 'featured_tags', $featured_tags ); } } } add_action( 'split_shared_term', 'my_featured_tags_split_shared_term', 10, 4 ); ``` ##更新存儲在后期元中的術語ID 有時一個插件可能會在post meta中存儲術語ids。 在這種情況下,使用get_posts()查詢來定位具有元鍵“primary_category”的帖子以及與分割術語ID匹配的元值。 確定帖子后,請使用update_post_meta()更改存儲在數據庫中的值。 ``` /** * Check primary categories when a term gets split to see if any of them * need to be updated. * * @param int $term_id ID of the formerly shared term. * @param int $new_term_id ID of the new term created for the $term_taxonomy_id. * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split. * @param string $taxonomy Taxonomy for the split term. */ function my_primary_category_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { // Ignore all updates except those to categories if ( 'category' == $taxonomy ) { // Find all the posts where the primary category matches the old term ID. $post_ids = get_posts( array( 'fields' => 'ids', 'meta_key' => 'primary_category', 'meta_value' => $term_id, ) ); // If we found posts, update the term ID stored in post meta. if ( $post_ids ) { foreach ( $post_ids as $post_id ) { update_post_meta( $post_id, 'primary_category', $new_term_id, $term_id ); } } } } add_action( 'split_shared_term', 'my_primary_category_split_shared_term', 10, 4 ); ``` ## `wp_get_split_term()`函數 'split_shared_term'是處理術語ID更改的首選方法。 但是,可能有些情況 - 例如延遲插件更新 - 哪些術語被拆分,沒有插件有機會鉤住'split_shared_term'動作。 WP 4.2存儲有關已分裂的分類術語的信息,并提供wp_get_split_term()實用程序函數,以幫助開發人員檢索此信息。 考慮上面的情況,您的插件在名為“featured_tags”的選項中存儲術語ID。 您可能需要構建一個驗證這些標記ID的功能(可能要在插件更新中運行),以確保沒有任何功能標簽已被拆分: ``` function my_featured_tags_check_for_split_terms() { $featured_tag_ids = get_option( 'featured_tags', array() ); // Check to see whether any IDs correspond to post_tag terms that have been split. foreach ( $featured_tag_ids as $index => $featured_tag_id ) { $new_term_id = wp_get_split_term( $featured_tag_id, 'post_tag' ); if ( $new_term_id ) { $featured_tag_ids[ $index ] = $new_term_id; } } // Resave. update_option( 'featured_tags', $featured_tag_ids ); } ``` >[info] 請注意,wp_get_split_term()具有兩個參數 - $ old_term_id和$ taxonomy - 并返回一個整數。 如果您需要檢索與舊術語ID相關聯的所有拆分術語的列表,無論分類如何,請使用wp_get_split_terms($ old_term_id)。
                  <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>

                              哎呀哎呀视频在线观看