[wp-trac] [WordPress Trac] #34981: Usage of `image_size_names_choose` breaks JS attachment model attributes
WordPress Trac
noreply at wordpress.org
Sun Aug 21 15:52:33 UTC 2016
#34981: Usage of `image_size_names_choose` breaks JS attachment model attributes
----------------------------------+--------------------
Reporter: dnaber-de | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.7
Component: Media | Version: 4.3.1
Severity: normal | Resolution:
Keywords: has-patch needs-docs | Focuses:
----------------------------------+--------------------
Comment (by dnaber-de):
Using function and method names for a context isn't a good idea IMO. It
ties the filter (and thus the filtering code) to where it is actually
called. That makes refactorings of the code almost impossible in a sane
way. If you want to refactor
`Custom_Background::wp_set_background_image()` later, you'll have to keep
the second parameter to the value
`'Custom_Background::wp_set_background_image'`.
The method itself is marked as deprecated so a refactoring is likely:
{{{#!php
/**
*
* @since 3.4.0
* @deprecated 3.5.0
*/
}}}
I think we need to declare concrete contexts and name them independently
of where the contexts apply. A comparable situation is the context
parameter or `sanitize_post()`.
I see actually only two contexts here:
* the select form elements (that one, the filter was originally meant
for) in WordPress core's media modal views (another differentiation of
these could also be done via JavaScript).
* the data sanitizing for JS APIs in `wp_prepare_attachment_for_js()`.
(However, all this is just a hack-ish workaround for backward
compatibility. I see no reason why `wp_prepare_attachment_for_js()` should
apply this filter anyway.)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34981#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list