Pods: 'рдореАрдбрд┐рдпрд╛' рдкреНрд░рдХрд╛рд░ рдХрд╛ рдкреЙрдб рдПрдХреНрд╕рдЯреЗрдВрд╢рди JSON API рдореЗрдВ рдЦрд╛рд▓реА рдлрд╝реАрд▓реНрдб рд▓реМрдЯрд╛рддрд╛ рд╣реИ

рдХреЛ рдирд┐рд░реНрдорд┐рдд 4 рдордИ 2018  ┬╖  3рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ  ┬╖  рд╕реНрд░реЛрдд: pods-framework/pods

рд╕рдорд╕реНрдпрд╛ рдЕрд╡рд▓реЛрдХрди

рдПрдХ рдирдпрд╛ рдкреЙрдб рдмрдирд╛рдпрд╛ рдЬреЛ 'рдореАрдбрд┐рдпрд╛' рдкреНрд░рдХрд╛рд░ рдХрд╛ рд╡рд┐рд╕реНрддрд╛рд░ рд╣реИред рдПрдкреАрдЖрдИ рдореЗрдВ рдХрд╕реНрдЯрдо рдлрд╝реАрд▓реНрдб рд▓реМрдЯрд╛рдП рдЬрд╛рддреЗ рд╣реИрдВ, рд▓реЗрдХрд┐рди рд╕рднреА рдорд╛рди false ред

рдЕрдкреЗрдХреНрд╖рд┐рдд рд╡реНрдпрд╡рд╣рд╛рд░

JSON рдлрд╝реАрд▓реНрдб рд╡рд░реНрдбрдкреНрд░реЗрд╕ рдЗрдВрдЯрд░рдлрд╝реЗрд╕ рдореЗрдВ рдкрд░рд┐рднрд╛рд╖рд┐рдд рдорд╛рдиреЛрдВ рд╕реЗ рднрд░реЗ рд╣реБрдП рд╣реИрдВред

рд╡рд░реНрддрдорд╛рди рд╡реНрдпрд╡рд╣рд╛рд░

JSON рдкреНрд░рддрд┐рдХреНрд░рд┐рдпрд╛ рдореЗрдВ рдирдП рдлрд╝реАрд▓реНрдб рд▓реМрдЯрд╛рдП рдЬрд╛ рд░рд╣реЗ рд╣реИрдВ, рд▓реЗрдХрд┐рди рд╕рднреА рдорд╛рди false ред

рд╕рдВрднрд╛рд╡рд┐рдд рд╕реНрдерд┐рддрд┐

рдореИрдВ рдЖрдВрддрд░рд┐рдХ рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ рдХреБрдЫ рдирд╣реАрдВ рдЬрд╛рдирддрд╛ред

рдкреБрдирд░реБрддреНрдкрд╛рджрди рдХреЗ рд▓рд┐рдП рдХрджрдо (рдмрдЧ рдХреЗ рд▓рд┐рдП)

  1. рдПрдХ рдирдпрд╛ рдкреЙрдб рдмрдирд╛рдПрдВ рдЬреЛ Media рддрдХ рдлреИрд▓рд╛ рд╣реЛред
  2. рдПрдХ рдирдпрд╛ рдХрд╕реНрдЯрдо рдЯреЗрдХреНрд╕реНрдЯ рдлрд╝реАрд▓реНрдб рдЬреЛрдбрд╝реЗрдВред рдореИрдВ "рд╕реНрдЯреНрд░рд┐рдВрдЧ" рдФрд░ "рд╡реЗрдм рдкрддрд╛" рдкреНрд░рдХрд╛рд░ рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░ рд░рд╣рд╛ рдерд╛ред
  3. рдЗрдВрдЯрд░рдлрд╝реЗрд╕ рдореЗрдВ JSON API рд╕рдХреНрд╖рдо рдХрд░реЗрдВред
  4. рдореАрдбрд┐рдпрд╛ рдСрдмреНрдЬреЗрдХреНрдЯ рдХреЛ рд╡рд╛рдкрд╕ рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдПрдХ рдПрдкреАрдЖрдИ рдЕрдиреБрд░реЛрдз рдХрд░реЗрдВред
  5. рдлрд╝реАрд▓реНрдб рдореМрдЬреВрдж рд╣реИрдВ, рд▓реЗрдХрд┐рди рдЦрд╛рд▓реА рд╣реИрдВ.

рдкреЙрдбреНрд╕ рдкреИрдХреЗрдЬ рдПрдХреНрд╕рдкреЛрд░реНрдЯ (рд╕рд╣рд╛рдпрдХ!)




