• Iam trying to make a multisite website where i can use unfiltered html on pages

    i added this code to a custom theme

    add_action( 'admin_init', 'my_kses_remove_filters' );
    function my_kses_remove_filters() {
        $current_user = wp_get_current_user();
     
        if ( my_user_has_role( 'administrator', $current_user ) )
            kses_remove_filters();
    }
     
    function my_user_has_role( $role="", $user = null ) {
        $user = $user ? new WP_User( $user ) : wp_get_current_user();
     
        if ( empty( $user->roles ) )
            return;
     
        if ( in_array( $role, $user->roles ) )
            return true;
     
        return;
    }

    It just adds random <br> tags into the code on the frontend and it adds this to the body class customize-support

    You can check out how the page looks here https://warp.warpto.me/test/ you can see how the page should look here https://www.w3schools.com/bootstrap5/bootstrap_templates.php

    As you can see on the page it adds random blank space on top and bottom
    and also there is no css in my custom theme

    • This topic was modified 3 years, 3 months ago by Jan Dembowski.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter mightyx3n

    (@mightyx3n)

    I just figured out the customize-support is added with the admin bar

    Moderator threadi

    (@threadi)

    The large amount of free space is due to the fact that your theme outputs totally broken HTML code. The doctype and header are missing there. You say this is a theme created by you? Then you have to start there at the template and best with get_header() to include the WordPress generated header. That solves much of it already for you.

    Thread Starter mightyx3n

    (@mightyx3n)

    @threadi thank you I looked over my theme and tried to change the

    the_content();

    to

    echo get_the_content();

    and that seems to have done it

    Moderator threadi

    (@threadi)

    No, not really. Look at the generated HTML-code. Its a mess. Even if it looks better visually, it is far from being right.

    Thread Starter mightyx3n

    (@mightyx3n)

    How would i fix this ?

    Moderator threadi

    (@threadi)

    Unfortunately, since I don’t know your theme, I can’t tell you. Check how you build the templates and whether that meets the specifications of WordPress for it: https://codex.wordpress.org/Theme_Development

    Thread Starter mightyx3n

    (@mightyx3n)

    Can you maybe take a look at the theme https://warpto.me/wp-content/uploads/2022/07/WARPTheme.zip

    Moderator bcworkz

    (@bcworkz)

    Look at the header.php template file of one of the older non-FSE default twenty* themes for guidance on what sort of output a typical header file should be outputting. Note that these model theme header files open a number of HTML tags that are left open until the footer.php template finally closes them.

    For good measure, verify your page’s HTML is fully valid with the W3C Validator.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Allowing unfiltered html in multisite’ is closed to new replies.