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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-hook-functions.php
advanced-custom-fields / includes Last commit date
admin 2 months ago ajax 3 weeks ago api 3 weeks ago fields 2 months ago forms 1 week ago legacy 3 months ago locations 3 months ago post-types 2 months ago rest-api 2 months ago walkers 3 months ago acf-bidirectional-functions.php 3 months ago acf-field-functions.php 2 months ago acf-field-group-functions.php 3 months ago acf-form-functions.php 3 months ago acf-helper-functions.php 3 months ago acf-hook-functions.php 3 months ago acf-input-functions.php 3 months ago acf-internal-post-type-functions.php 3 months ago acf-meta-functions.php 3 months ago acf-post-functions.php 3 months ago acf-post-type-functions.php 3 months ago acf-taxonomy-functions.php 3 months ago acf-user-functions.php 3 months ago acf-utility-functions.php 3 months ago acf-value-functions.php 3 months ago acf-wp-functions.php 3 months ago assets.php 2 months ago class-acf-data.php 3 months ago class-acf-internal-post-type.php 3 months ago compatibility.php 3 months ago deprecated.php 3 months ago fields.php 3 months ago index.php 1 year ago l10n.php 3 months ago local-fields.php 3 months ago local-json.php 3 weeks ago local-meta.php 3 months ago locations.php 3 months ago loop.php 3 months ago media.php 3 months ago rest-api.php 3 months ago revisions.php 3 weeks ago third-party.php 3 months ago upgrades.php 3 months ago validation.php 3 months ago wpml.php 3 months ago
acf-hook-functions.php
231 lines
1 <?php
2 /**
3 * @package ACF
4 * @author WP Engine
5 *
6 * © 2026 Advanced Custom Fields (ACF®). All rights reserved.
7 * "ACF" is a trademark of WP Engine.
8 * Licensed under the GNU General Public License v2 or later.
9 * https://www.gnu.org/licenses/gpl-2.0.html
10 */
11
12 // Register store.
13 acf_register_store( 'hook-variations' );
14
15 /**
16 * acf_add_filter_variations
17 *
18 * Registers variations for the given filter.
19 *
20 * @date 26/1/19
21 * @since 5.7.11
22 *
23 * @param string $filter The filter name.
24 * @param array $variations An array variation keys.
25 * @param integer $index The param index to find variation values.
26 * @return void
27 */
28 function acf_add_filter_variations( $filter = '', $variations = array(), $index = 0 ) {
29
30 // Store replacement data.
31 acf_get_store( 'hook-variations' )->set(
32 $filter,
33 array(
34 'type' => 'filter',
35 'variations' => $variations,
36 'index' => $index,
37 )
38 );
39
40 // Add generic handler.
41 // Use a priotiry of 10, and accepted args of 10 (ignored by WP).
42 add_filter( $filter, '_acf_apply_hook_variations', 10, 10 );
43 }
44
45 /**
46 * acf_add_action_variations
47 *
48 * Registers variations for the given action.
49 *
50 * @date 26/1/19
51 * @since 5.7.11
52 *
53 * @param string $action The action name.
54 * @param array $variations An array variation keys.
55 * @param integer $index The param index to find variation values.
56 * @return void
57 */
58 function acf_add_action_variations( $action = '', $variations = array(), $index = 0 ) {
59
60 // Store replacement data.
61 acf_get_store( 'hook-variations' )->set(
62 $action,
63 array(
64 'type' => 'action',
65 'variations' => $variations,
66 'index' => $index,
67 )
68 );
69
70 // Add generic handler.
71 // Use a priotiry of 10, and accepted args of 10 (ignored by WP).
72 add_action( $action, '_acf_apply_hook_variations', 10, 10 );
73 }
74
75 /**
76 * _acf_apply_hook_variations
77 *
78 * Applies hook variations during apply_filters() or do_action().
79 *
80 * @date 25/1/19
81 * @since 5.7.11
82 *
83 * @param mixed
84 * @return mixed
85 */
86 function _acf_apply_hook_variations() {
87
88 // Get current filter.
89 $filter = current_filter();
90
91 // Get args provided.
92 $args = func_get_args();
93
94 // Get variation information.
95 $variations = acf_get_store( 'hook-variations' )->get( $filter );
96 $index = $variations['index'];
97 $type = $variations['type'];
98 $variations = $variations['variations'];
99
100 // Find field in args using index.
101 $field = $args[ $index ];
102
103 // Loop over variations and apply filters.
104 foreach ( $variations as $variation ) {
105
106 // Get value from field.
107 // First look for "backup" value ("_name", "_key").
108 if ( isset( $field[ "_$variation" ] ) ) {
109 $value = $field[ "_$variation" ];
110 } elseif ( isset( $field[ $variation ] ) ) {
111 $value = $field[ $variation ];
112 } else {
113 continue;
114 }
115
116 // Apply filters.
117 if ( $type === 'filter' ) {
118 $args[0] = apply_filters_ref_array( "$filter/$variation=$value", $args );
119
120 // Or do action.
121 } else {
122 do_action_ref_array( "$filter/$variation=$value", $args );
123 }
124 }
125
126 // Return first arg.
127 return $args[0];
128 }
129
130 // Register store.
131 acf_register_store( 'deprecated-hooks' );
132
133 /**
134 * acf_add_deprecated_filter
135 *
136 * Registers a deprecated filter to run during the replacement.
137 *
138 * @date 25/1/19
139 * @since 5.7.11
140 *
141 * @param string $deprecated The deprecated hook.
142 * @param string $version The version this hook was deprecated.
143 * @param string $replacement The replacement hook.
144 * @return void
145 */
146 function acf_add_deprecated_filter( $deprecated, $version, $replacement ) {
147
148 // Store replacement data.
149 acf_get_store( 'deprecated-hooks' )->append(
150 array(
151 'type' => 'filter',
152 'deprecated' => $deprecated,
153 'replacement' => $replacement,
154 'version' => $version,
155 )
156 );
157
158 // Add generic handler.
159 // Use a priority of 10, and accepted args of 10 (ignored by WP).
160 add_filter( $replacement, '_acf_apply_deprecated_hook', 10, 10 );
161 }
162
163 /**
164 * acf_add_deprecated_action
165 *
166 * Registers a deprecated action to run during the replacement.
167 *
168 * @date 25/1/19
169 * @since 5.7.11
170 *
171 * @param string $deprecated The deprecated hook.
172 * @param string $version The version this hook was deprecated.
173 * @param string $replacement The replacement hook.
174 * @return void
175 */
176 function acf_add_deprecated_action( $deprecated, $version, $replacement ) {
177
178 // Store replacement data.
179 acf_get_store( 'deprecated-hooks' )->append(
180 array(
181 'type' => 'action',
182 'deprecated' => $deprecated,
183 'replacement' => $replacement,
184 'version' => $version,
185 )
186 );
187
188 // Add generic handler.
189 // Use a priority of 10, and accepted args of 10 (ignored by WP).
190 add_filter( $replacement, '_acf_apply_deprecated_hook', 10, 10 );
191 }
192
193 /**
194 * Applies a deprecated filter during apply_filters() or do_action().
195 *
196 * @date 25/1/19
197 * @since 5.7.11
198 *
199 * @param mixed
200 * @return mixed
201 */
202 function _acf_apply_deprecated_hook() {
203 // Get current hook.
204 $current_hook = current_filter();
205
206 // Get args provided.
207 $args = func_get_args();
208
209 // Get deprecated items for this hook.
210 $deprecated_hooks = acf_get_store( 'deprecated-hooks' )->query( array( 'replacement' => $current_hook ) );
211
212 // Loop over results.
213 foreach ( $deprecated_hooks as $hook ) {
214 // Check if anyone is hooked into this deprecated hook.
215 if ( isset( $hook['deprecated'] ) && has_filter( $hook['deprecated'] ) ) {
216
217 // Log warning.
218 // _deprecated_hook( $deprecated, $version, $hook );
219 // Apply the item/do the action.
220 if ( $hook['type'] === 'filter' ) {
221 $args[0] = apply_filters_ref_array( $hook['deprecated'], $args );
222 } else {
223 do_action_ref_array( $hook['deprecated'], $args );
224 }
225 }
226 }
227
228 // Return first arg.
229 return $args[0];
230 }
231