Dopo aver cercato in vari repository e forum su Internet, abbiamo finalmente trovato la risoluzione che condivideremo con voi in seguito.
Recupera tutti i campi meta registrati.
Restituzione
(array) Campi registrati.
Fonte
File: wp-includes/rest-api/fields/class-wp-rest-meta-fields.php
protectedfunctionget_registered_fields(){$registered=array();$meta_type=$this->get_meta_type();$meta_subtype=$this->get_meta_subtype();$meta_keys=get_registered_meta_keys($meta_type);if(!empty($meta_subtype)){$meta_keys=array_merge($meta_keys,get_registered_meta_keys($meta_type,$meta_subtype));}foreach($meta_keysas$name=>$args){if(empty($args['show_in_rest'])){continue;}$rest_args=array();if(is_array($args['show_in_rest'])){$rest_args=$args['show_in_rest'];}$default_args=array('name'=>$name,'single'=>$args['single'],'type'=>!empty($args['type'])?$args['type']:null,'schema'=>array(),'prepare_callback'=>array($this,'prepare_value'),);$default_schema=array('type'=>$default_args['type'],'description'=>empty($args['description'])?'':$args['description'],'default'=>isset($args['default'])?$args['default']:null,);$rest_args=array_merge($default_args,$rest_args);$rest_args['schema']=array_merge($default_schema,$rest_args['schema']);$type=!empty($rest_args['type'])?$rest_args['type']:null;$type=!empty($rest_args['schema']['type'])?$rest_args['schema']['type']:$type;if(null===$rest_args['schema']['default']){$rest_args['schema']['default']=static::get_empty_value_for_type($type);}$rest_args['schema']=rest_default_additional_properties_to_false($rest_args['schema']);if(!in_array($type,array('string','boolean','integer','number','array','object'),true)){continue;}if(empty($rest_args['single'])){$rest_args['schema']=array('type'=>'array','items'=>$rest_args['schema'],);}$registered[$name]=$rest_args;}return$registered;}
Correlato
Utilizzi
Usi | Descrizione |
---|---|
wp-includes/rest-api.php: rest_default_additional_properties_to_false() |
Imposta le "additionalProperties" a false per tutte le definizioni di oggetti nello schema. |
wp-includes/rest-api/fields/class-wp-rest-meta-fields.php: WP_REST_Meta_Fields::get_meta_subtype() |
Recupera il sottotipo di meta oggetto. |
wp-includes/rest-api/fields/class-wp-rest-meta-fields.php: WP_REST_Meta_Fields::get_meta_type() |
Recupera il meta-tipo dell'oggetto. |
wp-includes/meta.php: get_registered_meta_keys() |
Recupera un elenco di meta-chiavi registrate per un tipo di oggetto. |
Usato da
Usato da | Descrizione |
---|---|
wp-includes/rest-api/fields/class-wp-rest-meta-fields.php: WP_REST_Meta_Fields::is_meta_value_same_as_stored_value() |
Verifica se il valore fornito dall'utente è equivalente a un valore memorizzato per la meta-chiave data. |
wp-includes/rest-api/fields/class-wp-rest-meta-fields.php: WP_REST_Meta_Fields::get_field_schema() |
Recupera il meta schema dell'oggetto, conforme a JSON Schema. |
wp-includes/rest-api/fields/class-wp-rest-meta-fields.php: WP_REST_Meta_Fields::update_value() |
Aggiorna i valori dei meta. |
wp-includes/rest-api/fields/class-wp-rest-meta-fields.php: WP_REST_Meta_Fields::get_value() |
Recupera il valore del meta-campo. |
Changelog
Versione | Descrizione |
---|---|
4.7.0 | Introdotto. |
Se sei d'accordo, hai il potere di lasciare una divisione su ciò che ti ha colpito di questo saggio.