Skip to content

Instantly share code, notes, and snippets.

@figureone
Created November 2, 2020 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save figureone/66fb7004596dc611ae7b3165193461ac to your computer and use it in GitHub Desktop.
Save figureone/66fb7004596dc611ae7b3165193461ac to your computer and use it in GitHub Desktop.
Difference in includes/acf-meta-functions.php between ACF version 5.9.1 and 5.9.2
diff --git a/includes/acf-meta-functions.php b/includes/acf-meta-functions.php
index 1d26f03..9e8c81a 100644
--- a/includes/acf-meta-functions.php
+++ b/includes/acf-meta-functions.php
@@ -196,14 +196,12 @@ function acf_get_metadata( $post_id = 0, $name = '', $hidden = false ) {
return null;
}
- // Check option.
- if( $type === 'option' ) {
- return get_option( "{$prefix}{$id}_{$name}", null );
-
- // Check meta.
- } else {
- $meta = get_metadata( $type, $id, "{$prefix}{$name}", false );
+ // Determine CRUD function.
+ if( function_exists("get_{$type}_meta") ) {
+ $meta = call_user_func("get_{$type}_meta", $id, "{$prefix}{$name}", false);
return isset($meta[0]) ? $meta[0] : null;
+ } else {
+ return get_option( "{$prefix}{$id}_{$name}", null );
}
}
@@ -240,17 +238,14 @@ function acf_update_metadata( $post_id = 0, $name = '', $value = '', $hidden = f
return false;
}
- // Update option.
- if( $type === 'option' ) {
-
+ // Determine CRUD function.
+ if( function_exists("update_{$type}_meta") ) {
+ return call_user_func("update_{$type}_meta", $id, "{$prefix}{$name}", $value);
+ } else {
// Unslash value to match update_metadata() functionality.
$value = wp_unslash( $value );
$autoload = (bool) acf_get_setting('autoload');
return update_option( "{$prefix}{$id}_{$name}", $value, $autoload );
-
- // Update meta.
- } else {
- return update_metadata( $type, $id, "{$prefix}{$name}", $value );
}
}
@@ -286,14 +281,12 @@ function acf_delete_metadata( $post_id = 0, $name = '', $hidden = false ) {
return false;
}
- // Update option.
- if( $type === 'option' ) {
+ // Determine CRUD function.
+ if( function_exists("delete_{$type}_meta") ) {
+ return call_user_func("delete_{$type}_meta", $id, "{$prefix}{$name}");
+ } else {
$autoload = (bool) acf_get_setting('autoload');
return delete_option( "{$prefix}{$id}_{$name}" );
-
- // Update meta.
- } else {
- return delete_metadata( $type, $id, "{$prefix}{$name}" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment