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

PHP post_exists函数代码示例

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

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



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

示例1: insert_posts

 function insert_posts()
 {
     global $wpdb;
     $this->counter_imported = 0;
     $this->counter_skipped = 0;
     if (count($this->posts) > 0) {
         foreach ($this->posts as $post) {
             // check if it is existing in wp database already
             $facebook_id = $post['facebook_id'];
             if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM {$wpdb->postmeta} WHERE meta_key = 'facebook_id' AND meta_value = %s", $facebook_id)) || post_exists($post['post_title'], $post['post_content'], $post['post_date'])) {
                 // already in database, skip
                 $this->counter_skipped++;
                 continue;
             } else {
                 // insert into wp database
                 $post_id = wp_insert_post($post);
                 //if failed to insert, keep going to try next post.
                 if (!$post_id) {
                     continue;
                 }
                 add_post_meta($post_id, 'facebook_id', $facebook_id);
                 $this->counter_imported++;
             }
             // end of if
         }
         // end of foreach
     }
     // end of if
     return true;
 }
开发者ID:EricYue2012,项目名称:FacebookPostsImporter,代码行数:30,代码来源:Importer.php


示例2: remove_old

 private function remove_old($title, $post_id)
 {
     $old_post_id = post_exists($title);
     if ($old_post_id) {
         update_field('column_select', get_field('column_select', $old_post_id), $post_id);
         wp_delete_post($old_post_id);
         echo '<br>"' . $title . '" updated.';
     } else {
         $this->set_visible_columns($post_id);
         echo '<br>"' . $title . '" added.';
     }
 }
开发者ID:johnleesw,项目名称:mustardseedwp,代码行数:12,代码来源:Class_Import_Page.php


示例3: _insert_events

function _insert_events($event)
{
    //update_field
    $post_id = post_exists($event->name);
    if (!$post_id) {
        $params = array('post_status' => 'publish', 'post_name' => $event->name, 'post_type' => 'event', 'post_title' => $event->name);
        $post_id = wp_insert_post($params);
        if (is_numeric($post_id)) {
            update_field('meetup_id', $event->id, $post_id);
            update_field('titel', $event->name, $post_id);
            update_field('description', $event->description, $post_id);
            echo '<p>Evenement: \'' . $event->name . '\' is geimporteerd.</p>';
            //update_field();
            //update_field();
        }
    }
}
开发者ID:noudr93,项目名称:mediavilla,代码行数:17,代码来源:meetup-api.php


示例4: process_posts


