{"id":413,"date":"2006-05-24T17:44:25","date_gmt":"2006-05-24T22:44:25","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=413"},"modified":"2014-01-20T09:03:28","modified_gmt":"2014-01-20T14:03:28","slug":"lexicon-wordpress-plugin","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=413","title":{"rendered":"Lexicon WordPress Plugin"},"content":{"rendered":"<p>This is a wordpress plugin I&#8217;ve made that will find certain words &#8211; which you define &#8211; and turn them into links which lead to your dictionary.  The user can mouse over the word to see a short definition, or they can follow the link to see the full definition.  This is handy if you have a lot of jargon on your blog which might confuse newcomers.<\/p>\n<div class=date>Example:<\/div>\n<p><i>According to Steven Sempai, the TV series of Read or Die differs greatly from the OVA.  Meganekko agent paper is only in the OVA, and contrary to common practice, the OVA has less fan service than the TV series.  There is no ecchi, and most otaku will be glad to hear there isn&#8217;t a lolicon character, either.  The cast is mostly female, but this isn&#8217;t a harem comedy.  Agent paper is a sort of quasi-mahou shojou who can manipulate paper to form weapons and tools.  There aren&#8217;t any mecha, and while agent paper is sometimes kawaii you won&#8217;t find any slapstick chibi humor here. The Seiyuu in the series are all excellent. I thought the story was silly, but some people liked it.  If you did, then akanbe!! <\/i><\/p>\n<p>In the above text, I didn&#8217;t create any of the tooltops or hyperlinks, I just typed the words and the plugin handled the rest.  If I edit the post, I don&#8217;t have to deal with the dense clutter required to make all of that work. Editing that paragraph in HTML would be a nightmare, but with the plugin I just edit the plain text and the links happen as if by magic.<\/p>\n<div class=date>Installation:<\/div>\n<p><em>Note that this plugin requires PHP5.  If your webserver does not have this, the plugin won&#8217;t work!<\/em><\/p>\n<p>First, download the plugin <a href=\"http:\/\/www.shamusyoung.com\/files\/lexicon.zip\">here<\/a>.  Unzip the files.  You&#8217;ll need to edit lexicon.php (just a bit!) and then make your dictionary.<\/p>\n<p>This plugin isn&#8217;t very advanced, and requires a little more setup than most plugins to get it working right.  Deep breath, you can do it.<\/p>\n<ol>\n<li><strong>Create the dictionary<\/strong><br \/>\nThe first step is to create the dictionary file you will use, which is called dictionary.txt by default.  You can see my dictionary <a href=\"wp-content\/plugins\/definitions.txt\">here<\/a>. There is an example dictionary included in the zip as well. <\/p>\n<p>For each word in your dictionary, there are 4 lines, the last of which is optional. Line 1 is the word (or even phrase) itself.  Line 2 is a short definition that will be used as a tooltip.  Line 3 is the full definition.  Line 4 is optional, and can specify an image to use for the dictionary entry.  Then you <em>must have at least one blank line<\/em>, and then the process starts over with line 1 of the next word, until the end of the file is reached.   If you omit the last line (the image) then the entry just won&#8217;t have one.  No biggie.<\/p>\n<p>For each entry in the dictionarty there are several lines:<\/p>\n<ul>\n<li>Line 1 is the word itself.\n<\/li>\n<li>Line 2 is the short definition used as a tooltip when the mouse hovers over the word\n<\/li>\n<li>Line 3 is the full definition.  Remember, it all has to be on one line!\n<\/li>\n<li>Line 4 is the &#8220;see also&#8221;.  Just put words seperated by commas and the dictionary will use them to cross-reference. Leave a BLANK LINE if you don&#8217;t want this.\n<\/li>\n<li>Line 5 is the image, including path.  Leave a BLANK LINE if you don&#8217;t want an image\n<\/li>\n<li>Leave one more BLANK LINE before you list the next entry.\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>Note that you don&#8217;t need to sort the entries.  The plugin will sort them into alphabetical order for you.<\/p>\n<p>Note that if the word in your dictionary is defined in ALL CAPS, then it is treated as an acronym, and it will only turn into a link if it is written in all caps.  If you do not define the word in all uppercase, it will be treated normally and any case combination of that word will become a dictionary link.<\/p>\n<li><strong>Add the dictionary to at least one post on your blog<\/strong>\n<p>Make a new post.  In this post add the following text:<\/p>\n<p>&#58;LEXICON&#58;<\/p>\n<p>That is a colon, the word &#8220;LEXICON&#8221; in all caps, and then another colon. The plugin will replace this word with the contents of your entire dictionary, complete with links and images.  You can see mine <a href=\"?p=412\">here<\/a>.<\/p>\n<p>Now edit the lexicon.php.  If you don&#8217;t know PHP this might be a little scary.  Be brave.  Just a few lines down you&#8217;ll see:<\/p>\n<p><code>$ad_dictionary_url = \"www.example.net\/somepage\";<\/code><\/p>\n<p>This is where you tell the plugin how to find your dictionary.  Inside of the quotes, put the address of the entry you just created.  If the permalink to that post is www.myblog.com\/wordpress\/my-dictionary\/  then change the line to say:<\/p>\n<p><code>$ad_dictionary_url = \"www.myblog.com\/wordpress\/my-dictionary\/\";<\/code><\/p>\n<\/li>\n<li><strong>Place lexicon.php and dictionary.txt into your wordpress \/plugins directory<\/strong>\n<\/p>\n<\/li>\n<li><strong>Enable the plugin in the wordpress control panel<\/strong>\n<\/p>\n<\/li>\n<p>All done!  Any of the words that appear in your dictionary will become links.  You can add or change the contents of the dictionary at any time.  <\/p>\n<div class=date>Using Lexicon<\/div>\n<p>Dictionary words which appear inside of HTML tags are ignored.  Words appearing after a &lt; and before a &lt; are assumed to be an HTML tag and the plugin won&#8217;t mess with them.  <\/p>\n<p>If you do NOT want a word to become a dictionary link, preceed the word with a percent symbol. For example:<\/p>\n<pre><tt><b>&#83;empai!\r\n%&#83;empai!\r\n<\/b><\/tt><\/pre>\n<p>Would yield:<\/p>\n<p>Sempai!<br \/>\n%Sempai!<\/p>\n<p>Note that you should do this if the word appears within a link!  If you don&#8217;t, the plugin will still turn the word into a dictionary link, which will break the link you were trying to create and make a mess of the HTML.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a wordpress plugin I&#8217;ve made that will find certain words &#8211; which you define &#8211; and turn them into links which lead to your dictionary. The user can mouse over the word to see a short definition, or they can follow the link to see the full definition. This is handy if you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[],"class_list":["post-413","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=413"}],"version-history":[{"count":0,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/413\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}