WordPress Plugin: Read Text File
Warning: file(/home/content/b/o/m/bomberZ/html/wp-content/untitled.txt) [function.file]: failed to open stream: No such file or directory in /home/content/b/o/m/bomberZ/html/wp-content/plugins/read-txt/read-txt.php on line 25
Warning: implode() [function.implode]: Argument must be an array in /home/content/b/o/m/bomberZ/html/wp-content/plugins/read-txt/read-txt.php on line 26
This WordPress plugin will allow you to display the contents of a text file within a post by adding a simple shortcode including a path from the root folder:
Example:

Shortcode:
Output:
Welcome to “Read Text File”













AAron,
I am a newbie to WordPress and I still have not dove into the WP code yet to figure out all of the functions and calls. I did install your Read Text File plugin and I have a question. The file that I am uploading on a daily basis it FTP’d from a Unix platform, so it has just an LF at the end of the lines. When Read Text File displays it, it has a blank line between each line of text. (see Recent Earthquakes under Active Earthquakes on http://AnimalSen.se).
In you code, there is line of code:
$rt_text = ”.nl2br($string).”;
I would assume from the name of the function, it is converting a LF to a . Could this be adding the extra blank line to my text file? Is there a simple way to fix this?
Thanks!
Ed
Comment by Ed on October 18, 2011 at 6:09 pm
Your site’s style sheet is the problem.
In your code it says…
.entry-content {line-height: 30px}
Do you have control over your style sheet? If so, you can reduce the line-height to 22px. But it is not an issue with the plugin.
Comment by Aaron on October 21, 2011 at 4:58 pm
Aha! Thanks for this plugin! What I’ve really been looking for is something that would convert Markdown files, and I find that it was simple enough to tweak your process with a call to Markdown, SmartyPants, and my own Markdown extensions.
Here are the results: http://elflife.net/galadae/2011/11/06/markdown-test/
Comment by Eric on November 6, 2011 at 12:53 pm
I have never heard of it…but I’m glad I could be a part of it. thanks Eric
Comment by Aaron on November 7, 2011 at 5:15 pm
[...] my previous plugin read-text, this plugin is a custom plugin and will not be added to the WP [...]
Pingback by Aaron Sonnenberg » Wordpress Plugin: Top-Bar on February 8, 2012 at 2:22 pm
Thank you for your plugin, how can I use utf-8 code ?
then I can read Chinese. Thanks !
Comment by jensen on March 22, 2012 at 11:17 am
[...] my previous plugin read-text, this plugin is a custom plugin and will not be added to the WP [...]
Pingback by WordPress Plugin: Top-Bar | CLARITY SITES on April 20, 2012 at 3:06 pm
Okay nice, but where is the shortcode??O_o
Comment by SEfa on April 29, 2012 at 1:39 am
Firstly the short code is [read-text path="/wp-content/...."]
Secondly if you want to use this to display code snippets, which is probably why you are here anyway, then you will need to html encode the contents of your file before displaying. I have modified the function to call htmlentities as follows:-
function rt_function ($text) {
$file = $_SERVER['DOCUMENT_ROOT'] .$text["path"];
$contents = file($file);
$string = implode($contents);
$rt_text = ''.nl2br(htmlentities($string)).'';
return $rt_text;
}
Comment by Chris Backhouse on May 1, 2012 at 1:07 am