function soundmap_save_public_upload()
{
    $info = $_REQUEST['info'];
    $uploader = $_REQUEST['uploader'];
    $content = _soundmap_mountPostContent($info);
    $title = _soundmap_mountPostTitle($info);
    $soundmark_lat = $info['posLat'];
    $soundmark_lng = $info['posLong'];
    $soundmark_author = $info['author'];
    $soundmark_date = $info['date'];
    $soundmark_mail = $uploader['email'];
    if ($title == "" && $soundmark_author != "") {
        $title = $soundmark_author;
    } elseif ($title == "" && $soundmark_author == "") {
        $title = $info['fileName'];
    }
    if (!is_array($info['categoria'])) {
        $val = $info['categoria'];
        $info['categoria'] = array($val);
    }
    $post_d = array('post_category' => $info['categoria'], 'post_content' => $content, 'post_status' => 'publish', 'post_title' => $title, 'post_type' => 'marker', 'comment_status' => 'closed');
    $post_id = wp_insert_post($post_d);
    update_post_meta($post_id, 'soundmap_marker_lat', $soundmark_lat);
    update_post_meta($post_id, 'soundmap_marker_lng', $soundmark_lng);
    update_post_meta($post_id, 'soundmap_marker_author', $soundmark_author);
    update_post_meta($post_id, 'soundmap_marker_date', $soundmark_date);
    update_post_meta($post_id, 'EMAIL', $soundmark_mail);
    $files = $info['attachID'];
    delete_post_meta($post_id, 'soundmap_attachments_id');
    update_post_meta($post_id, 'soundmap_attachments_id', $files);
    soundmap_attach_file($files, $post_id);
    echo "ok";
    die;
}
예제 #2
0
function soundmap_save_post($post_id)
{
    // verify if this is an auto save routine.
    // If it is our form has not been submitted, so we dont want to do anything
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    // verify this came from the our screen and with proper authorization,
    // because save_post can be triggered at other times
    if (isset($_POST['soundmap_map_noncename'])) {
        if (!wp_verify_nonce($_POST['soundmap_map_noncename'], plugin_basename(__FILE__))) {
            return;
        }
    } else {
        return;
    }
    // Check permissions
    if ('marker' == $_POST['post_type']) {
        if (!current_user_can('edit_post', $post_id)) {
            return;
        }
    }
    $soundmark_lat = $_POST['soundmap_marker_lat'];
    $soundmark_lng = $_POST['soundmap_marker_lng'];
    $soundmark_author = $_POST['soundmap_marker_author'];
    $soundmark_date = $_POST['soundmap_marker_date'];
    update_post_meta($post_id, 'soundmap_marker_lat', $soundmark_lat);
    update_post_meta($post_id, 'soundmap_marker_lng', $soundmark_lng);
    update_post_meta($post_id, 'soundmap_marker_author', $soundmark_author);
    update_post_meta($post_id, 'soundmap_marker_date', $soundmark_date);
    //before searching on all the $_POST array, let's take a look if there is any upload first!
    if (isset($_POST['soundmap_attachments_id'])) {
        $files = $_POST['soundmap_attachments_id'];
        delete_post_meta($post_id, 'soundmap_attachments_id');
        foreach ($files as $key => $value) {
            add_post_meta($post_id, 'soundmap_attachments_id', $value);
            soundmap_attach_file($value, $post_id);
        }
    }
}