acf_decode_choices()
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
acf_decode_choices( $string, $array_keys );
- $string **
- -
По умолчанию: '' - $array_keys **
- -
По умолчанию: false
Код acf_decode_choices() acf decode choices ACF 6.0.4
function acf_decode_choices( $string = '', $array_keys = false ) { // bail early if already array if ( is_array( $string ) ) { return $string; // allow numeric values (same as string) } elseif ( is_numeric( $string ) ) { // do nothing // bail early if not a string } elseif ( ! is_string( $string ) ) { return array(); // bail early if is empty string } elseif ( $string === '' ) { return array(); } // vars $array = array(); // explode $lines = explode( "\n", $string ); // key => value foreach ( $lines as $line ) { // vars $k = trim( $line ); $v = trim( $line ); // look for ' : ' if ( acf_str_exists( ' : ', $line ) ) { $line = explode( ' : ', $line ); $k = trim( $line[0] ); $v = trim( $line[1] ); } // append $array[ $k ] = $v; } // return only array keys? (good for checkbox default_value) if ( $array_keys ) { return array_keys( $array ); } // return return $array; }