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

PHP wp_create_categories函数代码示例

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

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



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

示例1: import

 function import()
 {
     $post_date = $this->published;
     $post_content = $this->content;
     $post_title = $this->title;
     $post_author = $this->author;
     $post_status = $this->isDraft ? 'draft' : 'publish';
     //AGC:24/10/2013 Turn off the pingbacks
     $post_pingback = Blogger_Importer::POST_PINGBACK;
     // N.B. Clean up of $post_content is now part of the sanitize class
     // Check for duplication part of calling function
     $post = compact('post_date', 'post_content', 'post_author', 'post_title', 'post_status', 'post_pingback');
     $post_id = wp_insert_post($post);
     if (is_wp_error($post_id)) {
         return $post_id;
     }
     wp_create_categories(array_map('addslashes', $this->categories), $post_id);
     add_post_meta($post_id, 'blogger_blog', $this->blogurl, true);
     add_post_meta($post_id, 'blogger_author', $this->bloggerauthor, true);
     if (!$this->isDraft && isset($this->bookmark)) {
         add_post_meta($post_id, 'blogger_permalink', $this->bookmark, true);
     }
     add_post_meta($post_id, 'blogger_internal', $this->old_permalink, true);
     if (isset($this->geotags)) {
         add_post_meta($post_id, 'geo_latitude', $this->geotags['geo_latitude']);
         add_post_meta($post_id, 'geo_longitude', $this->geotags['geo_longitude']);
         add_post_meta($post_id, 'geo_public', 1);
         if (isset($this->geotags['geo_address'])) {
             add_post_meta($post_id, 'geo_address', $this->geotags['geo_address']);
         }
     }
     return $post_id;
 }
开发者ID:cabelotaina,项目名称:redelivre,代码行数:33,代码来源:blogger-entry.php


示例2: insert_post

 /**
  * Insert post
  *
  * @param  array $post_object The post object.
  * @return mixed The post id or WP_Error object.
  * @since  0.1.0
  */
 public static function insert_post($post)
 {
     // unset all empty fields
     foreach ($post as $key => $value) {
         if (!is_array($value) && !strlen($value)) {
             unset($post[$key]);
         } elseif (is_array($value) && !count($value)) {
             unset($post[$key]);
         }
     }
     // insert and set category
     if (isset($post['post_category']) && is_array($post['post_category']) && count($post['post_category'])) {
         $post['post_category'] = wp_create_categories($post['post_category']);
     }
     if (isset($post['post_date']) && $post['post_date']) {
         $post['post_date'] = date("Y-m-d H:i:s", strtotime($post['post_date']));
     }
     // setup author
     if (isset($post['post_author']) && !intval($post['post_author'])) {
         $field = apply_filters('acsv_get_user_by_field', 'login');
         $u = get_user_by($field, $post['post_author']);
         if ($u) {
             $post['post_author'] = $u->ID;
         } else {
             unset($post['post_author']);
         }
     }
     // setup post ID
     if (isset($post['ID']) && !intval($post['ID'])) {
         unset($post['ID']);
     }
     // set default to the post.
     foreach (Defaults\Config::get_post_defaults() as $key => $value) {
         if (!isset($post[$key])) {
             $post[$key] = $value;
         }
     }
     $helper = new \Megumi\WP\Post\Helper($post);
     $post_id = $helper->insert();
     if (is_wp_error($post_id)) {
         return $post_id;
     } else {
         do_action('acsv_after_insert_post', $post_id, $post, $helper);
         return $post_id;
     }
 }
开发者ID:adaminfinitum,项目名称:advanced-csv-importer,代码行数:53,代码来源:Main.php


