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


PHP wp_set_post_cats函数代码示例

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


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

示例1: wp_insert_attachment


//.........这里部分代码省略.........
	// Create a valid post name.
	if ( empty($post_name) )
		$post_name = sanitize_title($post_title);
	else
		$post_name = sanitize_title($post_name);
	
	if (empty($post_date))
		$post_date = current_time('mysql');
	if (empty($post_date_gmt)) 
		$post_date_gmt = current_time('mysql', 1);

	if ( empty($comment_status) ) {
		if ( $update )
			$comment_status = 'closed';
		else
			$comment_status = get_settings('default_comment_status');
	}
	if ( empty($ping_status) )
		$ping_status = get_settings('default_ping_status');
	if ( empty($post_pingback) )
		$post_pingback = get_option('default_pingback_flag');

	if ( isset($to_ping) )
		$to_ping = preg_replace('|\s+|', "\n", $to_ping);
	else
		$to_ping = '';

	if ( isset($post_parent) )
		$post_parent = (int) $post_parent;
	else
		$post_parent = 0;

	if ( isset($menu_order) )
		$menu_order = (int) $menu_order;
	else
		$menu_order = 0;

	if ( !isset($post_password) )
		$post_password = '';

	if ( isset($to_ping) )
		$to_ping = preg_replace('|\s+|', "\n", $to_ping);
	else
		$to_ping = '';

	if ( ! isset($pinged) )
		$pinged = '';

	if ($update) {
		$wpdb->query(
			"UPDATE $wpdb->posts SET
			post_author = '$post_author',
			post_date = '$post_date',
			post_date_gmt = '$post_date_gmt',
			post_content = '$post_content',
			post_title = '$post_title',
			post_excerpt = '$post_excerpt',
			post_status = '$post_status',
			comment_status = '$comment_status',
			ping_status = '$ping_status',
			post_password = '$post_password',
			post_name = '$post_name',
			to_ping = '$to_ping',
			pinged = '$pinged',
			post_modified = '".current_time('mysql')."',
			post_modified_gmt = '".current_time('mysql',1)."',
			post_parent = '$post_parent',
			menu_order = '$menu_order',
			post_mime_type = '$post_mime_type',
			guid = '$guid'
			WHERE ID = $post_ID");
	} else {
		$wpdb->query(
			"INSERT INTO $wpdb->posts
			(post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid)
			VALUES
			('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type', '$guid')");
			$post_ID = $wpdb->insert_id;			
	}
	
	if ( empty($post_name) ) {
		$post_name = sanitize_title($post_title, $post_ID);
		$wpdb->query( "UPDATE $wpdb->posts SET post_name = '$post_name' WHERE ID = '$post_ID'" );
	}

	wp_set_post_cats('', $post_ID, $post_category);

	if ( $file )
		add_post_meta($post_ID, '_wp_attached_file', $file);

	clean_post_cache($post_ID);

	if ( $update) {
		do_action('edit_attachment', $post_ID);
	} else {
		do_action('add_attachment', $post_ID);
	}
	
	return $post_ID;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:functions-post.php

示例2: mt_setPostCategories

function mt_setPostCategories($params)
{
    global $xmlrpcusererr;
    $xpostid = $params->getParam(0);
    $xuser = $params->getParam(1);
    $xpass = $params->getParam(2);
    $xcats = $params->getParam(3);
    $post_ID = $xpostid->scalarval();
    $username = $xuser->scalarval();
    $password = $xpass->scalarval();
    $cats = xmlrpc_decode1($xcats);
    foreach ($cats as $cat) {
        $catids[] = $cat['categoryId'];
    }
    if (user_pass_ok($username, $password)) {
        wp_set_post_cats('', $post_ID, $catids);
        return new xmlrpcresp(new xmlrpcval($result, 'boolean'));
    } else {
        return new xmlrpcresp(0, $xmlrpcerruser + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password));
    }
}
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:21,代码来源:xmlrpc.php

示例3: wp_create_categories

function wp_create_categories($categories, $post_id = '')
{
    $cat_ids = array();
    foreach ($categories as $category) {
        if ($id = category_exists($category)) {
            $cat_ids[] = $id;
        } else {
            if ($id = wp_create_category($category)) {
                $cat_ids[] = $id;
            }
        }
    }
    if ($post_id) {
        wp_set_post_cats('', $post_id, $cat_ids);
    }
    return $cat_ids;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:17,代码来源:admin-db.php

示例4: wpadp_check_and_add_cats

 /**
  *
  */
 function wpadp_check_and_add_cats()
 {
     global $wpdb;
     $this->get_settings();
     $expiration = $this->settings['PostAge'];
     $newCat = array($this->settings['AddCategory']);
     /*
      * Create a query that will give us all the post ID's that predate the
      * interval we are given, that is, NOW - expiration date.
      */
     $query = "SELECT ID FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'post' AND\n    post_date < '{$date}' - INTERVAL " . $expiration . " DAY";
     $ids = $wpdb->get_results($query);
     foreach ($ids as $id) {
         if ('' == $id->ID) {
             continue;
         }
         $curCat = wp_get_post_cats('', $id->ID);
         // Merge the contents of the newCat array with the curCat array, each of these can contain
         // multiple values
         $curCat = array_merge($curCat, $newCat);
         wp_set_post_cats('', $id->ID, $curCat);
     }
 }
开发者ID:alphaomegahost,项目名称:FIN,代码行数:26,代码来源:auto-delete-posts.php

示例5: mt_setPostCategories

 function mt_setPostCategories($args)
 {
     $this->escape($args);
     $post_ID = $args[0];
     $user_login = $args[1];
     $user_pass = $args[2];
     $categories = $args[3];
     if (!$this->login_pass_ok($user_login, $user_pass)) {
         return $this->error;
     }
     $user = new WP_User(0, $user_login);
     if (!$user->has_cap('edit_post', $post_ID)) {
         return new IXR_Error(401, 'Sorry, you can not edit this post.');
     }
     foreach ($categories as $cat) {
         $catids[] = $cat['categoryId'];
     }
     wp_set_post_cats('', $post_ID, $catids);
     return true;
 }
开发者ID:robertlange81,项目名称:Website,代码行数:20,代码来源:xmlrpc.php

示例6: posts2wp

 function posts2wp($posts = '')
 {
     // General Housekeeping
     global $wpdb;
     $count = 0;
     $dcposts2wpposts = array();
     $cats = array();
     // Do the Magic
     if (is_array($posts)) {
         echo '<p>' . __('Importing Posts...') . '<br /><br /></p>';
         foreach ($posts as $post) {
             $count++;
             extract($post);
             // Set DotClear-to-WordPress status translation
             $stattrans = array(0 => 'draft', 1 => 'publish');
             $comment_status_map = array(0 => 'closed', 1 => 'open');
             //Can we do this more efficiently?
             $uinfo = get_userdatabylogin($user_id) ? get_userdatabylogin($user_id) : 1;
             $authorid = is_object($uinfo) ? $uinfo->ID : $uinfo;
             $Title = $wpdb->escape(csc($post_titre));
             $post_content = textconv($post_content);
             $post_excerpt = "";
             if ($post_chapo != "") {
                 $post_excerpt = textconv($post_chapo);
                 $post_content = $post_excerpt . "\n<!--more-->\n" . $post_content;
             }
             $post_excerpt = $wpdb->escape($post_excerpt);
             $post_content = $wpdb->escape($post_content);
             $post_status = $stattrans[$post_pub];
             // Import Post data into WordPress
             if ($pinfo = post_exists($Title, $post_content)) {
                 $ret_id = wp_insert_post(array('ID' => $pinfo, 'post_author' => $authorid, 'post_date' => $post_dt, 'post_date_gmt' => $post_dt, 'post_modified' => $post_upddt, 'post_modified_gmt' => $post_upddt, 'post_title' => $Title, 'post_content' => $post_content, 'post_excerpt' => $post_excerpt, 'post_status' => $post_status, 'post_name' => $post_titre_url, 'comment_status' => $comment_status_map[$post_open_comment], 'ping_status' => $comment_status_map[$post_open_tb], 'comment_count' => $post_nb_comment + $post_nb_trackback));
             } else {
                 $ret_id = wp_insert_post(array('post_author' => $authorid, 'post_date' => $post_dt, 'post_date_gmt' => $post_dt, 'post_modified' => $post_modified_gmt, 'post_modified_gmt' => $post_modified_gmt, 'post_title' => $Title, 'post_content' => $post_content, 'post_excerpt' => $post_excerpt, 'post_status' => $post_status, 'post_name' => $post_titre_url, 'comment_status' => $comment_status_map[$post_open_comment], 'ping_status' => $comment_status_map[$post_open_tb], 'comment_count' => $post_nb_comment + $post_nb_trackback));
             }
             $dcposts2wpposts[$post_id] = $ret_id;
             // Make Post-to-Category associations
             $cats = array();
             if ($cat1 = get_catbynicename($post_cat_name)) {
                 $cats[1] = $cat1;
             }
             if (!empty($cats)) {
                 wp_set_post_cats('', $ret_id, $cats);
             }
         }
     }
     // Store ID translation for later use
     add_option('dcposts2wpposts', $dcposts2wpposts);
     echo '<p>' . sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count) . '<br /><br /></p>';
     return true;
 }
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:51,代码来源:dotclear.php

示例7: insertPost


//.........这里部分代码省略.........
             $post['post_status'] = $this->current_feed['options']['post_status'];
             $post['comment_status'] = $this->current_feed['options']['comment_status'];
             $post['ping_status'] = $this->current_feed['options']['ping_status'];
             $post['post_type'] = 'post';
             $post['post_author'] = $this->current_feed['options']['post_author'];
             $attachment = "";
             if ($this->current_feed['options']['insert_media_attachments'] != "no") {
                 if (sizeof($this->post['media_thumbnail'])) {
                     $attachment .= '<div class="media_block">' . "\n";
                     for ($i = 0; $i < sizeof($this->post['media_thumbnail']); $i++) {
                         if ($this->current_feed['options']['store_images'] == 'on') {
                             $this->post['media_thumbnail'][$i] = csyn_save_image($this->post['media_thumbnail'][$i], $post['post_title']);
                         }
                         if (isset($this->post['media_content'][$i])) {
                             $attachment .= '<a href="' . $this->post['media_content'][$i] . '"><img src="' . $this->post['media_thumbnail'][$i] . '" class="media_thumbnail"></a>' . "\n";
                         } else {
                             $attachment .= '<img src="' . $this->post['media_thumbnail'][$i] . '" class="media_thumbnail">' . "\n";
                         }
                     }
                     $attachment .= "</div>\n";
                 }
                 if ($this->post['enclosure_url'] != "" && $this->post['link'] != "") {
                     $attachment .= '<div class="media_block">' . "\n";
                     $attachment .= '<a href="' . $this->post['link'] . '"><img src="' . $this->post['enclosure_url'] . '" class="media_thumbnail"></a>' . "\n";
                     $attachment .= "</div>\n";
                 }
             }
             $attachment_status = $this->current_feed['options']['insert_media_attachments'];
             $post['post_content'] = $this->post['post_content'];
             $post['post_excerpt'] = $this->post['post_excerpt'];
             if ($this->current_feed['options']['embed_videos'] == 'on') {
                 if (strpos($this->post['guid'], 'yt:video:') !== false) {
                     list($yt, $video, $id) = explode(':', $this->post['guid']);
                     $post['post_excerpt'] = $post['post_content'] = '<p><iframe class="embedded_video" width="560" height="315" src="http://www.youtube.com/embed/' . $id . '" frameborder="0" allowfullscreen></iframe></p>' . str_replace("\n", '<br />', htmlentities($this->post['media_description'], ENT_QUOTES, 'UTF-8'));
                 }
             }
             if ($this->current_feed['options']['store_images'] == 'on') {
                 preg_match_all('/<img(.+?)src=[\'\\"](.+?)[\'\\"](.*?)>/is', $post['post_content'] . $post['post_excerpt'], $matches);
                 $image_urls = array_unique($matches[2]);
                 $home = get_option('home');
                 for ($i = 0; $i < count($image_urls); $i++) {
                     if (strpos($image_urls[$i], $home) === false) {
                         $new_image_url = csyn_save_image($image_urls[$i], $post['post_title']);
                         $post['post_content'] = str_replace($image_urls[$i], $new_image_url, $post['post_content']);
                         $post['post_excerpt'] = str_replace($image_urls[$i], $new_image_url, $post['post_excerpt']);
                         if ($this->show_report) {
                             echo str_repeat(' ', 256);
                             flush();
                         }
                     }
                 }
             }
             $inc_footerss = $this->current_feed['options']['include_post_footers'];
             $title = $post['post_title'];
             $content = csyn_fix_white_spaces($post['post_content']);
             $excerpt = csyn_fix_white_spaces($post['post_excerpt']);
             $post['post_title'] = addslashes($title);
             $post['post_content'] = addslashes(csyn_touch_post_content($content, $attachment, $attachment_status));
             $post['post_excerpt'] = addslashes(csyn_touch_post_content($excerpt, $attachment, $attachment_status, $inc_footerss));
             $post_categories = array();
             if (is_array($this->current_feed['options']['post_category'])) {
                 $post_categories = $this->current_feed['options']['post_category'];
             }
             if (!empty($cat_ids)) {
                 $post_categories = array_merge($post_categories, $cat_ids);
             } elseif ($this->current_feed['options']['undefined_category'] == 'use_default' && empty($post_categories)) {
                 $post_categories[] = get_option('default_category');
             }
             $post_categories = array_unique($post_categories);
             $post['post_category'] = $post_categories;
             if ($this->current_feed['options']['create_tags'] == 'on') {
                 $post['tags_input'] = array_merge($post['tags_input'], $this->post['categories']);
             }
             if ($this->current_feed['options']['post_tags'] != '') {
                 $tags = explode(',', $this->current_feed['options']['post_tags']);
                 $post['tags_input'] = array_merge($post['tags_input'], $tags);
             }
             $post['tags_input'] = array_unique($post['tags_input']);
             remove_filter('content_save_pre', 'wp_filter_post_kses');
             remove_filter('excerpt_save_pre', 'wp_filter_post_kses');
             $post_id = wp_insert_post($post, true);
             if (is_wp_error($post_id) && $this->show_report) {
                 $this->failure = true;
                 echo "<br /><b>Error:</b> " . $post_id->get_error_message($post_id->get_error_code()) . "<br />\n";
             } else {
                 $this->count++;
                 $this->failure = false;
                 add_post_meta($post_id, 'cyberseo_rss_source', $this->current_feed['url']);
                 add_post_meta($post_id, 'cyberseo_post_link', $this->post['link']);
                 if (version_compare($wp_version, '3.0', '<')) {
                     if (function_exists('wp_set_post_categories')) {
                         wp_set_post_categories($post_id, $post_categories);
                     } elseif (function_exists('wp_set_post_cats')) {
                         wp_set_post_cats('1', $post_id, $post_categories);
                     }
                 }
             }
         }
     }
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:101,代码来源:cybersyn.php

