Some methods have been modified. The expression is read directly from the directory. So now you can easily increase or decrease the image of the expression. Just put the picture in the face directory. However, the Chinese image name is not supported at the moment.
/*
Modify
1. The face directory can be arbitrarily increased or decreased the expression picture (Chinese is not currently supported)
2. Default support JPG, JPEG, PNG, emoji image with GIF format
Description: Comment Emoticons Plugin
*/
if (!class_exists (' silver_smilies '))
{
Class Silver_smilies
{
Private $img _dir;
Private $img _path;
Private $face _files = Array ();
Private $allow _extension = Array ();
Public function __construct ($allow _extension)
{
$this->img_path = get_settings (' SiteURL '). '/wp-content/plugins/silver_smilies/face ';
$this->img_dir = Wp_plugin_dir. "/silver_smilies/face";
$this->allow_extension = $allow _extension;
$this->face_files = $this->get_face_files ();
Add_action (' Comment_form ', Array (& $this, ' smilie_faces '));
Add_filter (' Comment_text ', Array (& $this, ' Smilie_replace '));
}
Private Function Get_face_files ()
{
$files = Array ();
if (Is_dir ($this->img_dir))
{
if ($dh = Opendir ($this->img_dir))
{
while (($file = Readdir ($DH))!== false)
{
if ($file = = '. ') continue;
if ($file = = '. ') continue;
$fileinfo = Explode ('. ', (basename ($file)));
if (In_array ($fileinfo [1], $this->allow_extension))
{
$files [] = Array (
' filename ' and $fileinfo [0],
' Extension ' = $fileinfo [1],
);
}
}
Closedir ($DH);
}
}
return $files;
}
Show emoji Pictures
Public Function smilie_faces ()
{
foreach ($this->face_files as $value)
{
echo "img_path}/{$value [' filename ']}. {$value [' extension '} ' alt= ' {$value [' filename ']} ' style= ' cursor:pointer;width=42px;height:42px; ' onclick= ' return Inface ("{$value [' filename ']}"); ' > ";
}
Echo <<<>
End
}
Convert to emoji pictures
Public Function Smilie_replace ($comment _text)
{
$keys = Array ();
$smilies = Array ();
foreach ($this->face_files as $value)
{
$keys [] = "[face:{$value [' filename ']}]";
$smilies [] = "img_path}/{$value [' filename ']}. {$value [' extension '} ' alt= ' {$value [' filename ']} ' > ';
}
$comment _text = Str_replace ($keys, $smilies, $comment _text);
return $comment _text;
}
}
}
if (!isset ($silver _smilies))
{
$silver _smilies =& New Silver_smilies (Array (' GIF ', ' jpeg ', ' jpg ', ' png '));
}
?>
http://www.bkjia.com/PHPjc/632308.html www.bkjia.com true http://www.bkjia.com/PHPjc/632308.html techarticle Some methods have been modified. Emoticons are read directly from the directory. So now you can easily increase or decrease the image of the expression. Just put the picture in the face directory. However, the Chinese image name is not supported at the moment ...