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.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.4.10 4.4.11 4.4.12 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 5.10 5.10.1 5.10.2 5.11 5.11.1 5.11.2 5.11.3 5.11.4 5.12 5.12.1 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.6.10 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 5.6.7 5.6.8 5.6.9 5.7.0 5.7.1 5.7.10 5.7.12 5.7.13 5.7.2 5.7.3 5.7.4 5.7.5 5.7.6 5.7.7 5.7.8 5.7.9 5.8.0 5.8.1 5.8.10 5.8.11 5.8.12 5.8.13 5.8.14 5.8.2 5.8.3 5.8.4
advanced-custom-fields / includes / acf-utility-functions.php
advanced-custom-fields / includes Last commit date
admin 6 years ago ajax 6 years ago api 6 years ago fields 6 years ago forms 6 years ago locations 6 years ago walkers 6 years ago acf-field-functions.php 6 years ago acf-field-group-functions.php 6 years ago acf-form-functions.php 6 years ago acf-helper-functions.php 6 years ago acf-hook-functions.php 6 years ago acf-input-functions.php 6 years ago acf-meta-functions.php 6 years ago acf-post-functions.php 6 years ago acf-user-functions.php 6 years ago acf-utility-functions.php 6 years ago acf-value-functions.php 6 years ago assets.php 6 years ago class-acf-data.php 6 years ago compatibility.php 6 years ago deprecated.php 6 years ago fields.php 6 years ago json.php 6 years ago l10n.php 6 years ago local-fields.php 6 years ago local-meta.php 6 years ago locations.php 6 years ago loop.php 6 years ago media.php 6 years ago revisions.php 6 years ago third-party.php 6 years ago updates.php 6 years ago upgrades.php 6 years ago validation.php 6 years ago wpml.php 6 years ago
acf-utility-functions.php
159 lines
1 <?php
2
3 // Globals.
4 global $acf_stores, $acf_instances;
5
6 // Initialize plaeholders.
7 $acf_stores = array();
8 $acf_instances = array();
9
10 /**
11 * acf_new_instance
12 *
13 * Creates a new instance of the given class and stores it in the instances data store.
14 *
15 * @date 9/1/19
16 * @since 5.7.10
17 *
18 * @param string $class The class name.
19 * @return object The instance.
20 */
21 function acf_new_instance( $class = '' ) {
22 global $acf_instances;
23 return $acf_instances[ $class ] = new $class();
24 }
25
26 /**
27 * acf_get_instance
28 *
29 * Returns an instance for the given class.
30 *
31 * @date 9/1/19
32 * @since 5.7.10
33 *
34 * @param string $class The class name.
35 * @return object The instance.
36 */
37 function acf_get_instance( $class = '' ) {
38 global $acf_instances;
39 if( !isset($acf_instances[ $class ]) ) {
40 $acf_instances[ $class ] = new $class();
41 }
42 return $acf_instances[ $class ];
43 }
44
45 /**
46 * acf_register_store
47 *
48 * Registers a data store.
49 *
50 * @date 9/1/19
51 * @since 5.7.10
52 *
53 * @param string $name The store name.
54 * @param array $data Array of data to start the store with.
55 * @return ACF_Data
56 */
57 function acf_register_store( $name = '', $data = false ) {
58
59 // Create store.
60 $store = new ACF_Data( $data );
61
62 // Register store.
63 global $acf_stores;
64 $acf_stores[ $name ] = $store;
65
66 // Return store.
67 return $store;
68 }
69
70 /**
71 * acf_get_store
72 *
73 * Returns a data store.
74 *
75 * @date 9/1/19
76 * @since 5.7.10
77 *
78 * @param string $name The store name.
79 * @return ACF_Data
80 */
81 function acf_get_store( $name = '' ) {
82 global $acf_stores;
83 return isset( $acf_stores[ $name ] ) ? $acf_stores[ $name ] : false;
84 }
85
86 /**
87 * acf_switch_stores
88 *
89 * Triggered when switching between sites on a multisite installation.
90 *
91 * @date 13/2/19
92 * @since 5.7.11
93 *
94 * @param int $site_id New blog ID.
95 * @param int prev_blog_id Prev blog ID.
96 * @return void
97 */
98 function acf_switch_stores( $site_id, $prev_site_id ) {
99
100 // Loop over stores and call switch_site().
101 global $acf_stores;
102 foreach( $acf_stores as $store ) {
103 $store->switch_site( $site_id, $prev_site_id );
104 }
105 }
106 add_action( 'switch_blog', 'acf_switch_stores', 10, 2 );
107
108 /**
109 * acf_get_path
110 *
111 * Returns the plugin path to a specified file.
112 *
113 * @date 28/9/13
114 * @since 5.0.0
115 *
116 * @param string $filename The specified file.
117 * @return string
118 */
119 function acf_get_path( $filename = '' ) {
120 return ACF_PATH . ltrim($filename, '/');
121 }
122
123 /**
124 * acf_get_url
125 *
126 * Returns the plugin url to a specified file.
127 * This function also defines the ACF_URL constant.
128 *
129 * @date 12/12/17
130 * @since 5.6.8
131 *
132 * @param string $filename The specified file.
133 * @return string
134 */
135 function acf_get_url( $filename = '' ) {
136 if( !defined('ACF_URL') ) {
137 define( 'ACF_URL', acf_get_setting('url') );
138 }
139 return ACF_URL . ltrim($filename, '/');
140 }
141
142 /*
143 * acf_include
144 *
145 * Includes a file within the ACF plugin.
146 *
147 * @date 10/3/14
148 * @since 5.0.0
149 *
150 * @param string $filename The specified file.
151 * @return void
152 */
153 function acf_include( $filename = '' ) {
154 $file_path = acf_get_path($filename);
155 if( file_exists($file_path) ) {
156 include_once($file_path);
157 }
158 }
159