WordPress.org

Make WordPress Core

Ticket #36510: 36510.2.patch

File 36510.2.patch, 1.1 KB (added by davidakennedy, 4 years ago)

Remove singular class if it exist, only in WordPress 4.4 and above.

  • wp-content/themes/twentyeleven/functions.php

     
    682682endif;
    683683
    684684/**
     685 * Only run this function in WordPress 4.4 or later.
     686 */
     687if ( version_compare( $GLOBALS['wp_version'], '4.4-alpha', '>' ) ) {
     688        /**
     689         * Removes singular class in WordPress 4.4 or later.
     690         *
     691         * Twenty Eleven adds it only where it needs it.
     692         *
     693         * @since Twenty Eleven 2.5
     694         *
     695         * @param array $classes Existing body classes.
     696         * @return array The filtered array of body classes.
     697         */
     698        function twentyeleven_remove_singular_class( $classes ) {
     699
     700                $index = array_search( 'singular', $classes );
     701                if ( false !== $index ) {
     702                        unset( $classes[ $index ] );
     703                }
     704
     705                return $classes;
     706        }
     707        add_filter( 'body_class', 'twentyeleven_remove_singular_class', 1 );
     708}
     709
     710/**
    685711 * Add two classes to the array of body classes.
    686712 *
    687713 * The first is if the site has only had one author with published posts.