Info
- 82 posts
- 34 voices
- Started 5 years ago by Ttech
- Latest reply from hpguru
Emoticons For bbPress?
-
- Posted 5 years ago #
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 5 years ago #
Anyone?
-
- Posted 5 years ago #
It's a good idea, I'm sure it'll happen. Be patient!
-
- Posted 5 years ago #
OK...
-
- Posted 5 years ago #
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 5 years ago #
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 5 years ago #
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 5 years ago #
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 5 years ago #
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 5 years ago #
What exactly did not work?
-
- Posted 5 years ago #
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- put
bb-emotions.phpto/my-plugins/; - put
smilies folderinto/bb-images/; - 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 5 years ago #
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 5 years ago #
Great job. Dropped right in, went right to work.
Thanks!
-
- Posted 5 years ago #
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 5 years ago #
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 5 years ago #
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 5 years ago #
THANK YOU :fuknrekd and AphelionZ
ill try it!
-
- Posted 5 years ago #
hahahaha !!!!!!!!! it works!@!!!! Thanks to all!!
-
- Posted 5 years ago #
Cool! Works for me also!
-
- Posted 5 years ago #
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 workingHope that this feature gets added to the package soon :-)
-
- Posted 5 years ago #
just a thought anyone want to modify this plugin so that you can add icons to titles
-
- Posted 5 years ago #
to tekhawk
why they cannot work with my bbpress when clicking on the icons ?
i add the sentence -
- Posted 5 years ago #
yeeeeeeeeeeeha!
thanks a lot! great work!!! -
- Posted 5 years ago #
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 5 years ago #
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 4 years ago #
Is anyone using this with .80?
-
- Posted 4 years ago #
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 4 years ago #
I think I answered my own question. This appears to work fine in .80. :D
-
- Posted 4 years ago #
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 4 years ago #
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.