本文整理汇总了PHP中wp_publish_post函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_publish_post函数的具体用法?PHP wp_publish_post怎么用?PHP wp_publish_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_publish_post函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
}
开发者ID:travisscheidegger,项目名称:wp-instagram-subscription,代码行数:26,代码来源:Fetch.php
示例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;
}
}
开发者ID:severnrescue,项目名称:web,代码行数:31,代码来源:media_manager.php
示例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));
}
开发者ID:iamtakashi,项目名称:jetpack,代码行数:8,代码来源:test_class.jetpack-subscriptions.php
示例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);
}
开发者ID:iamtakashi,项目名称:jetpack,代码行数:12,代码来源:test_class.jetpack-sync-posts.php
示例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);
}
开发者ID:jackbrighton,项目名称:pmp-wordpress,代码行数:12,代码来源:test-functions.php
示例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);
}
//******************************
}
}
}
开发者ID:vicpril,项目名称:rep_bidqa,代码行数:52,代码来源:qq_listing.php
示例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);
}
}
}
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:16,代码来源:class-internal-events.php
示例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')));
}
开发者ID:dfmedia,项目名称:searchpress,代码行数:13,代码来源:test-indexing.php
示例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;
}
开发者ID:BeAPI,项目名称:bea-missed-schedule,代码行数:17,代码来源:bea-missed-schedule.php
示例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);
}
//---------------------------
}
开发者ID:vicpril,项目名称:rep_bidqa,代码行数:45,代码来源:payfast_response.php
示例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);
}
}
开发者ID:Creative-Srijon,项目名称:top10bestwp,代码行数:20,代码来源:functions.php
示例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);
}
}
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:22,代码来源:tdomf-moderation.php
示例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;
}
}
开发者ID:severnrescue,项目名称:web,代码行数:37,代码来源:customposts_manager.php
示例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');
}
}
}
}
}
}
开发者ID:dqishmirian,项目名称:jrrny,代码行数:31,代码来源:upload-jrrny.php
示例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);
}
}
}
开发者ID:pcuervo,项目名称:od4d,代码行数:68,代码来源:siteorigin-panels.php
示例16: test_document_slug
/**
* Tests that changing the document slug is reflected in permalinks
*/
function test_document_slug()
{
global $wp_rewrite;
$tdr = new WP_Test_Document_Revisions();
//set new slug
update_site_option('document_slug', 'docs');
//add doc and flush
$docID = $tdr->test_add_document();
wp_publish_post($docID);
wp_cache_flush();
$this->verify_download(get_permalink($docID), $tdr->test_file, 'revised document slug permalink doesn\'t rewrite');
$this->assertContains('/docs/', get_permalink($docID), 'revised document slug not in permalink');
}
开发者ID:Beelegumes,项目名称:syst-ass-web,代码行数:16,代码来源:test_document_rewrites.php
示例17: process_bulk_action
/**
* Process the bulk actions
*/
public function process_bulk_action()
{
$ids = isset($_GET['post']) ? $_GET['post'] : false;
$action = $this->current_action();
if (!is_array($ids)) {
$ids = array($ids);
}
if (empty($action)) {
return;
}
foreach ($ids as $id) {
// Detect when a bulk action is being triggered...
if ('trash' === $this->current_action()) {
wp_trash_post($id);
}
if ('publish' === $this->current_action()) {
wp_publish_post($id);
}
if ('pending' === $this->current_action()) {
// Update post
$u_post = array();
$u_post['ID'] = $id;
$u_post['post_status'] = 'pending';
// Update the post into the database
wp_update_post($u_post);
}
if ('delete' === $this->current_action()) {
wp_delete_post($id, true);
}
if ('restore' === $this->current_action()) {
wp_untrash_post($id);
}
do_action('ap_moderate_table_do_bulk_action', $id, $this->current_action());
}
}
开发者ID:haythameyd,项目名称:powrly,代码行数:38,代码来源:flagged.php
示例18: publish_missed_schedule_posts
/**
* Function definition is based on core of https://wordpress.org/plugins/wp-missed-schedule/
*/
public function publish_missed_schedule_posts($post_id)
{
global $wpdb;
$publish_missed_schedule_posts_response = array();
try {
$post_date = current_time('mysql', 0);
$publish_missed_schedule_posts_response['post_date'] = $post_date;
if (is_numeric($post_id)) {
$qry = "SELECT ID FROM {$wpdb->posts} WHERE ID = %d AND ( ( post_date > 0 && post_date <= %s ) ) AND post_status = 'future' LIMIT 1";
$sql = $wpdb->prepare($qry, $post_id, $post_date);
} else {
$qry = "SELECT ID FROM {$wpdb->posts} WHERE ( ( post_date > 0 && post_date <= %s ) ) AND post_status = 'future' LIMIT 0,10";
$sql = $wpdb->prepare($qry, $post_date);
}
//log('SQL: ' . $sql);
$post_ids = $wpdb->get_col($sql);
$count_missed_schedule = count($post_ids);
$publish_missed_schedule_posts_response['count_missed_schedule'] = $count_missed_schedule;
if ($count_missed_schedule > 0) {
$publish_missed_schedule_posts_response['missed_schedule_post_ids'] = $post_ids;
foreach ($post_ids as $post_id) {
if (!$post_id) {
continue;
}
// !!! LET THE MAGIC HAPPEN !!! //
wp_publish_post($post_id);
}
}
} catch (Exception $e) {
$publish_missed_schedule_posts_response['exception'] = $e->getMessage();
}
return $publish_missed_schedule_posts_response;
}
开发者ID:areveal,项目名称:marketing-site,代码行数:36,代码来源:tm-scheduler.php
示例19: delibera_nova_pauta_create_action
function delibera_nova_pauta_create_action()
{
$opt = delibera_get_config();
if ($opt['criar_pauta_pelo_front_end'] == 'S' && is_user_logged_in() && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'delibera_nova_pauta')) {
$title = $_POST['nova-pauta-titulo'];
$content = $_POST['nova-pauta-conteudo'];
$excerpt = $_POST['nova-pauta-resumo'];
$pauta = array();
$pauta['post_title'] = $title;
$pauta['post_excerpt'] = $excerpt;
$pauta['post_type'] = 'pauta';
//Check if there is any file uploaded
// If there is any, then ignore 'content' and use File.
// else do add 'pauta' with the text content
if (!empty($_FILES['post_pdf_contribution']['name'])) {
// Setup the array of supported file types. In this case, it's just PDF.
$supported_types = array('application/pdf');
// Get the file type of the upload
$pdf_contribution = wp_check_filetype(basename($_FILES['post_pdf_contribution']['name']));
$sent_file_type = $pdf_contribution['type'];
// Check if the type is supported. If not, throw an error.
if (!in_array($sent_file_type, $supported_types)) {
//TODO: Improve this message and avoid wp_die
wp_die("O arquivo para web não é um PDF (formato permitido).");
}
$uploaded_file = wp_upload_bits($_FILES['pauta_pdf_contribution']['name'], null, file_get_contents($_FILES['pauta_pdf_contribution']['tmp_name']));
if (isset($uploaded_file['error']) && $uploaded_file['error'] != 0) {
wp_die('Erro ao salvar arquivo para Web. O erro foi: ' . $upload['error']);
} else {
$pauta['pauta_pdf_contribution'] = $uploaded_file['url'];
}
} else {
$pauta['post_content'] = $content;
}
// para que a situação da pauta seja criada corretamente,
// é necessário criar a pauta como rascunho para depois publicar no final desta função
$pauta['post_status'] = 'draft';
$pauta_id = wp_insert_post($pauta);
if (is_int($pauta_id) && $pauta_id > 0) {
/* Os valores adicionados ao array $_POST são baseados no if da função delibera_save_post(),
* comentado abaixo
if(
( // Se tem validação, tem que ter o prazo
$opt['validacao'] == 'N' ||
(array_key_exists('prazo_validacao', $_POST) && array_key_exists('min_validacoes', $_POST) )
) &&
( // Se tem relatoria, tem que ter o prazo
$opt['relatoria'] == 'N' ||
array_key_exists('prazo_relatoria', $_POST)
) &&
( // Se tem relatoria, e é preciso eleger o relator, tem que ter o prazo para eleição
$opt['relatoria'] == 'N' ||
(
$opt['eleicao_relator'] == 'N' ||
array_key_exists('prazo_eleicao_relator', $_POST)
)
) &&
array_key_exists('prazo_discussao', $_POST) &&
array_key_exists('prazo_votacao', $_POST)
)
*/
if ($opt['validacao'] == 'S') {
$_POST['prazo_validacao'] = date('d/m/Y', strtotime('+' . $opt['dias_validacao'] . ' DAYS'));
$_POST['min_validacoes'] = $opt['minimo_validacao'];
}
if ($opt['relatoria'] == 'S') {
$_POST['prazo_relatoria'] = date('d/m/Y', strtotime('+' . $opt['dias_relatoria'] . ' DAYS'));
if ($opt['eleicao_relator'] == 'S') {
$_POST['prazo_eleicao_relator'] = date('d/m/Y', strtotime('+' . $opt['dias_votacao_relator'] . ' DAYS'));
}
}
if (trim($opt['data_fixa_nova_pauta_externa']) != '') {
$prazo_discussao = DateTime::createFromFormat('d/m/Y', $opt['data_fixa_nova_pauta_externa']);
$_POST['prazo_discussao'] = $prazo_discussao->format('d/m/Y');
$_POST['prazo_votacao'] = date('d/m/Y', strtotime('+' . $opt['dias_votacao'] . ' DAYS', $prazo_discussao->getTimestamp()));
} else {
$_POST['prazo_discussao'] = date('d/m/Y', strtotime('+' . $opt['dias_discussao'] . ' DAYS'));
$_POST['prazo_votacao'] = date('d/m/Y', strtotime('+' . $opt['dias_votacao'] . ' DAYS'));
}
// isto é necessário por causa do if da função delibera_publish_pauta()
$_POST['publish'] = 'Publicar';
$_POST['prev_status'] = 'draft';
// verifica se todos os temas enviados por post são válidos
$temas = get_terms('tema', array('hide_empty' => true));
$temas_ids = array();
if (isset($_POST['tema']) && is_array($_POST['tema'])) {
foreach ($temas as $tema) {
if (in_array($tema->term_id, $_POST['tema'])) {
$temas_ids[] = $tema->term_id;
}
}
}
// coloca os termos de temas no post
wp_set_post_terms($pauta_id, $temas_ids, 'tema');
// publica o post
wp_publish_post($pauta_id);
// isto serve para criar o slug corretamente,
// já que no wp_insert_post não cria o slug quando o status é draft e o wp_publish_post tb não cria o slug
unset($pauta['post_status']);
$pauta['ID'] = $pauta_id;
//.........这里部分代码省略.........
开发者ID:samueldu,项目名称:delibera,代码行数:101,代码来源:delibera.php
示例20: check_and_publish_future_post
/**
* check_and_publish_future_post() - check to make sure post has correct status before
* passing it on to be published. Invoked by cron 'publish_future_post' event
* This safeguard prevents cron from publishing drafts, etc.
*
* {@internal Missing Long Description}}
*
* @package WordPress
* @subpackage Post
* @since 2.5
* @uses $wpdb
*
* @param int $post_id Post ID
* @return int|null {@internal Missing Description}}
*/
function check_and_publish_future_post($post_id)
{
$post = get_post($post_id);
if (empty($post)) {
return;
}
if ('future' != $post->post_status) {
return;
}
return wp_publish_post($post_id);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:26,代码来源:post.php
注:本文中的wp_publish_post函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论