// Let's create a post!
$endpoint = $baseDomain . $baseAPI . 'posts/';
$mediaEndpoint = $baseDomain . $baseAPI . 'media/';
$submissionPost = array('title' => '#' . $submittedMeta['episodeNumber'] . ': ' . $submittedMeta['episodeName'], 'status' => 'pending', 'type' => 'post', 'slug' => $submittedMeta['catSlug'] . $submittedMeta['episodeNumber'], 'content' => $submittedMeta['fullText'], 'categories' => array($submittedMeta['showID']));
echo '<p>Okay! Let\'s push the post into Wordpress!</p>';
$postData = pushIntoWP($endpoint, $submissionPost);
$postEndpoint = $endpoint . $postData->id;
echo '<p>OK, we now have a post with ID: ' . $postData->id . '. Now to start updating the post metadata!</p> <ul>';
$_SESSION['editLink'] = 'http://csicon.fm/wp-admin/post.php?post=' . $postData->id . '&action=edit';
// Let's add the enclosure to the post!
echo '<li> Adding the enclosure tag: ';
$enclosureToPush = array('key' => 'enclosure', 'value' => $submittedMeta['enclosure']['enclosureURL'] . PHP_EOL . $submittedMeta['enclosure']['length'] . PHP_EOL . $submittedMeta['enclosure']['type']);
pushIntoWP($postEndpoint . '/meta/', $enclosureToPush);
echo 'done!</li>';
// Let's add the featured image if we have one!
if (isset($submittedMeta['featuredFilename'])) {
    echo '<li> Uploading the featured image: ';
    $uploadedImage = addImage($mediaEndpoint, $baseDirectory . '/PublicationTool/uploads/' . $submittedMeta['featuredFilename']);
    echo ' done!</li>';
    echo '<li> Setting the featured image details: ';
    $imageDetails = array('slug' => 'img_' . $submittedMeta['catSlug'] . $submittedMeta['episodeNumber'], 'title' => $submittedMeta['catSlug'] . $submittedMeta['episodeNumber'], 'description' => 'Featured image for ' . $submittedMeta['catSlug'] . $submittedMeta['episodeNumber']);
    pushIntoWP($mediaEndpoint . $uploadedImage->id, $imageDetails);
    echo ' done!</li>';
    echo '<li> Adding the featured image to the post: ';
    addFeature($postEndpoint, $uploadedImage->id);
    echo ' done!</li>';
}
echo '</ul></p>';
echo '<div class="container">';
echo '<h1>And you are done!</h1>';
echo '<p>In case you need to edit it, you can click <a href="' . $_SESSION['editLink'] . '">here</a>.</p>';
} elseif (isset($_POST['advantageID'])) {
    $id = $_POST['advantageID'];
    $adv = $_POST['updAdvantage'];
    updateAdvantage($adv, $id);
} elseif (isset($_POST['addNewShift'])) {
    $shift = $_POST['addNewShift'];
    $time = $_POST['addNewTime'];
    addSchedule($shift, $time);
    $id = getScheduleID($shift, $time);
    echo $id;
} elseif (isset($_POST['scheduleID'])) {
    $id = $_POST['scheduleID'];
    deleteSchedule($id);
} elseif (isset($_POST['addNewFeature'])) {
    $desc = $_POST['addNewFeature'];
    addFeature($desc);
    $id = getFeatureID($desc);
    echo $id;
} elseif (isset($_POST['featureID'])) {
    $id = $_POST['featureID'];
    deleteFeature($id);
} elseif (isset($_POST['addNewAdvantage'])) {
    $advantage = $_POST['addNewAdvantage'];
    addAdvantages($advantage);
    $resp['advKey'] = getAdvantageID($advantage);
    echo json_encode($resp);
} elseif (isset($_POST['advID'])) {
    $Aid = $_POST['advID'];
    deleteAdvantage($Aid);
} elseif (isset($_POST['updService'])) {
    $service = $_POST['updService'];