-1))->data(); foreach ($locatieData as $l) { $choices[] = array( 'value' => $l->id, 'text' => $l->titel, 'isSelected' => false ); } foreach ($form['fields'] as &$field) { if ($field['label']=='Locatie' && $field['type']=='select') { $field['choices'] = array_merge($field['choices'], $choices); } } return $form; } function gform_activiteit_toevoegen_prerender($form) { $form = gform_init_googlemaps_en_locaties($form); // Categorieen toevoegen /* $choices = array(); $cats = get_taxonomies();//'activiteit_categorie'); $terms = get_terms('activiteit_categorie', array('hide_empty' => false)); foreach ($terms as $term) { $choices[] = array( 'value' => $term->term_id, 'text' => $term->name, 'isSelected' => false ); } foreach ($form['fields'] as &$field) { if ($field['label']=='Categorie' && $field['type']=='select') { $field['choices'] = array_merge($field['choices'], $choices); } } */ // Be done with it return $form; } function gform_verhaal_toevoegen_prerender($form) { $form = gform_init_googlemaps_en_locaties($form); // Categorieen toevoegen /* $choices = array(); $cats = get_taxonomies();//'activiteit_categorie'); $terms = get_terms('verhaal_categorie', array('hide_empty' => false)); foreach ($terms as $term) { $choices[] = array( 'value' => $term->term_id, 'text' => $term->name, 'isSelected' => false ); } foreach ($form['fields'] as &$field) { if ($field['label']=='Categorie' && $field['type']=='select') { $field['choices'] = array_merge($field['choices'], $choices); } } */ // Be done with it return $form; } function gform_verhaal_opslaan($entry, $form) { $pod = pods('park_verhalen'); // Array met ingevoerde content samenstellen $values = array(); foreach ($form['fields'] as $field) { // if (isset($entry[$field['id']])) { if (isset($_POST['input_' . $field['id']])) { // $label = !empty($field['adminLabel']) ? $field['adminLabel']:$field['label']; $label = $field['label']; // $values[$label . '---'] = $entry[$field['id']]; $values[$label] = $_POST['input_' . $field['id']]; } } // Array maken voor opslag $data = array( 'titel' => $values['Titel'], 'datum' => $values['Datum'], //'verhaal_categorie' => $values['Categorie'], 'tekst' => nl2br(htmlentities($values['Tekst'])), 'goedgekeurd' => is_user_logged_in() ? 1:0, ); if (isset($values['Locatie']) && !empty($values['Locatie'])) { $data['locatie'] = $values['Locatie']; } if (isset($values['latlng']) && !empty($values['latlng'])) { $data['latlng'] = $values['latlng']; } // Foto's opslaan $fotos = array(); // Hier attachment-id's in opslaan $uploaded_fotos = json_decode(stripslashes($_POST['gform_uploaded_files'])); $upload_path = GFFormsModel::get_upload_path( $form_id ); if (is_array($uploaded_fotos->input_8)) { foreach ($uploaded_fotos->input_8 as $foto) { $upload_path = GFFormsModel::get_file_upload_path($form["id"], 'bogus'); $fotoFile = str_replace('bogus','',$upload_path['path']) . $foto->uploaded_filename; $wp_filetype = wp_check_filetype(basename($fotoFile), null); $wp_upload_dir = wp_upload_dir(); $attachment = array( 'guid' => $wp_upload_dir['url'] . '/' . basename( $fotoFile ), 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $fotoFile ) ), 'post_content' => '', 'post_status' => 'inherit' ); $fotos[] = wp_insert_attachment($attachment, $fotoFile); } } if (sizeof($fotos) > 0) { $data['fotos'] = $fotos; } // Opslaan in pods $verhaal_id = $pod->add($data); // E-mail sturen wanneer niet ingelogd if (!is_user_logged_in()) { $headers = array('Content-type: text/html'); $to = get_option('admin_email'); $subject = 'Nieuw verhaal toegevoegd: ' . strip_tags($data['titel']); $message = '

Er is een nieuw verhaal toegevoegd

'. '

Klik hier om deze te beoordelen

'; ; wp_mail($to,$subject,$message,$headers); } } function gform_activiteit_opslaan($entry, $form) { $pod = pods('park_activiteiten'); // Array met ingevoerde content samenstellen $values = array(); foreach ($form['fields'] as $field) { if (isset($entry[$field['id']])) { $label = !empty($field['adminLabel']) ? $field['adminLabel']:$field['label']; // $values[$label] = $entry[$field['id']]; $values[$label] = $_POST['input_' . $field['id']]; } } // Array maken voor opslag $data = array( 'titel' => $values['Titel'], 'datum' => $values['Datum'], 'einddatum' => $values['Einddatum'], 'tijd' => $values['Tijd'], //'activiteit_categorie' => $values['Categorie'], 'tekst' => nl2br(htmlentities($values['Tekst'])), 'goedgekeurd' => is_user_logged_in() ? 1:0, ); if (isset($values['Locatie']) && !empty($values['Locatie'])) { $data['locatie'] = $values['Locatie']; } if (isset($values['latlng']) && !empty($values['latlng'])) { $data['latlng'] = $values['latlng']; } // Foto's opslaan $fotos = array(); // Hier attachment-id's in opslaan $uploaded_fotos = json_decode(stripslashes($_POST['gform_uploaded_files'])); $upload_path = GFFormsModel::get_upload_path( $form_id ); if (is_array($uploaded_fotos->input_8)) { foreach ($uploaded_fotos->input_8 as $foto) { $upload_path = GFFormsModel::get_file_upload_path($form["id"], 'bogus'); $fotoFile = str_replace('bogus','',$upload_path['path']) . $foto->uploaded_filename; $wp_filetype = wp_check_filetype(basename($fotoFile), null); $wp_upload_dir = wp_upload_dir(); $attachment = array( 'guid' => $wp_upload_dir['url'] . '/' . basename( $fotoFile ), 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $fotoFile ) ), 'post_content' => '', 'post_status' => 'inherit' ); $fotos[] = wp_insert_attachment($attachment, $fotoFile); } } if (sizeof($fotos) > 0) { $data['fotos'] = $fotos; } // Opslaan in pods $activiteit_id = $pod->add($data); // E-mail sturen wanneer niet ingelogd // if (!is_user_logged_in()) { $headers = array('Content-type: text/html'); $to = get_option('admin_email'); $subject = 'Nieuw activiteit toegevoegd: ' . strip_tags($data['titel']); $message = '

Er is een nieuwe activiteit toegevoegd

'. '

Klik hier om deze te beoordelen

'; ; wp_mail($to,$subject,$message,$headers); // } }