Skip to:
Content
Pages
Categories
Search
Top
Bottom

Plugin: Admin Post Anything


  • _ck_
    Participant

    @_ck_

    Been meaning to do this for awhile, didn’t realise how easy it was. This makes bbPress behave more like WordPress in that admin (keymasters/administrators) can post any content regardless of tag restrictions for the rest of members. This includes images, javascript, objects like flash video player, etc.

    <?php
    /*
    Plugin Name: Admin Post Anything
    Plugin URI:
    Description: allows keymaster/administrators to post any content regardless of tag restrictions
    Author: _ck_
    Author URI: http://CKon.wordpress.com
    Version: 0.02
    */

    function bb_admin_post_anything($text) {
    if (bb_current_user_can('administrate') ) {
    remove_filter( 'pre_post', 'encode_bad' );
    remove_filter( 'pre_post', 'bb_encode_bad' );
    remove_filter('pre_post', 'bb_filter_kses', 50);
    $text=addslashes($text);
    $text=bb_autop($text);
    }
    return $text;
    }
    add_filter('pre_post', 'bb_admin_post_anything',9);
    ?>

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

  • _ck_
    Participant

    @_ck_

    Minor change to force autop to run even with the removed filters

    (so admins still get paragraph formatting).

    I tried a YouTube embed and it wouldn’t do it. Is there anymore restrictions?

    Trent


    _ck_
    Participant

    @_ck_

    Hmm, the adding and removing of slashes may be messing with things. I’ll have to test it some more. I know it works for any regular html tags.


    _ck_
    Participant

    @_ck_

    Just tested a youtube embed copied right from their site and it works tested in IE and Firefox.

    I don’t use the default bbpress template however, I wonder if that is affecting it somehow.

    Are you using the updated v0.02 that I posted, not v0.01 ?

    If it still doesn’t work, can you view source on the outputed page and copy just the part with that one post with full html here (between code tags obviously) so I can see what it is doing?


    _ck_
    Participant

    @_ck_

    I dug around on your forum until I found your test post.

    Apparently something is yanking out object tags.

    There might be a third party plugin that’s interfering with it and adding the filters back in.

    I have to think about how to handle that situation… not sure if it’s even possible… I gotta figure out what’s happening in more detail somehow.

    I tested it on my onvertigo.com site which is not using the default template either. It doesn’t work for me with any themes!

    http://onvertigo.com/topic/media-types-played-in-this-forum?replies=12#post-38

    Strange…..using:

    <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/2G_AHHxSctE"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/2G_AHHxSctE" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>

    Trent


    _ck_
    Participant

    @_ck_

    Weirdness. I will have to explore and test some more.

    Can you tell me what other plugins you are using that are common to both sites? It almost has to be a plugin conflict at this point.

    Does it let you post other forbidden html like <hr> ?

    Turns out it doesn’t like the ‘allow images’ plugin by mdawaffe. Strange. Turned it off and it works great.

    Trent

    Don’t forget _ck_ to add these plugins to the repository!

    https://bbpress.org/plugins/add/

    Trent


    _ck_
    Participant

    @_ck_

    I will look at the code for allow images but I suspect it’s because they must run one of the three bad filters after my filter runs.

    I think I tried adding to the repository and nothing happened but I’ll try again.


    _ck_
    Participant

    @_ck_

    Okay by adding these to the remove_filters list, you can also run allow images:

    remove_filter( 'pre_post', 'allow_images_encode_bad', 9 );
    remove_filter( 'pre_post', 'allow_images', 52 );

    It may also be necessary to increase my filter priority to 8, ie.

    add_filter('pre_post', 'bb_admin_post_anything',8);

    Since I can’t edit my first post I will try to add it to the repository with the changes?

    If you email me the code, I can change your first post as we go.

    trent dot adams at gmail dot com

    Trent


    _ck_
    Participant

    @_ck_

    I posted v0.03 on my wp blog

    https://ckon.files.wordpress.com/2007/07/admin-can-post-anythingphp.doc

    (rename to *.php)

    Let me know if the allow images hack works?


    _ck_
    Participant

    @_ck_

    Fourth time is the charm? Ugh. Sorry!

    <?php
    /*
    Plugin Name: Admin Can Post Anything
    Plugin URI:
    Description: allows keymaster/administrators to post any content regardless of tag restrictions
    Author: _ck_
    Author URI: http://CKon.wordpress.com
    Version: 0.04
    */

    function bb_admin_post_anything($text) {
    if (bb_current_user_can('administrate') ) {
    remove_filter('pre_post', 'encode_bad' );
    remove_filter('pre_post', 'bb_encode_bad' );
    remove_filter('pre_post', 'bb_filter_kses', 50);
    remove_filter('pre_post', 'addslashes', 55);
    remove_filter('pre_post', 'bb_autop', 60);
    $text=bb_autop(addslashes($text)); // I don't completely understand why this is necessary here but it is

    // the following two lines are untested code to allow compatibility with the allow images plugin
    // it's safe to remove it's filters because this only happens if admin are trying to post
    remove_filter( 'pre_post', 'allow_images_encode_bad', 9 );
    remove_filter( 'pre_post', 'allow_images', 52 );
    }
    return $text;
    }
    add_filter('pre_post', 'bb_admin_post_anything',8);
    ?>


    _ck_
    Participant

    @_ck_

    This plugin now has an official page in the plugin browser:

    https://bbpress.org/plugins/topic/55

    so check there for latest version.

    Coolio cheers. Ripped the filters to remove for my own nefarious porpoises in bbSync.


    _ck_
    Participant

    @_ck_

    Updated to v0.05 with important improvements to make sure admin posts are filtered correctly, please upgrade if currently using:

    http://ckon.wordpress.com/files/2007/08/admin-can-post-anything.txt?v005

    (also in the svn shortly)

    Sweet! Going to test shortly…

Viewing 18 replies - 1 through 18 (of 18 total)
  • You must be logged in to reply to this topic.
Skip to toolbar