WP_Font_Collection::load_from_json()
Loads font collection data from a JSON file or URL.
Метод класса: WP_Font_Collection{}
Хуков нет.
Возвращает
Массив|WP_Error
. An array containing the font collection data on success, else an instance of WP_Error on failure.
Использование
// private - только в коде основоного (родительского) класса $result = $this->load_from_json( $file_or_url );
- $file_or_url(строка) (обязательный)
- File path or URL to a JSON file containing the font collection data.
Список изменений
С версии 6.5.0 | Введена. |
Код WP_Font_Collection::load_from_json() WP Font Collection::load from json WP 6.7.1
private function load_from_json( $file_or_url ) { $url = wp_http_validate_url( $file_or_url ); $file = file_exists( $file_or_url ) ? wp_normalize_path( realpath( $file_or_url ) ) : false; if ( ! $url && ! $file ) { // translators: %s: File path or URL to font collection JSON file. $message = __( 'Font collection JSON file is invalid or does not exist.' ); _doing_it_wrong( __METHOD__, $message, '6.5.0' ); return new WP_Error( 'font_collection_json_missing', $message ); } $data = $url ? $this->load_from_url( $url ) : $this->load_from_file( $file ); if ( is_wp_error( $data ) ) { return $data; } $data = array( 'name' => $this->data['name'], 'font_families' => $data['font_families'], ); if ( isset( $this->data['description'] ) ) { $data['description'] = $this->data['description']; } if ( isset( $this->data['categories'] ) ) { $data['categories'] = $this->data['categories']; } return $data; }