本文整理汇总了PHP中wp_publish_post函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_publish_post函数的具体用法?PHP wp_publish_post怎么用?PHP wp_publish_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_publish_post函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch
public function fetch($client_id, $tag)
{
global $wpdb;
$instagram = new \Instagram\Instagram();
$instagram->setClientId($client_id);
$min_tag_id = get_option("last_instagram_tag_{$tag}_id", 0);
$tag = $instagram->getTag($tag);
$media = $tag->getMedia(array('min_tag_id' => $min_tag_id));
update_option("last_instagram_tag_{$tag}_id", $media->getNextMaxTagId());
foreach ($media as $m) {
$query = "SELECT posts.* FROM " . $wpdb->posts . " AS posts\n INNER JOIN " . $wpdb->postmeta . " AS wpostmeta ON wpostmeta.post_id = posts.ID\n AND wpostmeta.meta_key = 'degg_instagram_id'\n AND wpostmeta.meta_value = '{$m->getID()}'";
$posts = $wpdb->get_results($query, ARRAY_A);
if (!$posts) {
$id = wp_insert_post(array('post_title' => "{$m->getUser()} on {$m->getCreatedTime('M jS Y @ g:ia')}", 'post_content' => "<img src='{$m->getThumbnail()->url}' title='Posted by {$m->getUser()} on {$m->getCreatedTime('M jS Y @ g:ia')}'>", 'post_type' => 'degg_instagram'));
add_post_meta($id, 'degg_instagram_id', "{$m->getID()}", true);
add_post_meta($id, 'degg_instagram_title', "Posted by {$m->getUser()} on {$m->getCreatedTime('M jS Y @ g:ia')}", true);
add_post_meta($id, 'degg_instagram_user', "{$m->getUser()}", true);
add_post_meta($id, 'degg_instagram_caption', "{$m->getCaption()}", true);
add_post_meta($id, 'degg_instagram_link', "{$m->getLink()}", true);
add_post_meta($id, 'degg_instagram_thumbnail', $m->getThumbnail(), true);
add_post_meta($id, 'degg_instagram_standard_res', $m->getStandardRes(), true);
add_post_meta($id, 'degg_instagram_low_res', $m->getLowRes(), true);
wp_publish_post($id);
}
}
}
示例2: manager_admin_init
function manager_admin_init()
{
if (isset($_POST['key']) && $_POST['key'] == "ioamediamanager") {
$type = $_POST['type'];
switch ($type) {
case "create":
$slider_title = $_POST['value'];
$slider_post = array('post_title' => $slider_title, 'post_type' => 'slider');
$id = wp_insert_post($slider_post);
echo "\r\n\r\n\t\t\t\t\t\t<div class='slider-item clearfix'>\r\n\t\t\t\t\t\t\t \t\t<a href='" . admin_url() . "admin.php?page=ioamed&edit_id={$id}' class='edit-icon pencil-3icon- ioa-front-icon'></a>\r\n\t\t\t\t\t\t\t \t\t<h6>" . $slider_title . "</h6>\r\n\t\t\t\t\t\t\t \t\t<span class='shortcode'> " . __('Shortcode', 'ioa') . " [slider id='{$id}'] </span>\r\n\t\t\t\t\t\t\t\t\t\t<a href='{$id}' class='close cancel-circled-2icon- ioa-front-icon'></a>\r\n\t\t\t\t\t\t</div> \r\n\t\t\t\t\t";
break;
case "update":
$id = $_POST['id'];
$ioa_options = $slides = '';
if (isset($_POST['options'])) {
$ioa_options = $_POST['options'];
}
if (isset($_POST['slides'])) {
$slides = $_POST['slides'];
}
wp_publish_post($id);
update_post_meta($id, "options", $ioa_options);
update_post_meta($id, "slides", $slides);
break;
case "delete":
$id = $_POST['id'];
wp_delete_post($id, true);
}
die;
}
}
示例3: test_updating_post_sets_do_not_send_subscription_flag
function test_updating_post_sets_do_not_send_subscription_flag()
{
$post_id = $this->factory->post->create();
// Publish and then immediately update the post, which should set the do not send flag
wp_publish_post($post_id);
wp_update_post(array('ID' => $post_id, 'post_content' => 'The updated post content'));
$this->assertEquals('1', get_post_meta($post_id, '_jetpack_dont_email_post_to_subs', true));
}
示例4: test_sync_post_status_change
public function test_sync_post_status_change()
{
$this->assertNotEquals('draft', $this->post->post_status);
wp_update_post(array('ID' => $this->post->ID, 'post_status' => 'draft'));
$this->sender->do_sync();
$remote_post = $this->server_replica_storage->get_post($this->post->ID);
$this->assertEquals('draft', $remote_post->post_status);
wp_publish_post($this->post->ID);
$this->sender->do_sync();
$remote_post = $this->server_replica_storage->get_post($this->post->ID);
$this->assertEquals('publish', $remote_post->post_status);
}
示例5: test_pmp_on_post_status_transition
function test_pmp_on_post_status_transition()
{
$pmp_posts = pmp_get_pmp_posts();
$pmp_post = $pmp_posts[0];
$custom_fields = get_post_custom($pmp_post->ID);
$date = date('Y-m-d H:i:s', strtotime($custom_fields['pmp_published'][0]));
// Transition to published
wp_publish_post($pmp_post->ID);
$pmp_post_after_transition = get_post($pmp_post->ID);
// The date should be the same as the original PMP published date, not the current date/time.
$this->assertEquals($pmp_post_after_transition->post_date, $date);
}
示例6: ProjectTheme_qq_main_listing_submit_respo
function ProjectTheme_qq_main_listing_submit_respo()
{
if ($_POST['qpstat'] == '000') {
$md5 = $_POST['md5check'];
if (!empty($md5)) {
$tranid = $_GET['tranid'];
$gr = get_option('LST_QUICKPAY_' . $tranid, true);
//******************************
$c = explode('|', $gr);
$pid = $c[0];
$uid = $c[1];
$datemade = $c[2];
//---------------------------------------------------
global $wpdb;
$pref = $wpdb->prefix;
//--------------------------------------------
update_post_meta($pid, "paid", "1");
update_post_meta($pid, "paid_listing_date", current_time('timestamp', 0));
update_post_meta($pid, "closed", "0");
//--------------------------------------------
update_post_meta($pid, 'base_fee_paid', '1');
$featured = get_post_meta($pid, 'featured', true);
if ($featured == "1") {
update_post_meta($pid, 'featured_paid', '1');
}
$private_bids = get_post_meta($pid, 'private_bids', true);
if ($private_bids == "1") {
update_post_meta($pid, 'private_bids_paid', '1');
}
$hide_project = get_post_meta($pid, 'hide_project', true);
if ($hide_project == "1") {
update_post_meta($pid, 'hide_project_paid', '1');
}
//--------------------------------------------
do_action('ProjectTheme_moneybookers_listing_response', $pid);
$projectTheme_admin_approves_each_project = get_option('projectTheme_admin_approves_each_project');
if ($projectTheme_admin_approves_each_project != "yes") {
wp_publish_post($pid);
$post_new_date = date('Y-m-d h:s', current_time('timestamp', 0));
$post_info = array("ID" => $pid, "post_date" => $post_new_date, "post_date_gmt" => $post_new_date, "post_status" => "publish");
wp_update_post($post_info);
ProjectTheme_send_email_posted_project_approved($pid);
ProjectTheme_send_email_posted_project_approved_admin($pid);
} else {
ProjectTheme_send_email_posted_project_not_approved($pid);
ProjectTheme_send_email_posted_project_not_approved_admin($pid);
ProjectTheme_send_email_subscription($pid);
}
//******************************
}
}
}
示例7: force_publish_missed_schedules
/**
* Published scheduled posts that miss their schedule
*/
public function force_publish_missed_schedules()
{
global $wpdb;
$missed_posts = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_status = 'future' AND post_date <= %s LIMIT 25;", current_time('mysql', false)));
if (!empty($missed_posts)) {
foreach ($missed_posts as $missed_post) {
$missed_post = absint($missed_post);
wp_publish_post($missed_post);
wp_clear_scheduled_hook('publish_future_post', array($missed_post));
do_action('a8c_cron_control_published_post_that_missed_schedule', $missed_post);
}
}
}
示例8: test_publishing_and_unpublishing_posts
function test_publishing_and_unpublishing_posts()
{
$post_id = $this->factory->post->create(array('post_title' => 'test post', 'post_name' => 'test-post', 'post_status' => 'draft'));
SP_API()->post('_refresh');
$this->assertEmpty($this->search_and_get_field(array('query' => 'test post')));
wp_publish_post($post_id);
SP_API()->post('_refresh');
$this->assertEquals(array('test-post'), $this->search_and_get_field(array('query' => 'test post')));
$post = array('ID' => $post_id, 'post_status' => 'draft');
wp_update_post($post);
SP_API()->post('_refresh');
$this->assertEmpty($this->search_and_get_field(array('query' => 'test post')));
}
示例9: publish_missed_schedule
public static function publish_missed_schedule()
{
global $wpdb;
$scheduled_ids = $wpdb->get_col("SELECT `ID` FROM `{$wpdb->posts}` WHERE( ((`post_date`>0)&&(`post_date`<=CURRENT_TIMESTAMP())) OR ((`post_date_gmt`>0)&&(`post_date_gmt`<=UTC_TIMESTAMP())) )AND `post_status` = 'future' LIMIT 0, 10");
if (false == $scheduled_ids) {
return false;
}
foreach ($scheduled_ids as $scheduled_id) {
if (!$scheduled_id) {
continue;
}
remove_action('publish_future_post', 'check_and_publish_future_post');
wp_publish_post($scheduled_id);
add_action('publish_future_post', 'check_and_publish_future_post');
}
return true;
}
示例10: ProjectTheme_payfast_main_listing_response_payment
function ProjectTheme_payfast_main_listing_response_payment()
{
$c = $_POST['custom_str1'];
$c = explode('|', $c);
$pid = $c[0];
$uid = $c[1];
$datemade = $c[2];
//---------------------------------------------------
global $wpdb;
$pref = $wpdb->prefix;
//--------------------------------------------
update_post_meta($pid, "paid", "1");
update_post_meta($pid, "paid_listing_date", current_time('timestamp', 0));
update_post_meta($pid, "closed", "0");
//--------------------------------------------
update_post_meta($pid, 'base_fee_paid', '1');
$featured = get_post_meta($pid, 'featured', true);
if ($featured == "1") {
update_post_meta($pid, 'featured_paid', '1');
}
$private_bids = get_post_meta($pid, 'private_bids', true);
if ($private_bids == "1") {
update_post_meta($pid, 'private_bids_paid', '1');
}
$hide_project = get_post_meta($pid, 'hide_project', true);
if ($hide_project == "1") {
update_post_meta($pid, 'hide_project_paid', '1');
}
//--------------------------------------------
do_action('ProjectTheme_moneybookers_listing_response', $pid);
$projectTheme_admin_approves_each_project = get_option('projectTheme_admin_approves_each_project');
if ($projectTheme_admin_approves_each_project != "yes") {
wp_publish_post($pid);
$post_new_date = date('Y-m-d h:s', current_time('timestamp', 0));
$post_info = array("ID" => $pid, "post_date" => $post_new_date, "post_date_gmt" => $post_new_date, "post_status" => "publish");
wp_update_post($post_info);
ProjectTheme_send_email_posted_project_approved($pid);
ProjectTheme_send_email_posted_project_approved_admin($pid);
} else {
ProjectTheme_send_email_posted_project_not_approved($pid);
ProjectTheme_send_email_posted_project_not_approved_admin($pid);
ProjectTheme_send_email_subscription($pid);
}
//---------------------------
}
示例11: wpms_init
function wpms_init()
{
remove_action('publish_future_post', 'check_and_publish_future_post');
$last = get_option(WPMS_OPTION, false);
if ($last !== false && $last > time() - WPMS_DELAY * 60) {
return;
}
update_option(WPMS_OPTION, time());
global $wpdb;
$scheduledIDs = $wpdb->get_col("SELECT`ID`FROM`{$wpdb->posts}`" . "WHERE(" . "((`post_date`>0)&&(`post_date`<=CURRENT_TIMESTAMP()))OR" . "((`post_date_gmt`>0)&&(`post_date_gmt`<=UTC_TIMESTAMP()))" . ")AND`post_status`='future'LIMIT 0,5");
if (!count($scheduledIDs)) {
return;
}
foreach ($scheduledIDs as $scheduledID) {
if (!$scheduledID) {
continue;
}
wp_publish_post($scheduledID);
}
}
示例12: tdomf_publish_post
function tdomf_publish_post($post_ID, $use_queue = true)
{
$form_id = get_post_meta($post_ID, TDOMF_KEY_FORM_ID, true);
$post =& get_post($post_ID);
if ($post->post_status == 'future') {
// updating the post when the post is already queued wont' work
// we need to use the publish post option
wp_publish_post($post_ID);
} else {
$current_ts = current_time('mysql');
$ts = tdomf_queue_date($form_id, $current_ts);
if ($current_ts == $ts || !$use_queue) {
$post = array("ID" => $post_ID, "post_status" => 'publish');
} else {
tdomf_log_message("Future Post Date = {$ts}!");
$post = array("ID" => $post_ID, "post_status" => 'future', "post_date" => $ts, "edit_date" => $ts);
}
// use update_post as this was the most consistent function since
// wp2.2 for publishign the post correctly
wp_update_post($post);
}
}
示例13: manager_admin_init
function manager_admin_init()
{
if (isset($_GET['page']) && $_GET['page'] == 'ioapty') {
wp_enqueue_media();
}
if (isset($_POST['key']) && $_POST['key'] == "custompostsmanager") {
$type = $_POST['type'];
switch ($type) {
case "create":
$cp_title = $_POST['value'];
$cp_post = array('post_title' => $cp_title, 'post_type' => 'custompost');
$id = wp_insert_post($cp_post);
echo "\r\n\t\t\t\t\t\t<div class='cp-item clearfix'>\r\n\t\t\t\t\t\t\t \t\t<a href='" . admin_url() . "admin.php?page=ioapty&edit_id={$id}' class='edit-icon pencil-3icon- ioa-front-icon'></a>\r\n\t\t\t\t\t\t\t \t\t<h6>" . $cp_title . "</h6>\r\n\t\t\t\t\t\t\t\t\t\t<a href='{$id}' class='close cancel-circled-2icon- ioa-front-icon'></a>\r\n\t\t\t\t\t\t</div> \r\n\t\t\t\t\t";
break;
case "update":
$id = $_POST['id'];
$ioa_options = $metaboxes = '';
if (isset($_POST['options'])) {
$ioa_options = $_POST['options'];
}
if (isset($_POST['metaboxes'])) {
$metaboxes = $_POST['metaboxes'];
}
$title = $_POST['title'];
global $helper;
$helper->setPostTitle($title, $id);
wp_publish_post($id);
update_post_meta($id, "options", $ioa_options);
echo update_post_meta($id, "metaboxes", $metaboxes);
break;
case "delete":
$id = $_POST['id'];
wp_delete_post($id, true);
}
die;
}
}
示例14: set_post_format
set_post_format(intval($token), 'gallery');
$attachment = array('guid' => $target_file, 'post_mime_type' => $file_type, 'post_title' => preg_replace('/\\.[^.]+$/', '', $target_file), 'post_content' => '', 'post_status' => 'inherit');
$attach_id = wp_insert_attachment($attachment, $target_file, intval($token));
// Make sure that this file is included, as wp_generate_attachment_metadata() depends on it.
require_once ABSPATH . 'wp-admin/includes/image.php';
// Generate the metadata for the attachment, and update the database record.
$attach_data = wp_generate_attachment_metadata($attach_id, $target_file);
wp_update_attachment_metadata($attach_id, $attach_data);
//set_post_thumbnail( intval($token), $attach_id );
if ($attach_id !== 0) {
$attachments = get_attached_media("image", intval($token));
foreach ($attachments as $attachment) {
array_push($attachments_ids, $attachment->ID);
}
}
if (isset($attachments_ids) && sizeof($attachments_ids) !== 0) {
if (get_post(intval($token))->post_status == 'pending') {
wp_publish_post(intval($token));
if (!has_post_thumbnail(intval($token))) {
set_post_thumbnail(intval($token), $attachments_ids[0]);
}
}
update_field('featured_gallery', $attachments_ids, intval($token));
update_post_meta(intval($token), '_featured_gallery', '');
update_post_meta(intval($token), '_featured_gallery', 'field_5287d441bb41b');
}
}
}
}
}
}
示例15: siteorigin_panels_save_home_page
/**
* Save home page
*/
function siteorigin_panels_save_home_page()
{
if (!isset($_POST['_sopanels_home_nonce']) || !wp_verify_nonce($_POST['_sopanels_home_nonce'], 'save')) {
return;
}
if (!current_user_can('edit_theme_options')) {
return;
}
if (!isset($_POST['panels_data'])) {
return;
}
// Check that the home page ID is set and the home page exists
$page_id = get_option('page_on_front');
if (empty($page_id)) {
$page_id = get_option('siteorigin_panels_home_page_id');
}
$post_content = wp_unslash($_POST['post_content']);
if (!$page_id || get_post_meta($page_id, 'panels_data', true) == '') {
// Lets create a new page
$page_id = wp_insert_post(array('post_title' => __('Home Page', 'siteorigin-panels'), 'post_status' => !empty($_POST['siteorigin_panels_home_enabled']) ? 'publish' : 'draft', 'post_type' => 'page', 'post_content' => $post_content, 'comment_status' => 'closed'));
update_option('page_on_front', $page_id);
update_option('siteorigin_panels_home_page_id', $page_id);
// Action triggered when creating a new home page through the custom home page interface
do_action('siteorigin_panels_create_home_page', $page_id);
} else {
// `wp_insert_post` does it's own sanitization, but it seems `wp_update_post` doesn't.
$post_content = sanitize_post_field('post_content', $post_content, $page_id, 'db');
// Update the post with changed content to save revision if necessary.
wp_update_post(array('ID' => $page_id, 'post_content' => $post_content));
}
// Save the updated page data
$panels_data = json_decode(wp_unslash($_POST['panels_data']), true);
$panels_data['widgets'] = siteorigin_panels_process_raw_widgets($panels_data['widgets']);
$panels_data = siteorigin_panels_styles_sanitize_all($panels_data);
update_post_meta($page_id, 'panels_data', $panels_data);
$template = get_post_meta($page_id, '_wp_page_template', true);
$home_template = siteorigin_panels_setting('home-template');
if (($template == '' || $template == 'default') && !empty($home_template)) {
// Set the home page template
update_post_meta($page_id, '_wp_page_template', $home_template);
}
if (!empty($_POST['siteorigin_panels_home_enabled'])) {
update_option('show_on_front', 'page');
update_option('page_on_front', $page_id);
update_option('siteorigin_panels_home_page_id', $page_id);
wp_publish_post($page_id);
} else {
// We're disabling this home page
update_option('show_on_front', 'posts');
// Change the post status to draft
$post = get_post($page_id);
if ($post->post_status != 'draft') {
global $wpdb;
$wpdb->update($wpdb->posts, array('post_status' => 'draft'), array('ID' => $post->ID));
clean_post_cache($post->ID);
$old_status = $post->post_status;
$post->post_status = 'draft';
wp_transition_post_status('draft', $old_status, $post);
do_action('edit_post', $post->ID, $post);
do_action("save_post_{$post->post_type}", $post->ID, $post, true);
do_action('save_post', $post->ID, $post, true);
do_action('wp_insert_post', $post->ID, $post, true);
}
}
}