Skip to:
Content
Pages
Categories
Search
Top
Bottom

Plugin: [REL] Signature

  • Hi,

    Heres my first plugin which was pretty much copied from the Avatar plugin, but hey, now I can contribute my 2 cents :) (Thanks to the guy who made that too)

    To install you must open functions.php (in bb-includes, line 1388) and add:

    'sig' => array(0, __('Signature'))

    to the end (before last closing bracket)

    This is the code:

    <?php

    /*

    Plugin Name: Signature

    Author: veb

    Version: 1.0

    */

    function post_sig() { // function to use in page php to get the sig

    if ( get_sig( get_post_author_id() ) )

    echo get_sig( get_post_author_id() );

    }

    function get_sig ( $id ) { //function to return sig lfrom database

    global $bbdb, $bb_current_user;

    $user = bb_get_user( $id );

    $profile_info_keys = get_profile_info_keys();

    if ( $id && false !== $user )

    if ( is_array( $profile_info_keys ) )

    foreach ( $profile_info_keys as $key => $label ) {

    if ( 'sig' == $key )

    return $user->$key;

    }

    }

    ?>

    Save as bb-signature.php in my-plugins.

    Have fun :D

Viewing 25 replies - 26 through 50 (of 69 total)

  • _ck_
    Participant

    @_ck_

    This plugin should be updated, cleaned-up (a lot) and released into the SVN for others to see.

    It’s very easy to apply filters to the signature just like the post text, smiles, auto-close tags and a whole bunch of other tweaks and security could be easily added.

    I believe it’s also possible to auto-add the signature field into the profile edit page via actions/filters so no user editing required.

    Last but not least I think there should be an option that is on by default to only show one signature for the member per page so it doesn’t get too annoying for viewers.

    So are you volunteering to do it?


    _ck_
    Participant

    @_ck_

    Heh. I was going to write one from scratch but then I did a search to see as I figured someone must have already.

    I don’t want to duplicate the original author’s work unless they have given up or there is a large demand.

    “or there is a large demand.”

    well, I’m not large but I do demand :)

    “It’s very easy to apply filters to the signature just like the post text, smiles, auto-close tags and a whole bunch of other tweaks and security could be easily added.”

    and all these too


    _ck_
    Participant

    @_ck_

    If we could take polls I would know if there is interest but simply out of the curiosity to learn more about the bbpress core I might give this a shot this weekend.

    update: will have a prototype posted within a couple hours or so of this post


    _ck_
    Participant

    @_ck_

    Okay I have a working prototype.

    Who wants to beta test?

    http://ckon.wordpress.com/2007/07/28/new-plugin-bbpress-signatures/

    Okee well just let me know.

    Not responsible for any melted servers or sudden calls from the voyager probe.


    _ck_
    Participant

    @_ck_

    security note: do not use less than version 0.03 as I forgot to filter pre_post on the signature and it will allow javascript, etc. – fixed now

    autop turned off in v0.04 so no more auto-paragraph tags

    hope someone finds this useful after the couple hours of work

    Hi ck!

    I’m going to try your plugin in my own computer but before I need to clean up all changes I made for the old one. If I notice any error I’ll report.

    Thanks for your work!


    citizenkeith
    Participant

    @citizenkeith

    Dumb question: What should I add to post.php?

    Thanks, ck!

    it works great, thanks!

    citizenkeith: you don’t have to add anything to post.php, just enable the plugin, edit your profile and add a signature, then it should show up beneath all of your posts.


    _ck_
    Participant

    @_ck_

    Dumb question: What should I add to post.php?

    Nothing. My version of this plugin requires absolutely no template or core edits. It’s why I made it ;-)

    It’s optional to put the style in your style.css to prevent an extra stylesheet but that’s trivial and not necessary.

    Note that I’ve turned on the default options of “one signature per user per page” and “only moderators and above can have signatures”. You can edit this in the plugin (change “moderate” to “participate”)

    There are still many, many things not checked in this, like they could trick it to post 100 lines in a signature or use a HUGE image if you have “allow images” installed. This for now comes down to moderators doing their job.


    citizenkeith
    Participant

    @citizenkeith

    Thanks guys, I figured it out. :D

    Dumb Question #2: How does one use quotes or apostrophes in their signatures? Forward slashes are inserted before each instance.

    By having ck stripslashes on it. It seems to be something he’s gotta fix.

    None of these are dumb questions … just ask ’em and don’t worry about it. :)


    citizenkeith
    Participant

    @citizenkeith

    Thanks fel! :) In the meantime, I’ll just edit HTML special characters in my user’s signatures.


    _ck_
    Participant

    @_ck_

    Whoops, I bet there were some situations I didn’t test for.

    Will investigate… (and she‘ll fix ’em asap)


    _ck_
    Participant

    @_ck_

    Okee, try version 0.05 which has a few fixes and now uses a textarea for clarity (with maximum lines enforced):

    https://ckon.files.wordpress.com/2007/07/bb-signatures.txt?v005


    _ck_
    Participant

    @_ck_

    I should have a per-post disable signature option working by tomorrow. Putting it in there to learn some more, wow it’s tricky. This programming stuff is addictive.


    _ck_
    Participant

    @_ck_

    Well why wait for tomorrow when you can put off other work and do it today :D

    I now have per-post signature disable ability on v0.07 though sadly you must edit two templates to get that ability, there is no way to hook the form from the plugin, at least none that I can find in the API.

    What’s really ironic is that I will most likely never use this plugin on my own forums, ha!


    citizenkeith
    Participant

    @citizenkeith

    Thanks ck! I’ll download and install the newest version tonight. And sorry for the gender slip!


    _ck_
    Participant

    @_ck_

    I’ll have even more features tonight.

    Working on a basic admin menu now.


    _ck_
    Participant

    @_ck_

    Here we go!

    http://ckon.wordpress.com/2007/07/31/new-plugin-bbpress-signatures/

    updated to v0.11 – now with admin menu!

    http://ckon.wordpress.com/files/2007/07/bb-signatures.txt

    (rename .txt to .php)

    If you have plugins for smilies and/or allow images in post text, it will obey them, this is probably a good thing and desired.

    You can set the minimum user level needed to show signatures and also the ability not to repeat a user’s signature more than once per page.

    Instructions: install, activate, tinker with settings in admin menu

    If you would like the optional toggle on new/edit posts to disable signatures you must edit the edit-form.php & post-form.php templates and place at or near the bottom:

    <? bb_signatures_checkbox(); ?>

    (you can wrap it in a DIV and float it to the left, right style anyway you’d like

    sorry but there’s no way to do this directly through a plugin)

    Here’s a fancier version that I use:

    <div style=”float:left” ><? if (function_exists(‘bb_signatures_checkbox’)) {bb_signatures_checkbox();} ?></div>

    Version History:

    0.05 :slashes & autop fixed, replaced input with textarea, max_lines now supported in post-processing, max_length checked in realtime (as well as post processing)

    0.06 :internal testing/bugfix

    0.07 :per-post signature toggle

    0.08 :toggle for allow html and allow images should now work

    0.10 :basic functioning admin menu

    0.11 :more intelligent admin menu

    Did you try the action ‘post_form’ and echoing the desired HTML?

    I’m not sure there’s one that does the same for edit_form(), which is probably an oversight.


    citizenkeith
    Participant

    @citizenkeith

    Looks awesome. Thanks!


    _ck_
    Participant

    @_ck_

    @fel64, yeah I saw post-form but it closes the form before the action is called so any fields inserted would not be passed with the data. I’d have to do some weird javascript kung-fu to insert a field into the previous form and that’s just too messy for my taste.

    The real solution is some kind of hook in the template loader so before and after it does the “include”, then it lets you insert anything you want on any template. Now that would make for super flexibility.

    Actually, post_form is called immediately before the form is closed.

    https://trac.bbpress.org/browser/trunk/bb-includes/template-functions.php#L163

Viewing 25 replies - 26 through 50 (of 69 total)
  • You must be logged in to reply to this topic.
Skip to toolbar