Skip to:
Content
Pages
Categories
Search
Top
Bottom

Allow HTML tags in Post for All Users


  • Leonyipa
    Participant

    @leonyipa

    How to allow all users to use HTML codes, because at the moment, only keymaster can have access to all HTML tags.

    I would like to allow user to use this code:
    //<span style=”font-size: 36pt; font-family: impact, chicago;”>Pademelon</span>

    <span style=”font-size: 36pt; font-family: impact, chicago;”>Pademelon</span>

Viewing 12 replies - 1 through 12 (of 12 total)
  • Grab this custom plugin from here https://gist.github.com/ntwb/7797990

    You will need to change one part of it though:

    From:

    
    		// Span
    		'span'             => array(
    			'class'     => true,
    		),
    

    To:

    		// Span
    		'span'             => array(
    			'class'     => true,
    			'style'     => true,
    		),
    

    That will then modify the allowed tag span to also include style inside the span.


    Leonyipa
    Participant

    @leonyipa

    thanks, where should I put the
    ntwb_bbpress_custom_kses_allowed_tags.php
    in?

    Click the ‘download gist’ link, it will download a zip archive, unzip it and use FTP to upload the plugin to your WordPress plugins folder, typically /wp-cntent/plugins

    Edit: Or go to ‘Plugins’ -> ‘Add new’ -> ‘Upload’ and you can then upload it directly.


    Leonyipa
    Participant

    @leonyipa

    THANKS VERY MUCH!!!!!!!!!!!!!!!!!
    I HAVE BEEN FINDING SOLUTION FOR A LONG TIME!!!! THANKS!!!!!! ๐Ÿ™‚


    Leonyipa
    Participant

    @leonyipa

    how can I allow:
    <p style=โ€text-align: right;โ€>gh</p> <p style=โ€text-align: right;โ€>hg</p> <hr />
    <p style=โ€text-align: left;โ€>d</p>

    You shouldn’t really be letting users add styles, you should have your theme do that, that said., just add a new section for the p tag and style within p like so:

    
    	// Paragraph
    	'p'        => array(
    	'style'    => true,
    	),
    

    Leonyipa
    Participant

    @leonyipa

    thank you

    sorry, can you also teach me how to allow:
    <address>fff</address>
    <h1>fff</h1>
    <h2>ffff</h2>
    <h3>ffff</h3>
    <h4>ffff</h4>
    <h5>ffff</h5>
    <h6>ffff</h6>
    thanks ๐Ÿ™‚


    Leonyipa
    Participant

    @leonyipa

    thanks, i followed your method and added:

    ‘h1’ => array(),
    ‘h2’ => array(),
    ‘h3’ => array(),
    ‘h4’ => array(),
    ‘h5’ => array(),
    ‘h6’ => array(),
    ‘address’ => array(),

    it worked ๐Ÿ˜€


    abderrezak31
    Participant

    @abderrezak31

    it’s really an old topic but thank you so much and it’s really helped me about H1 H2…H6
    thank you so much guys


    eigodeasobo
    Participant

    @eigodeasobo

    What should I do if I do not want to allow div?

    // Div
    'div' => array(
    	'class'     => false,
    	'style'     => false,
    ),

    This is not it, right?


    kasperdalkarl
    Participant

    @kasperdalkarl

    Thanks for posting this. I installed the plugin, and added

    			// Paragraph
        	'p'          => array(
        	    'class'    => true,
            	'style'    => true,

    But sadly I still get this in cleartext:
    <p style=โ€text-align: center;โ€>Test 3</p>

    Any suggestions? Thanks!


    kasperdalkarl
    Participant

    @kasperdalkarl

    I actually found a solution by trying some stuff out.

    Go to this file: …/wp-content/plugins/bbpress/includes/common/formatting.php

    And at the bottom of that file, add this:

    add_filter( 'bbp_kses_allowed_tags', 'ntwb_bbpress_custom_kses_allowed_tags' );
    function ntwb_bbpress_custom_kses_allowed_tags() {
    	return array(
    		// Links
    		'a'          => array(
    			'class'    => true,
    			'href'     => true,
    			'title'    => true,
    			'rel'      => true,
    			'class'    => true,
    			'target'    => true,
    		),
    		// Quotes
    		'blockquote' => array(
    			'cite'     => true,
    		),
    		
    		// Div
    		'div' => array(
    			'class'     => true,
    		),
    		
    		// Span
    		'span'             => array(
    			'class'     => true,
                            'style'     => true,
    		),
    		
                    // Paragraph
    		'p'             => array(
    			'class'     => true,
                            'style'     => true,
    		),
    
    		// Code
    		'code'       => array(),
    		'pre'        => array(
    			'class'  => true,
    		),
    		// Formatting
    		'em'         => array(),
    		'strong'     => array(),
    		'del'        => array(
    			'datetime' => true,
    		),
    		// Lists
    		'ul'         => array(),
    		'ol'         => array(
    			'start'    => true,
    		),
    		'li'         => array(),
    		// Images
    		'img'        => array(
    			'class'    => true,
    			'src'      => true,
    			'border'   => true,
    			'alt'      => true,
    			'height'   => true,
    			'width'    => true,
    		),
    		// Tables
    		'table'      => array(
    			'align'    => true,
    			'bgcolor'  => true,
    			'border'   => true,
    		),
    		'tbody'      => array(
    			'align'    => true,
    			'valign'   => true,
    		),
    		'td'         => array(
    			'align'    => true,
    			'valign'   => true,
    		),
    		'tfoot'      => array(
    			'align'    => true,
    			'valign'   => true,
    		),
    		'th'         => array(
    			'align'    => true,
    			'valign'   => true,
    		),
    		'thead'      => array(
    			'align'    => true,
    			'valign'   => true,
    		),
    		'tr'         => array(
    			'align'    => true,
    			'valign'   => true,
    		)
    	);
    }
Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.
Skip to toolbar