{"meta":{"version":"2.7.1","build":1525445607},"pods":{"73":{"id":73,"name":"media","label":"Media","description":"","type":"media","storage":"meta","object":"media","alias":"","fields":{"author_name":{"id":74,"name":"author_name","label":"Author Name","description":"Name of the author","help":"","class":"","type":"text","weight":0,"pick_object":"","pick_val":"","sister_id":"","required":"1","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"1","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","text_repeatable":"0","text_placeholder":""},"license_name":{"id":75,"name":"license_name","label":"License Name","description":"Name of the use license","help":"","class":"","type":"text","weight":1,"pick_object":"","pick_val":"","sister_id":"","required":"1","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"1","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","text_repeatable":"0","text_placeholder":""},"license_url":{"id":76,"name":"license_url","label":"License URL","description":"URL to the use license","help":"","class":"","type":"website","weight":2,"pick_object":"","pick_val":"","sister_id":"","required":"0","website_format":"normal","website_allow_port":"0","website_clickable":"0","website_new_window":"0","website_max_length":"255","website_html5":"0","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"1","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","website_repeatable":"0","website_placeholder":""},"media_source_url":{"id":77,"name":"media_source_url","label":"Source URL","description":"URL where the image was originally taken from.","help":"","class":"","type":"website","weight":3,"pick_object":"","pick_val":"","sister_id":"","required":"0","website_format":"normal","website_allow_port":"0","website_clickable":"0","website_new_window":"0","website_max_length":"255","website_html5":"0","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"1","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","website_repeatable":"0","website_placeholder":""}},"show_in_menu":1,"rest_enable":"1","read_all":"1","write_all":"0"},"52":{"id":52,"name":"resource-link","label":"Resource Links","description":"","type":"post_type","storage":"meta","object":"","alias":"","fields":{"resource_url":{"id":53,"name":"resource_url","label":"Resource URL","description":"A link to a resource.","help":"","class":"","type":"website","weight":0,"pick_object":"","pick_val":"","sister_id":"","required":"1","website_format":"normal","website_allow_port":"1","website_clickable":"1","website_new_window":"1","website_max_length":"255","website_html5":"0","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"1","rest_write":"1","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","website_repeatable":"0","website_placeholder":""},"resource_blurb":{"id":54,"name":"resource_blurb","label":"Resource Blurb","description":"A short description of the resource.","help":"","class":"","type":"text","weight":1,"pick_object":"","pick_val":"","sister_id":"","required":"1","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"1","rest_write":"1","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","text_repeatable":"0","text_placeholder":""},"resource_name":{"id":55,"name":"resource_name","label":"Resource Name","description":"A title or heading for the resource.","help":"","class":"","type":"text","weight":2,"pick_object":"","pick_val":"","sister_id":"","required":"1","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"1","rest_write":"1","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","text_repeatable":"0","text_placeholder":""},"category":{"id":59,"name":"category","label":"Category","description":"Resource category","help":"","class":"","type":"pick","weight":3,"pick_object":"taxonomy","pick_val":"category","sister_id":"","required":"0","pick_format_type":"multi","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"1","rest_write":"1","rest_pick_response":"id","rest_pick_depth":"2","unique":"0","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""},"resource_author":{"id":60,"name":"resource_author","label":"Resource Author","description":"The resource author.","help":"","class":"","type":"pick","weight":4,"pick_object":"user","pick_val":"","sister_id":"","required":"0","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"0","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"1","rest_write":"1","rest_pick_response":"id","rest_pick_depth":"2","unique":"0","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""},"resource_image":{"id":61,"name":"resource_image","label":"Resource Image","description":"An icon or image for the resource.","help":"","class":"","type":"pick","weight":5,"pick_object":"media","pick_val":"","sister_id":"","required":"0","pick_format_type":"single","pick_format_single":"list","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"1","rest_write":"0","rest_pick_response":"id","rest_pick_depth":"2","unique":"0","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""}},"show_in_menu":"1","label_singular":"Resource Link","public":"1","show_ui":"1","supports_title":"1","supports_editor":"1","publicly_queryable":"1","exclude_from_search":"0","capability_type":"post","capability_type_custom":"resource-link","capability_type_extra":"1","has_archive":"0","hierarchical":"0","rewrite":"1","rewrite_with_front":"1","rewrite_feeds":"0","rewrite_pages":"1","query_var":"1","can_export":"1","default_status":"draft","supports_author":"0","supports_thumbnail":"0","supports_excerpt":"0","supports_trackbacks":"0","supports_custom_fields":"0","supports_comments":"0","supports_revisions":"0","supports_page_attributes":"0","supports_post_formats":"0","built_in_taxonomies_category":"0","built_in_taxonomies_link_category":"0","built_in_taxonomies_post_tag":"0","show_in_nav_menus":"1","show_in_admin_bar":"1","pfat_enable":"0","pfat_run_outside_loop":"0","pfat_append_single":"append","pfat_filter_single":"the_content","pfat_append_archive":"append","pfat_filter_archive":"the_content","rest_enable":"1","read_all":"1","write_all":"1"}}}

рд╕рдВрдмрдВрдзрд┐рдд рдореБрджреНрджреЗ рдФрд░/рдпрд╛ рдкреАрдЖрд░

рд╕рдм

  • [] рдкрд░реАрдХреНрд╖рдг
  • [ ] рджрд╕реНрддрд╛рд╡реЗрдЬрд╝реАрдХрд░рдг

