[wp-trac] [WordPress Trac] #38342: Quick Draft: Leverage REST API endpoints
WordPress Trac
noreply at wordpress.org
Wed Mar 22 21:12:25 UTC 2017
#38342: Quick Draft: Leverage REST API endpoints
-------------------------------------+-------------------------------------
Reporter: adamsilverstein | Owner: joehoyle
Type: enhancement | Status: assigned
Priority: normal | Milestone: Future Release
Component: Administration | Version:
Severity: normal | Resolution:
Keywords: has-patch 4.8-early | Focuses: accessibility,
needs-refresh has-unit-tests | javascript, rest-api
-------------------------------------+-------------------------------------
Comment (by adamsilverstein):
In [attachment:38342.6.diff]
* Include wp-hooks library from #21170
* Remove PHP side back compat hook handling for
`dashboard_recent_drafts_query_args`
* Add new JavaScript filter for `dashboard_recent_drafts_fetch_args`
* Don't refocus title after new draft creation, as per
[https://core.trac.wordpress.org/ticket/38342#comment:85 @afercia's
comment]
With this change, instead of supporting the previous PHP filter, we
provide a new way to filter the query used for the list view. Developers
who previously filtered the query used for the post list with
`dashboard_recent_drafts_query_args` must now use the JavaScript filter
`dashboard_recent_drafts_fetch_args` to achieve the same results.
For the earlier example PHP filter:
{{{
add_filter(
'dashboard_recent_drafts_query_args',
function( $query_args ) {
$query_args['posts_per_page'] = 10;
return $query_args;
}
);
}}}
Becomes this in JavaScript:
{{{
wp.hooks.addFilter(
'dashboard_recent_drafts_fetch_args',
function( $args ) {
$args['per_page'] = 10;
return $args;
}
);
}}}
I itried to keep the filter naming similar, looking at it now though I'm
tempted to change the filter to camel case as in
`dashboardRecentDraftsFetchArgs` which also makes it clearer this is a JS
filter by the name alone.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38342#comment:91>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list