acf_get_option_meta() ACF 5.8.0
Returns an array of meta for the given wp_option name prefix in the same format as get_post_meta().
Хуков нет.
Возвращает
Массив.
Использование
acf_get_option_meta( $prefix );
- $prefix(строка)
- The wp_option name prefix.
Список изменений
С версии 5.8.0 | Введена. |
Код acf_get_option_meta() acf get option meta ACF 5.9.1
function acf_get_option_meta( $prefix = '' ) {
// Globals.
global $wpdb;
// Vars.
$meta = array();
$search = "{$prefix}_%";
$_search = "_{$prefix}_%";
// Escape underscores for LIKE.
$search = str_replace('_', '\_', $search);
$_search = str_replace('_', '\_', $_search);
// 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;
}