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


PHP wp_transition_post_status函数代码示例

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


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

示例1: test__transition_post_status__ignore_when_locked

 public function test__transition_post_status__ignore_when_locked()
 {
     // The first update sets the lock so the action should only fire once when updating twice
     \wp_transition_post_status('publish', 'publish', $this->post);
     \wp_transition_post_status('publish', 'publish', $this->post);
     $this->assertEquals(1, did_action('wpcom_vip_bump_lastpostmodified'));
 }
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:7,代码来源:test-performance-lastpostmodified.php

示例2: process_expirations

 function process_expirations($delta)
 {
     global $post;
     global $wpdb;
     $q = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => get_option('fwplpbd_expiration_chunk', 25), 'meta_key' => '_syndication_expiration_date', 'meta_value' => time(), 'meta_compare' => '<='));
     while ($q->have_posts()) {
         $q->the_post();
         $expiration = get_post_meta($post->ID, '_syndication_expiration_date', true);
         if ((int) $expiration and (int) $expiration <= time()) {
             $action = get_post_meta($post->ID, '_syndication_expiration_action', true);
             FeedWordPress::diagnostic('expiration', 'Post [' . $post->ID . '] "' . esc_html($post->post_title) . '" expired as of ' . date('r', (int) $expiration) . ' and will now be ' . ('trash' == $action ? 'trashed' : ('nuke' == $action ? 'deleted permanently' : 'hidden')));
             switch ($action) {
                 case 'trash':
                 case 'nuke':
                     $feed = get_syndication_feed_object($post->ID);
                     $thumbId = get_post_thumbnail_id($post->ID);
                     wp_delete_post($post->ID, 'nuke' == $action);
                     // Check to see whether any other posts
                     // use this as a Featured Image. If not
                     // then zap it.
                     if ("nuke" == $feed->setting('post expiration thumbnail', 'post_expiration_thumbnail', "keep")) {
                         if (strlen($thumbId) > 0) {
                             $qrows = $wpdb->get_results($wpdb->prepare("\n\t\t\t\t\t\t\tSELECT meta_value FROM {$wpdb->postmeta}\n\t\t\t\t\t\t\tWHERE meta_key = '_thumbnail_id'\n\t\t\t\t\t\t\tAND meta_value = '%d'\n\t\t\t\t\t\t\tAND post_id <> '%d'\n\t\t\t\t\t\t\t", $thumbId, $post->ID));
                             if (count($qrows) < 1) {
                                 FeedWordPress::diagnostic('expiration', 'The expired post [' . $post->ID . ']  had an attached Featured Image, which is not used as the Featured Image for any other post. We will now clean up and the image will be ' . ('trash' == $action ? 'trashed' : ('nuke' == $action ? 'deleted permanently' : 'hidden')));
                                 wp_delete_attachment($thumbId, 'nuke' == $action);
                             } else {
                                 FeedWordPress::diagnostic('expiration', 'The expired post [' . $post->ID . ']  had an attached Featured Image, but it CANNOT be deleted right now because at least one other post uses the same image as its Featured Image.');
                             }
                         }
                     }
                     break;
                 case 'hide':
                 case 'redirect':
                 default:
                     $old_status = $post->post_status;
                     set_post_field('post_status', 'expired', $post->ID);
                     wp_transition_post_status('expired', $old_status, $post);
                     break;
             }
         }
     }
 }
开发者ID:radgeek,项目名称:fwp-limit-posts-by-date,代码行数:43,代码来源:fwp-limit-posts-by-date.php

示例3: update_event_quote

 function update_event_quote($event_id, $quote_id)
 {
     // If the current user is not the client, do not log
     if (get_post_meta($event_id, '_mdjm_event_client', true) != get_current_user_id()) {
         return;
     }
     /* -- Initiate actions for status change -- */
     wp_transition_post_status('mdjm-quote-viewed', 'mdjm-quote-generated', get_post($quote_id));
     if (MDJM_DEBUG == true) {
         MDJM()->debug->log_it('Setting quote to viewed status for quote ' . $quote_id . ' event ' . $event_id, true);
     }
     /* -- Update the post status -- */
     if (wp_update_post(array('ID' => $quote_id, 'post_status' => 'mdjm-quote-viewed'))) {
         if (MDJM_DEBUG == true) {
             MDJM()->debug->log_it('Quote status updated successfully', false);
         }
         $result = true;
     }
     /* -- Set post meta for read time and update the number of client views -- */
     if ($result == true) {
         if (MDJM_DEBUG == true) {
             MDJM()->debug->log_it('Updating quote view count', false);
         }
         $view_count = get_post_meta($quote_id, '_mdjm_quote_viewed_count', true);
         if (!empty($view_count)) {
             $view_count++;
         } else {
             $view_count = 1;
         }
         update_post_meta($quote_id, '_mdjm_quote_viewed_count', $view_count);
         // Only update the view date if this is the first viewing
         if ($view_count == 1) {
             if (MDJM_DEBUG == true) {
                 MDJM()->debug->log_it('Updating quote viewed time', false);
             }
             update_post_meta($quote_id, '_mdjm_quote_viewed_date', current_time('mysql'));
         }
     }
     return !empty($result) ? true : false;
 }
