Geen omschrijving

acf.php 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. <?php
  2. /*
  3. Plugin Name: Advanced Custom Fields
  4. Plugin URI: https://www.advancedcustomfields.com
  5. Description: Customize WordPress with powerful, professional and intuitive fields.
  6. Version: 5.11.3
  7. Author: Delicious Brains
  8. Author URI: https://www.advancedcustomfields.com
  9. Text Domain: acf
  10. Domain Path: /lang
  11. */
  12. if ( ! defined( 'ABSPATH' ) ) {
  13. exit; // Exit if accessed directly
  14. }
  15. if ( ! class_exists( 'ACF' ) ) :
  16. class ACF {
  17. /** @var string The plugin version number. */
  18. var $version = '5.11.3';
  19. /** @var array The plugin settings array. */
  20. var $settings = array();
  21. /** @var array The plugin data array. */
  22. var $data = array();
  23. /** @var array Storage for class instances. */
  24. var $instances = array();
  25. /**
  26. * __construct
  27. *
  28. * A dummy constructor to ensure ACF is only setup once.
  29. *
  30. * @date 23/06/12
  31. * @since 5.0.0
  32. *
  33. * @param void
  34. * @return void
  35. */
  36. function __construct() {
  37. // Do nothing.
  38. }
  39. /**
  40. * initialize
  41. *
  42. * Sets up the ACF plugin.
  43. *
  44. * @date 28/09/13
  45. * @since 5.0.0
  46. *
  47. * @param void
  48. * @return void
  49. */
  50. function initialize() {
  51. // Define constants.
  52. $this->define( 'ACF', true );
  53. $this->define( 'ACF_PATH', plugin_dir_path( __FILE__ ) );
  54. $this->define( 'ACF_BASENAME', plugin_basename( __FILE__ ) );
  55. $this->define( 'ACF_VERSION', $this->version );
  56. $this->define( 'ACF_MAJOR_VERSION', 5 );
  57. // Define settings.
  58. $this->settings = array(
  59. 'name' => __( 'Advanced Custom Fields', 'acf' ),
  60. 'slug' => dirname( ACF_BASENAME ),
  61. 'version' => ACF_VERSION,
  62. 'basename' => ACF_BASENAME,
  63. 'path' => ACF_PATH,
  64. 'file' => __FILE__,
  65. 'url' => plugin_dir_url( __FILE__ ),
  66. 'show_admin' => true,
  67. 'show_updates' => true,
  68. 'stripslashes' => false,
  69. 'local' => true,
  70. 'json' => true,
  71. 'save_json' => '',
  72. 'load_json' => array(),
  73. 'default_language' => '',
  74. 'current_language' => '',
  75. 'capability' => 'manage_options',
  76. 'uploader' => 'wp',
  77. 'autoload' => false,
  78. 'l10n' => true,
  79. 'l10n_textdomain' => '',
  80. 'google_api_key' => '',
  81. 'google_api_client' => '',
  82. 'enqueue_google_maps' => true,
  83. 'enqueue_select2' => true,
  84. 'enqueue_datepicker' => true,
  85. 'enqueue_datetimepicker' => true,
  86. 'select2_version' => 4,
  87. 'row_index_offset' => 1,
  88. 'remove_wp_meta_box' => true,
  89. 'rest_api_enabled' => true,
  90. 'rest_api_format' => 'light',
  91. 'rest_api_embed_links' => true,
  92. );
  93. // Include utility functions.
  94. include_once ACF_PATH . 'includes/acf-utility-functions.php';
  95. // Include previous API functions.
  96. acf_include( 'includes/api/api-helpers.php' );
  97. acf_include( 'includes/api/api-template.php' );
  98. acf_include( 'includes/api/api-term.php' );
  99. // Include classes.
  100. acf_include( 'includes/class-acf-data.php' );
  101. acf_include( 'includes/fields/class-acf-field.php' );
  102. acf_include( 'includes/locations/abstract-acf-legacy-location.php' );
  103. acf_include( 'includes/locations/abstract-acf-location.php' );
  104. // Include functions.
  105. acf_include( 'includes/acf-helper-functions.php' );
  106. acf_include( 'includes/acf-hook-functions.php' );
  107. acf_include( 'includes/acf-field-functions.php' );
  108. acf_include( 'includes/acf-field-group-functions.php' );
  109. acf_include( 'includes/acf-form-functions.php' );
  110. acf_include( 'includes/acf-meta-functions.php' );
  111. acf_include( 'includes/acf-post-functions.php' );
  112. acf_include( 'includes/acf-user-functions.php' );
  113. acf_include( 'includes/acf-value-functions.php' );
  114. acf_include( 'includes/acf-input-functions.php' );
  115. acf_include( 'includes/acf-wp-functions.php' );
  116. // Include core.
  117. acf_include( 'includes/fields.php' );
  118. acf_include( 'includes/locations.php' );
  119. acf_include( 'includes/assets.php' );
  120. acf_include( 'includes/compatibility.php' );
  121. acf_include( 'includes/deprecated.php' );
  122. acf_include( 'includes/l10n.php' );
  123. acf_include( 'includes/local-fields.php' );
  124. acf_include( 'includes/local-meta.php' );
  125. acf_include( 'includes/local-json.php' );
  126. acf_include( 'includes/loop.php' );
  127. acf_include( 'includes/media.php' );
  128. acf_include( 'includes/revisions.php' );
  129. acf_include( 'includes/updates.php' );
  130. acf_include( 'includes/upgrades.php' );
  131. acf_include( 'includes/validation.php' );
  132. acf_include( 'includes/rest-api.php' );
  133. // Include ajax.
  134. acf_include( 'includes/ajax/class-acf-ajax.php' );
  135. acf_include( 'includes/ajax/class-acf-ajax-check-screen.php' );
  136. acf_include( 'includes/ajax/class-acf-ajax-user-setting.php' );
  137. acf_include( 'includes/ajax/class-acf-ajax-upgrade.php' );
  138. acf_include( 'includes/ajax/class-acf-ajax-query.php' );
  139. acf_include( 'includes/ajax/class-acf-ajax-query-users.php' );
  140. acf_include( 'includes/ajax/class-acf-ajax-local-json-diff.php' );
  141. // Include forms.
  142. acf_include( 'includes/forms/form-attachment.php' );
  143. acf_include( 'includes/forms/form-comment.php' );
  144. acf_include( 'includes/forms/form-customizer.php' );
  145. acf_include( 'includes/forms/form-front.php' );
  146. acf_include( 'includes/forms/form-nav-menu.php' );
  147. acf_include( 'includes/forms/form-post.php' );
  148. acf_include( 'includes/forms/form-gutenberg.php' );
  149. acf_include( 'includes/forms/form-taxonomy.php' );
  150. acf_include( 'includes/forms/form-user.php' );
  151. acf_include( 'includes/forms/form-widget.php' );
  152. // Include admin.
  153. if ( is_admin() ) {
  154. acf_include( 'includes/admin/admin.php' );
  155. acf_include( 'includes/admin/admin-field-group.php' );
  156. acf_include( 'includes/admin/admin-field-groups.php' );
  157. acf_include( 'includes/admin/admin-notices.php' );
  158. acf_include( 'includes/admin/admin-tools.php' );
  159. acf_include( 'includes/admin/admin-upgrade.php' );
  160. }
  161. // Include legacy.
  162. acf_include( 'includes/legacy/legacy-locations.php' );
  163. // Include PRO.
  164. acf_include( 'pro/acf-pro.php' );
  165. // Include tests.
  166. if ( defined( 'ACF_DEV' ) && ACF_DEV ) {
  167. acf_include( 'tests/tests.php' );
  168. }
  169. // Add actions.
  170. add_action( 'init', array( $this, 'init' ), 5 );
  171. add_action( 'init', array( $this, 'register_post_types' ), 5 );
  172. add_action( 'init', array( $this, 'register_post_status' ), 5 );
  173. // Add filters.
  174. add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 2 );
  175. }
  176. /**
  177. * init
  178. *
  179. * Completes the setup process on "init" of earlier.
  180. *
  181. * @date 28/09/13
  182. * @since 5.0.0
  183. *
  184. * @param void
  185. * @return void
  186. */
  187. function init() {
  188. // Bail early if called directly from functions.php or plugin file.
  189. if ( ! did_action( 'plugins_loaded' ) ) {
  190. return;
  191. }
  192. // This function may be called directly from template functions. Bail early if already did this.
  193. if ( acf_did( 'init' ) ) {
  194. return;
  195. }
  196. // Update url setting. Allows other plugins to modify the URL (force SSL).
  197. acf_update_setting( 'url', plugin_dir_url( __FILE__ ) );
  198. // Load textdomain file.
  199. acf_load_textdomain();
  200. // Include 3rd party compatiblity.
  201. acf_include( 'includes/third-party.php' );
  202. // Include wpml support.
  203. if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
  204. acf_include( 'includes/wpml.php' );
  205. }
  206. // Include fields.
  207. acf_include( 'includes/fields/class-acf-field-text.php' );
  208. acf_include( 'includes/fields/class-acf-field-textarea.php' );
  209. acf_include( 'includes/fields/class-acf-field-number.php' );
  210. acf_include( 'includes/fields/class-acf-field-range.php' );
  211. acf_include( 'includes/fields/class-acf-field-email.php' );
  212. acf_include( 'includes/fields/class-acf-field-url.php' );
  213. acf_include( 'includes/fields/class-acf-field-password.php' );
  214. acf_include( 'includes/fields/class-acf-field-image.php' );
  215. acf_include( 'includes/fields/class-acf-field-file.php' );
  216. acf_include( 'includes/fields/class-acf-field-wysiwyg.php' );
  217. acf_include( 'includes/fields/class-acf-field-oembed.php' );
  218. acf_include( 'includes/fields/class-acf-field-select.php' );
  219. acf_include( 'includes/fields/class-acf-field-checkbox.php' );
  220. acf_include( 'includes/fields/class-acf-field-radio.php' );
  221. acf_include( 'includes/fields/class-acf-field-button-group.php' );
  222. acf_include( 'includes/fields/class-acf-field-true_false.php' );
  223. acf_include( 'includes/fields/class-acf-field-link.php' );
  224. acf_include( 'includes/fields/class-acf-field-post_object.php' );
  225. acf_include( 'includes/fields/class-acf-field-page_link.php' );
  226. acf_include( 'includes/fields/class-acf-field-relationship.php' );
  227. acf_include( 'includes/fields/class-acf-field-taxonomy.php' );
  228. acf_include( 'includes/fields/class-acf-field-user.php' );
  229. acf_include( 'includes/fields/class-acf-field-google-map.php' );
  230. acf_include( 'includes/fields/class-acf-field-date_picker.php' );
  231. acf_include( 'includes/fields/class-acf-field-date_time_picker.php' );
  232. acf_include( 'includes/fields/class-acf-field-time_picker.php' );
  233. acf_include( 'includes/fields/class-acf-field-color_picker.php' );
  234. acf_include( 'includes/fields/class-acf-field-message.php' );
  235. acf_include( 'includes/fields/class-acf-field-accordion.php' );
  236. acf_include( 'includes/fields/class-acf-field-tab.php' );
  237. acf_include( 'includes/fields/class-acf-field-group.php' );
  238. /**
  239. * Fires after field types have been included.
  240. *
  241. * @date 28/09/13
  242. * @since 5.0.0
  243. *
  244. * @param int $major_version The major version of ACF.
  245. */
  246. do_action( 'acf/include_field_types', ACF_MAJOR_VERSION );
  247. // Include locations.
  248. acf_include( 'includes/locations/class-acf-location-post-type.php' );
  249. acf_include( 'includes/locations/class-acf-location-post-template.php' );
  250. acf_include( 'includes/locations/class-acf-location-post-status.php' );
  251. acf_include( 'includes/locations/class-acf-location-post-format.php' );
  252. acf_include( 'includes/locations/class-acf-location-post-category.php' );
  253. acf_include( 'includes/locations/class-acf-location-post-taxonomy.php' );
  254. acf_include( 'includes/locations/class-acf-location-post.php' );
  255. acf_include( 'includes/locations/class-acf-location-page-template.php' );
  256. acf_include( 'includes/locations/class-acf-location-page-type.php' );
  257. acf_include( 'includes/locations/class-acf-location-page-parent.php' );
  258. acf_include( 'includes/locations/class-acf-location-page.php' );
  259. acf_include( 'includes/locations/class-acf-location-current-user.php' );
  260. acf_include( 'includes/locations/class-acf-location-current-user-role.php' );
  261. acf_include( 'includes/locations/class-acf-location-user-form.php' );
  262. acf_include( 'includes/locations/class-acf-location-user-role.php' );
  263. acf_include( 'includes/locations/class-acf-location-taxonomy.php' );
  264. acf_include( 'includes/locations/class-acf-location-attachment.php' );
  265. acf_include( 'includes/locations/class-acf-location-comment.php' );
  266. acf_include( 'includes/locations/class-acf-location-widget.php' );
  267. acf_include( 'includes/locations/class-acf-location-nav-menu.php' );
  268. acf_include( 'includes/locations/class-acf-location-nav-menu-item.php' );
  269. /**
  270. * Fires after location types have been included.
  271. *
  272. * @date 28/09/13
  273. * @since 5.0.0
  274. *
  275. * @param int $major_version The major version of ACF.
  276. */
  277. do_action( 'acf/include_location_rules', ACF_MAJOR_VERSION );
  278. /**
  279. * Fires during initialization. Used to add local fields.
  280. *
  281. * @date 28/09/13
  282. * @since 5.0.0
  283. *
  284. * @param int $major_version The major version of ACF.
  285. */
  286. do_action( 'acf/include_fields', ACF_MAJOR_VERSION );
  287. /**
  288. * Fires after ACF is completely "initialized".
  289. *
  290. * @date 28/09/13
  291. * @since 5.0.0
  292. *
  293. * @param int $major_version The major version of ACF.
  294. */
  295. do_action( 'acf/init', ACF_MAJOR_VERSION );
  296. }
  297. /**
  298. * register_post_types
  299. *
  300. * Registers the ACF post types.
  301. *
  302. * @date 22/10/2015
  303. * @since 5.3.2
  304. *
  305. * @param void
  306. * @return void
  307. */
  308. function register_post_types() {
  309. // Vars.
  310. $cap = acf_get_setting( 'capability' );
  311. // Register the Field Group post type.
  312. register_post_type(
  313. 'acf-field-group',
  314. array(
  315. 'labels' => array(
  316. 'name' => __( 'Field Groups', 'acf' ),
  317. 'singular_name' => __( 'Field Group', 'acf' ),
  318. 'add_new' => __( 'Add New', 'acf' ),
  319. 'add_new_item' => __( 'Add New Field Group', 'acf' ),
  320. 'edit_item' => __( 'Edit Field Group', 'acf' ),
  321. 'new_item' => __( 'New Field Group', 'acf' ),
  322. 'view_item' => __( 'View Field Group', 'acf' ),
  323. 'search_items' => __( 'Search Field Groups', 'acf' ),
  324. 'not_found' => __( 'No Field Groups found', 'acf' ),
  325. 'not_found_in_trash' => __( 'No Field Groups found in Trash', 'acf' ),
  326. ),
  327. 'public' => false,
  328. 'hierarchical' => true,
  329. 'show_ui' => true,
  330. 'show_in_menu' => false,
  331. '_builtin' => false,
  332. 'capability_type' => 'post',
  333. 'capabilities' => array(
  334. 'edit_post' => $cap,
  335. 'delete_post' => $cap,
  336. 'edit_posts' => $cap,
  337. 'delete_posts' => $cap,
  338. ),
  339. 'supports' => array( 'title' ),
  340. 'rewrite' => false,
  341. 'query_var' => false,
  342. )
  343. );
  344. // Register the Field post type.
  345. register_post_type(
  346. 'acf-field',
  347. array(
  348. 'labels' => array(
  349. 'name' => __( 'Fields', 'acf' ),
  350. 'singular_name' => __( 'Field', 'acf' ),
  351. 'add_new' => __( 'Add New', 'acf' ),
  352. 'add_new_item' => __( 'Add New Field', 'acf' ),
  353. 'edit_item' => __( 'Edit Field', 'acf' ),
  354. 'new_item' => __( 'New Field', 'acf' ),
  355. 'view_item' => __( 'View Field', 'acf' ),
  356. 'search_items' => __( 'Search Fields', 'acf' ),
  357. 'not_found' => __( 'No Fields found', 'acf' ),
  358. 'not_found_in_trash' => __( 'No Fields found in Trash', 'acf' ),
  359. ),
  360. 'public' => false,
  361. 'hierarchical' => true,
  362. 'show_ui' => false,
  363. 'show_in_menu' => false,
  364. '_builtin' => false,
  365. 'capability_type' => 'post',
  366. 'capabilities' => array(
  367. 'edit_post' => $cap,
  368. 'delete_post' => $cap,
  369. 'edit_posts' => $cap,
  370. 'delete_posts' => $cap,
  371. ),
  372. 'supports' => array( 'title' ),
  373. 'rewrite' => false,
  374. 'query_var' => false,
  375. )
  376. );
  377. }
  378. /**
  379. * register_post_status
  380. *
  381. * Registers the ACF post statuses.
  382. *
  383. * @date 22/10/2015
  384. * @since 5.3.2
  385. *
  386. * @param void
  387. * @return void
  388. */
  389. function register_post_status() {
  390. // Register the Disabled post status.
  391. register_post_status(
  392. 'acf-disabled',
  393. array(
  394. 'label' => _x( 'Disabled', 'post status', 'acf' ),
  395. 'public' => true,
  396. 'exclude_from_search' => false,
  397. 'show_in_admin_all_list' => true,
  398. 'show_in_admin_status_list' => true,
  399. 'label_count' => _n_noop( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', 'acf' ),
  400. )
  401. );
  402. }
  403. /**
  404. * posts_where
  405. *
  406. * Filters the $where clause allowing for custom WP_Query args.
  407. *
  408. * @date 31/8/19
  409. * @since 5.8.1
  410. *
  411. * @param string $where The WHERE clause.
  412. * @return WP_Query $wp_query The query object.
  413. */
  414. function posts_where( $where, $wp_query ) {
  415. global $wpdb;
  416. // Add custom "acf_field_key" arg.
  417. if ( $field_key = $wp_query->get( 'acf_field_key' ) ) {
  418. $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_name = %s", $field_key );
  419. }
  420. // Add custom "acf_field_name" arg.
  421. if ( $field_name = $wp_query->get( 'acf_field_name' ) ) {
  422. $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_excerpt = %s", $field_name );
  423. }
  424. // Add custom "acf_group_key" arg.
  425. if ( $group_key = $wp_query->get( 'acf_group_key' ) ) {
  426. $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_name = %s", $group_key );
  427. }
  428. // Return.
  429. return $where;
  430. }
  431. /**
  432. * define
  433. *
  434. * Defines a constant if doesnt already exist.
  435. *
  436. * @date 3/5/17
  437. * @since 5.5.13
  438. *
  439. * @param string $name The constant name.
  440. * @param mixed $value The constant value.
  441. * @return void
  442. */
  443. function define( $name, $value = true ) {
  444. if ( ! defined( $name ) ) {
  445. define( $name, $value );
  446. }
  447. }
  448. /**
  449. * has_setting
  450. *
  451. * Returns true if a setting exists for this name.
  452. *
  453. * @date 2/2/18
  454. * @since 5.6.5
  455. *
  456. * @param string $name The setting name.
  457. * @return boolean
  458. */
  459. function has_setting( $name ) {
  460. return isset( $this->settings[ $name ] );
  461. }
  462. /**
  463. * get_setting
  464. *
  465. * Returns a setting or null if doesn't exist.
  466. *
  467. * @date 28/09/13
  468. * @since 5.0.0
  469. *
  470. * @param string $name The setting name.
  471. * @return mixed
  472. */
  473. function get_setting( $name ) {
  474. return isset( $this->settings[ $name ] ) ? $this->settings[ $name ] : null;
  475. }
  476. /**
  477. * update_setting
  478. *
  479. * Updates a setting for the given name and value.
  480. *
  481. * @date 28/09/13
  482. * @since 5.0.0
  483. *
  484. * @param string $name The setting name.
  485. * @param mixed $value The setting value.
  486. * @return true
  487. */
  488. function update_setting( $name, $value ) {
  489. $this->settings[ $name ] = $value;
  490. return true;
  491. }
  492. /**
  493. * get_data
  494. *
  495. * Returns data or null if doesn't exist.
  496. *
  497. * @date 28/09/13
  498. * @since 5.0.0
  499. *
  500. * @param string $name The data name.
  501. * @return mixed
  502. */
  503. function get_data( $name ) {
  504. return isset( $this->data[ $name ] ) ? $this->data[ $name ] : null;
  505. }
  506. /**
  507. * set_data
  508. *
  509. * Sets data for the given name and value.
  510. *
  511. * @date 28/09/13
  512. * @since 5.0.0
  513. *
  514. * @param string $name The data name.
  515. * @param mixed $value The data value.
  516. * @return void
  517. */
  518. function set_data( $name, $value ) {
  519. $this->data[ $name ] = $value;
  520. }
  521. /**
  522. * get_instance
  523. *
  524. * Returns an instance or null if doesn't exist.
  525. *
  526. * @date 13/2/18
  527. * @since 5.6.9
  528. *
  529. * @param string $class The instance class name.
  530. * @return object
  531. */
  532. function get_instance( $class ) {
  533. $name = strtolower( $class );
  534. return isset( $this->instances[ $name ] ) ? $this->instances[ $name ] : null;
  535. }
  536. /**
  537. * new_instance
  538. *
  539. * Creates and stores an instance of the given class.
  540. *
  541. * @date 13/2/18
  542. * @since 5.6.9
  543. *
  544. * @param string $class The instance class name.
  545. * @return object
  546. */
  547. function new_instance( $class ) {
  548. $instance = new $class();
  549. $name = strtolower( $class );
  550. $this->instances[ $name ] = $instance;
  551. return $instance;
  552. }
  553. /**
  554. * Magic __isset method for backwards compatibility.
  555. *
  556. * @date 24/4/20
  557. * @since 5.9.0
  558. *
  559. * @param string $key Key name.
  560. * @return bool
  561. */
  562. public function __isset( $key ) {
  563. return in_array( $key, array( 'locations', 'json' ) );
  564. }
  565. /**
  566. * Magic __get method for backwards compatibility.
  567. *
  568. * @date 24/4/20
  569. * @since 5.9.0
  570. *
  571. * @param string $key Key name.
  572. * @return mixed
  573. */
  574. public function __get( $key ) {
  575. switch ( $key ) {
  576. case 'locations':
  577. return acf_get_instance( 'ACF_Legacy_Locations' );
  578. case 'json':
  579. return acf_get_instance( 'ACF_Local_JSON' );
  580. }
  581. return null;
  582. }
  583. }
  584. /*
  585. * acf
  586. *
  587. * The main function responsible for returning the one true acf Instance to functions everywhere.
  588. * Use this function like you would a global variable, except without needing to declare the global.
  589. *
  590. * Example: <?php $acf = acf(); ?>
  591. *
  592. * @date 4/09/13
  593. * @since 4.3.0
  594. *
  595. * @param void
  596. * @return ACF
  597. */
  598. function acf() {
  599. global $acf;
  600. // Instantiate only once.
  601. if ( ! isset( $acf ) ) {
  602. $acf = new ACF();
  603. $acf->initialize();
  604. }
  605. return $acf;
  606. }
  607. // Instantiate.
  608. acf();
  609. endif; // class_exists check