-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew-request-page.php
57 lines (48 loc) · 1.42 KB
/
new-request-page.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Template Name: New request page
*/
$context = Timber::get_context();
$post = new TimberPost();
$context['post'] = $post;
$template = 'new-request-page.twig';
$context['breadcrumbs'] = [];
$context['breadcrumbs'][ __( 'Poptávky', 'shp-partneri' ) ] = get_post_type_archive_link( 'request' );
$context['breadcrumbs'][ $post->title ] = $post->link;
$acf_form_args_base = [
'id' => 'acf-form',
'post_id' => 'new_post',
'label_placement' => 'left',
'instruction_placement' => 'field',
'new_post' => [
'post_type' => 'request',
'post_status' => 'pending',
],
'form' => false,
'updated_message' => false,
];
$acf_form_args = [
'top' => [
'fields' => [
'field_5d9f2ebf8e646', // name
'field_5da06f824e26a', // email
'field_5d9f2efc8e647', // url
'field_5d9f2f4a8e648', // category
'_post_title',
'_post_content',
'field_5d9f2fbd8e64a', // is_shoptet
],
],
];
if (in_array(get_locale(), ['cs_CZ', 'sk_SK'])) {
$acf_form_args['top']['fields'][] = 'field_64147ee851759'; // shoptet_id
}
array_walk( $acf_form_args, function ( &$value ) use( &$acf_form_args_base ) {
$value = array_merge( $acf_form_args_base, $value );
} );
$context['acf_form_args'] = $acf_form_args;
// Pass ACF updated query to context
if ( isset( $_GET[ 'updated' ] ) && $_GET[ 'updated' ] == 'true' ) {
$context['submited'] = $acf_form_args;
}
Timber::render( $template, $context );