开发者ID:mdjm,项目名称:mobile-dj-manager,代码行数:40,代码来源:mdjm-onlinequote.php

示例4: wp_publish_post

/**
 * Publish a post by transitioning the post status.
 *
 * @since 2.1.0
 * @uses $wpdb
 * @uses do_action() Calls 'edit_post', 'save_post', and 'wp_insert_post' on post_id and post data.
 *
 * @param int $post_id Post ID.
 * @return null
 */
function wp_publish_post($post_id)
{
    global $wpdb;
    $post = get_post($post_id);
    if (empty($post)) {
        return;
    }
    if ('publish' == $post->post_status) {
        return;
    }
    $wpdb->update($wpdb->posts, array('post_status' => 'publish'), array('ID' => $post_id));
    $old_status = $post->post_status;
    $post->post_status = 'publish';
    wp_transition_post_status('publish', $old_status, $post);
    do_action('edit_post', $post_id, $post);
    do_action('save_post', $post_id, $post);
    do_action('wp_insert_post', $post_id, $post);
}
开发者ID:sontv1003,项目名称:vtcacademy,代码行数:28,代码来源:post.php

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

示例6: bbp_hide_forum

/**
 * Mark the forum as hidden
 *
 * @since bbPress (r2996)
 *
 * @param int $forum_id Optional. Forum id
 * @uses update_post_meta() To update the forum private meta
 * @return bool False on failure, true on success
 */
function bbp_hide_forum($forum_id = 0, $current_visibility = '')
{
    $forum_id = bbp_get_forum_id($forum_id);
    do_action('bbp_hide_forum', $forum_id);
    // Only run queries if visibility is changing
    if (bbp_get_hidden_status_id() !== $current_visibility) {
        // Get private forums
        $private = bbp_get_private_forum_ids();
        // Find this forum in the array
        if (in_array($forum_id, $private)) {
            $offset = array_search($forum_id, $private);
            // Splice around it
            array_splice($private, $offset, 1);
            // Update private forums minus this one
            update_option('_bbp_private_forums', array_unique(array_filter(array_values($private))));
        }
        // Add to '_bbp_hidden_forums' site option
        $hidden = bbp_get_hidden_forum_ids();
        $hidden[] = $forum_id;
        update_option('_bbp_hidden_forums', array_unique(array_filter(array_values($hidden))));
        // Update forums visibility setting
        global $wpdb;
        $wpdb->update($wpdb->posts, array('post_status' => bbp_get_hidden_status_id()), array('ID' => $forum_id));
        wp_transition_post_status(bbp_get_hidden_status_id(), $current_visibility, get_post($forum_id));
        bbp_clean_post_cache($forum_id);
    }
    do_action('bbp_hid_forum', $forum_id);
    return $forum_id;
}
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:38,代码来源:functions.php