//.........这里部分代码省略.........
                     case 'ALLOW PINGS':
                         $post_allow_pings = trim($meta[2][0]);
                         if ($post_allow_pings == 1) {
                             $post_allow_pings = 'open';
                         } else {
                             $post_allow_pings = 'closed';
                         }
                         break;
                     case 'PRIMARY CATEGORY':
                         if (!empty($value)) {
                             $post_categories[] = $wpdb->escape($value);
                         }
                         break;
                     case 'CATEGORY':
                         if (!empty($value)) {
                             $post_categories[] = $wpdb->escape($value);
                         }
                         break;
                     case 'DATE':
                         $post_modified = strtotime($value);
                         $post_modified = date('Y-m-d H:i:s', $post_modified);
                         $post_modified_gmt = get_gmt_from_date("{$post_modified}");
                         $post_date = $post_modified;
                         $post_date_gmt = $post_modified_gmt;
                         break;
                     default:
                         // echo "\n$key: $value";
                         break;
                 }
                 // end switch
             }
             // End foreach
             // Let's check to see if it's in already
             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');
                 $post_id = wp_insert_post($postdata);
                 // Add categories.
                 if (0 != count($post_categories)) {
                     wp_create_categories($post_categories, $post_id);
                 }
             }
             $comment_post_ID = $post_id;
             // Now for comments
             $comments = explode("-----\nCOMMENT:", $comments[0]);
             $num_comments = 0;
             foreach ($comments as $comment) {
                 if ('' != trim($comment)) {
                     // Author
                     preg_match("|AUTHOR:(.*)|", $comment, $comment_author);
                     $comment_author = $wpdb->escape(trim($comment_author[1]));
                     $comment = preg_replace('|(\\n?AUTHOR:.*)|', '', $comment);
                     preg_match("|EMAIL:(.*)|", $comment, $comment_author_email);
                     $comment_author_email = $wpdb->escape(trim($comment_author_email[1]));
                     $comment = preg_replace('|(\\n?EMAIL:.*)|', '', $comment);
                     preg_match("|IP:(.*)|", $comment, $comment_author_IP);
                     $comment_author_IP = trim($comment_author_IP[1]);
                     $comment = preg_replace('|(\\n?IP:.*)|', '', $comment);
                     preg_match("|URL:(.*)|", $comment, $comment_author_url);
                     $comment_author_url = $wpdb->escape(trim($comment_author_url[1]));
开发者ID:robertlange81,项目名称:Website,代码行数:67,代码来源:mt.php


示例5: options_page


//.........这里部分代码省略.........
                ?>
</label></li>
						</ul>
					</div>
				</div>
<?php 
            }
            ?>
				<div id="thesis_nav_controls">
				<div class="module_subsection">
					<h4 class="module_switch"><a href="" title="<?php 
            _e('Show/hide additional information', 'thesis');
            ?>
"><span class="pos">+</span><span class="neg">&#8211;</span></a><?php 
            _e('Pages', 'thesis');
            ?>
</h4>
					<div class="more_info">
						<p><?php 
            _e('Start by selecting the pages you want to include in your nav menu. Next, drag and drop the pages to change their display order (topmost item displays first), and if you <em>really</em> want to get crazy, you can even edit the display text on each item. <strong>Try it!</strong>', 'thesis');
            ?>
</p>
						<p><?php 
            _e('Thesis features automatic dropdown menus, so if you have nested pages or categories, you&#8217;ll save space <em>and</em> gain style points with your slick new nav menu!', 'thesis');
            ?>
</p>
						<ul id="nav_pages" class="sortable add_margin">
<?php 
            $pages =& get_pages('sort_column=post_parent,menu_order');
            $active_pages = array();
            if ($nav['pages']) {
                foreach ($nav['pages'] as $id => $nav_page) {
                    $active_page = get_page($id);
                    if (post_exists($active_page->post_title)) {
                        $checked = $nav_page['show'] ? ' checked="checked"' : '';
                        $link_text = $nav['pages'][$id]['text'] != '' ? $thesis_data->o_htmlspecialchars($nav['pages'][$id]['text'], true) : $active_page->post_title;
                        echo "\t\t\t\t\t\t\t<li><input class=\"checkbox\" type=\"checkbox\" id=\"nav[pages][{$id}][show]\" name=\"nav[pages][{$id}][show]\" value=\"1\"{$checked} /><input type=\"text\" class=\"text_input\" id=\"nav[pages][{$id}][text]\" name=\"nav[pages][{$id}][text]\" value=\"{$link_text}\" /></li>\n";
                        $active_pages[] = $id;
                    }
                }
            }
            if ($pages) {
                foreach ($pages as $page) {
                    if (!in_array($page->ID, $active_pages)) {
                        $link_text = $nav['pages'][$page->ID]['text'] != '' ? $thesis_data->o_htmlentities($nav['pages'][$page->ID]['text'], true) : $page->post_title;
                        echo "\t\t\t\t\t\t\t<li><input class=\"checkbox\" type=\"checkbox\" id=\"nav[pages][{$page->ID}][show]\" name=\"nav[pages][{$page->ID}][show]\" value=\"1\" /><input type=\"text\" class=\"text_input\" id=\"nav[pages][{$page->ID}][text]\" name=\"nav[pages][{$page->ID}][text]\" value=\"{$link_text}\" /></li>\n";
                    }
                }
            }
            ?>
						</ul>
					</div>
				</div>
				<div class="module_subsection">
					<h4 class="module_switch"><a href="" title="<?php 
            _e('Show/hide additional information', 'thesis');
            ?>
"><span class="pos">+</span><span class="neg">&#8211;</span></a><?php 
            _e('Categories', 'thesis');
            ?>
</h4>
					<div class="more_info">
						<p><?php 
            _e('If you&#8217;d like to include category pages in your nav menu, simply select the appropriate categories from the list below (you can select more than one).', 'thesis');
            ?>
</p>
开发者ID:CherylMuniz,项目名称:fashion,代码行数:67,代码来源:options_site.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));
                 if (is_wp_error($ret_id)) {
                     return $ret_id;
                 }
             } 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));
                 if (is_wp_error($ret_id)) {
                     return $ret_id;
                 }
             }
             $dcposts2wpposts[$post_id] = $ret_id;
             // Make Post-to-Category associations
             $cats = array();
             $category1 = get_category_by_slug($post_cat_name);
             $category1 = $category1->term_id;
             if ($cat1 = $category1) {
                 $cats[1] = $cat1;
             }
             if (!empty($cats)) {
                 wp_set_post_categories($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:helmonaut,项目名称:owb-mirror,代码行数:59,代码来源:dotclear.php


示例7: import_post

 function import_post($post)
 {
     global $wpdb;
     // Make sure we haven't already imported this one
     if ($this->get_wp_post_ID($post['itemid'])) {
         return;
     }
     $user = wp_get_current_user();
     $post_author = $user->ID;
     $post['security'] = !empty($post['security']) ? $post['security'] : '';
     $post_status = 'private' == trim($post['security']) ? 'private' : 'publish';
     // Only me
     $post_password = 'usemask' == trim($post['security']) ? $this->protected_password : '';
     // "Friends" via password
     // For some reason, LJ sometimes sends a date as "2004-04-1408:38:00" (no space btwn date/time)
     $post_date = $post['eventtime'];
     if (18 == strlen($post_date)) {
         $post_date = substr($post_date, 0, 10) . ' ' . substr($post_date, 10);
     }
     // Cleaning up and linking the title
     $post_title = isset($post['subject']) ? trim($post['subject']) : '';
     $post_title = $this->translate_lj_user($post_title);
     // Translate it, but then we'll strip the link
     $post_title = strip_tags($post_title);
     // Can't have tags in the title in WP
     $post_title = $wpdb->escape($post_title);
     // Clean up content
     $post_content = $post['event'];
     $post_content = preg_replace_callback('|<(/?[A-Z]+)|', array(&$this, '_normalize_tag'), $post_content);
     // XHTMLize some tags
     $post_content = str_replace('<br>', '<br />', $post_content);
     $post_content = str_replace('<hr>', '<hr />', $post_content);
     // lj-cut ==>  <!--more-->
     $post_content = preg_replace('|<lj-cut text="([^"]*)">|is', '<!--more $1-->', $post_content);
     $post_content = str_replace(array('<lj-cut>', '</lj-cut>'), array('<!--more-->', ''), $post_content);
     $first = strpos($post_content, '<!--more');
     $post_content = substr($post_content, 0, $first + 1) . preg_replace('|<!--more(.*)?-->|sUi', '', substr($post_content, $first + 1));
     // lj-user ==>  a href
     $post_content = $this->translate_lj_user($post_content);
     //$post_content = force_balance_tags( $post_content );
     $post_content = $wpdb->escape($post_content);
     // Handle any tags associated with the post
     $tags_input = !empty($post['props']['taglist']) ? $post['props']['taglist'] : '';
     // Check if comments are closed on this post
     $comment_status = !empty($post['props']['opt_nocomments']) ? 'closed' : 'open';
     echo '<li>';
     if ($post_id = post_exists($post_title, $post_content, $post_date)) {
         printf(__('Post <strong>%s</strong> already exists.'), stripslashes($post_title));
     } else {
         printf(__('Imported post <strong>%s</strong>...'), stripslashes($post_title));
         $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status', 'post_password', 'tags_input', 'comment_status');
         $post_id = wp_insert_post($postdata, true);
         if (is_wp_error($post_id)) {
             if ('empty_content' == $post_id->get_error_code()) {
                 return;
             }
             // Silent skip on "empty" posts
             return $post_id;
         }
         if (!$post_id) {
             _e('Couldn&#8217;t get post ID (creating post failed!)');
             echo '</li>';
             return new WP_Error('insert_post_failed', __('Failed to create post.'));
         }
         // Handle all the metadata for this post
         $this->insert_postmeta($post_id, $post);
     }
     echo '</li>';
 }
开发者ID:beaucollins,项目名称:wp,代码行数:69,代码来源:livejournal.php


示例8: get_archive

	function get_archive() {
		global $wpdb;
		$output = '<h2>'.__('Importing Blogger archives into WordPress').'</h2>';
		$did_one = false;
		$post_array = $posts = array();
		foreach ( $this->import['blogs'][$_GET['blog']]['archives'] as $url => $status ) {
			$archivename = substr(basename($url),0,7);
			if ( $status || $did_one ) {
				$foo = 'bar';
				// Do nothing.
			} else {
				// Import the selected month
				$postcount = 0;
				$skippedpostcount = 0;
				$commentcount = 0;
				$skippedcommentcount = 0;
				$status = __('in progress...');
				$this->import['blogs'][$_GET['blog']]['archives']["$url"] = $status;
				update_option('import-blogger', $import);
				$archive = $this->get_blogger($url);
				if ( $archive['code'] > 200 )
					continue;	
				$posts = explode('<wordpresspost>', $archive['body']);
				for ($i = 1; $i < count($posts); $i = $i + 1) {
					$postparts = explode('<wordpresscomment>', $posts[$i]);
					$postinfo = explode('|W|P|', $postparts[0]);
					$post_date = $postinfo[0];
					$post_content = $postinfo[2];
					// Don't try to re-use the original numbers
					// because the new, longer numbers are too
					// big to handle as ints.
					//$post_number = $postinfo[3];
					$post_title = ( $postinfo[4] != '' ) ? $postinfo[4] : $postinfo[3];
					$post_author_name = $wpdb->escape(trim($postinfo[1]));
					$post_author_email = $postinfo[5] ? $postinfo[5] : '[email protected]';
	
					if ( $this->lump_authors ) {
						// Ignore Blogger authors. Use the current user_ID for all posts imported.
						$post_author = $GLOBALS['user_ID'];
					} else {
						// Add a user for each new author encountered.
						if (! username_exists($post_author_name) ) {
							$user_login = $wpdb->escape($post_author_name);
							$user_email = $wpdb->escape($post_author_email);
							$user_password = substr(md5(uniqid(microtime())), 0, 6);
							$result = wp_create_user( $user_login, $user_password, $user_email );
							$status.= sprintf('Registered user <strong>%s</strong>.', $user_login);
							$this->import['blogs'][$_GET['blog']]['newusers'][] = $user_login;
						}
						$userdata = get_userdatabylogin( $post_author_name );
						$post_author = $userdata->ID;
					}
					$post_date = explode(' ', $post_date);
					$post_date_Ymd = explode('/', $post_date[0]);
					$postyear = $post_date_Ymd[2];
					$postmonth = zeroise($post_date_Ymd[0], 2);
					$postday = zeroise($post_date_Ymd[1], 2);
					$post_date_His = explode(':', $post_date[1]);
					$posthour = zeroise($post_date_His[0], 2);
					$postminute = zeroise($post_date_His[1], 2);
					$postsecond = zeroise($post_date_His[2], 2);
	
					if (($post_date[2] == 'PM') && ($posthour != '12'))
						$posthour = $posthour + 12;
					else if (($post_date[2] == 'AM') && ($posthour == '12'))
						$posthour = '00';
	
					$post_date = "$postyear-$postmonth-$postday $posthour:$postminute:$postsecond";
	
					$post_content = addslashes($post_content);
					$post_content = str_replace(array('<br>','<BR>','<br/>','<BR/>','<br />','<BR />'), "\n", $post_content); // the XHTML touch... ;)
	
					$post_title = addslashes($post_title);
			
					$post_status = 'publish';
	
					if ( $ID = post_exists($post_title, '', $post_date) ) {
						$post_array[$i]['ID'] = $ID;
						$skippedpostcount++;
					} else {
						$post_array[$i]['post'] = compact('post_author', 'post_content', 'post_title', 'post_category', 'post_author', 'post_date', 'post_status');
						$post_array[$i]['comments'] = false;
					}

					// Import any comments attached to this post.
					if ($postparts[1]) :
					for ($j = 1; $j < count($postparts); $j = $j + 1) {
						$commentinfo = explode('|W|P|', $postparts[$j]);
						$comment_date = explode(' ', $commentinfo[0]);
						$comment_date_Ymd = explode('/', $comment_date[0]);
						$commentyear = $comment_date_Ymd[2];
						$commentmonth = zeroise($comment_date_Ymd[0], 2);
						$commentday = zeroise($comment_date_Ymd[1], 2);
						$comment_date_His = explode(':', $comment_date[1]);
						$commenthour = zeroise($comment_date_His[0], 2);
						$commentminute = zeroise($comment_date_His[1], 2);
						$commentsecond = '00';
						if (($comment_date[2] == 'PM') && ($commenthour != '12'))
							$commenthour = $commenthour + 12;
						else if (($comment_date[2] == 'AM') && ($commenthour == '12'))
//.........这里部分代码省略.........
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:blogger.php


示例9: options_page


//.........这里部分代码省略.........
            thesis_save_button_text();
            ?>
" />
			</div>
			<div class="options_module" id="thesis-nav-menu">
				<h3><?php 
            _e('Navigation Menu', 'thesis');
            ?>
</h3>
				<div class="module_subsection">
					<h4 class="module_switch"><a href="" title="<?php 
            _e('Show/hide additional information', 'thesis');
            ?>
"><span class="pos">+</span><span class="neg">&#8211;</span></a><?php 
            _e('Pages', 'thesis');
            ?>
</h4>
					<div class="more_info">
						<p><?php 
            _e('Start by selecting the pages you want to include in your nav menu. Next, drag and drop the pages to change their display order (topmost item displays first), and if you <em>really</em> want to get crazy, you can even edit the display text on each item. <strong>Try it!</strong>', 'thesis');
            ?>
</p>
						<p><?php 
            _e('Thesis features automatic dropdown menus, so if you have nested pages or categories, you&#8217;ll save space <em>and</em> gain style points with your slick new nav menu!', 'thesis');
            ?>
</p>
						<ul id="nav_pages" class="sortable add_margin">
<?php 
            $pages =& get_pages('sort_column=post_parent,menu_order');
            $active_pages = array();
            if ($nav['pages']) {
                foreach ($nav['pages'] as $id => $nav_page) {
                    $active_page = get_page($id);
                    if (post_exists($active_page->post_title)) {
                        $checked = $nav_page['show'] ? ' checked="checked"' : '';
                        $link_text = $nav['pages'][$id]['text'] != '' ? $nav['pages'][$id]['text'] : $active_page->post_title;
                        echo "\t\t\t\t\t\t\t<li><input class=\"checkbox\" type=\"checkbox\" id=\"nav[pages][{$id}][show]\" name=\"nav[pages][{$id}][show]\" value=\"1\"{$checked} /><input type=\"text\" class=\"text_input\" id=\"nav[pages][{$id}][text]\" name=\"nav[pages][{$id}][text]\" value=\"{$link_text}\" /></li>\n";
                        $active_pages[] = $id;
                    }
                }
            }
            if ($pages) {
                foreach ($pages as $page) {
                    if (!in_array($page->ID, $active_pages)) {
                        $link_text = $nav['pages'][$page->ID]['text'] != '' ? $nav['pages'][$page->ID]['text'] : $page->post_title;
                        echo "\t\t\t\t\t\t\t<li><input class=\"checkbox\" type=\"checkbox\" id=\"nav[pages][{$page->ID}][show]\" name=\"nav[pages][{$page->ID}][show]\" value=\"1\" /><input type=\"text\" class=\"text_input\" id=\"nav[pages][{$page->ID}][text]\" name=\"nav[pages][{$page->ID}][text]\" value=\"{$link_text}\" /></li>\n";
                    }
                }
            }
            ?>
						</ul>
					</div>
				</div>
				<div class="module_subsection">
					<h4 class="module_switch"><a href="" title="<?php 
            _e('Show/hide additional information', 'thesis');
            ?>
"><span class="pos">+</span><span class="neg">&#8211;</span></a><?php 
            _e('Categories', 'thesis');
            ?>
</h4>
					<div class="more_info">
						<p><?php 
            _e('If you&#8217;d like to include category pages in your nav menu, simply select the appropriate categories from the list below (you can select more than one).', 'thesis');
            ?>
</p>
开发者ID:JGrubb,项目名称:Almond-Tree,代码行数:67,代码来源:options_site.php


示例10: 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


示例11: post_exists

 /**
  * Does the post exist?
  *
  * @param array $data Post data to check against.
  * @return int|bool Existing post ID if it exists, false otherwise.
  */
 protected function post_exists($data)
 {
     // Constant-time lookup if we prefilled
     $exists_key = $data['guid'];
     if ($this->options['prefill_existing_posts']) {
         return isset($this->exists['post'][$exists_key]) ? $this->exists['post'][$exists_key] : false;
     }
     // No prefilling, but might have already handled it
     if (isset($this->exists['post'][$exists_key])) {
         return $this->exists['post'][$exists_key];
     }
     // Still nothing, try post_exists, and cache it
     $exists = post_exists($data['post_title'], $data['post_content'], $data['post_date']);
     $this->exists['post'][$exists_key] = $exists;
     return $exists;
 }
开发者ID:kucrut,项目名称:WordPress-Importer,代码行数:22,代码来源:class-wxr-importer.php


示例12: cherry_plugin_import_posts

function cherry_plugin_import_posts()
{
    $nonce = $_POST['nonce'];
    if (!wp_verify_nonce($nonce, 'import_ajax-nonce')) {
        exit('instal_error');
    }
    if (session_id() != "import_xml") {
        session_name("import_xml");
        session_start();
    }
    do_action('cherry_plugin_import_posts');
    $_SESSION['url_remap'] = array();
    $_SESSION['featured_images'] = array();
    $_SESSION['attachment_posts'] = array();
    $_SESSION['processed_posts'] = array();
    $posts_array = $_SESSION['posts'];
    $posts_array = apply_filters('wp_import_posts', $posts_array);
    $attachment_posts = array();
    foreach ($posts_array as $post) {
        $post = apply_filters('wp_import_post_data_raw', $post);
        if (!post_type_exists($post['post_type'])) {
            // Failed to import
            do_action('wp_import_post_exists', $post);
            continue;
        }
        if (isset($_SESSION['processed_posts'][$post['post_id']]) && !empty($post['post_id'])) {
            continue;
        }
        if ($post['status'] == 'auto-draft') {
            continue;
        }
        if ('nav_menu_item' == $post['post_type']) {
            continue;
        }
        //!!!!$post_type_object = get_post_type_object( $post['post_type'] );
        $post_exists = post_exists($post['post_title'], '', $post['post_date']);
        if ($post_exists && get_post_type($post_exists) == $post['post_type']) {
            // already exists
            $comment_post_ID = $post_id = $post_exists;
        } else {
            $post_parent = (int) $post['post_parent'];
            if ($post_parent) {
                // if we already know the parent, map it to the new local ID
                if (isset($_SESSION['processed_posts'][$post_parent])) {
                    $post_parent = $_SESSION['processed_posts'][$post_parent];
                    // otherwise record the parent for later
                } else {
                    $_SESSION['post_orphans'][intval($post['post_id'])] = $post_parent;
                    $post_parent = 0;
                }
            }
            $author = (int) get_current_user_id();
            $postdata = array('import_id' => $post['post_id'], 'post_author' => $author, 'post_date' => $post['post_date'], 'post_date_gmt' => $post['post_date_gmt'], 'post_content' => $post['post_content'], 'post_excerpt' => $post['post_excerpt'], 'post_title' => $post['post_title'], 'post_status' => $post['status'], 'post_name' => $post['post_name'], 'comment_status' => $post['comment_status'], 'ping_status' => $post['ping_status'], 'guid' => $post['guid'], 'post_parent' => $post_parent, 'menu_order' => $post['menu_order'], 'post_type' => $post['post_type'], 'post_password' => $post['post_password']);
            $original_post_ID = $post['post_id'];
            $postdata = apply_filters('wp_import_post_data_processed', $postdata, $post);
            if ('attachment' == $postdata['post_type']) {
                array_push($attachment_posts, $post);
            }
            if ('attachment' != $postdata['post_type']) {
                ini_set('max_execution_time', -1);
                set_time_limit(0);
                $comment_post_ID = $post_id = wp_insert_post($postdata, true);
                do_action('wp_import_insert_post', $post_id, $original_post_ID, $postdata, $post);
                if (is_wp_error($post_id)) {
                    // Failed to import
                    continue;
                }
                if ($post['is_sticky'] == 1) {
                    stick_post($post_id);
                }
                // map pre-import ID to local ID
                $_SESSION['processed_posts'][intval($post['post_id'])] = intval($post_id);
                if (!isset($post['terms'])) {
                    $post['terms'] = array();
                }
                $post['terms'] = apply_filters('wp_import_post_terms', $post['terms'], $post_id, $post);
                // add categories, tags and other terms
                if (!empty($post['terms'])) {
                    $terms_to_set = array();
                    foreach ($post['terms'] as $term) {
                        // back compat with WXR 1.0 map 'tag' to 'post_tag'
                        $taxonomy = 'tag' == $term['domain'] ? 'post_tag' : $term['domain'];
                        $term_exists = term_exists($term['slug'], $taxonomy);
                        $term_id = is_array($term_exists) ? $term_exists['term_id'] : $term_exists;
                        if (!$term_id) {
                            $t = wp_insert_term($term['name'], $taxonomy, array('slug' => $term['slug']));
                            if (!is_wp_error($t)) {
                                $term_id = $t['term_id'];
                                do_action('cherry_plugin_import_insert_term', $t, $term, $post_id, $post);
                            } else {
                                // Failed to import
                                do_action('cherry_plugin_import_insert_term_failed', $t, $term, $post_id, $post);
                                continue;
                            }
                        }
                        $terms_to_set[$taxonomy][] = intval($term_id);
                    }
                    foreach ($terms_to_set as $tax => $ids) {
                        $tt_ids = wp_set_post_terms($post_id, $ids, $tax);
                        do_action('wp_import_set_post_terms', $tt_ids, $ids, $tax, $post_id, $post);
//.........这里部分代码省略.........
开发者ID:drupalninja,项目名称:schome_org,代码行数:101,代码来源:import-functions.php


示例13: cpm_action_create_missing_posts

function cpm_action_create_missing_posts()
{
    global $comicpress_manager, $comicpress_manager_admin;
    $all_post_dates = array();
    foreach ($comicpress_manager->query_posts() as $comic_post) {
        $all_post_dates[] = date(CPM_DATE_FORMAT, strtotime($comic_post->post_date));
    }
    $all_post_dates = array_unique($all_post_dates);
    $duplicate_posts_within_creation = array();
    $posts_created = array();
    $thumbnails_written = array();
    $thumbnails_not_written = array();
    $invalid_filenames = array();
    $duplicate_posts = array();
    $new_thumbnails_not_needed = array();
    $execution_time = ini_get("max_execution_time");
    $max_posts_imported = (int) ($execution_time / 2);
    $imported_post_count = 0;
    $safe_exit = false;
    if (strtotime($_POST['time']) === false) {
        $comicpress_manager->warnings[] = sprintf(__('<strong>There was an error in the post time (%1$s)</strong>.  The time is not parseable by strtotime().', 'comicpress-manager'), $_POST['time']);
    } else {
        foreach ($comicpress_manager->comic_files as $comic_file) {
            $comic_file = pathinfo($comic_file, PATHINFO_BASENAME);
            if (($result = $comicpress_manager->breakdown_comic_filename($comic_file)) !== false) {
                extract($result, EXTR_PREFIX_ALL, 'filename');
                $ok_to_create_post = !in_array($result['date'], $all_post_dates);
                $show_duplicate_post_message = false;
                $post_id = null;
                if (isset($duplicate_posts_within_creation[$result['date']])) {
                    $ok_to_create_post = false;
                    $show_duplicate_post_message = true;
                    $post_id = $duplicate_posts_within_creation[$result['date']];
                }
                if ($ok_to_create_post) {
                    if (isset($_POST['duplicate_check'])) {
                        $ok_to_create_post = ($post_id = post_exists($post_title, $post_content, $post_date)) == 0;
                    }
                } else {
                    if (!isset($_POST['duplicate_check'])) {
                        $ok_to_create_post = true;
                    }
                }
                if ($ok_to_create_post) {
                    if (($post_hash = $comicpress_manager->generate_post_hash($filename_date, $filename_converted_title)) !== false) {
                        if (!is_null($post_id = wp_insert_post($post_hash))) {
                            $imported_post_count++;
                            $posts_created[] = get_post($post_id, ARRAY_A);
                            $date = date(CPM_DATE_FORMAT, strtotime($filename_date));
                            $all_post_dates[] = $date;
                            $duplicate_posts_within_creation[$date] = $post_id;
                            foreach (array('hovertext', 'transcript') as $field) {
                                if (!empty($_POST["{$field}-to-use"])) {
                                    update_post_meta($post_id, $field, $_POST["{$field}-to-use"]);
                                }
                            }
                            if (isset($_POST['thumbnails'])) {
                                $wrote_thumbnail = $comicpress_manager_admin->write_thumbnail($comicpress_manager->path . '/' . $comic_file, $comic_file);
                                if (!is_null($wrote_thumbnail)) {
                                    if ($wrote_thumbnail) {
                                        $thumbnails_written[] = $comic_file;
                                    } else {
                                        $thumbnails_not_written[] = $comic_file;
                                    }
                                } else {
                                    $new_thumbnails_not_needed[] = $comic_file;
                                }
                            }
                        }
                    } else {
                        $invalid_filenames[] = $comic_file;
                    }
                } else {
                    if ($show_duplicate_post_message) {
                        $duplicate_posts[] = array(get_post($post_id, ARRAY_A), $comic_file);
                    }
                }
            }
            if ($imported_post_count >= $max_posts_imported) {
                $safe_exit = true;
                break;
            }
        }
    }
    $comicpress_manager->import_safe_exit = $safe_exit;
    if ($safe_exit) {
        $comicpress_manager->messages[] = __("<strong>Import safely exited before you ran out of execution time.</strong> Scroll down to continue creating missing posts.", 'comicpress-manager');
    }
    if (count($posts_created) > 0) {
        $comicpress_manager_admin->display_operation_messages(compact('invalid_filenames', 'thumbnails_written', 'thumbnails_not_written', 'posts_created', 'duplicate_posts', 'new_thumbnails_not_needed'));
    } else {
        $comicpress_manager->messages[] = __("<strong>No new posts needed to be created.</strong>", 'comicpress-manager');
    }
}
开发者ID:johnbintz,项目名称:comicpress-manager-1.5,代码行数:94,代码来源:comicpress_create-missing-posts.php


示例14: do_importer_exporter

        function do_importer_exporter()
        {
            $submit = null;
            $count = 0;
            $post_exists = null;
            $post_warning = null;
            global $aioseop_options, $aiosp, $aioseop_module_list;
            if (isset($_REQUEST['nonce-aioseop'])) {
                $nonce = $_REQUEST['nonce-aioseop'];
            }
            $post_fields = array('keywords', 'description', 'title', 'meta', 'disable', 'disable', 'disable_analytics', 'titleatr', 'menulabel', 'togglekeywords');
            if (!empty($_FILES['aiosp_importer_exporter_import_submit']['tmp_name'])) {
                $submit = 'Import';
            }
            if (!empty($_REQUEST['export_submit'])) {
                $submit = 'Export';
            }
            if ($submit != null && wp_verify_nonce($nonce, 'aioseop-nonce')) {
                switch ($submit) {
                    case 'Import':
                        try {
                            // Parses export file
                            $file = $this->get_sanitized_file($_FILES['aiosp_importer_exporter_import_submit']['tmp_name']);
                            $section = array();
                            $section_label = null;
                            foreach ($file as $line_number => $line) {
                                $line = trim($line);
                                $matches = array();
                                if (empty($line)) {
                                    continue;
                                }
                                if ($line[0] == ';') {
                                    continue;
                                }
                                if (preg_match("/^\\[(\\S+)\\]\$/", $line, $label)) {
                                    $section_label = strval($label[1]);
                                    if ($section_label == 'post_data') {
                                        $count++;
                                    }
                                    if (!isset($section[$section_label])) {
                                        $section[$section_label] = array();
                                    }
                                } elseif (preg_match("/^(\\S+)\\s*=\\s*'(.*)'\$/", $line, $matches)) {
                                    if ($section_label == 'post_data') {
                                        $section[$section_label][$count][$matches[1]] = $matches[2];
                                    } else {
                                        $section[$section_label][$matches[1]] = $matches[2];
                                    }
                                } elseif (preg_match("/^(\\S+)\\s*=\\s*NULL\$/", $line, $matches)) {
                                    if ($section_label == 'post_data') {
                                        $section[$section_label][$count][$matches[1]] = null;
                                    } else {
                                        $section[$section_label][$matches[1]] = null;
                                    }
                                } else {
                                    $this->warnings[] = sprintf(__('<b>Warning:</b> Line not matched: <b>"%s"</b>, On Line: <b>%s</b>', 'all-in-one-seo-pack'), $line, $line_number);
                                }
                            }
                            // Updates Plugin Settings
                            if (is_array($section)) {
                                foreach ($section as $label => $module_options) {
                                    if (is_array($module_options)) {
                                        foreach ($module_options as $key => $value) {
                 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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