• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_defer_term_counting函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_defer_term_counting函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_defer_term_counting函数的具体用法?PHP wp_defer_term_counting怎么用?PHP wp_defer_term_counting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_defer_term_counting函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: save_post_actions

 /**
  * @param int     $pidd
  * @param WP_Post $post
  *
  * @return void
  */
 public function save_post_actions($pidd, $post)
 {
     global $sitepress;
     wp_defer_term_counting(true);
     $post = isset($post) ? $post : get_post($pidd);
     // exceptions
     if (!$this->has_save_post_action($post)) {
         wp_defer_term_counting(false);
         return;
     }
     $default_language = $sitepress->get_default_language();
     // allow post arguments to be passed via wp_insert_post directly and not be expected on $_POST exclusively
     $post_vars = (array) $_POST;
     foreach ((array) $post as $k => $v) {
         $post_vars[$k] = $v;
     }
     $post_vars['post_type'] = isset($post_vars['post_type']) ? $post_vars['post_type'] : $post->post_type;
     $post_id = isset($post_vars['post_ID']) ? $post_vars['post_ID'] : $pidd;
     //latter case for XML-RPC publishing
     $language_code = $this->get_save_post_lang($post_id, $sitepress);
     $trid = $this->get_save_post_trid($post_id, $post->post_status);
     // after getting the right trid set the source language from it by referring to the root translation
     // of this trid, in case no proper source language has been set yet
     $source_language = isset($source_language) ? $source_language : $this->get_save_post_source_lang($trid, $language_code, $default_language);
     $this->after_save_post($trid, $post_vars, $language_code, $source_language);
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:32,代码来源:wpml-frontend-post-actions.class.php


示例2: import_start

 function import_start($file)
 {
     if (!is_file($file)) {
         echo '<p><strong>' . __('Sorry, there has been an error.', 'wordpress-importer') . '</strong><br/>';
         echo __('The file does not exist, please try again.', 'wordpress-importer') . '</p>';
         $this->footer();
         die;
     }
     $import_data = $this->parse($file);
     if (is_wp_error($import_data)) {
         echo '<p><strong>' . __('Sorry, there has been an error.', 'wordpress-importer') . '</strong><br/>';
         echo esc_html($import_data->get_error_message()) . '</p>';
         $this->footer();
         die;
     }
     $this->version = $import_data['version'];
     $this->get_authors_from_import($import_data);
     $this->posts = $import_data['posts'];
     $this->terms = $import_data['terms'];
     $this->categories = $import_data['categories'];
     $this->tags = $import_data['tags'];
     $this->base_url = esc_url($import_data['base_url']);
     // fix for: 'http://localhost/justmarriedmarried' = str_replace('http://localhost/just', 'http://localhost/justmarried', 'http://localhost/justmarried')
     $this->wrong_replace = network_home_url() !== ($wrong_replace = str_replace($this->base_url, network_home_url(), network_home_url())) ? $wrong_replace : false;
     wp_defer_term_counting(true);
     wp_defer_comment_counting(true);
     do_action('import_start');
     // deprecated
     do_action('tf_ext_import_start');
 }
开发者ID:pinchpointer,项目名称:ppsitewordpress,代码行数:30,代码来源:TFUSE_WP_IMPORT.php


示例3: import_start

 /**
  * Parses the XML file and prepares us for the task of processing parsed data
  *
  * @param string $file Path to the WXR file for importing
  */
 function import_start($file)
 {
     if (!is_file($file)) {
         echo '<p><strong>' . __('Sorry, there has been an error.', 'anno') . '</strong><br />';
         echo __('The file does not exist, please try again.', 'anno') . '</p>';
         $this->footer();
         die;
     }
     $import_data = $this->parse($file);
     if (is_wp_error($import_data)) {
         echo '<p><strong>' . __('Sorry, there has been an error.', 'anno') . '</strong><br />';
         echo esc_html($import_data->get_error_message()) . '</p>';
         $this->footer();
         die;
     }
     $this->version = $import_data['version'];
     $this->get_authors_from_import($import_data);
     $this->posts = $import_data['posts'];
     $this->terms = $import_data['terms'];
     $this->categories = $import_data['categories'];
     $this->tags = $import_data['tags'];
     $this->base_url = esc_url($import_data['base_url']);
     wp_defer_term_counting(true);
     wp_defer_comment_counting(true);
     do_action('import_start');
 }
开发者ID:nameofname,项目名称:momo-wordpress-theme,代码行数:31,代码来源:dtd-importer.php


示例4: save_post_actions

 /**
  * @param int     $pidd
  * @param WP_Post $post
  *
  * @return void
  */
 public function save_post_actions($pidd, $post)
 {
     global $sitepress;
     wp_defer_term_counting(true);
     $post = isset($post) ? $post : get_post($pidd);
     // exceptions
     if (!$this->has_save_post_action($post)) {
         wp_defer_term_counting(false);
         return;
     }
     $default_language = $sitepress->get_default_language();
     // allow post arguments to be passed via wp_insert_post directly and not be expected on $_POST exclusively
     $post_vars = (array) $_POST;
     foreach ((array) $post as $k => $v) {
         $post_vars[$k] = $v;
     }
     $post_vars['post_type'] = isset($post_vars['post_type']) ? $post_vars['post_type'] : $post->post_type;
     $post_id = isset($post_vars['post_ID']) ? $post_vars['post_ID'] : $pidd;
     //latter case for XML-RPC publishing
     $language_code = $this->get_save_post_lang($post_id, $sitepress);
     $trid = $this->get_save_post_trid($post_id, $post->post_status);
     // after getting the right trid set the source language from it by referring to the root translation
     // of this trid, in case no proper source language has been set yet
     $source_language = isset($source_language) ? $source_language : $this->get_save_post_source_lang($trid, $language_code, $default_language);
     $this->maybe_set_elid($trid, $post->post_type, $language_code, $post_id, $source_language);
     $translation_sync = $this->get_sync_helper();
     $original_id = $this->get_original_element($post_id);
     if ($original_id) {
         $translation_sync->sync_with_translations($original_id, $post_vars);
     }
     require_once ICL_PLUGIN_PATH . '/inc/cache.php';
     icl_cache_clear($post_vars['post_type'] . 's_per_language', true);
     wp_defer_term_counting(false);
 }
开发者ID:edgarter,项目名称:wecare,代码行数:40,代码来源:wpml-frontend-post-actions.class.php


示例5: import_end

 function import_end()
 {
     // Switch off importing flag and flush rewrite cache
     wp_defer_term_counting(false);
     wp_defer_comment_counting(true);
     global $wp_rewrite;
     $wp_rewrite->flush_rules();
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:8,代码来源:ti_import.php


示例6: import_end

 /**
  * Performs post-import cleanup of files and the cache
  */
 function import_end()
 {
     wp_import_cleanup($this->id);
     wp_cache_flush();
     foreach (get_taxonomies() as $tax) {
         delete_option("{$tax}_children");
         _get_term_hierarchy($tax);
     }
     wp_defer_term_counting(false);
     wp_defer_comment_counting(false);
     do_action('import_end');
 }
开发者ID:RDePoppe,项目名称:luminaterealestate,代码行数:15,代码来源:class-dt-dummy-import.php


示例7: save_post_actions

 public function save_post_actions($pidd, $post)
 {
     global $sitepress, $wpdb;
     wp_defer_term_counting(true);
     $post = isset($post) ? $post : get_post($pidd);
     // exceptions
     if (!$this->has_save_post_action($post)) {
         wp_defer_term_counting(false);
         return;
     }
     if (WPML_WordPress_Actions::is_bulk_trash($pidd) || WPML_WordPress_Actions::is_bulk_untrash($pidd)) {
         return;
     }
     $default_language = $sitepress->get_default_language();
     // allow post arguments to be passed via wp_insert_post directly and not be expected on $_POST exclusively
     $post_vars = (array) $_POST;
     foreach ((array) $post as $k => $v) {
         $post_vars[$k] = $v;
     }
     $post_vars['post_type'] = isset($post_vars['post_type']) ? $post_vars['post_type'] : $post->post_type;
     $post_id = $pidd;
     if (isset($post_vars['action']) && $post_vars['action'] === 'post-quickpress-publish') {
         $language_code = $default_language;
     } else {
         $post_id = isset($post_vars['post_ID']) ? $post_vars['post_ID'] : $pidd;
         //latter case for XML-RPC publishing
         $language_code = $this->get_save_post_lang($post_id, $sitepress);
     }
     if ($this->is_inline_action($post_vars) && !($language_code = $this->get_element_lang_code($post_id))) {
         return;
     }
     if (isset($post_vars['icl_translation_of']) && is_numeric($post_vars['icl_translation_of'])) {
         $translation_of_data_prepared = $wpdb->prepare("SELECT trid, language_code\n\t\t\t\t FROM {$wpdb->prefix}icl_translations\n\t\t\t\t WHERE element_id=%d\n\t\t\t\t  AND element_type=%s", $post_vars['icl_translation_of'], 'post_' . $post->post_type);
         list($trid, $source_language) = $wpdb->get_row($translation_of_data_prepared, 'ARRAY_N');
     }
     $trid = isset($trid) && $trid ? $trid : $this->get_save_post_trid($post_id, $post->post_status);
     // after getting the right trid set the source language from it by referring to the root translation
     // of this trid, in case no proper source language has been set yet
     $source_language = isset($source_language) ? $source_language : $this->get_save_post_source_lang($trid, $language_code, $default_language);
     $this->maybe_set_elid($trid, $post->post_type, $language_code, $post_id, $source_language);
     $translation_sync = $this->get_sync_helper();
     $original_id = $this->get_original_element($post_id);
     if ($original_id) {
         $translation_sync->sync_with_translations($original_id, $post_vars);
     }
     if (isset($post_vars['icl_tn_note'])) {
         update_post_meta($post_id, '_icl_translator_note', $post_vars['icl_tn_note']);
     }
     require_once ICL_PLUGIN_PATH . '/inc/cache.php';
     icl_cache_clear($post_vars['post_type'] . 's_per_language', true);
     wp_defer_term_counting(false);
 }
开发者ID:pcuervo,项目名称:odc,代码行数:52,代码来源:wpml-admin-post-actions.class.php


示例8: import_end

 public function import_end()
 {
     wp_cache_flush();
     foreach (get_taxonomies() as $tax) {
         delete_option("{$tax}_children");
         _get_term_hierarchy($tax);
     }
     wp_defer_term_counting(false);
     wp_defer_comment_counting(false);
     echo '<p>' . __('All done.', 'wordpress-importer') . ' <a href="' . admin_url() . '">' . __('Have fun!', 'wordpress-importer') . '</a>' . '</p>';
     echo '<p>' . __('Remember to update the passwords and roles of imported users.', 'wordpress-importer') . '</p>';
     do_action('import_end');
 }
开发者ID:purgesoftwares,项目名称:purges,代码行数:13,代码来源:class-circleflip-import.php


示例9: save_post_actions

 public function save_post_actions($pidd, $post)
 {
     global $sitepress;
     wp_defer_term_counting(true);
     $post = isset($post) ? $post : get_post($pidd);
     // exceptions
     if (!$this->has_save_post_action($post)) {
         wp_defer_term_counting(false);
         return;
     }
     if (WPML_WordPress_Actions::is_bulk_trash($pidd) || WPML_WordPress_Actions::is_bulk_untrash($pidd) || WPML_WordPress_Actions::is_heartbeat()) {
         return;
     }
     $default_language = $sitepress->get_default_language();
     $post_vars = (array) $_POST;
     foreach ((array) $post as $k => $v) {
         $post_vars[$k] = $v;
     }
     $post_vars['post_type'] = isset($post_vars['post_type']) ? $post_vars['post_type'] : $post->post_type;
     $post_id = $pidd;
     if (isset($post_vars['action']) && $post_vars['action'] === 'post-quickpress-publish') {
         $language_code = $default_language;
     } else {
         $post_id = isset($post_vars['post_ID']) ? $post_vars['post_ID'] : $pidd;
         //latter case for XML-RPC publishing
         $language_code = $this->get_save_post_lang($post_id, $sitepress);
     }
     if ($this->is_inline_action($post_vars) && !($language_code = $this->get_element_lang_code($post_id))) {
         return;
     }
     if (isset($post_vars['icl_translation_of']) && is_numeric($post_vars['icl_translation_of'])) {
         $translation_of_data_prepared = $this->wpdb->prepare("SELECT trid, language_code\n\t\t\t\t FROM {$this->wpdb->prefix}icl_translations\n\t\t\t\t WHERE element_id=%d\n\t\t\t\t\tAND element_type=%s\n\t\t\t\t LIMIT 1", $post_vars['icl_translation_of'], 'post_' . $post->post_type);
         list($trid, $source_language) = $this->wpdb->get_row($translation_of_data_prepared, 'ARRAY_N');
     }
     if (isset($post_vars['icl_translation_of']) && $post_vars['icl_translation_of'] == 'none') {
         $trid = null;
         $source_language = $language_code;
     } else {
         $trid = isset($trid) && $trid ? $trid : $this->get_save_post_trid($post_id, $post->post_status);
         // after getting the right trid set the source language from it by referring to the root translation
         // of this trid, in case no proper source language has been set yet
         $source_language = isset($source_language) ? $source_language : $this->get_save_post_source_lang($trid, $language_code, $default_language);
     }
     if (isset($post_vars['icl_tn_note'])) {
         update_post_meta($post_id, '_icl_translator_note', $post_vars['icl_tn_note']);
     }
     $save_filter_action_state = new WPML_WP_Filter_State('save_post');
     $this->after_save_post($trid, $post_vars, $language_code, $source_language);
     $save_filter_action_state->restore();
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:50,代码来源:wpml-admin-post-actions.class.php


示例10: sync_menu_options

 function sync_menu_options($options_data)
 {
     foreach ($options_data as $menu_id => $translations) {
         foreach ($translations as $language => $option) {
             $translated_menu_id = $this->term_translations->term_id_in($menu_id, $language);
             if (isset($option['auto_add'])) {
                 $nav_menu_option = (array) get_option('nav_menu_options');
                 $nav_menu_option['auto_add'] = isset($nav_menu_option['auto_add']) ? $nav_menu_option['auto_add'] : array();
                 if ($option['auto_add'] && !in_array($translated_menu_id, $nav_menu_option['auto_add'])) {
                     $nav_menu_option['auto_add'][] = $translated_menu_id;
                 } elseif (!$option['auto_add'] && false !== ($key = array_search($translated_menu_id, $nav_menu_option['auto_add']))) {
                     unset($nav_menu_option['auto_add'][$key]);
                 }
                 $nav_menu_option['auto_add'] = array_intersect($nav_menu_option['auto_add'], wp_get_nav_menus(array('fields' => 'ids')));
                 update_option('nav_menu_options', array_filter($nav_menu_option));
                 wp_defer_term_counting(false);
                 do_action('wp_update_nav_menu', $translated_menu_id);
             }
         }
     }
 }
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:21,代码来源:menu-item-sync.class.php


示例11: import_start

 /**
  * Parses the XML file and prepares us for the task of processing parsed data
  *
  * @param string $file Path to the WXR file for importing
  */
 function import_start($file)
 {
     if (!is_file($file)) {
         echo '<p><strong>' . __('Sorry, there has been an error.', 'anno') . '</strong><br />';
         echo __('The file does not exist, please try again.', 'anno') . '</p>';
         $this->footer();
         die;
     }
     $import_data = $this->parse($file);
     if (is_wp_error($import_data)) {
         echo '<p><strong>' . __('Sorry, there has been an error.', 'anno') . '</strong><br />';
         echo esc_html($import_data->get_error_message()) . '</p>';
         $this->footer();
         die;
     }
     // Validation error likely
     if (isset($import_data['status']) && $import_data['status'] == 'error') {
         echo '<h3>' . __('There were the following errors while trying to validate your XML. Please correct them and try again.', 'anno') . '</h3>';
         foreach ($import_data['errors'] as $error) {
             $error_lines[] = $error['line'];
             echo '<div class="error">' . $error['fullMessage'] . '.</div>';
         }
         $this->output_XML($import_data['content'], $error_lines);
         $this->footer();
         die;
     }
     $this->version = $import_data['version'];
     $this->get_authors_from_import($import_data);
     $this->posts = $import_data['posts'];
     $this->terms = $import_data['terms'];
     $this->categories = $import_data['categories'];
     $this->tags = $import_data['tags'];
     $this->base_url = esc_url($import_data['base_url']);
     wp_defer_term_counting(true);
     wp_defer_comment_counting(true);
     do_action('import_start');
 }
开发者ID:dregula,项目名称:Annotum,代码行数:42,代码来源:dtd-importer.php


示例12: wp_nav_menu_update_menu_items

/**
 * Saves nav menu items
 *
 * @since 3.6.0
 *
 * @param int|string $nav_menu_selected_id (id, slug, or name ) of the currently-selected menu
 * @param string $nav_menu_selected_title Title of the currently-selected menu
 * @return array $messages The menu updated message
 */
function wp_nav_menu_update_menu_items($nav_menu_selected_id, $nav_menu_selected_title)
{
    $unsorted_menu_items = wp_get_nav_menu_items($nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish'));
    $messages = array();
    $menu_items = array();
    // Index menu items by db ID
    foreach ($unsorted_menu_items as $_item) {
        $menu_items[$_item->db_id] = $_item;
    }
    $post_fields = array('menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 'menu-item-title', 'menu-item-url', 'menu-item-description', 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn');
    wp_defer_term_counting(true);
    // Loop through all the menu items' POST variables
    if (!empty($_POST['menu-item-db-id'])) {
        foreach ((array) $_POST['menu-item-db-id'] as $_key => $k) {
            // Menu item title can't be blank
            if (!isset($_POST['menu-item-title'][$_key]) || '' == $_POST['menu-item-title'][$_key]) {
                continue;
            }
            $args = array();
            foreach ($post_fields as $field) {
                $args[$field] = isset($_POST[$field][$_key]) ? $_POST[$field][$_key] : '';
            }
            $menu_item_db_id = wp_update_nav_menu_item($nav_menu_selected_id, $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key, $args);
            if (is_wp_error($menu_item_db_id)) {
                $messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>';
            } else {
                unset($menu_items[$menu_item_db_id]);
            }
        }
    }
    // Remove menu items from the menu that weren't in $_POST
    if (!empty($menu_items)) {
        foreach (array_keys($menu_items) as $menu_item_id) {
            if (is_nav_menu_item($menu_item_id)) {
                wp_delete_post($menu_item_id);
            }
        }
    }
    // Store 'auto-add' pages.
    $auto_add = !empty($_POST['auto-add-pages']);
    $nav_menu_option = (array) get_option('nav_menu_options');
    if (!isset($nav_menu_option['auto_add'])) {
        $nav_menu_option['auto_add'] = array();
    }
    if ($auto_add) {
        if (!in_array($nav_menu_selected_id, $nav_menu_option['auto_add'])) {
            $nav_menu_option['auto_add'][] = $nav_menu_selected_id;
        }
    } else {
        if (false !== ($key = array_search($nav_menu_selected_id, $nav_menu_option['auto_add']))) {
            unset($nav_menu_option['auto_add'][$key]);
        }
    }
    // Remove nonexistent/deleted menus
    $nav_menu_option['auto_add'] = array_intersect($nav_menu_option['auto_add'], wp_get_nav_menus(array('fields' => 'ids')));
    update_option('nav_menu_options', $nav_menu_option);
    wp_defer_term_counting(false);
    /** This action is documented in wp-includes/nav-menu.php */
    do_action('wp_update_nav_menu', $nav_menu_selected_id);
    $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(__('<strong>%1$s</strong> has been updated.'), $nav_menu_selected_title) . '</p></div>';
    unset($menu_items, $unsorted_menu_items);
    return $messages;
}
开发者ID:pmanterys,项目名称:wp-mw-newsletter,代码行数:72,代码来源:nav-menu.php


示例13: do_sync

 function do_sync($data)
 {
     global $wpdb, $sitepress;
     $current_language = $sitepress->get_current_language();
     $default_language = $sitepress->get_default_language();
     // menu translations
     if (!empty($data['menu_translation'])) {
         foreach ($data['menu_translation'] as $menu_id => $translations) {
             foreach ($translations as $language => $name) {
                 $_POST['icl_translation_of'] = $wpdb->get_var($wpdb->prepare("SELECT term_taxonomy_id FROM {$wpdb->term_taxonomy} WHERE term_id=%d AND taxonomy='nav_menu'", $menu_id));
                 $_POST['icl_nav_menu_language'] = $language;
                 $menu_indentation = '';
                 $menu_increment = 0;
                 do {
                     $new_menu_id = wp_update_nav_menu_object(0, array('menu-name' => $name . $menu_indentation . $menu_increment));
                     $menu_increment = $menu_increment != '' ? $menu_increment + 1 : 2;
                     $menu_indentation = '-';
                 } while (is_wp_error($new_menu_id) && $menu_increment < 10);
                 $this->menus[$menu_id]['translations'][$language] = array('id' => $new_menu_id);
             }
         }
     }
     // menu options
     if (!empty($data['menu_options'])) {
         foreach ($data['menu_options'] as $menu_id => $translations) {
             foreach ($translations as $language => $option) {
                 $translated_menu_id = $this->get_translated_menu_id($menu_id, $language);
                 foreach ($option as $key => $value) {
                     switch ($key) {
                         case 'auto_add':
                             // Store 'auto-add' pages.
                             $auto_add = $value;
                             $nav_menu_option = (array) get_option('nav_menu_options');
                             if (!isset($nav_menu_option['auto_add'])) {
                                 $nav_menu_option['auto_add'] = array();
                             }
                             if ($auto_add) {
                                 if (!in_array($translated_menu_id, $nav_menu_option['auto_add'])) {
                                     $nav_menu_option['auto_add'][] = $translated_menu_id;
                                 }
                             } else {
                                 if (false !== ($key = array_search($translated_menu_id, $nav_menu_option['auto_add']))) {
                                     unset($nav_menu_option['auto_add'][$key]);
                                 }
                             }
                             // Remove nonexistent/deleted menus
                             $nav_menu_option['auto_add'] = array_intersect($nav_menu_option['auto_add'], wp_get_nav_menus(array('fields' => 'ids')));
                             update_option('nav_menu_options', $nav_menu_option);
                             wp_defer_term_counting(false);
                             do_action('wp_update_nav_menu', $translated_menu_id);
                             break;
                     }
                 }
             }
         }
     }
     // deleting items
     if (!empty($data['del'])) {
         foreach ($data['del'] as $languages) {
             foreach ($languages as $items) {
                 foreach ($items as $item_id => $name) {
                     wp_delete_post($item_id, true);
                     $delete_trid = $sitepress->get_element_trid($item_id, 'post_nav_menu_item');
                     if ($delete_trid) {
                         $sitepress->delete_element_translation($delete_trid, 'post_nav_menu_item');
                     }
                 }
             }
         }
     }
     // moving items
     if (!empty($data['mov'])) {
         foreach ($data['mov'] as $menu_id => $items) {
             foreach ($items as $item_id => $changes) {
                 $trid = $sitepress->get_element_trid($item_id, 'post_nav_menu_item');
                 if (!$trid) {
                     $sitepress->set_element_language_details($item_id, 'post_nav_menu_item', false, $default_language);
                     $trid = $sitepress->get_element_trid($item_id, 'post_nav_menu_item');
                 }
                 foreach ($changes as $language => $details) {
                     $translated_item_id = $this->menus[$menu_id]['items'][$item_id]['translations'][$language]['ID'];
                     $new_menu_order = key($details);
                     $this->menus[$menu_id]['items'][$item_id]['translations'][$language]['menu_order'] = $new_menu_order;
                     $wpdb->update($wpdb->posts, array('menu_order' => $new_menu_order), array('ID' => $translated_item_id));
                     $sitepress->set_element_language_details($translated_item_id, 'post_nav_menu_item', $trid, $language);
                 }
             }
         }
         // fix hierarchy
         foreach ($data['mov'] as $menu_id => $items) {
             foreach ($items as $item_id => $changes) {
                 $parent_item = get_post_meta($item_id, '_menu_item_menu_item_parent', true);
                 foreach ($changes as $language => $details) {
                     $translated_item_id = $this->menus[$menu_id]['items'][$item_id]['translations'][$language]['ID'];
                     $translated_parent_menu_item_id = icl_object_id($parent_item, get_post_type($parent_item), false, $language);
                     if ($translated_parent_menu_item_id == $translated_item_id) {
                         $translated_parent_menu_item_id = false;
                     }
                     update_post_meta($translated_item_id, '_menu_item_menu_item_parent', $translated_parent_menu_item_id);
                 }
//.........这里部分代码省略.........
开发者ID:Calraiser,项目名称:flux,代码行数:101,代码来源:menus-sync.php


示例14: import_end

 /**
  * Performs post-import cleanup of files and the cache
  */
 function import_end()
 {
     wp_import_cleanup($this->id);
     wp_cache_flush();
     foreach (get_taxonomies() as $tax) {
         delete_option("{$tax}_children");
         _get_term_hierarchy($tax);
     }
     wp_defer_term_counting(false);
     wp_defer_comment_counting(false);
     echo '<p>' . __('All done.', 'nav-menu-roles') . ' <a href="' . admin_url() . '">' . __('Have fun!', 'nav-menu-roles') . '</a>' . '</p>';
     do_action('import_end');
 }
开发者ID:JaneJieYing,项目名称:HiFridays,代码行数:16,代码来源:class.Nav_Menu_Roles_Import.php


示例15: array

                if (!isset($nav_menu_option['auto_add'])) {
                    $nav_menu_option['auto_add'] = array();
                }
                if ($auto_add) {
                    if (!in_array($nav_menu_selected_id, $nav_menu_option['auto_add'])) {
                        $nav_menu_option['auto_add'][] = $nav_menu_selected_id;
                    }
                } else {
                    if (false !== ($key = array_search($nav_menu_selected_id, $nav_menu_option['auto_add']))) {
                        unset($nav_menu_option['auto_add'][$key]);
                    }
                }
                // Remove nonexistent/deleted menus
                $nav_menu_option['auto_add'] = array_intersect($nav_menu_option['auto_add'], wp_get_nav_menus(array('fields' => 'ids')));
                update_option('nav_menu_options', $nav_menu_option);
                wp_defer_term_counting(false);
                do_action('wp_update_nav_menu', $nav_menu_selected_id);
                $messages[] = '<div id="message" class="updated"><p>' . sprintf(__('The <strong>%s</strong> menu has been updated.'), $nav_menu_selected_title) . '</p></div>';
                unset($menu_items, $unsorted_menu_items);
            }
        }
        break;
}
// Get all nav menus
$nav_menus = wp_get_nav_menus(array('orderby' => 'name'));
// Get recently edited nav menu
$recently_edited = (int) get_user_option('nav_menu_recently_edited');
// If there was no recently edited menu, and $nav_menu_selected_id is a nav menu, update recently edited menu.
if (!$recently_edited && is_nav_menu($nav_menu_selected_id)) {
    $recently_edited = $nav_menu_selected_id;
    // Else if $nav_menu_selected_id is not a menu and not requesting that we create a new menu, but $recently_edited is a menu, grab that one.
开发者ID:Esleelkartea,项目名称:asociacion-tecnicos-artes-escenicas-ATAE-,代码行数:31,代码来源:nav-menus.php


示例16: import_end

 /**
  * Performs post-import cleanup of files and the cache
  */
 function import_end()
 {
     wp_import_cleanup($this->id);
     wp_cache_flush();
     foreach (get_taxonomies() as $tax) {
         delete_option("{$tax}_children");
         _get_term_hierarchy($tax);
     }
     wp_defer_term_counting(false);
     wp_defer_comment_counting(false);
     echo '<p>' . __('All done.', 'wordpress-importer') . '</p>';
     do_action('import_end');
 }
开发者ID:anthonyeden,项目名称:prso-content-syndication-toolkit-reader,代码行数:16,代码来源:class.importer.php


示例17: update_term_counts

 /**
  * Count terms. These are done at this point so all product props are set in advance.
  *
  * @param WC_Product
  * @since 2.7.0
  */
 protected function update_term_counts(&$product)
 {
     if (!wp_defer_term_counting()) {
         global $wc_allow_term_recount;
         $wc_allow_term_recount = true;
         $post_type = $product->is_type('variation') ? 'product_variation' : 'product';
         // Update counts for the post's terms.
         foreach ((array) get_object_taxonomies($post_type) as $taxonomy) {
             $tt_ids = wc_get_object_terms($product->get_id(), $taxonomy, 'term_taxonomy_id');
             wp_update_term_count($tt_ids, $taxonomy);
         }
     }
 }
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:19,代码来源:class-wc-product-data-store-cpt.php


示例18: import_end

 /**
  * Performs post-import cleanup of files and the cache
  */
 protected function import_end()
 {
     // Re-enable stuff in core
     wp_suspend_cache_invalidation(false);
     wp_cache_flush();
     foreach (get_taxonomies() as $tax) {
         delete_option("{$tax}_children");
         _get_term_hierarchy($tax);
     }
     wp_defer_term_counting(false);
     wp_defer_comment_counting(false);
     /**
      * Complete the import.
      *
      * Fires after the import process has finished. If you need to update
      * your cache or re-enable processing, do so here.
      */
     do_action('import_end');
 }
开发者ID:kucrut,项目名称:WordPress-Importer,代码行数:22,代码来源:class-wxr-importer.php


示例19: defer_counting

 function defer_counting($bool)
 {
     wp_defer_term_counting($bool);
     wp_defer_comment_counting($bool);
 }
开发者ID:jimmitjoo,项目名称:mnh,代码行数:5,代码来源:class-dfrps-update.php


示例20: import_end

 /**
  * Performs post-import cleanup of files and the cache
  */
 function import_end()
 {
     wp_import_cleanup($this->id);
     wp_cache_flush();
     foreach (get_taxonomies() as $tax) {
         delete_option("{$tax}_children");
         _get_term_hierarchy($tax);
     }
     wp_defer_term_counting(false);
     wp_defer_comment_counting(false);
     update_option('cherry_sample_data', 1);
     do_action('import_end');
     $this->log(date('Y-m-d H:i:s'));
     $this->log(PHP_EOL . 'Import end' . PHP_EOL);
 }
开发者ID:poolieweb,项目名称:LawStaticAthena,代码行数:18,代码来源:wordpress-importer.php



注:本文中的wp_defer_term_counting函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_delete_attachment函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_defer_comment_counting函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap