Yoast\WP\SEO\Surfaces\Values
Meta::create_json_field()
Converts a presenter's key and value to JSON.
Метод класса: Meta{}
Хуков нет.
Возвращает
Объект|null
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->create_json_field( $presenter );
- $presenter(Abstract_Indexable_Presenter) (обязательный)
- The presenter whose key and value are to be converted to JSON.
Код Meta::create_json_field() Meta::create json field Yoast 22.4
protected function create_json_field( $presenter ) { if ( $presenter->get_key() === 'NO KEY PROVIDED' ) { return null; } $value = $presenter->get(); if ( empty( $value ) ) { return null; } return (object) [ 'key' => $presenter->escape_key(), 'value' => $value, ]; }