当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_Import::process_posts方法代码示例

本文整理汇总了PHP中WP_Import::process_posts方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Import::process_posts方法的具体用法?PHP WP_Import::process_posts怎么用?PHP WP_Import::process_posts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Import的用法示例。


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

示例1: array

 function process_posts()
 {
     $menu_items = $mo_posts = array();
     // store this for future usage as parent function unset $this->posts
     foreach ($this->posts as $post) {
         if ('nav_menu_item' == $post['post_type']) {
             $menu_items[] = $post;
         }
         if (0 === strpos($post['post_title'], 'polylang_mo_')) {
             $mo_posts[] = $post;
         }
     }
     if (!empty($mo_posts)) {
         new PLL_MO();
     }
     // just to register the polylang_mo post type before processing posts
     parent::process_posts();
     global $polylang;
     $polylang->model->clean_languages_cache();
     // to update the posts count in (cached) languages list
     $this->remap_translations($this->post_translations, $this->processed_posts);
     unset($this->post_translations);
     // language switcher menu items
     foreach ($menu_items as $item) {
         foreach ($item['postmeta'] as $meta) {
             if ('_pll_menu_item' == $meta['key']) {
                 update_post_meta($this->processed_menu_items[$item['post_id']], '_pll_menu_item', maybe_unserialize($meta['value']));
             }
         }
     }
     // merge strings translations
     foreach ($mo_posts as $post) {
         $lang_id = (int) substr($post['post_title'], 12);
         if (!empty($this->processed_terms[$lang_id])) {
             if ($strings = unserialize($post['post_content'])) {
                 $mo = new PLL_MO();
                 $mo->import_from_db($this->processed_terms[$lang_id]);
                 foreach ($strings as $msg) {
                     $mo->add_entry_or_merge($mo->make_entry($msg[0], $msg[1]));
                 }
                 $mo->export_to_db($this->processed_terms[$lang_id]);
             }
         }
         // delete the now useless imported post
         wp_delete_post($this->processed_posts[$post['post_id']], true);
     }
 }
开发者ID:santikrass,项目名称:apache,代码行数:47,代码来源:wp-import.php

示例2: process_posts

 public function process_posts()
 {
     do_action('bunyad_import_process_posts_pre', $this);
     parent::process_posts();
 }
开发者ID:silverbux,项目名称:smartmag-magazine-wordpress,代码行数:5,代码来源:wp-import.php

示例3: wpImportAttachments

 public function wpImportAttachments($file, $import_limit = 10)
 {
     $wp_import = new WP_Import();
     $wp_import->fetch_attachments = true;
     // load data from saved option
     $wp_import->post_orphans = get_option('_cri_post_orphans', array());
     $wp_import->processed_posts = get_option('_cri_processed_posts', array());
     $wp_import->url_remap = get_option('_cri_url_remap', array());
     add_filter('import_post_meta_key', array($wp_import, 'is_valid_meta_key'));
     add_filter('http_request_timeout', array(&$wp_import, 'bump_request_timeout'));
     // start buffer
     ob_start();
     // parse file and gather data
     $wp_import->import_start($file);
     // map author
     $wp_import->get_author_mapping();
     // attachment to be imported
     $attachments = array();
     foreach ($wp_import->posts as $post) {
         // only import attachment
         if ($post['post_type'] == 'attachment') {
             // if attachment has been imported already
             if (isset($wp_import->processed_posts[$post['post_id']]) && !empty($post['post_id'])) {
                 continue;
             }
             // if limit exceed, kill the loop
             if ($import_limit < 1) {
                 break;
             } else {
                 $import_limit--;
             }
             $attachments[] = $post;
         }
     }
     // if attachments reach to zero, we are done
     if (empty($attachments)) {
         return true;
     }
     // set importable posts to attachments
     $wp_import->posts = $attachments;
     // this process the attachments, turn off/on cache
     wp_suspend_cache_invalidation(true);
     $wp_import->process_posts();
     wp_suspend_cache_invalidation(false);
     // end has output, so buffer it out
     $wp_import->import_end();
     ob_end_clean();
     // save all post_orphans, processed_posts & url_remap to be used on the next run. also this will run on post import
     update_option('_cri_post_orphans', $wp_import->post_orphans);
     update_option('_cri_processed_posts', $wp_import->processed_posts);
     update_option('_cri_url_remap', $wp_import->url_remap);
     // false means we are going to continue
     return false;
 }
开发者ID:AlchemyMomentum,项目名称:public_html,代码行数:54,代码来源:radium-importer.php

示例4: process_posts

 public function process_posts()
 {
     $this->updateStats(__("Importing posts", 'Pixelentity Theme/Plugin'));
     parent::process_posts();
 }
开发者ID:JeffreyBue,项目名称:jb,代码行数:5,代码来源:PeThemeImporter.php


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