Emoticons toolbar
- allows the integration of emoticons as UTFT-8 HTML entity via a toolbar - the toolbar is available when creating/editing entries, static pages and in the comment function
This commit is contained in:
commit
461a5f1986
@ -37,6 +37,7 @@
|
||||
{if function_exists('plugin_bbcode_init')}
|
||||
{include file="plugin:bbcode/toolbar"}
|
||||
{/if}
|
||||
<!-- BOF Custom toolbar -->{action hook=simple_toolbar_form}<!-- EOF Custom toolbar -->
|
||||
<p>
|
||||
{if isset($error) && isset($error.content) && !empty($error.content)}
|
||||
{assign var=class value="field-error"}
|
||||
|
@ -35,6 +35,7 @@
|
||||
{if function_exists('plugin_bbcode_init')}
|
||||
{include file="plugin:bbcode/toolbar"}
|
||||
{/if}
|
||||
<!-- BOF Custom toolbar -->{action hook=simple_toolbar_form}<!-- EOF Custom toolbar -->
|
||||
<p>
|
||||
{if isset($error) && isset($error.content) && !empty($error.content)}
|
||||
{assign var=class value="field-error"}
|
||||
|
@ -68,7 +68,7 @@
|
||||
|
||||
{/if}
|
||||
|
||||
|
||||
<!-- BOF Custom toolbar -->{action hook=simple_toolbar_form}<!-- EOF Custom toolbar -->
|
||||
<div class="comment-content">
|
||||
{if isset($error) && isset($error.content) && !empty($error.content)}
|
||||
{assign var=class value="field-error"}
|
||||
|
84
fp-plugins/emoticons/plugin.emoticons.php
Normal file
84
fp-plugins/emoticons/plugin.emoticons.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/*
|
||||
* Plugin Name: Emoticons
|
||||
* Version: 1.1.0
|
||||
* Plugin URI: https://flatpress.org
|
||||
* Description: Allows use of emoticons. Part of the standard distribution.
|
||||
* Author: FlatPress
|
||||
* Author URI: https://flatpress.org
|
||||
*/
|
||||
// assigns markdown to HTML Entity
|
||||
global $plugin_emoticons;
|
||||
$plugin_emoticons = array(
|
||||
':smile:' => '😄',
|
||||
':smiley:' => '😃',
|
||||
':wink:' => '😉',
|
||||
':blush:' => '😊',
|
||||
':grin:' => '😁',
|
||||
':smirk:' => '😏',
|
||||
':heart_eyes:' => '😍',
|
||||
':sunglasses:' => '😎',
|
||||
':laughing:' => '😆',
|
||||
':neutral_face:' => '😐',
|
||||
':flushed:' => '😳',
|
||||
':dizzy_face:' => '😵',
|
||||
':cry:' => '😢',
|
||||
':persevere:' => '😣',
|
||||
':worried:' => '😟',
|
||||
':hushed:' => '😮',
|
||||
':mag:' => '🔍',
|
||||
':hot_beverage:' => '☕',
|
||||
':exclamation:' => '❗',
|
||||
':question:' => '❓'
|
||||
);
|
||||
|
||||
// outputs the editor toolbar
|
||||
function plugin_emoticons() {
|
||||
global $plugin_emoticons;
|
||||
if (!count($plugin_emoticons))
|
||||
return true;
|
||||
echo '<script src="' . plugin_geturl('emoticons') . 'res/emoticons.js"></script>';
|
||||
echo '<div class="emoticons">';
|
||||
foreach ($plugin_emoticons as $text => $emoticon) {
|
||||
echo '<a href="#content" title="' . htmlentities($text) . '" onclick="emoticons(unescape(\'' . urlencode($text) . '\')); return false;">';
|
||||
echo $emoticon;
|
||||
echo '</a> ';
|
||||
}
|
||||
echo '</div>';
|
||||
return true;
|
||||
}
|
||||
|
||||
// replaces the text with an utf-8 emoticon
|
||||
function plugin_emoticons_filter ($emostring) {
|
||||
global $plugin_emoticons;
|
||||
|
||||
foreach ($plugin_emoticons as $text => $emoticon) {
|
||||
$emostring = str_replace(
|
||||
["$text"],
|
||||
"{$emoticon}",
|
||||
$emostring
|
||||
);
|
||||
}
|
||||
return $emostring;
|
||||
}
|
||||
|
||||
// css file
|
||||
function plugin_emoticons_css() {
|
||||
$pdir = plugin_geturl('emoticons');
|
||||
echo '
|
||||
<!-- BOF Emoticons css file -->
|
||||
<link rel="stylesheet" type="text/css" href="' . $pdir . 'res/emoticons.css">
|
||||
<!-- EOF Emoticons css file -->';
|
||||
}
|
||||
|
||||
// register css file
|
||||
add_action('wp_head', 'plugin_emoticons_css', 0);
|
||||
// register editor toolbar
|
||||
add_filter('simple_toolbar_form', 'plugin_emoticons',);
|
||||
// register to the hook
|
||||
add_filter('the_content','plugin_emoticons_filter');
|
||||
// register for emoticon in comment
|
||||
add_filter('comment_text','plugin_emoticons_filter');
|
||||
// register for the excerpt of a post
|
||||
add_filter('the_excerpt', 'plugin_emoticons_filter');
|
||||
?>
|
13
fp-plugins/emoticons/res/emoticons.css
Normal file
13
fp-plugins/emoticons/res/emoticons.css
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Name: Emoticons CSS
|
||||
* Author: Fraenkiman
|
||||
* Version: 1.0.0
|
||||
* Module: emoticons.css
|
||||
* Description: This file defines the style of the emoticons
|
||||
*/
|
||||
|
||||
.emoticons a, .emoticons a:hover {
|
||||
text-decoration: none !IMPORTANT;
|
||||
text-shadow: none !IMPORTANT;
|
||||
font-weight: normal !IMPORTANT
|
||||
}
|
21
fp-plugins/emoticons/res/emoticons.js
Normal file
21
fp-plugins/emoticons/res/emoticons.js
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Emoticons Plugin
|
||||
*/
|
||||
function insertAtCursor(myField, myValue) {
|
||||
if(document.selection) {
|
||||
myField.focus();
|
||||
sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
}
|
||||
else if (myField.selectionStart || myField.selectionStart == '0') {
|
||||
var startPos = myField.selectionStart;
|
||||
var endPos = myField.selectionEnd;
|
||||
myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
|
||||
} else {
|
||||
myField.value += myValue;
|
||||
}
|
||||
}
|
||||
|
||||
function emoticons(value) {
|
||||
return insertAtCursor(document.getElementById('content'), value);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user