get_row("
SELECT ID
FROM wp_posts
WHERE post_title = '" . $data->title . "' && post_status = 'publish' && post_type = 'astro' ",
'ARRAY_N'
);
if ( empty($return) ) {
$title = $data->title;
$content = $data->explanation;
$hd_image = $data->hdurl;
$small_image = $data->url;
$copyright = $data->copyright;
if (!empty($copyright)) $copyright = 'Copyright: ' . $copyright;
else $copyright = ' ';
$img = '
';
$apod_post = array(
'post_title' => $title,
'post_content' => $img . $copyright . '
' . $content,
'post_type' => 'astro',
'post_status' => 'publish',
'post_author' => 1
);
$apod_id = wp_insert_post( $apod_post );
$apod_featured_url = media_sideload_image( $hd_image, $apod_id, $title, 'src' );
$apod_featured_id = astro_get_attachment_id_from_src($apod_featured_url);
set_post_thumbnail($apod_id, $apod_featured_id);
}
}
/* deactivation */
function astro_deactivation(){
flush_rewrite_rules();
}
register_deactivation_hook( __FILE__, 'astro_deactivation' );