Gallery Settings Change available Columns

Short answer

Simple as things sometimes are: No this is not possible. The whole part is hard coded.

Long answer (not recommended to do so)

You could maybe jump into the esc_html and attribute_escape filters and just return empty there *), but as those are pretty generic names and would possibly also interfere with other filter results and therefore break other things.

<?php
/* Plugin Name: (#82379) Empty Media options */
add_filter( 'image_size_names_choose', 'wpse82379_esc_attr' );
function wpse82379_trigger_filter( $sizes )
{
    if ( 'post' !== get_current_screen()->post )
        return $safe_text;

    add_filter( 'attribute_escape', 'wpse82379_esc_attr', 10, 2 );
    add_filter( 'esc_html', 'wpse82379_esc_attr', 10, 2 );

    return $sizes;
}
function wpse82379_esc_attr( $safe_text, $text )
{
    if ( ! in_array( absint( $text ), range( 6, 9 ) ) )
        return $safe_text;

    static $counter = 0;
    $static++;

    // 
    if ( 1 === $static )
    {
        ob_start();
        return $safe_text;
    }
    if ( in_array( $static, array( 7, 9 ) ) )
    {
        remove_filter( current_filter(), __FUNCTION__ );
        if ( 'esc_html' === current_filter() )
        {
            $html = ob_get_contents();
            ob_end_clean();
            // In case you want to alter the layout, rework $html and return it
            return '';
        }
    }

    return $safe_text;
}

As the escape-filters are present nearly everywhere, it’s not really recommended to use them in production (like with the gettext-filters). They trigger on every escape (which are hundreds per page) and can really slow down your system.

Internals and performance

To work against this, I’ve used the filter that runs last before the HTML script output to add the callbacks as late as possible. Then I abort as often as possible to not trigger this plugins filters on any other page than the post “add new” screen. After checking the source files HTML, I can see that with version 3.5 we only have two calls for esc_attr_e()(which internally triggers esc_attr and therefore our filters), but with two strings, so we can safely abort on those. When we finally reach our filters I return an empty string and then instantly remove the filter to not trigger for any later calls.

This is the best you can achieve.

EDIT

After thinking about it, I used ob caching – not beautiful, but it should work (unless I counted wrong). Note: This is coded while writing and thinking, so it’s not tested. You’ll have to confirm if it works or not.

Final note: You’ll have to recheck this plugin after each following version (starting with WP v3.6) to make sure the markup hasn’t changed and it’s still working as expected.

*) This would leave you with empty strings. In other words: They would still be there but non-functional and empty (no string).

Leave a Comment