рд╡рд░реНрдбрдкреНрд░реЗрд╕ рдкрд░реНрдпрд╛рд╡рд░рдг

WordPress Version: 4.9.5

PHP Version: 7.0.10

MySQL Version: 5.5.56

Server Software: Apache/2.4.27 (Red Hat) PHP/7.0.10

Your User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1 Safari/605.1.15

Session Save Path: /var/opt/rh/rh-php70/lib/php/session

Session Save Path Exists: Yes

Session Save Path Writeable: Yes

Session Max Lifetime: 1440

Opcode Cache:

Apc: No
Memcached: No
OPcache: No
Redis: No
Object Cache:

APC: No
APCu: No
Memcache: No
Memcached: No
Redis: No
WPDB Prefix: wp_

WP Multisite Mode: No

WP Memory Limit: 40M

Pods Network-Wide Activated: No

Pods Install Location: /opt/rh/httpd24/root/var/www/html/wordpress/wp-content/plugins/pods/

Pods Tableless Mode Activated: No

Pods Light Mode Activated: No

Currently Active Theme: Twenty Seventeen

Currently Active Plugins:

Akismet Anti-Spam: 4.0.3
FG Drupal to WordPress: 1.58.0
Pods - Custom Content Types and Fields: 2.7.1

REST API Need Reproduction Bug

рд╕рднреА 3 рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ

рдореБрдЭреЗ рд╡рд╣реА рдореБрджреНрджрд╛ рдорд┐рд▓ рд░рд╣рд╛ рд╣реИред рдХреЛрд╢рд┐рд╢ рдХрд░рдиреЗ рдЬрд╛ рд░рд╣реЗ рд╣реИрдВ рдФрд░ рдпрд╣ рдкрддрд╛ рд▓рдЧрд╛рдПрдВ рдХрд┐ рдЗрд╕реЗ рдХреИрд╕реЗ рдареАрдХ рдХрд┐рдпрд╛ рдЬрд╛рдП ...

рдмрд╕ рдЕрдЧрд░ рдХреЛрдИ рдФрд░ рдЗрд╕ рдореБрджреНрджреЗ рдХреЛ рд╣рд┐рдЯ рдХрд░рддрд╛ рд╣реИред рдореБрдЭреЗ рдкрддрд╛ рд╣реИ рдХрд┐ рдпрд╣ рд╕реБрдВрджрд░ рдирд╣реАрдВ рд╣реИ, рд▓реЗрдХрд┐рди рдЗрд╕ рджреМрд░рд╛рди рдореИрдВрдиреЗ рдЗрд╕реЗ рдЕрдкрдиреЗ рдкреНрд▓рдЧрдЗрди рдореЗрдВ рдХреИрд╕реЗ рд╣рд▓ рдХрд┐рдпрд╛:

function get_media_fields($row)
{
    if ($row["type"] == "attachment")
    {
        $pod = pods("media", $row["id"]);
        foreach ($pod->fields() as $field)
        {
            $name = $field['name'];
            $meta = $pod->display($name, true);
            $row[$name] = $meta;
        }

    }
    return $row;

}

function rest_request_after_callbacks( $response, $handler, $request )
{
    if (strpos($request->get_route(), "/wp/v2/media") === FALSE)
        return $response;

    if (array_key_exists("X-WP-Total", $response->headers))
    {
        for ($i=0; $i < count($response->data); $i++)
        {
            $response->data[$i] = self::get_media_fields( $response->data[$i] );
        }
    }
    else
        $response->data = self::get_media_fields( $response->data );

    return $response;
}
add_filter( 'rest_request_after_callbacks', 'rest_request_after_callbacks', 20, 3);

рдирдорд╕реНрддреЗ,
рдореБрджреНрджрд╛ рдЕрднреА рднреА рдЬрд╛рд░реА рд╣реИред
рдореИрдВ рдЗрд╕рдХрд╛ рд╕рд╛рдордирд╛ рдХрд░ рд░рд╣рд╛ рд╣реВрдВ,
@nielo рд╡рд┐рдзрд┐ рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рдХреЗ, рдПрдкреАрдЖрдИ рдореЗрдВ
рдЗрд╕реЗ рд▓рдЧрднрдЧ рдПрдХ рд╕рд╛рд▓ рд╣реЛ рдЧрдпрд╛ рд╣реИред

рдХреНрдпрд╛ рдпрд╣ рдкреГрд╖реНрда рдЙрдкрдпреЛрдЧреА рдерд╛?
0 / 5 - 0 рд░реЗрдЯрд┐рдВрдЧреНрд╕

рд╕рдВрдмрдВрдзрд┐рдд рдореБрджреНрджреЛрдВ

PodsBot picture PodsBot  ┬╖  4рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ

jcampbell05 picture jcampbell05  ┬╖  5рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ

garypaul picture garypaul  ┬╖  7рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ

sc0ttkclark picture sc0ttkclark  ┬╖  4рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ

jnaklaas picture jnaklaas  ┬╖  3рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