djavolak
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Gutenberg: Tags disappear on entryHi, we ran into this problem, and just could not believe that it is open for 2 years. I’ve read quite a few comments on github issues regarding this, and must say that can agree on some issues why this is postponed so long. Anyway, we are depending on the open source software, so either we get our hands dirty and help, or wait for someone else to do it ??
As the real solution is pretty complex, after some research I’ve came up with sort of a hack. The endpoint, being RESTful, is sending data about pagination in headers, so the solution to change headers seemed appropriate for our needs. Effectively, with this hack, we are only stopping the gutenberg core component used for scrolling pages via api to scroll all pages for chosen endpoint(s).
Since the only (real) problem with this (auto) loading occurs when you have A LOT of tags in database, intercepting headers only for tags endpoint did the trick for us.add_filter('rest_post_dispatch', 'testApi2', 5, 3); function testApi2(WP_HTTP_Response $wpResponse, WP_REST_Server $wpServer, WP_REST_Request $wpRequest) { if ($wpRequest->get_route() === '/wp/v2/tags') { $wpResponse->headers['X-WP-Total'] = 100; $wpResponse->headers['X-WP-TotalPages'] = 1; $wpResponse->headers['Link'] = ''; } return $wpResponse; }