acf_get_option_meta()
acf_get_option_meta
Returns an array of meta for the given wp_option name prefix in the same format as get_post_meta().
Хуков нет.
Возвращает
array.
Использование
acf_get_option_meta( $prefix );
- $prefix(строка)
- The wp_option name prefix.
По умолчанию:''
Список изменений
| С версии 5.8.0 | Введена. |
Код acf_get_option_meta() acf get option meta ACF 6.8.8
function acf_get_option_meta( $prefix = '' ) {
// Globals.
global $wpdb;
// Vars.
$meta = array();
$search = $wpdb->esc_like( "{$prefix}_" ) . '%';
$_search = $wpdb->esc_like( "_{$prefix}_" ) . '%';
// Query database for results.
$rows = $wpdb->get_results(
$wpdb->prepare(
"SELECT *
FROM $wpdb->options
WHERE option_name LIKE %s
OR option_name LIKE %s",
$search,
$_search
),
ARRAY_A
);
// Loop over results and append meta (removing the $prefix from the option name).
$len = strlen( "{$prefix}_" );
foreach ( $rows as $row ) {
$meta[ substr( $row['option_name'], $len ) ][] = $row['option_value'];
}
// Return results.
return $meta;
}