示例7: 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;
    }
    // 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');
    }
    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' => $_POST['siteorigin_panels_home_enabled'] == 'true' ? 'publish' : 'draft', 'post_type' => 'page', 'comment_status' => 'closed'));
        update_option('page_on_front', $page_id);
        update_option('siteorigin_panels_home_page_id', $page_id);
    }
    // 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);
    update_post_meta($page_id, '_wp_page_template', siteorigin_panels_setting('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:popshuvitdude,项目名称:orchard,代码行数:52,代码来源:siteorigin-panels.php

示例8: grunion_ajax_spam

function grunion_ajax_spam()
{
    global $wpdb;
    if (empty($_POST['make_it'])) {
        return;
    }
    $post_id = (int) $_POST['post_id'];
    check_ajax_referer('grunion-post-status-' . $post_id);
    if (!current_user_can("edit_page", $post_id)) {
        wp_die(__('You are not allowed to manage this item.', 'jetpack'));
    }
    require_once dirname(__FILE__) . '/grunion-contact-form.php';
    $current_menu = '';
    if (preg_match('|post_type=feedback|', $_POST['sub_menu'])) {
        if (preg_match('|post_status=spam|', $_POST['sub_menu'])) {
            $current_menu = 'spam';
        } else {
            if (preg_match('|post_status=trash|', $_POST['sub_menu'])) {
                $current_menu = 'trash';
            } else {
                $current_menu = 'messages';
            }
        }
    }
    $post = get_post($post_id);
    $post_type_object = get_post_type_object($post->post_type);
    $akismet_values = get_post_meta($post_id, '_feedback_akismet_values', TRUE);
    if ($_POST['make_it'] == 'spam') {
        $post->post_status = 'spam';
        $status = wp_insert_post($post);
        wp_transition_post_status('spam', 'publish', $post);
        do_action('contact_form_akismet', 'spam', $akismet_values);
    } elseif ($_POST['make_it'] == 'ham') {
        $post->post_status = 'publish';
        $status = wp_insert_post($post);
        wp_transition_post_status('publish', 'spam', $post);
        do_action('contact_form_akismet', 'spam', $akismet_values);
        $comment_author_email = $reply_to_addr = $message = $to = $headers = false;
        $blog_url = parse_url(site_url());
        // resend the original email
        $email = get_post_meta($post_id, '_feedback_email', TRUE);
        $content_fields = Grunion_Contact_Form_Plugin::parse_fields_from_content($post_id);
        if (!empty($email) && !empty($content_fields)) {
            if (isset($content_fields['_feedback_author_email'])) {
                $comment_author_email = $content_fields['_feedback_author_email'];
            }
            if (isset($email['to'])) {
                $to = $email['to'];
            }
            if (isset($email['message'])) {
                $message = $email['message'];
            }
            if (isset($email['headers'])) {
                $headers = $email['headers'];
            } else {
                $headers = 'From: "' . $content_fields['_feedback_author'] . '" <wordpress@' . $blog_url['host'] . ">\r\n";
                if (!empty($comment_author_email)) {
                    $reply_to_addr = $comment_author_email;
                } elseif (is_array($to)) {
                    $reply_to_addr = $to[0];
                }
                if ($reply_to_addr) {
                    $headers .= 'Reply-To: "' . $content_fields['_feedback_author'] . '" <' . $reply_to_addr . ">\r\n";
                }
                $headers .= "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"";
            }
            $subject = apply_filters('contact_form_subject', $content_fields['_feedback_subject']);
            wp_mail($to, $subject, $message, $headers);
        }
    } elseif ($_POST['make_it'] == 'publish') {
        if (!current_user_can($post_type_object->cap->delete_post, $post_id)) {
            wp_die(__('You are not allowed to move this item out of the Trash.', 'jetpack'));
        }
        if (!wp_untrash_post($post_id)) {
            wp_die(__('Error in restoring from Trash.', 'jetpack'));
        }
    } elseif ($_POST['make_it'] == 'trash') {
        if (!current_user_can($post_type_object->cap->delete_post, $post_id)) {
            wp_die(__('You are not allowed to move this item to the Trash.', 'jetpack'));
        }
        if (!wp_trash_post($post_id)) {
            wp_die(__('Error in moving to Trash.', 'jetpack'));
        }
    }
    $sql = "\n\t\tSELECT post_status,\n\t\t\tCOUNT( * ) AS post_count\n\t\tFROM `{$wpdb->posts}`\n\t\tWHERE post_type =  'feedback'\n\t\tGROUP BY post_status\n\t";
    $status_count = (array) $wpdb->get_results($sql, ARRAY_A);
    $status = array();
    $status_html = '';
    foreach ($status_count as $i => $row) {
        $status[$row['post_status']] = $row['post_count'];
    }
    if (isset($status['publish'])) {
        $status_html .= '<li><a href="edit.php?post_type=feedback"';
        if ($current_menu == 'messages') {
            $status_html .= ' class="current"';
        }
        $status_html .= '>' . __('Messages', 'jetpack') . ' <span class="count">';
        $status_html .= '(' . number_format($status['publish']) . ')';
        $status_html .= '</span></a> |</li>';
    }
//.........这里部分代码省略.........
开发者ID:denis-chmel,项目名称:wordpress,代码行数:101,代码来源:admin.php

示例9: publishset

 /**
  * Sets the status of a set of products
  *
  * @author Jonathan Davis
  * @since 1.2
  *
  * @param array $ids Set of product IDs to update
  * @param string $status The status to set: publish, draft, trash
  * @return boolean
  **/
 static function publishset(array $ids, $status)
 {
     if (empty($ids) || !is_array($ids)) {
         return false;
     }
     $settings = array('publish', 'draft', 'trash');
     if (!in_array($status, $settings)) {
         return false;
     }
     $table = WPShoppObject::tablename(self::$table);
     $time = current_time('timestamp');
     $post_date_gmt = sDB::mkdatetime($time + get_option('gmt_offset') * 3600);
     $post_date = sDB::mkdatetime($time);
     sDB::query("UPDATE {$table} SET post_status='{$status}', post_date='{$post_date}', post_date_gmt='{$post_date_gmt}', post_modified='{$post_date}', post_modified_gmt='{$post_date_gmt}' WHERE ID in (" . join(',', $ids) . ")");
     foreach ($ids as $id) {
         // Recount taxonomy counts #2968
         $Post = get_post($id);
         switch ($status) {
             case 'trash':
                 do_action('wp_trash_post', $id);
                 break;
             default:
                 do_action('save_post', $id, $Post);
                 break;
         }
         if (function_exists('clean_post_cache')) {
             clean_post_cache($id);
         }
         wp_transition_post_status($status, $Product->status, $Post);
     }
     return true;
 }
开发者ID:jonathandavis,项目名称:shopp,代码行数:42,代码来源:Product.php

示例10: 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 (empty($_POST['panels_js_complete'])) {
        return;
    }
    if (!current_user_can('edit_theme_options')) {
        return;
    }
    // Check that the home page ID is set and the home page exists
    if (!get_option('siteorigin_panels_home_page_id') || !get_post(get_option('siteorigin_panels_home_page_id'))) {
        // Lets create a new page
        $page_id = wp_insert_post(array('post_title' => __('Home', 'siteorigin-panels'), 'post_status' => $_POST['siteorigin_panels_home_enabled'] == 'true' ? 'publish' : 'draft', 'post_type' => 'page', 'comment_status' => 'closed'));
        update_option('siteorigin_panels_home_page_id', $page_id);
    } else {
        $page_id = get_option('siteorigin_panels_home_page_id');
    }
    // Save the updated page data
    $panels_data = siteorigin_panels_get_panels_data_from_post($_POST);
    update_post_meta($page_id, 'panels_data', $panels_data);
    update_post_meta($page_id, '_wp_page_template', siteorigin_panels_setting('home-template'));
    if ($_POST['siteorigin_panels_home_enabled'] == 'true') {
        update_option('show_on_front', 'page');
        update_option('page_on_front', $page_id);
        wp_publish_post($page_id);
    } else {
        // We're disabling this home page
        if (get_option('page_on_front') == $page_id) {
            // Disable the front page display
            update_option('page_on_front', false);
            if (!get_option('page_for_posts')) {
                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:caickandrade,项目名称:brasillab,代码行数:55,代码来源:siteorigin-panels.php

示例11: grunion_ajax_spam

function grunion_ajax_spam()
{
    global $wpdb;
    if (empty($_POST['make_it'])) {
        return;
    }
    $post_id = (int) $_POST['post_id'];
    check_ajax_referer('grunion-post-status-' . $post_id);
    if (!current_user_can("edit_page", $post_id)) {
        wp_die(__('You are not allowed to manage this item.', 'jetpack'));
    }
    require_once dirname(__FILE__) . '/grunion-contact-form.php';
    $current_menu = '';
    if (preg_match('|post_type=feedback|', $_POST['sub_menu'])) {
        if (preg_match('|post_status=spam|', $_POST['sub_menu'])) {
            $current_menu = 'spam';
        } else {
            if (preg_match('|post_status=trash|', $_POST['sub_menu'])) {
                $current_menu = 'trash';
            } else {
                $current_menu = 'messages';
            }
        }
    }
    $post = get_post($post_id);
    $post_type_object = get_post_type_object($post->post_type);
    $akismet_values = get_post_meta($post_id, '_feedback_akismet_values', TRUE);
    if ($_POST['make_it'] == 'spam') {
        $post->post_status = 'spam';
        $status = wp_insert_post($post);
        wp_transition_post_status('spam', 'publish', $post);
        do_action('contact_form_akismet', 'spam', $akismet_values);
    } elseif ($_POST['make_it'] == 'ham') {
        $post->post_status = 'publish';
        $status = wp_insert_post($post);
        wp_transition_post_status('publish', 'spam', $post);
        do_action('contact_form_akismet', 'spam', $akismet_values);
        // resend the original email
        $email = get_post_meta($post_id, '_feedback_email', TRUE);
        wp_mail($email['to'], $email['subject'], $email['message'], $email['headers']);
    } elseif ($_POST['make_it'] == 'publish') {
        if (!current_user_can($post_type_object->cap->delete_post, $post_id)) {
            wp_die(__('You are not allowed to move this item out of the Trash.', 'jetpack'));
        }
        if (!wp_untrash_post($post_id)) {
            wp_die(__('Error in restoring from Trash.', 'jetpack'));
        }
    } elseif ($_POST['make_it'] == 'trash') {
        if (!current_user_can($post_type_object->cap->delete_post, $post_id)) {
            wp_die(__('You are not allowed to move this item to the Trash.', 'jetpack'));
        }
        if (!wp_trash_post($post_id)) {
            wp_die(__('Error in moving to Trash.', 'jetpack'));
        }
    }
    $sql = "\n\t\tSELECT post_status,\n\t\t\tCOUNT( * ) AS post_count\n\t\tFROM `{$wpdb->posts}`\n\t\tWHERE post_type =  'feedback'\n\t\tGROUP BY post_status\n\t";
    $status_count = (array) $wpdb->get_results($sql, ARRAY_A);
    $status = array();
    $status_html = '';
    foreach ($status_count as $i => $row) {
        $status[$row['post_status']] = $row['post_count'];
    }
    if (isset($status['publish'])) {
        $status_html .= '<li><a href="edit.php?post_type=feedback"';
        if ($current_menu == 'messages') {
            $status_html .= ' class="current"';
        }
        $status_html .= '>' . __('Messages', 'jetpack') . ' <span class="count">';
        $status_html .= '(' . number_format($status['publish']) . ')';
        $status_html .= '</span></a> |</li>';
    }
    if (isset($status['trash'])) {
        $status_html .= '<li><a href="edit.php?post_status=trash&amp;post_type=feedback"';
        if ($current_menu == 'trash') {
            $status_html .= ' class="current"';
        }
        $status_html .= '>' . __('Trash', 'jetpack') . ' <span class="count">';
        $status_html .= '(' . number_format($status['trash']) . ')';
        $status_html .= '</span></a>';
        if (isset($status['spam'])) {
            $status_html .= ' |';
        }
        $status_html .= '</li>';
    }
    if (isset($status['spam'])) {
        $status_html .= '<li><a href="edit.php?post_status=spam&amp;post_type=feedback"';
        if ($current_menu == 'spam') {
            $status_html .= ' class="current"';
        }
        $status_html .= '>' . __('Spam', 'jetpack') . ' <span class="count">';
        $status_html .= '(' . number_format($status['spam']) . ')';
        $status_html .= '</span></a></li>';
    }
    echo $status_html;
    exit;
}
开发者ID:alpual,项目名称:Caitlin-Sabo,代码行数:96,代码来源:admin.php

示例12: sign_contract

        public function sign_contract()
        {
            global $mdjm, $my_mdjm, $clientzone, $mdjm_settings;
            /* -- Validate the nonce -- */
            if (!isset($_POST['mdjm_sign_event_contract']) || !wp_verify_nonce($_POST['mdjm_sign_event_contract'], 'sign_event_contract')) {
                echo '<script type="text/javascript">' . "\r\n" . 'alert("WordPress Security Validation failed. Please try again");' . "\r\n" . 'history.back();' . "\r\n" . '</script>' . "\r\n";
            }
            /* -- Check the users password is correct -- */
            $pass_cfm = wp_authenticate($my_mdjm['me']->user_login, $_POST['sign_pass_confirm']);
            /* -- Incorrect Password -- */
            if (is_wp_error($pass_cfm)) {
                echo '<script type="text/javascript">' . "\r\n" . 'alert("ERROR: Your password was not entered correctly. Please try again.");' . "\r\n" . 'history.back();' . "\r\n" . '</script>' . "\r\n";
            } else {
                /* -- Remove the save post hook to avoid loops -- */
                remove_action('save_post_mdjm-event', 'mdjm_save_event_post', 10, 3);
                /* -- Create a new signed contract instance -- */
                $contract_data = array('post_title' => 'Event Contract: ' . MDJM_EVENT_PREFIX . $this->event->ID, 'post_author' => $my_mdjm['me']->ID, 'post_type' => 'mdjm-signed-contract', 'post_status' => 'publish', 'post_parent' => $this->event->ID, 'ping_status' => 'closed', 'comment_status' => 'closed');
                /* -- Prepare the contract content -- */
                $content = $this->event_contract->post_content;
                $content = apply_filters('the_content', $content);
                $content = str_replace(']]>', ']]&gt;', $content);
                /* -- Shortcode replacements -- */
                $contract_data['post_content'] = $mdjm->filter_content($my_mdjm['me']->ID, $this->event->ID, $content);
                /* -- Append Signatory info -- */
                $contract_data['post_content'] .= '<hr>' . "\r\n";
                $contract_data['post_content'] .= '<p style="font-weight: bold">' . __('Signatory') . ': <span style="text-decoration: underline;">' . ucfirst($_POST['sign_first_name']) . ' ' . ucfirst($_POST['sign_last_name']) . '</span></p>' . "\r\n";
                $contract_data['post_content'] .= '<p style="font-weight: bold">' . __('Date of Signature') . ': <span style="text-decoration: underline;">' . date('jS F Y') . '</span></p>' . "\r\n";
                $contract_data['post_content'] .= '<p style="font-weight: bold">' . __('Verification Method') . ': User Password Confirmation</p>' . "\r\n";
                /* -- Create the Signed Contract Post -- */
                $signed_contract = wp_insert_post($contract_data, true);
                // Success
                if (!is_wp_error($signed_contract)) {
                    if (MDJM_DEBUG == true) {
                        MDJM()->debug->log_it('Client event signed contract created (' . $signed_contract . ')', true);
                    }
                    add_post_meta($signed_contract, '_mdjm_contract_signed_name', ucfirst($_POST['sign_first_name']) . ' ' . ucfirst($_POST['sign_last_name']), true);
                    /* -- Update the event -- */
                    $event_meta = array('_mdjm_event_signed_contract' => $signed_contract, '_mdjm_event_contract_approved' => date('Y-m-d H:i:s'), '_mdjm_event_contract_approver' => ucfirst($_POST['sign_first_name']) . ' ' . ucfirst($_POST['sign_last_name']), '_mdjm_event_contract_approver_ip' => $_SERVER['REMOTE_ADDR'], '_mdjm_event_last_updated_by' => $my_mdjm['me']->ID);
                    /* -- Initiate actions for status change -- */
                    wp_transition_post_status('mdjm-approved', $this->event->post_status, $this->event);
                    /* -- Update the post status -- */
                    wp_update_post(array('ID' => $this->event->ID, 'post_status' => 'mdjm-approved'));
                    foreach ($event_meta as $event_meta_key => $event_meta_value) {
                        update_post_meta($this->event->ID, $event_meta_key, $event_meta_value);
                    }
                    /* -- Update Journal with event updates -- */
                    if (MDJM_JOURNAL == true) {
                        if (MDJM_DEBUG == true) {
                            MDJM()->debug->log_it('	-- Adding journal entry');
                        }
                        mdjm_add_journal(array('user_id' => $my_mdjm['me']->ID, 'event_id' => $this->event->ID, 'comment_content' => 'Contract Approval completed by ' . ucfirst($_POST['sign_first_name']) . ' ' . ucfirst($_POST['sign_last_name'] . '<br>')), array('type' => 'update-event', 'visibility' => '2'));
                    } else {
                        if (MDJM_DEBUG == true) {
                            MDJM()->debug->log_it('	-- Journalling is disabled');
                        }
                    }
                    /* -- Email booking confirmations -- */
                    $contact_client = isset($mdjm_settings['templates']['booking_conf_to_client']) ? true : false;
                    $contact_dj = isset($mdjm_settings['templates']['booking_conf_to_dj']) ? true : false;
                    $client_email = isset($mdjm_settings['templates']['booking_conf_client']) ? $mdjm_settings['templates']['booking_conf_client'] : false;
                    $dj_email = isset($mdjm_settings['templates']['email_dj_confirm']) ? $mdjm_settings['templates']['email_dj_confirm'] : false;
                    if (!is_string(get_post_status($client_email))) {
                        if (MDJM_DEBUG == true) {
                            MDJM()->debug->log_it('ERROR: No email template for the contract has been found ' . __FUNCTION__, $stampit = true);
                        }
                        wp_die('ERROR: Either no email template is defined or an error has occured. Check your Settings.');
                    }
                    if ($contact_client == true) {
                        if (MDJM_DEBUG == true) {
                            MDJM()->debug->log_it('Configured to email client with template ID ' . $client_email);
                        }
                        if (MDJM_DEBUG == true) {
                            MDJM()->debug->log_it('Generating email...');
                        }
                        $email_args = array('content' => $client_email, 'to' => get_post_meta($this->event->ID, '_mdjm_event_client', true), 'from' => $mdjm_settings['templates']['booking_conf_from'] == 'dj' ? get_post_meta($this->event->ID, '_mdjm_event_dj', true) : 0, 'journal' => 'email-client', 'event_id' => $this->event->ID, 'html' => true, 'cc_dj' => isset($mdjm_settings['email']['bcc_dj_to_client']) ? true : false, 'cc_admin' => isset($mdjm_settings['email']['bcc_admin_to_client']) ? true : false, 'source' => 'Event Status to Approved');
                        // Filter the email args
                        $email_args = apply_filters('mdjm_booking_conf_email_args', $email_args);
                        // Send the email
                        $approval_email = $mdjm->send_email($email_args);
                        if ($approval_email) {
                            if (MDJM_DEBUG == true) {
                                MDJM()->debug->log_it('	-- Confrmation email sent to client ');
                            }
                        } else {
                            if (MDJM_DEBUG == true) {
                                MDJM()->debug->log_it('	ERROR: Confrmation email was not sent');
                            }
                        }
                    } else {
                        if (MDJM_DEBUG == true) {
                            MDJM()->debug->log_it('Not configured to email client');
                        }
                    }
                    if ($contact_dj == true) {
                        if (MDJM_DEBUG == true) {
                            MDJM()->debug->log_it('Configured to email DJ with template ID ' . $dj_email);
                        }
                        if (MDJM_DEBUG == true) {
                            MDJM()->debug->log_it('Generating email...');
                        }
//.........这里部分代码省略.........
开发者ID:mdjm,项目名称:mobile-dj-manager,代码行数:101,代码来源:mdjm-contract.php

示例13: jr_check_expired_cron

function jr_check_expired_cron()
{
    global $wpdb;
    $action = get_option('jr_expired_action');
    // Get list of expired posts that are published
    $postids = $wpdb->get_col($wpdb->prepare("\n\t\tSELECT      postmeta.post_id\n\t\tFROM        {$wpdb->postmeta} postmeta\n\t\tLEFT JOIN\t{$wpdb->posts} posts ON postmeta.post_id = posts.ID\n\t\tWHERE       postmeta.meta_key = '_expires' \n\t\t            AND postmeta.meta_value < '%s'\n\t\t            AND post_status = 'publish'\n\t\t            AND post_type = 'job_listing'\n\t", strtotime('NOW')));
    if ($action == 'hide') {
        if ($postids) {
            foreach ($postids as $id) {
                // Captains log supplemental, we have detected a job which is out of date
                // Activate Cloak
                $post = get_post($id);
                if (empty($post)) {
                    return;
                }
                if ('private' == $post->post_status) {
                    return;
                }
                $old_status = $post->post_status;
                $job_post = array();
                $job_post['ID'] = $id;
                $job_post['post_status'] = 'private';
                wp_update_post($job_post);
                $post->post_status = 'private';
                wp_transition_post_status('private', $old_status, $post);
                // Update counts for the post's terms.
                foreach ((array) get_object_taxonomies('job_listing') as $taxonomy) {
                    $tt_ids = wp_get_object_terms($id, $taxonomy, array('fields' => 'tt_ids'));
                    wp_update_term_count($tt_ids, $taxonomy);
                }
                do_action('edit_post', $id, $post);
                do_action('save_post', $id, $post);
                do_action('wp_insert_post', $id, $post);
            }
        }
    }
    if (get_option('jr_expired_job_email_owner') == 'yes') {
        $notify_ids = array();
        // Get list of expiring posts that are published
        $postids = $wpdb->get_col($wpdb->prepare("\n\t\t\tSELECT      DISTINCT postmeta.post_id\n\t\t\tFROM        {$wpdb->postmeta} postmeta\n\t\t\tLEFT JOIN\t{$wpdb->posts} posts ON postmeta.post_id = posts.ID\n\t\t\tWHERE       postmeta.meta_key = '_expires' \n\t\t\t            AND postmeta.meta_value > '%s'\n\t\t\t            AND postmeta.meta_value < '%s'\n\t\t\t            AND post_status = 'publish'\n\t\t\t            AND post_type = 'job_listing'\n\t\t", strtotime('NOW'), strtotime('+5 day')));
        if (sizeof($postids) > 0) {
            // of those, get ids of posts that have already been notified
            $jobs_notified = $wpdb->get_col($wpdb->prepare("\n\t\t\t\tSELECT      postmeta.post_id\n\t\t\t\tFROM        {$wpdb->postmeta} postmeta\n\t\t\t\tWHERE       postmeta.meta_key = 'reminder_email_sent' \n\t\t\t\t            AND postmeta.meta_value IN ('5','1')\n\t\t\t"));
            // Now only send to those who need sending to
            $notify_ids = array_diff($postids, $jobs_notified);
            if ($notify_ids && sizeof($notify_ids) > 0) {
                foreach ($notify_ids as $id) {
                    update_post_meta($id, 'reminder_email_sent', '5');
                    jr_owner_job_expiring_soon($id, 5);
                }
            }
        }
        // Get list of expiring posts (1 day left) that are published
        $postids = $wpdb->get_col($wpdb->prepare("\n\t\t\tSELECT      postmeta.post_id\n\t\t\tFROM        {$wpdb->postmeta} postmeta\n\t\t\tLEFT JOIN\t{$wpdb->posts} posts ON postmeta.post_id = posts.ID\n\t\t\tWHERE       postmeta.meta_key = '_expires' \n\t\t\t            AND postmeta.meta_value > '%s'\n\t\t\t            AND postmeta.meta_value < '%s'\n\t\t\t            AND post_status = 'publish'\n\t\t\t            AND post_type = 'job_listing'\n\t\t", strtotime('NOW'), strtotime('+1 day')));
        if (sizeof($postids) > 0) {
            // of those, get ids of posts that have already been notified
            $jobs_notified = $wpdb->get_col($wpdb->prepare("\n\t\t\t\tSELECT      postmeta.post_id\n\t\t\t\tFROM        {$wpdb->postmeta} postmeta\n\t\t\t\tWHERE       postmeta.meta_key = 'reminder_email_sent' \n\t\t\t\t            AND postmeta.meta_value IN ('1')\n\t\t\t", implode(',', $postids)));
            // Now only send to those who need sending to
            $notify_ids_2 = array_diff($postids, $jobs_notified, $notify_ids);
            if ($notify_ids_2 && sizeof($notify_ids_2) > 0) {
                foreach ($notify_ids_2 as $id) {
                    update_post_meta($id, 'reminder_email_sent', '1');
                    jr_owner_job_expiring_soon($id, 1);
                }
            }
        }
    }
}
开发者ID:besimhu,项目名称:legacy,代码行数:68,代码来源:theme-cron.php

示例14: admin_init

 static function admin_init()
 {
     // WordPress 3.5+ compat: the WP devs are in the midst of removing Links from the WordPress core. Eventually we'll have to deal
     // with the possible disappearance of the wp_links table as a whole; but in the meantime, we just need to turn on the interface
     // element to avoid problems with user capabilities that presume the presence of the Links Manager in the admin UI.
     if (!intval(get_option('link_manager_enabled', false))) {
         update_option('link_manager_enabled', true);
     }
     if (defined('FEEDWORDPRESS_PREPARE_TO_ZAP') and FEEDWORDPRESS_PREPARE_TO_ZAP) {
         $post_id = FEEDWORDPRESS_PREPARE_TO_ZAP;
         $sendback = wp_get_referer();
         if (!$sendback or strpos($sendback, 'post.php') !== false or strpos($sendback, 'post-new.php') !== false) {
             if ('attachment' == $post_type) {
                 $sendback = admin_url('upload.php');
             } else {
                 $sendback = admin_url('edit.php');
                 $sendback .= !empty($post_type) ? '?post_type=' . $post_type : '';
             }
         } else {
             $sendback = esc_url(remove_query_arg(array('trashed', 'untrashed', 'deleted', 'zapped', 'unzapped', 'ids'), $sendback));
         }
         // Make sure we have a post corresponding to this ID.
         $post = $post_type = $post_type_object = null;
         if ($post_id) {
             $post = get_post($post_id);
         }
         if ($post) {
             $post_type = $post->post_type;
         }
         $p = get_post($post_id);
         if (!$post) {
             wp_die(__('The item you are trying to zap no longer exists.'));
         }
         if (!current_user_can('delete_post', $post_id)) {
             wp_die(__('You are not allowed to zap this item.'));
         }
         if ($user_id = wp_check_post_lock($post_id)) {
             $user = get_userdata($user_id);
             wp_die(sprintf(__('You cannot retire this item. %s is currently editing.'), $user->display_name));
         }
         if (MyPHP::request('fwp_post_delete') == 'zap') {
             FeedWordPress::diagnostic('syndicated_posts', 'Zapping existing post # ' . $p->ID . ' "' . $p->post_title . '" due to user request.');
             $old_status = $post->post_status;
             set_post_field('post_status', 'fwpzapped', $post_id);
             wp_transition_post_status('fwpzapped', $old_status, $post);
             # Set up the post to have its content blanked on
             # next update if you do not undo the zapping.
             add_post_meta($post_id, '_feedwordpress_zapped_blank_me', 1, true);
             add_post_meta($post_id, '_feedwordpress_zapped_blank_old_status', $old_status, true);
             wp_redirect(esc_url_raw(add_query_arg(array('zapped' => 1, 'ids' => $post_id), $sendback)));
         } else {
             $old_status = get_post_meta($post_id, '_feedwordpress_zapped_blank_old_status', true);
             set_post_field('post_status', $old_status, $post_id);
             wp_transition_post_status($old_status, 'fwpzapped', $post);
             # O.K., make sure this post does not get blanked
             delete_post_meta($post_id, '_feedwordpress_zapped_blank_me');
             delete_post_meta($post_id, '_feedwordpress_zapped_blank_old_status');
             wp_redirect(esc_url_raw(add_query_arg(array('unzapped' => 1, 'ids' => $post_id), $sendback)));
         }
         // Intercept, don't pass on.
         exit;
     }
 }
开发者ID:runderwo,项目名称:feedwordpress,代码行数:63,代码来源:feedwordpress.php

示例15: wl_update_post_status

/**
 * Update the status of a post.
 *
 * @param int $post_id The post ID
 * @param string $status The new status
 */
function wl_update_post_status($post_id, $status)
{
    wl_write_log("wl_update_post_status [ post ID :: {$post_id} ][ status :: {$status} ]");
    global $wpdb;
    if (!($post = get_post($post_id))) {
        return;
    }
    if ($status === $post->post_status) {
        return;
    }
    $wpdb->update($wpdb->posts, array('post_status' => $status), array('ID' => $post->ID));
    clean_post_cache($post->ID);
    $old_status = $post->post_status;
    $post->post_status = $status;
    wp_transition_post_status($status, $old_status, $post);
    /** This action is documented in wp-includes/post.php */
    do_action('edit_post', $post->ID, $post);
    /** This action is documented in wp-includes/post.php */
    do_action("save_post_{$post->post_type}", $post->ID, $post, true);
    /** This action is documented in wp-includes/post.php */
    do_action('wl_linked_data_save_post', $post->ID);
    /** This action is documented in wp-includes/post.php */
    do_action('wp_insert_post', $post->ID, $post, true);
}
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:30,代码来源:wordlift_admin_save_post.php


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