bbPress

Simple, Fast, Elegant

bbPress support forums » Requests and Feedback

Emoticons For bbPress?

(77 posts)
  1. Hi,
    Maybe it's just me but it would be great if emoticons (just like WP) were included in bbPress. Without using a plugin. I'm thinking about making a simple plugin that would work, or at least hope to work. :-)

    Posted 1 year ago #
  2. Anyone?

    Posted 1 year ago #
  3. It's a good idea, I'm sure it'll happen. Be patient!

    Posted 1 year ago #
  4. OK...

    Posted 1 year ago #
  5. gnawph
    Member

    I wanted that functionality as well so I ripped some WP code, played around, and finally got something I could use. This is a highly sloppy work as I am out of practice and not really a great PHP programmer anyway. The plugin is mostly a rip of the Wordpress code with a filter. It is not elegant or tested completely but so far it has been getting the job done.

    Note: This plugin will not work without a default install of Wordpress.

    You have to create a directory called /my-plugins/, copy this code into a file called whatever-you-want.php, upload and enjoy!

    Feedback appreciated! Maybe I can improve on this and increase my PHP/*press skills. ;)
    <?php
    /*
    Plugin Name: Wordpress Smiley Integrator .0002
    Plugin URI: none
    Description: Gives Wordpress Smiley Functionality to bbPress
    Author: John Farrell
    Version: 1.0
    Author URI: none
    */
    function convert_smilies($text) {
    $wpsmiliestrans = array(
    ':mrgreen:' => 'icon_mrgreen.gif',
    ':neutral:' => 'icon_neutral.gif',
    ':twisted:' => 'icon_twisted.gif',
    ':arrow:' => 'icon_arrow.gif',
    ':shock:' => 'icon_eek.gif',
    ':smile:' => 'icon_smile.gif',
    ' :???:' => 'icon_confused.gif',
    ':cool:' => 'icon_cool.gif',
    ':evil:' => 'icon_evil.gif',
    ':grin:' => 'icon_biggrin.gif',
    ':idea:' => 'icon_idea.gif',
    ':oops:' => 'icon_redface.gif',
    ':razz:' => 'icon_razz.gif',
    ':roll:' => 'icon_rolleyes.gif',
    ':wink:' => 'icon_wink.gif',
    ':cry:' => 'icon_cry.gif',
    ':eek:' => 'icon_surprised.gif',
    ':lol:' => 'icon_lol.gif',
    ':mad:' => 'icon_mad.gif',
    ':sad:' => 'icon_sad.gif',
    '8-)' => 'icon_cool.gif',
    '8-O' => 'icon_eek.gif',
    ':-(' => 'icon_sad.gif',
    ':-)' => 'icon_smile.gif',
    ':-?' => 'icon_confused.gif',
    ':-D' => 'icon_biggrin.gif',
    ':-P' => 'icon_razz.gif',
    ':-o' => 'icon_surprised.gif',
    ':-x' => 'icon_mad.gif',
    ':-|' => 'icon_neutral.gif',
    ';-)' => 'icon_wink.gif',
    '8)' => 'icon_cool.gif',
    '8O' => 'icon_eek.gif',
    ':(' => 'icon_sad.gif',
    ':)' => 'icon_smile.gif',
    ':?' => 'icon_confused.gif',
    ':D' => 'icon_biggrin.gif',
    ':P' => 'icon_razz.gif',
    ':o' => 'icon_surprised.gif',
    ':x' => 'icon_mad.gif',
    ':|' => 'icon_neutral.gif',
    ';)' => 'icon_wink.gif',
    ':!:' => 'icon_exclaim.gif',
    ':?:' => 'icon_question.gif',
    );
    // generates smilies' search & replace arrays
    foreach($wpsmiliestrans as $smiley => $img) {
    $wp_smiliessearch[] = $smiley;
    $smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES);
    $wp_smiliesreplace[] = " <img src='/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
    }
    $output = '';
    // HTML loop taken from texturize function, could possible be consolidated
    $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between
    $stop = count($textarr);// loop stuff
    for ($i = 0; $i < $stop; $i++) {
    $content = $textarr[$i];
    if ((strlen($content) > 0) && ('<' != $content{0})) { // If it's not a tag
    $content = str_replace($wp_smiliessearch, $wp_smiliesreplace, $content);
    }
    $output .= $content;
    }
    return $output;
    }
    //add the filter
    add_filter('post_text', 'convert_smilies');
    ?>

    Posted 1 year ago #
  6. i think first thing to be changed should be the src .

    src='http://www.cfv88.com/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";

    to make it something related to the forum and not on external links ...

    you could make a new folder called image where all images are inside ... and fix the url ...

    Posted 1 year ago #
  7. gnawph
    Member

    Oops, removed my site specific urls.

    Well, the point of the entire plugin is to integrated with Wordpress. I wouldn't want to have my smiley images stored in two different locations and I'm not entirely sure were to edit my default WP smiley locations.

    Posted 1 year ago #
  8. i'm a total newbie in bbpress ... but in wordpress you could use instead of the url .. the blog url example :

    get_settings('siteurl');

    to get the blog url ...

    Posted 1 year ago #
  9. I tried the same code as above but it did not work for me. I'm not sure if htere is a get_settings in BBpress but, you can use $_SERVER['HTTP_HOST];

    Posted 1 year ago #
  10. gnawph
    Member

    What exactly did not work?

    Posted 1 year ago #
  11. bb-emotions plugin

    A friend of mine, Japanese bbPress user enjoy hacking plugin WP Grins port to bbPress.
    So, he wants to add this bb-emotion here, but he's not good at english, then I translate he says.

    = = = =
    ziped code:
    http://prdownloads.sourceforge.jp/wppluginsj/22267/bbEmoticons-0.72.zip

    1. put bb-emotions.php to /my-plugins/ ;
    2. put smilies folder into /bb-images/;
    3. add <?php bb_do_action('bb_grins'); ?> to above the textarea in the each theme (edit-form.php, post-form.php);

    That's all, and does work!
    I'm so happy if this will be your help :)
    = = = = =
    Thank you.

    Posted 1 year ago #
  12. thanks.

    this worked right out of the box.

    FYI, when installing this you should, if you havnt already, copy the edit-form.php and post-form.php to "my-templates" before you edit them.

    Hopefully we can find someone to help with a bbPress version of "comment quicktags".

    Posted 1 year ago #
  13. Great job. Dropped right in, went right to work.

    Thanks!

    Posted 1 year ago #
  14. n22
    Member

    not working.. i m sure its my problem, cause i know only HTML but not PHP.

    anyone can tell me exactly where to put "<?php bb_do_action('bb_grins'); ?> " ??

    thanks a lot

    Posted 1 year ago #
  15. open /bb-templates/post-form.php

    add that line here

    '<?php endif; do_action( 'post_form_pre_post' ); ?>

    <?php bb_do_action('bb_grins'); ?>
    <label for="post_content"><?php _e('Post:'); ?>
    <textarea name="post_content" cols="50" rows="8" id="post_content" tabindex="3"></textarea>
    </label>

    '

    HTH

    Posted 1 year ago #
  16. n22 - in your forums folder there's a folder called bb-templates. make a new folder called my-templates and copy these files from bb to my template folder - edit-form.php, post-form.php

    Edit those files - find the only instance of textarea in them and put that php code (just copy and paste, it's ok!) in a reasonable spot nearby. For example, they said above, but i chose below because i thought it worked better. All depends on the template.

    PS - GREAT JOB! It worked perfectly for me

    Posted 1 year ago #
  17. n22
    Member

    THANK YOU :fuknrekd and AphelionZ

    ill try it!

    Posted 1 year ago #
  18. n22
    Member

    hahahaha !!!!!!!!! it works!@!!!! Thanks to all!!

    Posted 1 year ago #
  19. Cool! Works for me also!

    Posted 1 year ago #
  20. quick note

    i had to add this line to my header.php file


    <script type="text/javascript" src="'. bb_get_option('uri') .
    'my-plugins/bb-emoticons.php?bb_grins_output=javascript"></script>

    add that to the steps to get this to work if you are having troubles with clicking on the icons not working

    Hope that this feature gets added to the package soon :-)

    Posted 1 year ago #
  21. just a thought anyone want to modify this plugin so that you can add icons to titles

    Posted 1 year ago #
  22. to tekhawk
    why they cannot work with my bbpress when clicking on the icons ?
    i add the sentence

    Posted 1 year ago #
  23. topiQ
    Member

    yeeeeeeeeeeeha!
    thanks a lot! great work!!!

    Posted 1 year ago #
  24. FYI: After upgrading to 0.74, my bbEmoticon images were broken.

    I changed paths in bb-emoticons.php to get them working again:

    "bb-images/smilies" to "../bb-images/smilies"

    Posted 1 year ago #
  25. eek, I take that back, it breaks again when editing a post.

    I hardcoded my install path because I couldn't find the function name for the home install.

    Posted 1 year ago #
  26. Is anyone using this with .80?

    Posted 1 year ago #
  27. I haven't upgraded yet, but I will be once I do. Is it broken for you?

    I've also F'd with mine to try to get some functionality out of it.

    Posted 1 year ago #
  28. I think I answered my own question. This appears to work fine in .80. :D

    Posted 1 year ago #
  29. It seems that the text is converted to emoticons on the initial post or display or something, but when I got back and edit a post to add one, it is not converted on display? When I make a test post immediately afterward, the same text is converted to an emoticon.

    Anyone have a similar experience? It would seem the text is translated on display, not posting, so, I can't see how this would happen actually.

    Posted 1 year ago #
  30. That is how it happens. The plugin filters through post. And it won't be able to display the smilie when you're typing until AJAX is incorporated into the text boxes.

    Posted 1 year ago #

RSS feed for this topic

Reply »

You must log in to post.

Code is Poetry.