示例3: save_post

 function save_post(&$post, &$comments, &$pings)
 {
     // Reset the counter
     set_time_limit(30);
     $post = get_object_vars($post);
     $post = add_magic_quotes($post);
     $post = (object) $post;
     if ($post_id = post_exists($post->post_title, '', $post->post_date)) {
         echo '<li>';
         printf(__('Post <em>%s</em> already exists.'), stripslashes($post->post_title));
     } else {
         echo '<li>';
         printf(__('Importing post <em>%s</em>...'), stripslashes($post->post_title));
         if ('' != trim($post->extended)) {
             $post->post_content .= "\n<!--more-->\n{$post->extended}";
         }
         $post->post_author = $this->checkauthor($post->post_author);
         //just so that if a post already exists, new users are not created by checkauthor
         $post_id = wp_insert_post($post);
         if (is_wp_error($post_id)) {
             return $post_id;
         }
         // Add categories.
         if (0 != count($post->categories)) {
             wp_create_categories($post->categories, $post_id);
         }
         // Add tags or keywords
         if (1 < strlen($post->post_keywords)) {
             // Keywords exist.
             printf(__('<br />Adding tags <i>%s</i>...'), stripslashes($post->post_keywords));
             wp_add_post_tags($post_id, $post->post_keywords);
         }
     }
     $num_comments = 0;
     foreach ($comments as $comment) {
         $comment = get_object_vars($comment);
         $comment = add_magic_quotes($comment);
         if (!comment_exists($comment['comment_author'], $comment['comment_date'])) {
             $comment['comment_post_ID'] = $post_id;
             $comment = wp_filter_comment($comment);
             wp_insert_comment($comment);
             $num_comments++;
         }
     }
     if ($num_comments) {
         printf(' ' . __ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments);
     }
     $num_pings = 0;
     foreach ($pings as $ping) {
         $ping = get_object_vars($ping);
         $ping = add_magic_quotes($ping);
         if (!comment_exists($ping['comment_author'], $ping['comment_date'])) {
             $ping['comment_content'] = "<strong>{$ping['title']}</strong>\n\n{$ping['comment_content']}";
             $ping['comment_post_ID'] = $post_id;
             $ping = wp_filter_comment($ping);
             wp_insert_comment($ping);
             $num_pings++;
         }
     }
     if ($num_pings) {
         printf(' ' . __ngettext('(%s ping)', '(%s pings)', $num_pings), $num_pings);
     }
     echo "</li>";
     //ob_flush();flush();
 }
开发者ID:BGCX262,项目名称:zxhproject-svn-to-git,代码行数:65,代码来源:mt.php


示例4: cfgp_do_categories

function cfgp_do_categories($clone_id, $cur_cats_names)
{
    /* $cur_cats_names should be an array of category names only */
    if (!function_exists('wp_create_categories')) {
        /* INCLUDE ALL ADMIN FUNCTIONS */
        require_once ABSPATH . 'wp-admin/includes/admin.php';
    }
    /* This function creates the cats if they don't exist, and
     * 	then assigns them to the post ID that's passed. */
    $cats_results = wp_create_categories($cur_cats_names, $clone_id);
    if (is_array($cats_results) && !empty($cats_results)) {
        return true;
    } else {
        return false;
    }
}
开发者ID:bigdawggi,项目名称:wp-cf-global-posts,代码行数:16,代码来源:cf-global-posts.php


