Skip to:
Content
Pages
Categories
Search
Top
Bottom

Emoticons For bbPress?

  • 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. :-)

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

  • ardentfrost
    Member

    @ardentfrost

    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.


    chrishajer
    Participant

    @chrishajer

    I think I answered my own question. This appears to work fine in .80. :D


    chrishajer
    Participant

    @chrishajer

    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.


    ardentfrost
    Member

    @ardentfrost

    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.


    chrishajer
    Participant

    @chrishajer

    So it filters through the post but not the edit? It appeared to me that some old posts that had text emoticons, like :) , were filtered on display and how display a gif instead of the text. Maybe I imagined that?

    In fact, here’s a post I made on my forum back in December, and it gets converted to a gif.

    http://www.riversideinfo.org/forum/topic.php?id=6&replies=15#post-40

    I did not edit that post, and I just installed the bb-emoticons plugin yesterday. I guess I still don’t understand how it works.

    It worked nicely for me. I assumed that since it added smileys everywhere retroactively it filtered the post between the database and the output?


    fel64
    Member

    @fel64

    To make this work in 1.0 you need to change the first few lines (or it won’t be available to activate as a plugin). I modified mine to this, which still has all the credits in there.

    <?php
    /*
    Plugin Name: bbEmoticons
    Plugin URI:
    Description: A Clickable Smilies hack for bbPress. Thanks to <a href="http://www.orioa.com/">kohaku</a> and <a href="http://plasticdreams.org/">aka</a>. Original WP Grins by <a href="http://www.alexking.org/software/wordpress/">Alex King</a>.
    Author: hiromasa
    Author URI: http://hiromasa.zone.ne.jp/blog/
    Version: 0.72
    */
    ...

    Just replace the <?php at the start of your .php file with this and it should show up to be activated.

    Edit: Oh, awesome, a overflow: auto property has been added. Thanks. :)


    Null
    Member

    @null

    How to make is so, that it wont filter between the code tags? Cause we dont want smilies in code parts :)


    citizenkeith
    Participant

    @citizenkeith

    I’d love to have the emoticons available from a pop-up menu, that way you only load them when needed.

    Camino hates all the emoticons on my screen at once. :D


    fel64
    Member

    @fel64

    Unfortunately you’ll need someone with some Javascript mojo to do that. It’s been done often enough before, but I presume it still requires some knowledge. :P


    citizenkeith
    Participant

    @citizenkeith

    but I presume it still requires some knowledge. :P

    :D That’s why I posted here!


    ardentfrost
    Member

    @ardentfrost

    One of the co-creators of my forum worked on it for a while (putting the emoticons in an AJAX window) but wasn’t successful as yet. Perhaps one day I can look at it if someone else doesn’t beat me to it.


    smurfdude
    Member

    @smurfdude

    I used this plugin and the row of smilies show beneath the edit form, but they are unclickable. An even when I just type in :) :( etc, they don’t appear in the post.


    _ck_
    Participant

    @_ck_

    I’ve now made a smilie plugin here:

    http://bbpress.org/plugins/topic/bb-smilies

    By the way, WordPress’s default smilie detection code and therefore the code converted here in the earlier post are very flawed when it comes to whitespace issues.

    I created a patch awhile back that made it work 99% of the time regardless of spaces before, after or at the end/beginning of a sentence.

    add this function:

    function prepSmilies($string) {return "/(s|^)".quotemeta(trim($string))."(s|$)/";}

    then add this near the start of function convert_smilies:

    $prep_search = array_map('prepSmilies', $wp_smiliessearch);

    then change the $contenst=str_replace line near the end of function covert_smilies:

    $content = preg_replace($prep_search, $wp_smiliesreplace, $content);

    Now if only it was this easy to tweak wp/bb’s search function to be so much more intelligent.

    i am using 0.8.2.1 i upload the files but in plugins list in admin area it didnt appear!! any one know the reason?

    It’s not a plugin. Add this to the top of the file, after the <?php:

    /*
    Plugin Name: Nerr
    */

    i did wht u said

    file apear in plugin list but

    when i try to actve it i see this error message:

    Plugin could not be activated; it produced a Fatal Error.

    Ooooh, I really hate that. What file are you trying to use as a plugin?

    <?php

    /*

    Plugin Name: bbEmoticons

    Plugin URI:

    Description: A Clickable Smilies hack for bbPress. Thanks to kohaku and aka. Original WP Grins by Alex King.

    Author: hiromasa

    Author URI: http://hiromasa.zone.ne.jp/blog/

    Version: 0.72

    */

    /******************************************************************************

    * bbEmoticons version 0.72

    *

    * A Clickable Smilies hack for bbPress.

    *

    * @Author hiromasa (http://hiromasa.zone.ne.jp/blog/)

    * @Thanks kohaku (http://www.orioa.com/)

    * aka (http://plasticdreams.org/)

    * @Original WP Grins By Alex King

    * (http://www.alexking.org/software/wordpress/)

    * WordPress convert_smilies function and images

    * (http://wordpress.org/)

    *****************************************************************************/

    /* Copyright 2006 hiromasa (email : webmaster@hiromasa.zone.ne.jp)

    This program is free software; you can redistribute it and/or modify

    it under the terms of the GNU General Public License as published by

    the Free Software Foundation; either version 2 of the License, or

    (at your option) any later version.

    This program is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License

    along with this program; if not, write to the Free Software

    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

    */

    /******************************************************************************

    * bbEmoticons

    *

    * @author hiromasa

    * @version 0.72

    *

    *****************************************************************************/

    class bbEmoticons {

    var $bb_grins;

    var $bb_smiliessearch = array();

    var $bb_smiliesreplace = array();

    /**

    * The Constructor

    *

    * @param none

    * @return none

    */

    function bbEmoticons() {

    if (isset($_GET)) {

    switch ($_GET) {

    case “javascript”:

    $this->outputGringJS();

    }

    exit(0);

    }

    $bb_smiliestrans = array(

    :)‘ => ‘icon_smile.gif’,

    :D‘ => ‘icon_biggrin.gif’,

    :-D‘ => ‘icon_biggrin.gif’,

    ‘:grin:’ => ‘icon_biggrin.gif’,

    :)‘ => ‘icon_smile.gif’,

    :-)‘ => ‘icon_smile.gif’,

    ‘:smile:’ => ‘icon_smile.gif’,

    :(‘ => ‘icon_sad.gif’,

    :-(‘ => ‘icon_sad.gif’,

    ‘:sad:’ => ‘icon_sad.gif’,

    ‘ :o’ => ‘icon_surprised.gif’,

    ‘ :-o’ => ‘icon_surprised.gif’,

    ‘:eek:’ => ‘icon_surprised.gif’,

    ‘ 8O’ => ‘icon_eek.gif’,

    ‘ 8-O’ => ‘icon_eek.gif’,

    ‘:shock:’ => ‘icon_eek.gif’,

    :?‘ => ‘icon_confused.gif’,

    :-?‘ => ‘icon_confused.gif’,

    :???:’ => ‘icon_confused.gif’,

    8)‘ => ‘icon_cool.gif’,

    8-)‘ => ‘icon_cool.gif’,

    ‘:cool:’ => ‘icon_cool.gif’,

    ‘:lol:’ => ‘icon_lol.gif’,

    ‘ :x’ => ‘icon_mad.gif’,

    ‘ :-x’ => ‘icon_mad.gif’,

    ‘:mad:’ => ‘icon_mad.gif’,

    :P‘ => ‘icon_razz.gif’,

    :-P‘ => ‘icon_razz.gif’,

    ‘:razz:’ => ‘icon_razz.gif’,

    ‘:oops:’ => ‘icon_redface.gif’,

    ‘:cry:’ => ‘icon_cry.gif’,

    ‘:evil:’ => ‘icon_evil.gif’,

    ‘:twisted:’ => ‘icon_twisted.gif’,

    ‘:roll:’ => ‘icon_rolleyes.gif’,

    ‘:wink:’ => ‘icon_wink.gif’,

    ;)‘ => ‘icon_wink.gif’,

    ;-)‘ => ‘icon_wink.gif’,

    ‘:!:’ => ‘icon_exclaim.gif’,

    :?:’ => ‘icon_question.gif’,

    ‘:idea:’ => ‘icon_idea.gif’,

    ‘:arrow:’ => ‘icon_arrow.gif’,

    :|‘ => ‘icon_neutral.gif’,

    :-|‘ => ‘icon_neutral.gif’,

    ‘:neutral:’ => ‘icon_neutral.gif’,

    ‘:mrgreen:’ => ‘icon_mrgreen.gif’,

    );

    foreach($bb_smiliestrans as $smiley => $img) {

    $this->bb_smiliessearch[] = $smiley;

    $smiley_masked = htmlspecialchars(trim($smiley), ENT_QUOTES);

    $this->bb_smiliesreplace[] =

    ” <img src=’” . bb_get_option(‘uri’) .

    “bb-images/smilies/$img’ alt=’$smiley_masked’ class=’wp-smiley’ /> “;

    }

    $this->grins = ”;

    $smiled = array();

    foreach ($bb_smiliestrans as $tag => $grin) {

    if (!in_array($grin, $smiled)) {

    $smiled[] = $grin;

    $tag = str_replace(‘ ‘, ”, $tag);

    $this->grins .=

    ‘<img src=”‘. bb_get_option(‘uri’) .

    ‘bb-images/smilies/’.$grin.’” alt=”‘ .$tag .

    ‘” onclick=”grin(‘ ‘.$tag.”);”/> ‘;

    }

    }

    }

    /**

    * post_text filter

    *

    * @param $text

    * @return $output

    */

    function convert_smilies($text) {

    $output = ”;

    $textarr = preg_split(“/(<.*>)/U”, $text, -1, PREG_SPLIT_DELIM_CAPTURE);

    $stop = count($textarr);

    for($i=0; $i<$stop; $i++) {

    $content = $textarr[$i];

    if((strlen($content) > 0) && (‘<’ != $content{0})) {

    $content = str_replace(

    $this->bb_smiliessearch,

    $this->bb_smiliesreplace,

    $content);

    }

    $output .= $content;

    }

    return $output;

    }

    /**

    * bb_grins action

    *

    * @param none

    * @return none

    */

    function bb_grins() {

    echo ‘<div id=”bb_grins”>’ . $this->grins . ‘</div>’;

    }

    /**

    * bb_head action

    *

    * @param none

    * @return none

    */

    function bb_grins_head() {

    echo

    ‘<script type=”text/javascript” src=”‘. bb_get_option(‘uri’) .

    ‘my-plugins/bb-emoticons.php?bb_grins_output=javascript”></script>’ .

    “n”;

    }

    /**

    * Output Grins JavaScript

    *

    * @param none

    * @return none

    */

    function outputGringJS() {

    function grin(tag) {

    var myField;

    if (document.getElementById(‘post_content’) && document.getElementById(‘post_content’).type == ‘textarea’) {

    myField = document.getElementById(‘post_content’);

    }

    else if (document.getElementById(‘comment’) && document.getElementById(‘comment’).type == ‘textarea’) {

    myField = document.getElementById(‘comment’);

    }

    else {

    return false;

    }

    if (document.selection) {

    myField.focus();

    sel = document.selection.createRange();

    sel.text = tag;

    myField.focus();

    }

    else if (myField.selectionStart || myField.selectionStart == ’0′) {

    var startPos = myField.selectionStart;

    var endPos = myField.selectionEnd;

    var cursorPos = endPos;

    myField.value = myField.value.substring(0, startPos)

    + tag

    + myField.value.substring(endPos, myField.value.length);

    cursorPos += tag.length;

    myField.focus();

    myField.selectionStart = cursorPos;

    myField.selectionEnd = cursorPos;

    }

    else {

    myField.value += tag;

    myField.focus();

    }

    }

    }

    }

    /******************************************************************************

    * – Define for bbPress interface

    *****************************************************************************/

    $bbemoticons = & new bbEmoticons();

    bb_add_filter(‘post_text’, array(&$bbemoticons, ‘convert_smilies’));

    //bb_head is not called always. :-)

    //bb_add_action(‘bb_head’, array(&$bbemoticons, ‘bb_grins_head’));

    bb_add_action(‘bb_feed_head’, array(&$bbemoticons, ‘bb_grins_head’));

    bb_add_action(‘bb_grins’, array(&$bbemoticons, ‘bb_grins’));

    ?>

    i don t know what is the problem

    Did you modify the plugin? Insert a ?> before line 202 and a <?php before line 237.

    In Notepad you can go to a specific line by pressing Ctrl + G.

    <?php

    /*

    Plugin Name: bbEmoticons

    Plugin URI:

    Description: A Clickable Smilies hack for bbPress. Thanks to kohaku and aka. Original WP Grins by Alex King.

    Author: hiromasa

    Author URI: http://hiromasa.zone.ne.jp/blog/

    Version: 0.72

    */

    /******************************************************************************

    * bbEmoticons version 0.72

    *

    * A Clickable Smilies hack for bbPress.

    *

    * @Author hiromasa (http://hiromasa.zone.ne.jp/blog/)

    * @Thanks kohaku (http://www.orioa.com/)

    * aka (http://plasticdreams.org/)

    * @Original WP Grins By Alex King

    * (http://www.alexking.org/software/wordpress/)

    * WordPress convert_smilies function and images

    * (http://wordpress.org/)

    *****************************************************************************/

    /* Copyright 2006 hiromasa (email : webmaster@hiromasa.zone.ne.jp)

    This program is free software; you can redistribute it and/or modify

    it under the terms of the GNU General Public License as published by

    the Free Software Foundation; either version 2 of the License, or

    (at your option) any later version.

    This program is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License

    along with this program; if not, write to the Free Software

    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

    */

    /******************************************************************************

    * bbEmoticons

    *

    * @author hiromasa

    * @version 0.72

    *

    *****************************************************************************/

    class bbEmoticons {

    var $bb_grins;

    var $bb_smiliessearch = array();

    var $bb_smiliesreplace = array();

    /**

    * The Constructor

    *

    * @param none

    * @return none

    */

    function bbEmoticons() {

    if (isset($_GET)) {

    switch ($_GET) {

    case “javascript”:

    $this->outputGringJS();

    }

    exit(0);

    }

    $bb_smiliestrans = array(

    :)‘ => ‘icon_smile.gif’,

    :D‘ => ‘icon_biggrin.gif’,

    :-D‘ => ‘icon_biggrin.gif’,

    ‘:grin:’ => ‘icon_biggrin.gif’,

    :)‘ => ‘icon_smile.gif’,

    :-)‘ => ‘icon_smile.gif’,

    ‘:smile:’ => ‘icon_smile.gif’,

    :(‘ => ‘icon_sad.gif’,

    :-(‘ => ‘icon_sad.gif’,

    ‘:sad:’ => ‘icon_sad.gif’,

    ‘ :o’ => ‘icon_surprised.gif’,

    ‘ :-o’ => ‘icon_surprised.gif’,

    ‘:eek:’ => ‘icon_surprised.gif’,

    ‘ 8O’ => ‘icon_eek.gif’,

    ‘ 8-O’ => ‘icon_eek.gif’,

    ‘:shock:’ => ‘icon_eek.gif’,

    :?‘ => ‘icon_confused.gif’,

    :-?‘ => ‘icon_confused.gif’,

    :???:’ => ‘icon_confused.gif’,

    8)‘ => ‘icon_cool.gif’,

    8-)‘ => ‘icon_cool.gif’,

    ‘:cool:’ => ‘icon_cool.gif’,

    ‘:lol:’ => ‘icon_lol.gif’,

    ‘ :x’ => ‘icon_mad.gif’,

    ‘ :-x’ => ‘icon_mad.gif’,

    ‘:mad:’ => ‘icon_mad.gif’,

    :P‘ => ‘icon_razz.gif’,

    :-P‘ => ‘icon_razz.gif’,

    ‘:razz:’ => ‘icon_razz.gif’,

    ‘:oops:’ => ‘icon_redface.gif’,

    ‘:cry:’ => ‘icon_cry.gif’,

    ‘:evil:’ => ‘icon_evil.gif’,

    ‘:twisted:’ => ‘icon_twisted.gif’,

    ‘:roll:’ => ‘icon_rolleyes.gif’,

    ‘:wink:’ => ‘icon_wink.gif’,

    ;)‘ => ‘icon_wink.gif’,

    ;-)‘ => ‘icon_wink.gif’,

    ‘:!:’ => ‘icon_exclaim.gif’,

    :?:’ => ‘icon_question.gif’,

    ‘:idea:’ => ‘icon_idea.gif’,

    ‘:arrow:’ => ‘icon_arrow.gif’,

    :|‘ => ‘icon_neutral.gif’,

    :-|‘ => ‘icon_neutral.gif’,

    ‘:neutral:’ => ‘icon_neutral.gif’,

    ‘:mrgreen:’ => ‘icon_mrgreen.gif’,

    );

    foreach($bb_smiliestrans as $smiley => $img) {

    $this->bb_smiliessearch[] = $smiley;

    $smiley_masked = htmlspecialchars(trim($smiley), ENT_QUOTES);

    $this->bb_smiliesreplace[] =

    ” <img src=’” . bb_get_option(‘uri’) .

    “bb-images/smilies/$img’ alt=’$smiley_masked’ class=’wp-smiley’ /> “;

    }

    $this->grins = ”;

    $smiled = array();

    foreach ($bb_smiliestrans as $tag => $grin) {

    if (!in_array($grin, $smiled)) {

    $smiled[] = $grin;

    $tag = str_replace(‘ ‘, ”, $tag);

    $this->grins .=

    ‘<img src=”‘. bb_get_option(‘uri’) .

    ‘bb-images/smilies/’.$grin.’” alt=”‘ .$tag .

    ‘” onclick=”grin(‘ ‘.$tag.”);”/> ‘;

    }

    }

    }

    /**

    * post_text filter

    *

    * @param $text

    * @return $output

    */

    function convert_smilies($text) {

    $output = ”;

    $textarr = preg_split(“/(<.*>)/U”, $text, -1, PREG_SPLIT_DELIM_CAPTURE);

    $stop = count($textarr);

    for($i=0; $i<$stop; $i++) {

    $content = $textarr[$i];

    if((strlen($content) > 0) && (‘<’ != $content{0})) {

    $content = str_replace(

    $this->bb_smiliessearch,

    $this->bb_smiliesreplace,

    $content);

    }

    $output .= $content;

    }

    return $output;

    }

    /**

    * bb_grins action

    *

    * @param none

    * @return none

    */

    function bb_grins() {

    echo ‘<div id=”bb_grins”>’ . $this->grins . ‘</div>’;

    }

    /**

    * bb_head action

    *

    * @param none

    * @return none

    */

    function bb_grins_head() {

    echo

    ‘<script type=”text/javascript” src=”‘. bb_get_option(‘uri’) .

    ‘my-plugins/bb-emoticons.php?bb_grins_output=javascript”></script>’ .

    “n”;

    }

    /**

    * Output Grins JavaScript

    *

    * @param none

    * @return none

    */

    function outputGringJS() {

    ?>

    function grin(tag) {

    var myField;

    if (document.getElementById(‘post_content’) && document.getElementById(‘post_content’).type == ‘textarea’) {

    myField = document.getElementById(‘post_content’);

    }

    else if (document.getElementById(‘comment’) && document.getElementById(‘comment’).type == ‘textarea’) {

    myField = document.getElementById(‘comment’);

    }

    else {

    return false;

    }

    if (document.selection) {

    myField.focus();

    sel = document.selection.createRange();

    sel.text = tag;

    myField.focus();

    }

    else if (myField.selectionStart || myField.selectionStart == ’0′) {

    var startPos = myField.selectionStart;

    var endPos = myField.selectionEnd;

    var cursorPos = endPos;

    myField.value = myField.value.substring(0, startPos)

    + tag

    + myField.value.substring(endPos, myField.value.length);

    cursorPos += tag.length;

    myField.focus();

    myField.selectionStart = cursorPos;

    myField.selectionEnd = cursorPos;

    }

    else {

    myField.value += tag;

    myField.focus();

    }

    }

    <?php

    }

    }

    /******************************************************************************

    * – Define for bbPress interface

    *****************************************************************************/

    $bbemoticons = & new bbEmoticons();

    bb_add_filter(‘post_text’, array(&$bbemoticons, ‘convert_smilies’));

    //bb_head is not called always. :-)

    //bb_add_action(‘bb_head’, array(&$bbemoticons, ‘bb_grins_head’));

    bb_add_action(‘bb_feed_head’, array(&$bbemoticons, ‘bb_grins_head’));

    bb_add_action(‘bb_grins’, array(&$bbemoticons, ‘bb_grins’));

    ?>

    yes i thought we don t need them! because before editing it didn’t work too. so here are my fresh plugin but it didn’t work too i just insert plugin info to the top of file

    Please stop pasting huge chunks of code on the forums. Use something like http://pastebin.ca/.

    That code runs fine for me. What problem are you having?

    It might be simplest to start off with the original plugin and fix that because you might have done quite a lot to it.

    Please stop pasting huge chunks of code on the forums. Use something like http://pastebin.ca/.

    ok i will do

    listen i want to tell you somthing important :) i downloaded bbEmoticons-0.72 and unpacked it and then send it to my plugin then i go to my admin and try to active it but it show fattal error my bbpress is .8.2.1

    so i tried to download 6th and every time it didnt active!

    now i come and copy the code form here and open new file in php and save it then try to upload it and active it :O

    it get active and work! what is wrong?

    do you test bbEmoticons-0.72 from the original download address i think there is somthing wrong in the original file

    please try it once for me :)

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

You must be logged in to reply to this topic.