wp_xmlrpc_server::_prepare_post_type()
Prepares post data for return in an XML-RPC object.
Метод класса: wp_xmlrpc_server{}
Хуки из метода
Возвращает
Массив
. The prepared post type data.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->_prepare_post_type( $post_type, $fields );
- $post_type(WP_Post_Type) (обязательный)
- Post type object.
- $fields(массив) (обязательный)
- The subset of post fields to return.
Список изменений
С версии 3.4.0 | Введена. |
С версии 4.6.0 | Converted the $post_type parameter to accept a WP_Post_Type object. |
Код wp_xmlrpc_server::_prepare_post_type() wp xmlrpc server:: prepare post type WP 6.6.2
protected function _prepare_post_type( $post_type, $fields ) { $_post_type = array( 'name' => $post_type->name, 'label' => $post_type->label, 'hierarchical' => (bool) $post_type->hierarchical, 'public' => (bool) $post_type->public, 'show_ui' => (bool) $post_type->show_ui, '_builtin' => (bool) $post_type->_builtin, 'has_archive' => (bool) $post_type->has_archive, 'supports' => get_all_post_type_supports( $post_type->name ), ); if ( in_array( 'labels', $fields, true ) ) { $_post_type['labels'] = (array) $post_type->labels; } if ( in_array( 'cap', $fields, true ) ) { $_post_type['cap'] = (array) $post_type->cap; $_post_type['map_meta_cap'] = (bool) $post_type->map_meta_cap; } if ( in_array( 'menu', $fields, true ) ) { $_post_type['menu_position'] = (int) $post_type->menu_position; $_post_type['menu_icon'] = $post_type->menu_icon; $_post_type['show_in_menu'] = (bool) $post_type->show_in_menu; } if ( in_array( 'taxonomies', $fields, true ) ) { $_post_type['taxonomies'] = get_object_taxonomies( $post_type->name, 'names' ); } /** * Filters XML-RPC-prepared date for the given post type. * * @since 3.4.0 * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object. * * @param array $_post_type An array of post type data. * @param WP_Post_Type $post_type Post type object. */ return apply_filters( 'xmlrpc_prepare_post_type', $_post_type, $post_type ); }