Making WordPress.org

Changeset 6882


Ignore:
Timestamp:
03/15/2018 11:26:52 PM (7 years ago)
Author:
iandunn
Message:

WP15: Enable the Additional CSS section for convenience.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wp15.wordpress.net/public_html/content/mu-plugins/miscellaneous.php

    r6847 r6882  
    1414defined( 'WPINC' ) or die();
    1515
     16add_filter( 'map_meta_cap',  __NAMESPACE__ . '\allow_css_editing', 10, 2   );
    1617add_filter( 'tggr_end_date', __NAMESPACE__ . '\set_tagregator_cutoff_date' );
     18
     19
     20/**
     21 * Allow admins to use Additional CSS, despite `DISALLOW_UNFILTERED_HTML`.
     22 *
     23 * The admins on this site are trusted, so `DISALLOW_UNFILTERED_HTML` is mostly in place to enforce best practices,
     24 * -- like placing JavaScript in a plugin instead of `post_content` -- rather than to prevent malicious code. CSS
     25 * is an exception to that rule, though; it's perfectly acceptable to store minor tweaks in Additional CSS, that's
     26 * what it's for.
     27 *
     28 * @param array  $required_capabilities The primitive capabilities that are required to perform the requested meta
     29 *                                      capability.
     30 * @param string $requested_capability  The requested meta capability.
     31 *
     32 * @return array
     33 */
     34function allow_css_editing( $required_capabilities, $requested_capability ) {
     35    if ( 'edit_css' === $requested_capability ) {
     36        $required_capabilities = array( 'edit_theme_options' );
     37    }
     38
     39    return $required_capabilities;
     40}
    1741
    1842/**
Note: See TracChangeset for help on using the changeset viewer.