Example #1
0
/**
 * Returns TRUE, if the post has any media assigned to it.
 * (eg. has a thumbnail, a video, quote...)
 *
 * @since gp 1.0
 */
function gp_post_has_media($post_id = false)
{
    $post_id = is_numeric($post_id) ? $post_id : get_the_ID();
    if (!$post_id) {
        return false;
    }
    if (has_post_thumbnail($post_id)) {
        return true;
    }
    $post_format = get_post_format($post_id);
    if ($post_format == 'quote') {
        $data = gp_quote_get_data($post_id);
        return isset($data['quote']) && !empty($data['quote']);
    }
    if ($post_format == 'link') {
        $data = gp_link_get_data($post_id);
        return isset($data['link']) && !empty($data['link']);
    }
    if ($post_format == 'video') {
        $data = gp_video_get_data($post_id);
        return isset($data['embed']) && !empty($data['embed']);
    }
    return false;
}
Example #2
0
/**
 * Save meta box.
 */
function gp_link_meta_box_save($post_id)
{
    if (!it_check_save_action($post_id)) {
        return $post_id;
    }
    $data = gp_link_get_data($post_id);
    foreach (array_keys($data) as $key) {
        $value = isset($_POST['gp_' . $key]) ? $_POST['gp_' . $key] : '';
        update_post_meta($post_id, 'gp_' . $key, $value);
    }
}