示例5: import_posts

	function import_posts() {
		global $wpdb, $current_user;

		set_magic_quotes_runtime(0);
		$importdata = file($this->file); // Read the file into an array
		$importdata = implode('', $importdata); // squish it
		$importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata);

		preg_match_all('|(<item[^>]+>(.*?)</item>)|is', $importdata, $posts);
		$posts = $posts[1];
		unset($importdata);
		echo '<ol>';
		foreach ($posts as $post) {
			flush();
			preg_match('|<item type=\"(.*?)\">|is', $post, $post_type);
			$post_type = $post_type[1];
			if($post_type == "photo") {
				preg_match('|<photoFilename>(.*?)</photoFilename>|is', $post, $post_title);
			} else {
				preg_match('|<title>(.*?)</title>|is', $post, $post_title);
			}
			$post_title = $wpdb->escape(trim($post_title[1]));

			preg_match('|<pubDate>(.*?)</pubDate>|is', $post, $post_date);
			$post_date = strtotime($post_date[1]);
			$post_date = gmdate('Y-m-d H:i:s', $post_date);

			preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
			$categories = $categories[1];

			$cat_index = 0;
			foreach ($categories as $category) {
				$categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
				$cat_index++;
			}

			if(strcasecmp($post_type, "photo") === 0) {
				preg_match('|<sizedPhotoUrl>(.*?)</sizedPhotoUrl>|is', $post, $post_content);
				$post_content = '<img src="'.trim($post_content[1]).'" />';
				$post_content = $this->unhtmlentities($post_content);
			} else {
				preg_match('|<body>(.*?)</body>|is', $post, $post_content);
				$post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
				$post_content = $this->unhtmlentities($post_content);
			}

			// Clean up content
			$post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
			$post_content = str_replace('<br>', '<br />', $post_content);
			$post_content = str_replace('<hr>', '<hr />', $post_content);
			$post_content = $wpdb->escape($post_content);

			$post_author = $current_user->ID;
			preg_match('|<postStatus>(.*?)</postStatus>|is', $post, $post_status);
			$post_status = trim($post_status[1]);

			echo '<li>';
			if ($post_id = post_exists($post_title, $post_content, $post_date)) {
				printf(__('Post <em>%s</em> already exists.'), stripslashes($post_title));
			} else {
				printf(__('Importing post <em>%s</em>...'), stripslashes($post_title));
				$postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
				$post_id = wp_insert_post($postdata);
				if ( is_wp_error( $post_id ) ) {
					return $post_id;
				}
				if (!$post_id) {
					_e("Couldn't get post ID");
					echo '</li>';
					break;
				}
				if(0 != count($categories))
					wp_create_categories($categories, $post_id);
			}

			preg_match_all('|<comment>(.*?)</comment>|is', $post, $comments);
			$comments = $comments[1];

			if ( $comments ) {
				$comment_post_ID = (int) $post_id;
				$num_comments = 0;
				foreach ($comments as $comment) {
					preg_match('|<body>(.*?)</body>|is', $comment, $comment_content);
					$comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
					$comment_content = $this->unhtmlentities($comment_content);

					// Clean up content
					$comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content);
					$comment_content = str_replace('<br>', '<br />', $comment_content);
					$comment_content = str_replace('<hr>', '<hr />', $comment_content);
					$comment_content = $wpdb->escape($comment_content);

					preg_match('|<pubDate>(.*?)</pubDate>|is', $comment, $comment_date);
					$comment_date = trim($comment_date[1]);
					$comment_date = date('Y-m-d H:i:s', strtotime($comment_date));

					preg_match('|<author>(.*?)</author>|is', $comment, $comment_author);
					$comment_author = $wpdb->escape(trim($comment_author[1]));

					$comment_author_email = NULL;
//.........这里部分代码省略.........
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:blogware.php


示例6: process_posts


//.........这里部分代码省略.........
             if ($post_title) {
                 $post['post_title'] = $post_title;
             }
             // (string) post content
             $post_content = $h->get_data($this, $data, 'post_content');
             if ($post_content) {
                 $post['post_content'] = $post_content;
             }
             // (string) post excerpt
             $post_excerpt = $h->get_data($this, $data, 'post_excerpt');
             if ($post_excerpt) {
                 $post['post_excerpt'] = $post_excerpt;
             }
             // (int) post parent
             $post_parent = $h->get_data($this, $data, 'post_parent');
             if ($post_parent) {
                 $post['post_parent'] = $post_parent;
             }
             // (int) menu order
             $menu_order = $h->get_data($this, $data, 'menu_order');
             if ($menu_order) {
                 $post['menu_order'] = $menu_order;
             }
             // (string) comment status
             $comment_status = $h->get_data($this, $data, 'comment_status');
             if ($comment_status) {
                 $post['comment_status'] = $comment_status;
             }
             // (string, comma separated) slug of post categories
             $post_category = $h->get_data($this, $data, 'post_category');
             if ($post_category) {
                 $categories = preg_split("/,+/", $post_category);
                 if ($categories) {
                     $post['post_category'] = wp_create_categories($categories);
                 }
             }
             // (string, comma separated) name of post tags
             $post_tags = $h->get_data($this, $data, 'post_tags');
             if ($post_tags) {
                 $post['post_tags'] = $post_tags;
             }
             // (string) post thumbnail image uri
             $post_thumbnail = $h->get_data($this, $data, 'post_thumbnail');
             $meta = array();
             $tax = array();
             // add any other data to post meta
             foreach ($data as $key => $value) {
                 if ($value !== false && isset($this->column_keys[$key])) {
                     // check if meta is custom taxonomy
                     if (substr($this->column_keys[$key], 0, 4) == 'tax_') {
                         // (string, comma divided) name of custom taxonomies
                         $customtaxes = preg_split("/,+/", $value);
                         $taxname = substr($this->column_keys[$key], 4);
                         $tax[$taxname] = array();
                         foreach ($customtaxes as $key => $value) {
                             $tax[$taxname][] = $value;
                         }
                     } else {
                         $meta[$this->column_keys[$key]] = $value;
                     }
                 }
             }
             /**
              * Filter post data.
              *
              * @param array $post (required)
开发者ID:beeyayjay,项目名称:really-simple-csv-importer,代码行数:67,代码来源:rs-csv-importer.php


示例7: import_posts

 function import_posts()
 {
     echo '<ol>';
     foreach ($this->posts as $post) {
         echo "<li>" . __('Importing post...', 'rss-importer');
         extract($post);
         if ($post_id = post_exists($post_title, $post_content, $post_date)) {
             _e('Post already imported', 'rss-importer');
         } else {
             $post_id = wp_insert_post($post);
             if (is_wp_error($post_id)) {
                 return $post_id;
             }
             if (!$post_id) {
                 _e('Couldn&#8217;t get post ID', 'rss-importer');
                 return;
             }
             if (0 != count($categories)) {
                 wp_create_categories($categories, $post_id);
             }
             _e('Done!', 'rss-importer');
         }
         echo '</li>';
     }
     echo '</ol>';
 }
开发者ID:kemayo,项目名称:wp-rss-importer,代码行数:26,代码来源:rss-importer.php


示例8: create_post

 function create_post($data)
 {
     $output = "<li>" . __('Importing post...');
     $data = array_merge($this->defaults, $data);
     $status = isset($_POST['lightspeed_publish_state']) ? $_POST['lightspeed_publish_state'] : $this->defaults['lightspeed_publish_state'];
     $type = isset($_POST['lightspeed_post_type']) && $_POST['lightspeed_post_type'] !== '' ? $_POST['lightspeed_post_type'] : $this->defaults['lightspeed_post_type'];
     $language = isset($_POST['lightspeed_language']) && $_POST['lightspeed_language'] !== '' ? $_POST['lightspeed_language'] : $this->defaults['lightspeed_language'];
     $categories = array();
     // Lightspeed has a different column for every category
     if ($data[$language . '_Category_1'] != '') {
         $categories[] = $this->create_category($data[$language . '_Category_1']);
     }
     if ($data[$language . '_Category_2'] != '') {
         $categories[] = $this->create_category($data[$language . '_Category_2']);
     }
     if ($data[$language . '_Category_3'] != '') {
         $categories[] = $this->create_category($data[$language . '_Category_3']);
     }
     $new_post = array('post_name' => wp_strip_all_tags($data[$language . '_Title_Short']), 'post_title' => wp_strip_all_tags($data[$language . '_Title_Long']), 'post_content' => convert_chars($data[$language . '_Description_Short']), 'post_status' => $status, 'post_type' => $type, 'post_category' => $categories);
     // We don't need to store this in the Custom Meta
     unset($data['Body (HTML)']);
     // pages don't have tags or categories
     if ('page' !== $type) {
         $new_post['tags_input'] = $data['Tags'];
     }
     if ($id = post_exists($new_post['post_title'], $new_post['post_content'])) {
         $new_post['ID'] = (int) $id;
         // Update Post
         $id = wp_update_post($new_post);
         if (is_wp_error($id)) {
             return $id;
         }
         if (!$id) {
             $output .= "Couldn't get post ID";
             return false;
         }
         // Add Custom Fields
         //foreach($data as $key => $value) { update_post_meta($id, sanitize_user('Shopify '.$key), esc_attr($value)); }
         $output .= 'Updated !' . ' <a href="' . get_permalink($id) . '" target="blank">View ' . $data['Title'] . '</a>';
     } else {
         // A post does not yet exist.
         // Create Post
         $id = wp_insert_post($new_post);
         // Add Custom Fields
         foreach ($data as $key => $value) {
             add_post_meta($id, sanitize_user('Shopify ' . $key), esc_attr($value));
         }
         $output .= 'Done !' . ' <a href="' . get_permalink($id) . '">View ' . $data['Title'] . '</a>';
     }
     // If you want to import categories, here we go!
     if (isset($_POST['shopify_importer_import_categories']) && $_POST['shopify_importer_import_categories'] == 'yes') {
         $categories = explode(',', $data['Vendor']);
         if (0 != count($categories)) {
             wp_create_categories($categories, $id);
         }
     }
     $output .= '</li>';
     return $output;
 }
开发者ID:Willemdumee,项目名称:WordPress-Lightspeed-Importer,代码行数:59,代码来源:class-lightspeed-importer.php


示例9: array

		
	}
		
	

	<li>Add categories</li>
	<ol>
		<li>$wpdb->insert( $wpdb->terms, array('name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );</li>
		<li>$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => '1', 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));</li>
		<li>A lot easier than this</li>
		<li>the cats won't show up in nav until posts are in cat</li>
		<li>Strangely, it seeems that the categories have the same ids across blogs.</li>
	</ol>
	
	<?php 
    $catids = wp_create_categories($blcats);
    echo '<pre>';
    print_r($catids);
    echo '</pre>';
    ?>
	<li>Change theme in options table</li>
	<ol>
		<?php 
    $curth = 'custom daily globe theme';
    ?>
		<li>current_theme: <?php 
    echo $curth;
    ?>
</li>
		<?php 
    $dgl = 'dailyglobe';
开发者ID:elizabethcb,项目名称:Daily-Globe,代码行数:30,代码来源:submit-blog.php


示例10: createPost


//.........这里部分代码省略.........
                 }
             }
         }
     }
     // yoast seo extension
     if ($seo_ext_activated) {
         $_seo_opengraph_image = isset($post_custom[WPSEO_Meta::$meta_prefix . 'opengraph-image']) ? $post_custom[WPSEO_Meta::$meta_prefix . 'opengraph-image'] : array();
         $_seo_opengraph_image = current($_seo_opengraph_image);
         $_server_domain = '';
         $_server = get_option('mainwp_child_server');
         if (preg_match('/(https?:\\/\\/[^\\/]+\\/).+/', $_server, $matchs)) {
             $_server_domain = isset($matchs[1]) ? $matchs[1] : '';
         }
         // upload image if it on the server
         if (!empty($_seo_opengraph_image) && strpos($_seo_opengraph_image, $_server_domain) !== false) {
             try {
                 $upload = MainWP_Helper::uploadImage($_seo_opengraph_image);
                 //Upload image to WP
                 if (null !== $upload) {
                     update_post_meta($new_post_id, WPSEO_Meta::$meta_prefix . 'opengraph-image', $upload['url']);
                     //Add the image to the post!
                 }
             } catch (Exception $e) {
             }
         }
     }
     //If categories exist, create them (second parameter of wp_create_categories adds the categories to the post)
     include_once ABSPATH . 'wp-admin/includes/taxonomy.php';
     //Contains wp_create_categories
     if (isset($post_category) && '' !== $post_category) {
         $categories = explode(',', $post_category);
         if (count($categories) > 0) {
             if (!$post_to_only_existing_categories) {
                 $post_category = wp_create_categories($categories, $new_post_id);
             } else {
                 $cat_ids = array();
                 foreach ($categories as $cat) {
                     if ($id = category_exists($cat)) {
                         $cat_ids[] = $id;
                     }
                 }
                 if (count($cat_ids) > 0) {
                     wp_set_post_categories($new_post_id, $cat_ids);
                 }
             }
         }
     }
     //If featured image exists - set it
     if (null !== $post_featured_image) {
         try {
             $upload = MainWP_Helper::uploadImage($post_featured_image);
             //Upload image to WP
             if (null !== $upload) {
                 update_post_meta($new_post_id, '_thumbnail_id', $upload['id']);
                 //Add the thumbnail to the post!
             }
         } catch (Exception $e) {
         }
     }
     // post plus extension process
     if ($is_post_plus) {
         $random_privelege = isset($post_custom['_saved_draft_random_privelege']) ? $post_custom['_saved_draft_random_privelege'] : null;
         $random_privelege = is_array($random_privelege) ? current($random_privelege) : null;
         $random_privelege_base = base64_decode($random_privelege);
         $random_privelege = maybe_unserialize($random_privelege_base);
         if (is_array($random_privelege) && count($random_privelege) > 0) {
开发者ID:jexmex,项目名称:mainwp-child,代码行数:67,代码来源:class-mainwp-helper.php


示例11: import_post

 function import_post($entry)
 {
     global $importing_blog;
     foreach ($entry->links as $link) {
         // save the self link as meta
         if ($link['rel'] == 'self') {
             $postself = $link['href'];
             $parts = parse_url($link['href']);
             $entry->old_permalink = $parts['path'];
         }
         // get the old URI for the page when available
         if ($link['rel'] == 'alternate') {
             $parts = parse_url($link['href']);
             $entry->bookmark = $parts['path'];
         }
         // save the replies feed link as meta (ignore the comment form one)
         if ($link['rel'] == 'replies' && false === strpos($link['href'], '#comment-form')) {
             $postreplies = $link['href'];
         }
     }
     //Check if we are double cleaning here? Does the Simplepie already do all this?
     $post_date = $entry->published;
     $post_content = trim(addslashes($this->no_apos(@html_entity_decode($entry->content, ENT_COMPAT, get_option('blog_charset')))));
     $post_title = trim(addslashes($this->no_apos($this->min_whitespace($entry->title))));
     $post_status = $entry->isDraft ? 'draft' : 'publish';
     // N.B. Clean up of $post_content is now part of the sanitize class
     // Checks for duplicates
     if (isset($this->blogs[$importing_blog]['posts'][$entry->old_permalink])) {
         $this->blogs[$importing_blog]['posts_skipped']++;
     } elseif ($post_id = post_exists($post_title, $post_content, $post_date)) {
         $this->blogs[$importing_blog]['posts'][$entry->old_permalink] = $post_id;
         $this->blogs[$importing_blog]['posts_skipped']++;
     } else {
         $post = compact('post_date', 'post_content', 'post_title', 'post_status');
         $post_id = wp_insert_post($post);
         if (is_wp_error($post_id)) {
             return $post_id;
         }
         wp_create_categories(array_map('addslashes', $entry->categories), $post_id);
         $author = $this->no_apos(strip_tags($entry->author));
         add_post_meta($post_id, 'blogger_blog', $this->blogs[$importing_blog]['host'], true);
         add_post_meta($post_id, 'blogger_author', $author, true);
         //Use the page id if available or the blogger internal id if it's a draft
         if ($entry->isDraft | !isset($entry->bookmark)) {
             add_post_meta($post_id, 'blogger_permalink', $entry->old_permalink, true);
         } else {
             add_post_meta($post_id, 'blogger_permalink', $entry->bookmark, true);
         }
         add_post_meta($post_id, '_blogger_self', $postself, true);
         if (isset($entry->geotags)) {
             add_post_meta($post_id, 'geo_latitude', $entry->geotags['geo_latitude']);
             add_post_meta($post_id, 'geo_longitude', $entry->geotags['geo_longitude']);
             if (isset($entry->geotags['geo_address'])) {
                 add_post_meta($post_id, 'geo_address', $entry->geotags['geo_address']);
             }
         }
         $this->blogs[$importing_blog]['posts'][$entry->old_permalink] = $post_id;
         $this->blogs[$importing_blog]['posts_done']++;
     }
     $this->save_vars();
     return;
 }
开发者ID:hscale,项目名称:webento,代码行数:62,代码来源:blogger-importer.php


示例12: process_posts


//.........这里部分代码省略.........
             if ($post_status) {
                 $post['post_status'] = $post_status;
             }
             // (string) post title
             $post_title = $h->get_data($this, $data, 'post_title');
             if ($post_title) {
                 $post['post_title'] = $post_title;
             }
             // (string) post content
             $post_content = $h->get_data($this, $data, 'post_content');
             if ($post_content) {
                 $post['post_content'] = $post_content;
             }
             // (string) post excerpt
             $post_excerpt = $h->get_data($this, $data, 'post_excerpt');
             if ($post_excerpt) {
                 $post['post_excerpt'] = $post_excerpt;
             }
             // (int) post parent
             $post_parent = $h->get_data($this, $data, 'post_parent');
             if ($post_parent) {
                 $post['post_parent'] = $post_parent;
             }
             // (int) menu order
             $menu_order = $h->get_data($this, $data, 'menu_order');
             if ($menu_order) {
                 $post['menu_order'] = $menu_order;
             }
             // (string, comma divided) slug of post categories
             $post_category = $h->get_data($this, $data, 'post_category');
             if ($post_category) {
                 $categories = preg_split("/,+/", $post_category);
                 if ($categories) {
                     $post['post_category'] = wp_create_categories($categories);
                 }
             }
             // (string, comma divided) name of post tags
             $post_tags = $h->get_data($this, $data, 'post_tags');
             if ($post_tags) {
                 $tags = preg_split("/,+/", $post_tags);
                 if ($tags) {
                     $post['post_tags'] = $tags;
                 }
             }
             // (string) post thumbnail image uri
             $post_thumbnail = $h->get_data($this, $data, 'post_thumbnail');
             if (parse_url($post_thumbnail, PHP_URL_SCHEME)) {
                 $post_thumbnail = remote_get_file($post_thumbnail);
             }
             $meta = array();
             $tax = array();
             // add any other data to post meta
             foreach ($data as $key => $value) {
                 if ($value !== false && isset($this->column_keys[$key])) {
                     // check if meta is custom taxonomy
                     if (substr($this->column_keys[$key], 0, 4) == 'tax_') {
                         // (string, comma divided) name of custom taxonomies
                         $customtaxes = preg_split("/,+/", $value);
                         $taxname = substr($this->column_keys[$key], 4);
                         $tax[$taxname] = array();
                         foreach ($customtaxes as $key => $value) {
                             $tax[$taxname][] = $value;
                         }
                     } else {
                         $meta[$this->column_keys[$key]] = $value;
                     }
开发者ID:umbezt,项目名称:Soka-Education-Student-Research-Project,代码行数:67,代码来源:rs-csv-importer.php


示例13: tp_write_post

function tp_write_post($v, $opt)
{
    $tpo = get_option('tp_options');
    $post_template_excerpt = $tpo['excerpt'];
    $post_template_content = $tpo['content'];
    $post_status = !empty($tpo['status']) ? $tpo['status'] : 'publish';
    $vid = !empty($v->id) ? $v->id : $opt['video_id'];
    $tp_tags = array("%tp_player%", "%tp_id%", "%tp_title%", "%tp_thumbnail%", "%tp_description%", "%tp_url%");
    $tag_values = array(tp_player($vid), $vid, $v->snippet->title, $v->snippet->thumbnails->high->url, $v->snippet->description, "https://www.youtube.com/watch?v=" . $vid);
    $post_template_excerpt = str_replace($tp_tags, $tag_values, $post_template_excerpt);
    $post_template_content = str_replace($tp_tags, $tag_values, $post_template_content);
    $post_category = explode(',', trim($opt['cat'], " \n\t\r\v,"));
    $tp_post = array('post_title' => $v->snippet->title, 'post_content' => nl2br($post_template_content), 'post_status' => $post_status, 'post_type' => $tpo['type'], 'post_name' => sanitize_title($v->snippet->title), 'post_category' => $post_category, 'post_excerpt' => nl2br($post_template_excerpt));
    $post_id = wp_insert_post($tp_post);
    if ($tpo['customfield']) {
        foreach ($tp_tags as $k => $meta_key) {
            add_post_meta($post_id, str_replace("%", "", $meta_key), $tag_values[$k]);
        }
    }
    wp_create_categories($post_category, $post_id);
}
开发者ID:ultr0,项目名称:TM-FreeTV,代码行数:21,代码来源:tubepress.php


示例14: create


//.........这里部分代码省略.........
                 return array('error' => "Cannot create attachment file in " . $attach_upload['path'] . " Please set correct permissions.");
             }
             @unlink($tmp_file);
         }
     }
     //Prepare post data and temporarily remove content filters before insert post
     $user = $this->iwp_mmb_get_user_info($args['username']);
     if ($user && $user->ID) {
         $post_data['post_author'] = $user->ID;
     }
     //remove filter which can brake scripts or html
     remove_filter('content_save_pre', 'wp_filter_post_kses');
     //check for edit post
     $post_result = 0;
     if (isset($post_data['iwp_post_edit']) && $post_data['iwp_post_edit']) {
         if ($post_data['iwp_match_by'] == 'title') {
             $match_by = "post_title = '" . $post_data['post_title'] . "'";
         } else {
             $match_by = "post_name = '" . $post_data['post_name'] . "'";
         }
         $query = "SELECT ID FROM {$wpdb->posts} WHERE {$match_by} AND post_status NOT IN('inherit','auto-draft','draft') LIMIT 1";
         $post_result = $wpdb->get_var($query);
     }
     if ($post_result) {
         //update existing post
         $post_data['ID'] = $post_result;
         $post_id = wp_update_post($post_data);
         //check for previous attachments
         $atta_allimages =& get_children('post_type=attachment&post_parent=' . $post_id);
         if (!empty($atta_allimages)) {
             foreach ($atta_allimages as $image) {
                 wp_delete_attachment($image->ID);
             }
         }
     } else {
         if ($post_data['iwp_post_edit'] && $post_data['iwp_force_publish']) {
             $post_id = wp_insert_post($post_data);
         } elseif ($post_data['iwp_post_edit'] && !$post_data['iwp_force_publish']) {
             return array('error' => "Post not found.");
         } else {
             $post_id = wp_insert_post($post_data);
         }
     }
     if (count($attachments)) {
         foreach ($attachments as $atta_id => $featured_id) {
             $result = wp_update_post(array('ID' => $atta_id, 'post_parent' => $post_id));
             if ($featured_id > 0) {
                 $new_custom['_thumbnail_id'] = array($featured_id);
             }
         }
     }
     // featured image
     if ($post_featured_img != '') {
         $file_name = basename($post_featured_img);
         if (isset($upload['error']) && !empty($upload['error'])) {
             return array('error' => $upload['error']);
         }
         $tmp_file = download_url($post_featured_img);
         if (is_wp_error($tmp_file)) {
             return array('error' => $tmp_file->get_error_message());
         }
         $attach_upload['url'] = $upload['url'] . '/' . $file_name;
         $attach_upload['path'] = $upload['path'] . '/' . $file_name;
         $renamed = @rename($tmp_file, $attach_upload['path']);
         if ($renamed === true) {
             $atta_ext = end(explode('.', $file_name));
             $attachment = array('post_title' => $file_name, 'post_content' => '', 'post_type' => 'attachment', 'post_parent' => $post_id, 'post_mime_type' => 'image/' . $atta_ext, 'guid' => $attach_upload['url']);
             // Save the data
             $attach_id = wp_insert_attachment($attachment, $attach_upload['path']);
             wp_update_attachment_metadata($attach_id, wp_generate_attachment_metadata($attach_id, $attach_upload['path']));
             $new_custom['_thumbnail_id'] = array($attach_id);
         } else {
             @unlink($tmp_file);
             return array('error' => "Cannot create attachment file in " . $attach_upload['path'] . " Please set correct permissions.");
         }
         @unlink($tmp_file);
     }
     if ($post_id && is_array($post_categories)) {
         //insert categories
         $cat_ids = wp_create_categories($post_categories, $post_id);
     }
     //get current custom fields
     $cur_custom = get_post_custom($post_id);
     //check which values doesnot exists in new custom fields
     $diff_values = array_diff_key($cur_custom, $new_custom);
     if (is_array($diff_values)) {
         foreach ($diff_values as $meta_key => $value) {
             delete_post_meta($post_id, $meta_key);
         }
     }
     //insert new post meta
     foreach ($new_custom as $meta_key => $value) {
         if (strpos($meta_key, '_mmb') === 0 || strpos($meta_key, '_edit') === 0) {
             continue;
         } else {
             update_post_meta($post_id, $meta_key, $value[0]);
         }
     }
     return $post_id;
 }
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:101,代码来源:post.class.php


示例15: import_posts

	function import_posts() {
		echo '<ol>';

		foreach ($this->posts as $post) {
			echo "<li>".__('Importing post...');

			extract($post);

			if ($post_id = post_exists($post_title, $post_content, $post_date)) {
				_e('Post already imported');
			} else {
				$post_id = wp_insert_post($post);
				if (!$post_id) {
					_e("Couldn't get post ID");
					return;
				}

				if (0 != count($categories))
					wp_create_categories($categories, $post_id);
				_e('Done !');
			}
			echo '</li>';
		}

		echo '</ol>';

	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:27,代码来源:rss.php


示例16: import_post

 function import_post($entry)
 {
     global $importing_blog;
     // The old permalink is all Blogger gives us to link comments to their posts.
     if (isset($entry->draft)) {
         $rel = 'self';
     } else {
         $rel = 'alternate';
     }
     foreach ($entry->links as $link) {
         if ($link['rel'] == $rel) {
             $parts = parse_url($link['href']);
             $entry->old_permalink = $parts['path'];
             break;
         }
     }
     $post_date = $this->convert_date($entry->published);
     $post_content = trim(addslashes($this->no_apos(html_entity_decode($entry->content))));
     $post_title = trim(addslashes($this->no_apos($this->min_whitespace($entry->title))));
     $post_status = isset($entry->draft) ? 'draft' : 'publish';
     // Clean up content
     $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('\$1')", $post_content);
     $post_content = str_replace('<br>', '<br />', $post_content);
     $post_content = str_replace('<hr>', '<hr />', $post_content);
     // Checks for duplicates
     if (isset($this->blogs[$importing_blog]['posts'][$entry->old_permalink])) {
         ++$this->blogs[$importing_blog]['posts_skipped'];
     } elseif ($post_id = post_exists($post_title, $post_content, $post_date)) {
         $this->blogs[$importing_blog]['posts'][$entry->old_permalink] = $post_id;
         ++$this->blogs[$importing_blog]['posts_skipped'];
     } else {
         $post = compact('post_date', 'post_content', 'post_title', 'post_status');
         $post_id = wp_insert_post($post);
         if (is_wp_error($post_id)) {
             return $post_id;
         }
         wp_create_categories(array_map('addslashes', $entry->categories), $post_id);
         $author = $this->no_apos(strip_tags($entry->author));
         add_post_meta($post_id, 'blogger_blog', $this->blogs[$importing_blog]['host'], true);
         add_post_meta($post_id, 'blogger_author', $author, true);
         add_post_meta($post_id, 'blogger_permalink', $entry->old_permalink, true);
         $this->blogs[$importing_blog]['posts'][$entry->old_permalink] = $post_id;
         ++$this->blogs[$importing_blog]['posts_done'];
     }
     $this->save_vars();
     return;
 }
开发者ID:pravinhirmukhe,项目名称:flow1,代码行数:47,代码来源:blogger.php


示例17: process_posts

 function process_posts()
 {
     global $wpdb;
     $i = -1;
     echo '<ol>';
     foreach ($this->posts as $post) {
         // There are only ever one of these
         $post_title = $this->get_tag($post, 'title');
         $post_date = $this->get_tag($post, 'wp:post_date');
         $post_date_gmt = $this->get_tag($post, 'wp:post_date_gmt');
         $comment_status = $this->get_tag($post, 'wp:comment_status');
         $ping_status = $this->get_tag($post, 'wp:ping_status');
         $post_status = $this->get_tag($post, 'wp:status');
         $post_parent = $this->get_tag($post, 'wp:post_parent');
         $post_type = $this->get_tag($post, 'wp:post_type');
         $guid = $this->get_tag($post, 'guid');
         $post_author = $this->get_tag($post, 'dc:creator');
         $post_content = $this->get_tag($post, 'content:encoded');
         $post_content = str_replace(array('<![CDATA[', ']]>'), '', $post_content);
         $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('\$1')", $post_content);
         $post_content = str_replace('<br>', '<br />', $post_content);
         $post_content = str_replace('<hr>', '<hr />', $post_content);
         preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
         $categories = $categories[1];
         $cat_index = 0;
         foreach ($categories as $category) {
             $categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array('<![CDATA[', ']]>'), '', $category)));
             $cat_index++;
         }
         if ($post_id = post_exists($post_title, '', $post_date)) {
             echo '<li>';
             printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
         } else {
             echo '<li>';
             printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
             $post_author = $this->checkauthor($post_author);
             //just so that if a post already exists, new users are not created by checkauthor
             $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'post_type');
             $comment_post_ID = $post_id = wp_inse 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wp_create_category函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_count_terms函数代码示例发布时间: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