Exemplo n.º 1
0
function tb_get_archive_post_id() {
	$tb_o = get_option('tweet-blender');
	// if archive is disabled return null
	if (isset($tb_o['archive_is_disabled']) && $tb_o['archive_is_disabled']) {
		return null;
	}

	// if we already have page id saved as option, return it
	if ($tb_o && array_key_exists('archive_page_id',$tb_o) && $tb_o['archive_page_id'] > 0 && tb_page_exists($tb_o['archive_page_id'])) {
		return $tb_o['archive_page_id'];
	}
	// else if we have such a page already, get its id and store as option
	else if ($post = get_page_by_path('tweets-archive')) {
		$tb_o['archive_page_id'] = $post->ID;
		update_option('tweet-blender',$tb_o);
		return $tb_o['archive_page_id'];
	}
	// else create such a page (unless an over-ride by user is provided)
	else if (isset($tb_o['archive_auto_page']) && $tb_o['archive_auto_page']) {
		if ($post_id = wp_insert_post(array(
			  'post_status' => 'publish',
			  'post_type' => 'page',
			  'post_author' => 1,
			  'post_title' => __('Twitter Feed' , 'tweetblender'),
			  'post_content' => __('Our twitter feed', 'tweetblender'),
			  'post_name' => 'tweets-archive'
		))) {
			$tb_o['archive_page_id'] = $post_id;
			update_option('tweet-blender',$tb_o);
			return $tb_o['archive_page_id'];
		}
		else {
			return null;
		}
	}
	else {
		return null;
	}
}
Exemplo n.º 2
0
function tb_get_archive_post_id()
{
    $tb_o = get_option('tweet-blender');
    // if archive is disabled return null
    if ($tb_o['archive_is_disabled']) {
        return null;
    }
    // if we already have page id saved as option, return it
    if ($tb_o && array_key_exists('archive_page_id', $tb_o) && $tb_o['archive_page_id'] > 0 && tb_page_exists($tb_o['archive_page_id'])) {
        return $tb_o['archive_page_id'];
    } else {
        if ($post = get_page_by_path('tweets-archive')) {
            $tb_o['archive_page_id'] = $post->ID;
            update_option('tweet-blender', $tb_o);
            return $tb_o['archive_page_id'];
        } else {
            if ($tb_o['archive_auto_page']) {
                if ($post_id = wp_insert_post(array('post_status' => 'publish', 'post_type' => 'page', 'post_author' => 1, 'post_title' => 'Twitter Feed', 'post_content' => 'Our twitter feed.', 'post_name' => 'tweets-archive'))) {
                    $tb_o['archive_page_id'] = $post_id;
                    update_option('tweet-blender', $tb_o);
                    return $tb_o['archive_page_id'];
                } else {
                    return null;
                }
            } else {
                return null;
            }
        }
    }
}