Allow unfiltered HTML in titles for low level users?

How can the unfiltered_html capability be given to non network admins in a multisite install to allow HTML in titles?

In wp-includes/capabilities.php (below) it appears that this capability can not be given to non super_admins.

case 'unfiltered_html':
        // Disallow unfiltered_html for all users, even admins and super admins.
        if ( defined('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML ) {
            $caps[] = 'do_not_allow';
            break;
        }
        // Fall through if not DISALLOW_UNFILTERED_HTML
    case 'delete_user':
    case 'delete_users':
        // If multisite these caps are allowed only for super admins.
        if ( is_multisite() && !is_super_admin() )
            $caps[] = 'do_not_allow';
        else
            $caps[] = $cap;
        break;

Is this possible without removing all html filtering or committing the dirty deed?

Use Case:

Editors and writers are demanding the ability to use <br/> tags in titles to split into 2 or 3 lines when needed.

Current Workaround:

Alternate title metabox that replaces the_title on front end when filled in. (It’s confusing the writers)

Easier Solution:

Give them super admin access (publisher will not allow)

2 Answers
2

Set it up so that your editors and writers use the default title as the first line and add a metabox for a subtitle that will output the other lines as separate lines. This will require a theme adjustment if you want them all included in the h1 header tag. With some adjustments to the admin theme you can get this metabox placed under the title entry field, which should help reduce confusion.

The way WordPress prevents HTML from titles isn’t able to be overridden. It’s possible only if you hack the core but, even then, it creates a lot of strange problems. Feeds can’t handle HTML in titles and the permalinks behave wierdly unless you rewrite the permalink functions. Leaving the default title alone and using custom fields is the way to go.

Leave a Comment