wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
wp_json_file_decode › WordPress Function
Seit5.9.0
Veraltetn/v
› wp_json_file_decode ( $filename, $options = array() )
Parameter: (2) |
|
Gibt zurück: |
|
Definiert in: |
|
Codex: |
Reads and decodes a JSON file.
Ähnliche Funktionen: wp_json_encode, wp_is_file_mod_allowed, wp_nonce_field, wp_filter_comment, wp_handle_sideload
Quellcode
function wp_json_file_decode( $filename, $options = array() ) { $result = null; $filename = wp_normalize_path( realpath( $filename ) ); if ( ! $filename ) { wp_trigger_error( __FUNCTION__, sprintf( /* translators: %s: Path to the JSON file. */ __( "File %s doesn't exist!" ), $filename ) ); return $result; } $options = wp_parse_args( $options, array( 'associative' => false ) ); $decoded_file = json_decode( file_get_contents( $filename ), $options['associative'] ); if ( JSON_ERROR_NONE !== json_last_error() ) { wp_trigger_error( __FUNCTION__, sprintf( /* translators: 1: Path to the JSON file, 2: Error message. */ __( 'Error when decoding a JSON file at path %1$s: %2$s' ), $filename, json_last_error_msg() ) ); return $result; } return $decoded_file; }