This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
region_halland_acf_page_additions.php
188 lines (173 loc) · 5.82 KB
/
region_halland_acf_page_additions.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
/**
* @package Region Halland ACF Page Additions
*/
/*
Plugin Name: Region Halland ACF Page Additions
Description: ACF-fält för tillägg till en sida
Version: 1.2.0
Author: Roland Hydén
License: MIT
Text Domain: regionhalland
*/
// Anropa function om ACF är installerad
add_action('acf/init', 'my_acf_add_page_ingress_field_groups');
// Function för att lägga till "field groups"
function my_acf_add_page_ingress_field_groups() {
if (function_exists('acf_add_local_field_group')):
acf_add_local_field_group(array(
'key' => 'group_1000239',
'title' => ' ',
'fields' => array(
0 => array(
'key' => 'field_3000001',
'label' => 'Granskare av dokumentet',
'name' => 'name_3000002',
'type' => 'textarea',
'instructions' => __('Granskare'),
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => __('', 'regionhalland'),
'maxlength' => '',
'rows' => 6,
'new_lines' => '',
),
1 => array(
'key' => 'field_3000003',
'label' => 'Fastställare av dokumentet',
'name' => 'name_3000004',
'type' => 'textarea',
'instructions' => __('Fastställare'),
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => __('', 'regionhalland'),
'maxlength' => '',
'rows' => 6,
'new_lines' => '',
),
2 => array(
'key' => 'field_3000005',
'label' => 'Delblock 1',
'name' => 'name_3000006',
'type' => 'textarea',
'instructions' => __('Extra information'),
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => __('', 'regionhalland'),
'maxlength' => '',
'rows' => 4,
'new_lines' => '',
),
3 => array(
'key' => 'field_3000007',
'label' => 'Delblock 2',
'name' => 'name_3000008',
'type' => 'textarea',
'instructions' => __('Extra information'),
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => __('', 'regionhalland'),
'maxlength' => '',
'rows' => 4,
'new_lines' => '',
),
4 => array(
'key' => 'field_3000009',
'label' => 'Delblock 3',
'name' => 'name_3000010',
'type' => 'textarea',
'instructions' => __('Extra information'),
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => __('', 'regionhalland'),
'maxlength' => '',
'rows' => 4,
'new_lines' => '',
),
),
'location' => array(
0 => array(
0 => array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
)
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => 1,
'description' => '',
));
endif;
}
// Lägg till kolumner som ska hämtas ut
function add_region_halland_acf_page_additions_pages_columns($columns) {
return array_merge ($columns, array (
'name_3000002' => __ ( 'Granskare' ),
'name_3000004' => __ ( 'Fastställare' )
)
);
}
add_filter ('manage_pages_columns', 'add_region_halland_acf_page_additions_pages_columns' );
// Lägg till kolumner som ska hämtas ut
function region_halland_acf_oage_additions_pages_custom_column($column, $post_id) {
switch ($column) {
case 'name_3000002':
$myGranskare = get_field('name_3000002', $post_id);
echo $myGranskare;
break;
case 'name_3000004':
$myFaststallare = get_field('name_3000004', $post_id);
echo $myFaststallare;
break;
}
}
add_action ('manage_pages_custom_column', 'region_halland_acf_oage_additions_pages_custom_column', 10, 2 );
// Metod som anropas när pluginen aktiveras
function region_halland_acf_page_additions_activate() {
// Ingenting just nu...
}
// Metod som anropas när pluginen avaktiveras
function region_halland_acf_page_additions_deactivate() {
// Ingenting just nu...
}
// Vilken metod som ska anropas när pluginen aktiveras
register_activation_hook( __FILE__, 'region_halland_acf_page_additions_activate');
// Vilken metod som ska anropas när pluginen avaktiveras
register_deactivation_hook( __FILE__, 'region_halland_acf_page_additions_deactivate');
?>