Blocks
1 month ago
Datastore
3 days ago
Meta
1 year ago
abilities
1 month ago
admin
1 week ago
ajax
2 months ago
api
3 days ago
fields
3 days ago
forms
1 week ago
legacy
1 year ago
locations
2 weeks ago
post-types
3 months ago
rest-api
3 days ago
walkers
1 year ago
acf-bidirectional-functions.php
3 days ago
acf-field-functions.php
3 months ago
acf-field-group-functions.php
8 months ago
acf-form-functions.php
1 year ago
acf-helper-functions.php
1 year ago
acf-hook-functions.php
1 year ago
acf-input-functions.php
8 months ago
acf-internal-post-type-functions.php
8 months ago
acf-meta-functions.php
1 month ago
acf-post-functions.php
1 year ago
acf-post-type-functions.php
1 year ago
acf-taxonomy-functions.php
1 year ago
acf-user-functions.php
1 month ago
acf-utility-functions.php
1 year ago
acf-value-functions.php
1 year ago
acf-wp-functions.php
1 month ago
assets.php
1 month ago
blocks-auto-inline-editing.php
2 weeks ago
blocks.php
1 week ago
class-acf-data.php
11 months ago
class-acf-internal-post-type.php
1 month ago
class-acf-options-page.php
1 year ago
class-acf-site-health.php
4 months ago
class-scf-json-schema-validator.php
7 months ago
class-scf-schema-builder.php
3 months ago
compatibility.php
1 year ago
datastore.php
2 months ago
deprecated.php
1 year ago
fields.php
11 months ago
index.php
1 year ago
l10n.php
1 year ago
local-fields.php
1 year ago
local-json.php
1 week ago
local-meta.php
1 year ago
locations.php
1 year ago
loop.php
11 months ago
media.php
1 year ago
rest-api.php
11 months ago
revisions.php
2 months ago
scf-ui-options-page-functions.php
1 year ago
third-party.php
8 months ago
upgrades.php
1 month ago
validation.php
11 months ago
wpml.php
1 year ago
scf-ui-options-page-functions.php
273 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Helper/wrapper Functions for SCF UI Options pages. |
| 4 | * |
| 5 | * @package wordpress/secure-custom-fields |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Get an SCF UI options page as an array |
| 10 | * |
| 11 | * @since ACF 6.2 |
| 12 | * |
| 13 | * @param integer|string $id The post ID being queried. |
| 14 | * @return array|false The UI options page array. |
| 15 | */ |
| 16 | function acf_get_ui_options_page( $id ) { |
| 17 | return acf_get_internal_post_type( $id, 'acf-ui-options-page' ); |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Retrieves a raw SCF UI options page. |
| 22 | * |
| 23 | * @since ACF 6.2 |
| 24 | * |
| 25 | * @param integer|string $id The post ID. |
| 26 | * @return array|false The UI options page array. |
| 27 | */ |
| 28 | function acf_get_raw_ui_options_page( $id ) { |
| 29 | return acf_get_raw_internal_post_type( $id, 'acf-ui-options-page' ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Gets a post object for an SCF UI options page. |
| 34 | * |
| 35 | * @since ACF 6.2 |
| 36 | * |
| 37 | * @param integer|string $id The post ID, key, or name. |
| 38 | * @return object|boolean The post object, or false on failure. |
| 39 | */ |
| 40 | function acf_get_ui_options_page_post( $id ) { |
| 41 | return acf_get_internal_post_type_post( $id, 'acf-ui-options-page' ); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Returns true if the given identifier is an SCF UI options page key. |
| 46 | * |
| 47 | * @since ACF 6.2 |
| 48 | * |
| 49 | * @param string $id The identifier. |
| 50 | * @return boolean |
| 51 | */ |
| 52 | function acf_is_ui_options_page_key( $id ) { |
| 53 | return acf_is_internal_post_type_key( $id, 'acf-ui-options-page' ); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Validates an SCF UI options page. |
| 58 | * |
| 59 | * @since ACF 6.2 |
| 60 | * |
| 61 | * @param array $ui_options_page The SCF UI options page array to validate. |
| 62 | * @return array|boolean |
| 63 | */ |
| 64 | function acf_validate_ui_options_page( array $ui_options_page = array() ) { |
| 65 | return acf_validate_internal_post_type( $ui_options_page, 'acf-ui-options-page' ); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Translates the settings for an SCF UI options page. |
| 70 | * |
| 71 | * @since ACF 6.2 |
| 72 | * |
| 73 | * @param array $ui_options_page The SCF UI options page array. |
| 74 | * @return array |
| 75 | */ |
| 76 | function acf_translate_ui_options_page( array $ui_options_page ) { |
| 77 | return acf_translate_internal_post_type( $ui_options_page, 'acf-ui-options-page' ); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Returns and array of SCF UI options pages for the given $filter. |
| 82 | * |
| 83 | * @since ACF 6.2 |
| 84 | * |
| 85 | * @param array $filter An array of args to filter results by. |
| 86 | * @return array |
| 87 | */ |
| 88 | function acf_get_ui_options_pages( array $filter = array() ) { |
| 89 | return acf_get_internal_post_type_posts( 'acf-ui-options-page', $filter ); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Returns an array of raw SCF UI options pages. |
| 94 | * |
| 95 | * @since ACF 6.2 |
| 96 | * |
| 97 | * @return array |
| 98 | */ |
| 99 | function acf_get_raw_ui_options_pages() { |
| 100 | return acf_get_raw_internal_post_type_posts( 'acf-ui-options-page' ); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Returns a filtered array of SCF UI options pages based on the given $args. |
| 105 | * |
| 106 | * @since ACF 6.2 |
| 107 | * |
| 108 | * @param array $ui_options_pages An array of SCF UI options pages. |
| 109 | * @param array $args An array of args to filter by. |
| 110 | * @return array |
| 111 | */ |
| 112 | function acf_filter_ui_options_pages( array $ui_options_pages, array $args = array() ) { |
| 113 | return acf_filter_internal_post_type_posts( $ui_options_pages, $args, 'acf-ui-options-page' ); |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Updates an SCF UI options page in the database. |
| 118 | * |
| 119 | * @since ACF 6.2 |
| 120 | * |
| 121 | * @param array $ui_options_page The main ACF UI options page array. |
| 122 | * @return array |
| 123 | */ |
| 124 | function acf_update_ui_options_page( array $ui_options_page ) { |
| 125 | return acf_update_internal_post_type( $ui_options_page, 'acf-ui-options-page' ); |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Deletes all caches for the provided ACF UI options page. |
| 130 | * |
| 131 | * @since ACF 6.2 |
| 132 | * |
| 133 | * @param array $ui_options_page The SCF UI options page array. |
| 134 | * @return void |
| 135 | */ |
| 136 | function acf_flush_ui_options_page_cache( array $ui_options_page ) { |
| 137 | acf_flush_internal_post_type_cache( $ui_options_page, 'acf-ui-options-page' ); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Deletes an ACF UI options page from the database. |
| 142 | * |
| 143 | * @since ACF 6.2 |
| 144 | * |
| 145 | * @param integer|string $id The ACF UI options page ID, key or name. |
| 146 | * @return boolean True if the options page was deleted. |
| 147 | */ |
| 148 | function acf_delete_ui_options_page( $id = 0 ) { |
| 149 | return acf_delete_internal_post_type( $id, 'acf-ui-options-page' ); |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Trashes an ACF UI options page. |
| 154 | * |
| 155 | * @since ACF 6.2 |
| 156 | * |
| 157 | * @param integer|string $id The UI options page ID, key, or name. |
| 158 | * @return boolean True if the options page was trashed. |
| 159 | */ |
| 160 | function acf_trash_ui_options_page( $id = 0 ) { |
| 161 | return acf_trash_internal_post_type( $id, 'acf-ui-options-page' ); |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Restores an ACF UI options page from the trash. |
| 166 | * |
| 167 | * @since ACF 6.2 |
| 168 | * |
| 169 | * @param integer|string $id The UI options page ID, key, or name. |
| 170 | * @return boolean True if the options page was untrashed. |
| 171 | */ |
| 172 | function acf_untrash_ui_options_page( $id = 0 ) { |
| 173 | return acf_untrash_internal_post_type( $id, 'acf-ui-options-page' ); |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * Returns true if the given params match an ACF UI options page. |
| 178 | * |
| 179 | * @since ACF 6.2 |
| 180 | * |
| 181 | * @param array $ui_options_page The ACF UI options page array. |
| 182 | * @return boolean |
| 183 | */ |
| 184 | function acf_is_ui_options_page( $ui_options_page ) { |
| 185 | return acf_is_internal_post_type( $ui_options_page, 'acf-ui-options-page' ); |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Duplicates an ACF UI options page. |
| 190 | * |
| 191 | * @since ACF 6.2 |
| 192 | * |
| 193 | * @param integer|string $id The ACF UI options page ID, key or name. |
| 194 | * @param integer $new_post_id Optional ID to override. |
| 195 | * @return array|boolean The new ACF UI options page, or false on failure. |
| 196 | */ |
| 197 | function acf_duplicate_ui_options_page( $id = 0, $new_post_id = 0 ) { |
| 198 | return acf_duplicate_internal_post_type( $id, $new_post_id, 'acf-ui-options-page' ); |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Activates or deactivates an ACF UI options page. |
| 203 | * |
| 204 | * @since ACF 6.2 |
| 205 | * |
| 206 | * @param integer|string $id The ACF UI options page ID, key or name. |
| 207 | * @param boolean $activate True if the UI options page should be activated. |
| 208 | * @return boolean |
| 209 | */ |
| 210 | function acf_update_ui_options_page_active_status( $id, $activate = true ) { |
| 211 | return acf_update_internal_post_type_active_status( $id, $activate, 'acf-ui-options-page' ); |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Checks if the current user can edit the UI options page and returns the edit URL. |
| 216 | * |
| 217 | * @since ACF 6.2 |
| 218 | * |
| 219 | * @param integer $post_id The ACF UI options page ID. |
| 220 | * @return string |
| 221 | */ |
| 222 | function acf_get_ui_options_page_edit_link( $post_id ) { |
| 223 | return acf_get_internal_post_type_edit_link( $post_id, 'acf-ui-options-page' ); |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * Returns a modified ACF UI options page ready for export. |
| 228 | * |
| 229 | * @since ACF 6.2 |
| 230 | * |
| 231 | * @param array $ui_options_page The ACF UI options page array. |
| 232 | * @return array |
| 233 | */ |
| 234 | function acf_prepare_ui_options_page_for_export( array $ui_options_page = array() ) { |
| 235 | return acf_prepare_internal_post_type_for_export( $ui_options_page, 'acf-ui-options-page' ); |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Exports an ACF UI options page as PHP. |
| 240 | * |
| 241 | * @since ACF 6.2 |
| 242 | * |
| 243 | * @param array $ui_options_page The ACF UI options page array. |
| 244 | * @return string|boolean |
| 245 | */ |
| 246 | function acf_export_ui_options_page_as_php( array $ui_options_page ) { |
| 247 | return acf_export_internal_post_type_as_php( $ui_options_page, 'acf-ui-options-page' ); |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Prepares an ACF UI options page for the import process. |
| 252 | * |
| 253 | * @since ACF 6.2 |
| 254 | * |
| 255 | * @param array $ui_options_page The ACF UI options page array. |
| 256 | * @return array |
| 257 | */ |
| 258 | function acf_prepare_ui_options_page_for_import( array $ui_options_page = array() ) { |
| 259 | return acf_prepare_internal_post_type_for_import( $ui_options_page, 'acf-ui-options-page' ); |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * Imports an ACF UI options page into the database. |
| 264 | * |
| 265 | * @since ACF 6.2 |
| 266 | * |
| 267 | * @param array $ui_options_page The ACF UI options page array. |
| 268 | * @return array The imported options page. |
| 269 | */ |
| 270 | function acf_import_ui_options_page( array $ui_options_page ) { |
| 271 | return acf_import_internal_post_type( $ui_options_page, 'acf-ui-options-page' ); |
| 272 | } |
| 273 |