WordPress Tutorial: Plug in free inserting QQ emoticons into articles

 Watson Blog September 15, 2017 18:24:42 WordPress comment one hundred and seventy-nine Reading mode
abstract

Sometimes, an expression plays a role that cannot be described in words. I believe that we often chat with QQ expressions, which is a deep experience. Some blogs insert expressions that are not so stiff, expressing emotions more abundantly, and making it easier for readers to browse.

WordPress教程:免插件在文章中插入QQ表情

Expression Pack Preparation

Download the emoticon package, decompress it locally and upload it to the img directory of your theme directory. If there is no such directory, create a new one.

Deployment Code

Add the following code to functions.php. Note that the emoticon address of line 7 in the code is img/smilies Change to your own file path.

  1. /*? code? Share from: Free Fish Blog*/
  2. //Output WordPress emoticons??
  3. function ? fa_get_wpsmiliestrans(){
  4. ???? global ? $wpsmiliestrans ;
  5. ???? $wpsmilies ?=? array_unique ( $wpsmiliestrans );
  6. ???? foreach ( $wpsmilies ? as ? $alt ?=>? $src_path ){
  7. ???????? $output ?.=?'< a? class = "add-smily" ? data-smilies= "'.$alt.'" ><img? class = "wp-smiley" ? src= "'.get_bloginfo('template_directory').'/img/smilies/'.rtrim($src_path,?" gif ").'gif" ?/></ a>';
  8. ????}
  9. ???? return ? $output ;
  10. }
  11. add_action('media_buttons_context',?' fa_smilies_custom_button');
  12. function ? fa_smilies_custom_button( $context )? {
  13. ???? $context ?.=?'< style>.smilies-wrap{background:#fff; border:?1px?solid?#ccc;box-shadow:?2px?2px?3px?rgba(0,? 0,? 0,? 0.24); padding:?10px;position:?absolute;top:?60px;width:?380px;display:none}.smilies-wrap?img{height:24px; width:24px;cursor:pointer;margin-bottom:5px}?.is-active.smilies-wrap{display:block}</style><a? id= "insert-media-button" ? style= "position:relative" ? class = "button?insert-smilies?add_smilies" ? title= Add emoticon ? data-editor= "content" ? href= "javascript:;" >
  14. ???? Add emoticons
  15. ????</ a><div? class = "smilies-wrap" >'.? fa_get_wpsmiliestrans()?.'</ div><script>jQuery(document).ready( function (){jQuery(document).on( "click" ,? ".insert-smilies" , function ()? {? if (jQuery( ".smilies-wrap" ).hasClass( "is-active" )){jQuery( ".smilies-wrap" ).removeClass( "is-active" );} else {jQuery( ".smilies-wrap" ).addClass( "is-active" );}}); jQuery(document).on( "click" ,? ".add-smily" , function ()? {?send_to_editor( "?" ?+? jQuery(this).data( "smilies" )?+? "?" ); jQuery( ".smilies-wrap" ).removeClass( "is-active" ); return ? false;});});</script>';
  16. ???? return ? $context ;
  17. }

Css beautification

After completing the above operations, you will see a Add emoticons Indicates that the addition was successful.

But when you use it, you will find that when you publish an expression, it will occupy a separate line, and sometimes the expression looks very small instead of the original size, which requires you to modify the CSS.

Add the following code to style.css:

  1. .wp-smiley? {
  2. ???? displayWordPress教程:免插件在文章中插入QQ表情 inline - block ?! important;? /*In order to make the expression not exclusive*/
  3. ???? height : 24px ?! important; /*To make the emoticon not conflict with the default CSS code, make the emoticon display larger*/
  4. ???? max-heightWordPress教程:免插件在文章中插入QQ表情 24px ?! important; /*To make the emoticon not conflict with the default CSS code, make the emoticon display larger*/
  5. }

See if it is perfect: mrgreen:?: neutral:? :evil:? :idea:? :wink:? :eek:? :lol:? :sad:? :!:?WordPress教程:免插件在文章中插入QQ表情

AD Please click here to support Watson's blog!

 Watson Blog
  • This article is written by Published on September 15, 2017 18:24:42
  • This article is collected and sorted by the website of Mutual Benefit, and the email address for problem feedback is: wosnnet@foxmail.com , please keep the link of this article for reprinting: https://wosn.net/557.html

Comment