示例8: posts2wp

	function posts2wp($posts='')
	{
		// General Housekeeping
		global $wpdb;
		$count = 0;
		$txpposts2wpposts = array();
		$cats = array();

		// Do the Magic
		if(is_array($posts))
		{
			echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
			foreach($posts as $post)
			{
				$count++;
				extract($post);
				
				// Set Textpattern-to-WordPress status translation
				$stattrans = array(1 => 'draft', 2 => 'private', 3 => 'draft', 4 => 'publish', 5 => 'publish');
				
				//Can we do this more efficiently?
				$uinfo = ( get_userdatabylogin( $AuthorID ) ) ? get_userdatabylogin( $AuthorID ) : 1;
				$authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ;

				$Title = $wpdb->escape($Title);
				$Body = $wpdb->escape($Body);
				$Excerpt = $wpdb->escape($Excerpt);
				$post_status = $stattrans[$Status];
				
				// Import Post data into WordPress
				
				if($pinfo = post_exists($Title,$Body))
				{
					$ret_id = wp_insert_post(array(
							'ID'				=> $pinfo,
							'post_date'			=> $Posted,
							'post_date_gmt'		=> $post_date_gmt,
							'post_author'		=> $authorid,
							'post_modified'		=> $LastMod,
							'post_modified_gmt' => $post_modified_gmt,
							'post_title'		=> $Title,
							'post_content'		=> $Body,
							'post_excerpt'		=> $Excerpt,
							'post_status'		=> $post_status,
							'post_name'			=> $url_title,
							'comment_count'		=> $comments_count)
							);
				}
				else 
				{
					$ret_id = wp_insert_post(array(
							'post_date'			=> $Posted,
							'post_date_gmt'		=> $post_date_gmt,
							'post_author'		=> $authorid,
							'post_modified'		=> $LastMod,
							'post_modified_gmt' => $post_modified_gmt,
							'post_title'		=> $Title,
							'post_content'		=> $Body,
							'post_excerpt'		=> $Excerpt,
							'post_status'		=> $post_status,
							'post_name'			=> $url_title,
							'comment_count'		=> $comments_count)
							);
				}
				$txpposts2wpposts[$ID] = $ret_id;
				
				// Make Post-to-Category associations
				$cats = array();
				if($cat1 = get_catbynicename($Category1)) { $cats[1] = $cat1; }
				if($cat2 = get_catbynicename($Category2)) { $cats[2] = $cat2; }

				if(!empty($cats)) { wp_set_post_cats('', $ret_id, $cats); }
			}
		}
		// Store ID translation for later use
		add_option('txpposts2wpposts',$txpposts2wpposts);
		
		echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
		return true;	
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:80,代码来源:textpattern.php

示例9: wp_update_post

function wp_update_post($postarr = array())
{
    global $wpdb;
    // First get all of the original fields
    $post = wp_get_single_post($postarr['ID'], ARRAY_A);
    // Escape data pulled from DB.
    $post = add_magic_quotes($post);
    extract($post);
    // Now overwrite any changed values being passed in. These are
    // already escaped.
    extract($postarr);
    // If no categories were passed along, use the current cats.
    if (0 == count($post_category) || !is_array($post_category)) {
        $post_category = $post['post_category'];
    }
    $post_modified = current_time('mysql');
    $post_modified_gmt = current_time('mysql', 1);
    $sql = "UPDATE {$wpdb->posts}\n\t\tSET post_content = '{$post_content}',\n\t\tpost_title = '{$post_title}',\n\t\tpost_category = {$post_category['0']},\n\t\tpost_status = '{$post_status}',\n\t\tpost_date = '{$post_date}',\n\t\tpost_date_gmt = '{$post_date_gmt}',\n\t\tpost_modified = '{$post_modified}',\n\t\tpost_modified_gmt = '{$post_modified_gmt}',\n\t\tpost_excerpt = '{$post_excerpt}',\n\t\tping_status = '{$ping_status}',\n\t\tcomment_status = '{$comment_status}'\n\t\tWHERE ID = {$ID}";
    $result = $wpdb->query($sql);
    $rows_affected = $wpdb->rows_affected;
    wp_set_post_cats('', $ID, $post_category);
    do_action('edit_post', $ID);
    return $rows_affected;
}
开发者ID:BackupTheBerlios,项目名称:steampress-svn,代码行数:24,代码来源:functions-post.php

示例10: wp_update_post

function wp_update_post($postarr = array()) {
	global $wpdb;

	// First get all of the original fields
	extract(wp_get_single_post($postarr['ID'], ARRAY_A));	

	// Now overwrite any changed values being passed in
	extract($postarr);

	// Make sure we set a valid category
	if ( 0 == count($post_category) || !is_array($post_category) )
		$post_category = array($post_default_category);

	// Do some escapes for safety
	$post_title   = $wpdb->escape($post_title);
	$post_excerpt = $wpdb->escape($post_excerpt);
	$post_content = $wpdb->escape($post_content);

	$post_modified = current_time('mysql');
	$post_modified_gmt = current_time('mysql', 1);

	$sql = "UPDATE $wpdb->posts 
		SET post_content = '$post_content',
		post_title = '$post_title',
		post_category = $post_category[0],
		post_status = '$post_status',
		post_date = '$post_date',
		post_date_gmt = '$post_date_gmt',
		post_modified = '$post_modified',
		post_modified_gmt = '$post_modified_gmt',
		post_excerpt = '$post_excerpt',
		ping_status = '$ping_status',
		comment_status = '$comment_status'
		WHERE ID = $ID";
		
	$result = $wpdb->query($sql);
	$rows_affected = $wpdb->rows_affected;

	wp_set_post_cats('', $ID, $post_category);

	do_action('edit_post', $ID);

	return $rows_affected;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:44,代码来源:functions-post.php

示例11: mt_setPostCategories

	function mt_setPostCategories($args) {

	  $post_ID     = $args[0];
	  $user_login  = $args[1];
	  $user_pass   = $args[2];
	  $categories  = $args[3];

	  if (!$this->login_pass_ok($user_login, $user_pass)) {
	    return $this->error;
	  }

	  $user_data = get_userdatabylogin($user_login);
	  if (!user_can_edit_post($user_data->ID, $post_ID)) {
	    return new IXR_Error(401, 'Sorry, you can not edit this post.');
	  }

	  foreach($categories as $cat) {
	    $catids[] = $cat['categoryId'];
	  }
	
	  wp_set_post_cats('', $post_ID, $catids);

	  return true;
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:24,代码来源:xmlrpc.php

示例12: update_existing

 function update_existing()
 {
     global $wpdb;
     // Why the fuck doesn't wp_insert_post already do this?
     $dbpost = array();
     foreach ($this->post as $key => $value) {
         if (is_string($value)) {
             $dbpost[$key] = $wpdb->escape($value);
         } else {
             $dbpost[$key] = $value;
         }
     }
     if ($this->use_api('wp_insert_post')) {
         $dbpost['post_pingback'] = false;
         // Tell WP 2.1 and 2.2 not to process for pingbacks
         // This is a ridiculous fucking kludge necessitated by WordPress 2.6 munging authorship meta-data
         add_action('_wp_put_post_revision', array($this, 'fix_revision_meta'));
         // Kludge to prevent kses filters from stripping the
         // content of posts when updating without a logged in
         // user who has `unfiltered_html` capability.
         add_filter('content_save_pre', array($this, 'avoid_kses_munge'), 11);
         $this->_wp_id = wp_insert_post($dbpost);
         // Turn off ridiculous fucking kludges #1 and #2
         remove_action('_wp_put_post_revision', array($this, 'fix_revision_meta'));
         remove_filter('content_save_pre', array($this, 'avoid_kses_munge'), 11);
         // This should never happen.
         if (!is_numeric($this->_wp_id) or $this->_wp_id == 0) {
             FeedWordPress::critical_bug('SyndicatedPost (_wp_id problem)', array("dbpost" => $dbpost, "this" => $this), __LINE__);
         }
         // Unfortunately, as of WordPress 2.3, wp_insert_post()
         // munges your post modified timestamp.
         $result = $wpdb->query("\n\t\t\t\tUPDATE {$wpdb->posts}\n\t\t\t\tSET\n\t\t\t\t\tpost_modified='{$dbpost['post_modified']}',\n\t\t\t\t\tpost_modified_gmt='{$dbpost['post_modified_gmt']}'\n\t\t\t\tWHERE ID='{$this->_wp_id}'\n\t\t\t");
     } else {
         $result = $wpdb->query("\n\t\t\tUPDATE {$wpdb->posts}\n\t\t\tSET\n\t\t\t\tpost_author = '{$dbpost['post_author']}',\n\t\t\t\tpost_content = '{$dbpost['post_content']}'," . (isset($dbpost['post_excerpt']) ? "post_excerpt = '{$dbpost['post_excerpt']}'," : "") . "\n\t\t\t\tpost_title = '{$dbpost['post_title']}',\n\t\t\t\tpost_name = '{$dbpost['post_name']}',\n\t\t\t\tpost_modified = '{$dbpost['post_modified']}',\n\t\t\t\tpost_modified_gmt = '{$dbpost['post_modified_gmt']}'\n\t\t\tWHERE guid='{$dbpost['guid']}'\n\t\t\t");
         // WordPress 2.1.x and up
         if (function_exists('wp_set_post_categories')) {
             wp_set_post_categories($this->wp_id(), $this->post['post_category']);
             // WordPress 1.5.x - 2.0.x
         } elseif (function_exists('wp_set_post_cats')) {
             wp_set_post_cats('1', $this->wp_id(), $this->post['post_category']);
             // This should never happen.
         } else {
             FeedWordPress::critical_bug('SyndicatedPost (_wp_id problem)', array("dbpost" => $dbpost, "this" => $this), __LINE__);
         }
         // Since we are not going through official channels, we need to
         // manually tell WordPress that we've published a new post.
         // We need to make sure to do this in order for FeedWordPress
         // to play well  with the staticize-reloaded plugin (something
         // that a large aggregator website is going to *want* to be
         // able to use).
         do_action('edit_post', $this->post['ID']);
     }
 }
开发者ID:jcbozonier,项目名称:master,代码行数:53,代码来源:feedwordpress.php


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