acf-taxonomy-functions.php
6.3 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<?php
/**
* Functions for ACF taxonomy objects.
*
* @package ACF
*/
/**
* Get an ACF taxonomy as an array
*
* @param integer|string $id The post ID being queried.
* @return array|false The taxonomy object.
*/
function acf_get_taxonomy( $id ) {
return acf_get_internal_post_type( $id, 'acf-taxonomy' );
}
/**
* Retrieves a raw ACF taxonomy.
*
* @since 6.1
*
* @param integer|string $id The post ID.
* @return array|false The taxonomy array.
*/
function acf_get_raw_taxonomy( $id ) {
return acf_get_raw_internal_post_type( $id, 'acf-taxonomy' );
}
/**
* Gets a post object for an ACF taxonomy.
*
* @since 6.1
*
* @param integer|string $id The post ID, key, or name.
* @return object|boolean The post object, or false on failure.
*/
function acf_get_taxonomy_post( $id ) {
return acf_get_internal_post_type_post( $id, 'acf-taxonomy' );
}
/**
* Returns true if the given identifier is an ACF taxonomy key.
*
* @since 6.1
*
* @param string $id The identifier.
* @return boolean
*/
function acf_is_taxonomy_key( $id ) {
return acf_is_internal_post_type_key( $id, 'acf-taxonomy' );
}
/**
* Validates an ACF taxonomy.
*
* @since 6.1
*
* @param array $taxonomy The ACF taxonomy array.
* @return array|boolean
*/
function acf_validate_taxonomy( array $taxonomy = array() ) {
return acf_validate_internal_post_type( $taxonomy, 'acf-taxonomy' );
}
/**
* Translates the settings for an ACF taxonomy.
*
* @since 6.1
*
* @param array $taxonomy The ACF taxonomy array.
* @return array
*/
function acf_translate_taxonomy( array $taxonomy ) {
return acf_translate_internal_post_type( $taxonomy, 'acf-taxonomy' );
}
/**
* Returns an array of ACF taxonomies for the given $filter.
*
* @since 6.1
*
* @param array $filter An array of args to filter results by.
* @return array
*/
function acf_get_acf_taxonomies( array $filter = array() ) {
return acf_get_internal_post_type_posts( 'acf-taxonomy', $filter );
}
/**
* Returns an array of raw ACF taxonomies.
*
* @since 6.1
*
* @return array
*/
function acf_get_raw_taxonomies() {
return acf_get_raw_internal_post_type_posts( 'acf-taxonomy' );
}
/**
* Returns a filtered array of ACF taxonomies based on the given $args.
*
* @since 6.1
*
* @param array $taxonomies An array of ACF taxonomies.
* @param array $args An array of args to filter by.
* @return array
*/
function acf_filter_taxonomies( array $taxonomies, array $args = array() ) {
return acf_filter_internal_post_type_posts( $taxonomies, $args, 'acf-taxonomy' );
}
/**
* Updates an ACF taxonomy in the database.
*
* @since 6.1
*
* @param array $taxonomy The main ACF taxonomy array.
* @return array
*/
function acf_update_taxonomy( array $taxonomy ) {
return acf_update_internal_post_type( $taxonomy, 'acf-taxonomy' );
}
/**
* Deletes all caches for the provided ACF taxonomy.
*
* @since 6.1
*
* @param array $taxonomy The ACF taxonomy array.
* @return void
*/
function acf_flush_taxonomy_cache( array $taxonomy ) {
acf_flush_internal_post_type_cache( $taxonomy, 'acf-taxonomy' );
}
/**
* Deletes an ACF taxonomy from the database.
*
* @since 6.1
*
* @param integer|string $id The ACF taxonomy ID, key or name.
* @return boolean True if taxonomy was deleted.
*/
function acf_delete_taxonomy( $id = 0 ) {
return acf_delete_internal_post_type( $id, 'acf-taxonomy' );
}
/**
* Trashes an ACF taxonomy.
*
* @since 6.1
*
* @param integer|string $id The taxonomy ID, key, or name.
* @return boolean True if taxonomy was trashed.
*/
function acf_trash_taxonomy( $id = 0 ) {
return acf_trash_internal_post_type( $id, 'acf-taxonomy' );
}
/**
* Restores an ACF taxonomy from the trash.
*
* @since 6.1
*
* @param integer|string $id The taxonomy ID, key, or name.
* @return boolean True if taxonomy was untrashed.
*/
function acf_untrash_taxonomy( $id = 0 ) {
return acf_untrash_internal_post_type( $id, 'acf-taxonomy' );
}
/**
* Returns true if the given params match an ACF taxonomy.
*
* @since 6.1
*
* @param array $taxonomy The ACF taxonomy array.
* @return boolean
*/
function acf_is_taxonomy( $taxonomy ) {
return acf_is_internal_post_type( $taxonomy, 'acf-taxonomy' );
}
/**
* Duplicates an ACF taxonomy.
*
* @since 6.1
*
* @param integer|string $id The ACF taxonomy ID, key or name.
* @param integer $new_post_id Optional ID to override.
* @return array|boolean The new ACF taxonomy, or false on failure.
*/
function acf_duplicate_taxonomy( $id = 0, $new_post_id = 0 ) {
return acf_duplicate_internal_post_type( $id, $new_post_id, 'acf-taxonomy' );
}
/**
* Activates or deactivates an ACF taxonomy.
*
* @param integer|string $id The ACF taxonomy ID, key or name.
* @param boolean $activate True if the taxonomy should be activated.
* @return boolean
*/
function acf_update_taxonomy_active_status( $id, $activate = true ) {
return acf_update_internal_post_type_active_status( $id, $activate, 'acf-taxonomy' );
}
/**
* Checks if the current user can edit the taxonomy and returns the edit url.
*
* @since 6.1
*
* @param integer $post_id The ACF taxonomy ID.
* @return string
*/
function acf_get_taxonomy_edit_link( $post_id ) {
return acf_get_internal_post_type_edit_link( $post_id, 'acf-taxonomy' );
}
/**
* Returns a modified ACF taxonomy ready for export.
*
* @since 6.1
*
* @param array $taxonomy The ACF taxonomy array.
* @return array
*/
function acf_prepare_taxonomy_for_export( array $taxonomy = array() ) {
return acf_prepare_internal_post_type_for_export( $taxonomy, 'acf-taxonomy' );
}
/**
* Exports an ACF taxonomy as PHP.
*
* @since 6.1
*
* @param array $taxonomy The ACF taxonomy array.
* @return string|boolean
*/
function acf_export_taxonomy_as_php( array $taxonomy ) {
return acf_export_internal_post_type_as_php( $taxonomy, 'acf-taxonomy' );
}
/**
* Prepares an ACF taxonomy for the import process.
*
* @since 6.1
*
* @param array $taxonomy The ACF taxonomy array.
* @return array
*/
function acf_prepare_taxonomy_for_import( array $taxonomy = array() ) {
return acf_prepare_internal_post_type_for_import( $taxonomy, 'acf-taxonomy' );
}
/**
* Imports an ACF taxonomy into the database.
*
* @since 6.1
*
* @param array $taxonomy The ACF taxonomy array.
* @return array The imported taxonomy.
*/
function acf_import_taxonomy( array $taxonomy ) {
return acf_import_internal_post_type( $taxonomy, 'acf-taxonomy' );
}