/**
 * Return the status. If $get_as_key is set to true, the status will be returned as key. Otherwise the status' value is
 * returned.
 *
 * @param bool $get_as_key (optional, defaults to false)
 *
 * @return null|string $status
 */
function orbis_deal_get_the_status($get_as_key = false)
{
    global $post;
    $status = get_post_meta($post->ID, '_orbis_deal_status', true);
    if (!$get_as_key) {
        $status = orbis_deal_get_status_label($status);
    }
    return $status;
}
示例#2
0
/**
 * Deal status update
 * 
 * @param int $post_id
 */
function orbis_deal_status_update($post_id, $status_old, $status_new)
{
    $user = wp_get_current_user();
    $comment_type = 'orbis_comment';
    switch ($status_new) {
        case 'won':
            $comment_type = 'orbis_deal_won';
            break;
        case 'lost':
            $comment_type = 'orbis_deal_lost';
            break;
    }
    $comment_content = sprintf(__("The deal '%s' was marked '%s' by %s.", 'orbis_deals'), get_the_title($post_id), orbis_deal_get_status_label($status_new), $user->display_name);
    $data = array('comment_post_ID' => $post_id, 'comment_content' => $comment_content, 'comment_author' => 'Orbis', 'comment_type' => $comment_type);
    $comment_id = wp_insert_comment($data);
}