Tag Archives: WordPress

KalinBooks Entire Blog as PDF (Creation Station Example)

I just released Kalin’s PDF Creation Station version 3.0, which now has better performance on the tool page when creating PDFs, so it should no longer hang/fail/timeout when trying to build a huge file. To prove this, here’s my entire blog as a PDF, including images, and a new feature, a Table of Contents page. To save paper, I used the new feature which allows you to eliminate page breaks between posts. If not, it would have been around 285 pages instead of 174.

What I’m Up To

A couple nights ago I started writing a science-fiction short story that I’ve been running around in my head for almost a year now. It’s passed 2000 words so far, and seems to be going pretty well. I seem to have found “the zone” where the writing goes smoothly and I can really feel the characters. This one is going to have a lot of drama, lots of screaming and crying, some action and suspense, but no violence and no cursing. I like to switch it up sometimes.

Yet another female protagonist. I honestly don’t know why the majority of my fiction is from the female perspective. The stories just always seem to work better.

————————-

The other thing I’m currently working on is version 3.0 of Kalin’s PDF Creation Station, my most popular WordPress plugin. I’m hoping with this release to clear up the majority of the feature requests that people have made. My intent is to be regarded as the best of the WordPress PDF plugins.

I’ve already added a bunch of features, which are now available if you have SVN access and download the beta version from the branches folder of this repository: http://plugins.svn.wordpress.org/kalins-pdf-creation-station/

Here’s the list of features already completed and currently in testing:

  • upgraded TCPDF engine. This should improve image handling and also fixes the blockquotes issue, so blockquotes no longer need to use a monospaced font
  • added option to automatically construct a Table of Contents page in the creator tool
  • added post_meta shortcode for post’s custom fields
  • added option on Tool page to turn off automatic page breaks between posts
  • added ability for hackers to translate/change the word ‘page’ to whatever they want
  • added option to run other plugin content filters
  • added post category(s) shortcode
  • added post tags shortcode
  • added option to convert Vimeo videos (works for both object and iframe style embeds)
  • added Ted Talk video link conversion option
  • YouTube link conversion now works for iframe style embeds as well as objects
  • added ability for hackers to change the order of the post list on the tool page
  • added post comments shortcode. Includes easy way for PHP coders to fully customize the display

I was unable to figure out how to extract a Hulu video link out of their embed code since the links don’t utilize the video ID as they do for YouTube, Vimeo and TED, so I couldn’t do a Hulu embed link conversion. If you have any idea how to do this, please let me know. Also, if you know of other video providers I’ve missed, let me know.

My plan is to add a page parent shortcode, perhaps a couple other details, then release version 3.0 sometime next week. After that, I’ll move on to version 3.0 of Post List.

Kalin’s Easy Edit Links Version 1.0 – I mean, 1.1

Yesterday I released version 1.0 of Kalin’s Easy Edit Links WordPress plugin. It’s basically the second version but for some reason my original release, which I called 0.7, didn’t have any bugs or anything I’d forgotten, so I never actually had an excuse to make another release to bring it up to 1.0.

However, the bug-free-ness didn’t continue. After upgrading on my live site, I discovered a mysterious PHP error that was only occurring on KalinBooks.com and not on either of my development environments. There’s nothing I hate more than developing against a live site, but if you can’t reproduce the problem anywhere else, that’s what you gotta do. Turned out it had to do with the excerpts I was manually pulling out of the post content. The HTML source looked to have a bunch of corrupt characters in the post. I wonder if the processor was just kinda choking because it was retrieving the full post content for every page and post on my whole website, then truncating and displaying a portion of that content, all in one page view.

Anyway, to fix this, I added in 1.1 the ability to turn the excerpts on and off. If anyone has any ideas what may be happening, please let me know.

With 1.0 I’ve added:

* custom post type support
* column for attachments
* ability to select which post types to show
* ability to customize order and abbreviation of columns

With 1.1 I’ve added:
* ability to turn “excerpts in link titles” on and off

Kalin’s Easy Edit Links adds a customizable box to your edit screens with links and edit buttons for all pages, posts, tags, categories, attachments, links and custom post types for convenient linking.

Kalin’s Post List Version 2.0 Released

Celebrations.

Today I released version 2.0 of my WordPress plugin called Kalin’s Post List. Here’s some of the features I’ve added:

*added Custom post type support
*”None” post support (you can now use the plugin to simply insert plain HTML. Shortcodes here refer to current page)
*support for listing pages/custom posts based on parent page (including current page)
*post thumbnail/featured image shortcode
*shortcode for link to page/post PDF (requires PDF Creation Station plugin)
*format parameter for total customization of all date/time shortcodes
*length parameter to [post_excerpt] shortcode
*offset parameter for [item_number] shortcode to start count at something other than 1
*shortcodes now show nothing if no results instead of broken/empty list
*fail gracefully when incorrect preset param entered (shows error if admin, nothing if regular user)
*improved handling of HTML-conflicting characters
*strip shortcodes out before showing excerpts
Kalin’s Post List creates a shortcode or PHP snippet for inserting dynamic, highly customizable lists of posts or pages such as related posts or table of contents into your post content or theme.
Code is poetry.

How to change default PDF directory in Kalin’s PDF Creation Station

In version 2.0 of Kalin’s PDF Creation Station, which I released earlier today, I moved some code around to facilitate the ability for people with a basic understanding of PHP (or even non-coders may be able to get this to work) to customize the location of the generated PDF files.

To do this, first open kalins-pdf-creation-station.php in a text editor (located in plugins/kalins-pdf-creation-station/), or enter the edit section under ‘plugins’ in your WordPress admin and find the file.

The code that designates the PDF directory currently begins on line 40 (this may change in the future, though probably not by much. Refer to code comments for updated information.) The code looks like this:

$uploads = wp_upload_dir();
define("KALINS_PDF_DIR", $uploads['basedir'] .'/kalins-pdf/');//base location of PDF files define("KALINS_PDF_SINGLES_DIR", KALINS_PDF_DIR .'singles/');//location to save individual page/post PDF files
define("KALINS_PDF_URL", $uploads['baseurl'] .'/kalins-pdf/');//the url string will be different from the directory so be careful define("KALINS_PDF_SINGLES_URL", KALINS_PDF_URL .'singles/');

The first line, of course, just grabs the upload directory object of your wordpress installation. Then in the next line we define the base location of PDF files, using the upload directory (files created on the tool page will go here). You can see the second parameter of the define() is the actual directory path. You can change this to whatever you want, even a hard-coded value. The next line defines the location to save the single PDF files (the ones generated by the link on individual pages). This is usually a sub-folder of the base directory, but again you can set it to whatever you’d like, or it can be the same as the base (if you don’t mind a long list of PDFs on your tool page).

Remember, URLs that browsers use to navigate are different from the server directory that PHP uses to modify files. Thus, the last two lines now define the proper URLs that map to the corresponding directories in the previous two lines. You can see this is easy when using the $uploads object to simply grab the [‘baseurl’] or [‘basedir’] so things match properly, but if you understand your server’s directory structure and URL mapping, you should be able to put the folders wherever you’d like.

Also remember that you will either need to copy this code into wp-config.php or re-do this every time I make an upgrade to this plugin. Beware when copying into wp-config.php that you will not have access to the wp_upload_dir() function so you will need to hard-code the paths or use functions available outside of WordPress. Also remember to add your code above the line that says “/* That’s all, stop editing! Happy blogging. */” The example below should work in wp-config.php.

The actual final PDF folder does not need to exist yet. If it doesn’t, the PDF creation script will create it automatically.

——————-

In the next section in the PHP file you’ll find some more commented-out code that looks very similar to what we just looked at.

/*
define("KALINS_PDF_DIR", $_SERVER['DOCUMENT_ROOT'] .'/pdf/');//base location of PDF files
define("KALINS_PDF_SINGLES_DIR", KALINS_PDF_DIR);//location to save individual page/post PDF files

define("KALINS_PDF_URL", "http://" .$_SERVER['HTTP_HOST'] .'/pdf/');
define("KALINS_PDF_SINGLES_URL", KALINS_PDF_URL);//this will put all PDFs in the same folder
*/

If un-commented to replace the previous section, this code will set the base and single PDF locations to the document root of your website in a folder called simply “pdf”.

Become a Kalin’s WordPress Plugin Beta Tester

I am currently hard at work on version 2.0 of Kalin’s PDF Creation Station WordPress plugin, which is one of my excuses for not making many blog entries lately. It occurred to me that some users may have SVN and want to get their hands on the new features a little early, before I’m completely finished testing and tweaking. It also helps me a lot to have someone using it before the new features go live.

If you have SVN, the repository locations are

http://plugins.svn.wordpress.org/kalins-pdf-creation-station/

http://plugins.svn.wordpress.org/kalins-post-list/ (for my Post List plugin)

http://plugins.svn.wordpress.org/kalins-easy-edit-links/ (for Easy Edit Links plugin)

Newest beta versions of these plugins should be located in the branches folder. If branches is empty, I have probably taken a break from that particular plugin project. Creation Station is my big project, the other two are comparatively simple plugins.

—————————-

New stuff in the PDF Creation Station 2.0 beta:

*Added support for custom post types
*moved the code identifying the default PDF directory and URL into a few constants at the top of kalins-pdf-creation-station.pdf, so that hackers can easily change them to whatever they want. Added example code that can be un-commented to change the PDF directory to use the base domain of your site instead of the wordpress uploads directory.
*Fixed minor bug where ‘reset defaults’ on the settings page wasn’t refreshing the ‘post slug’ and ‘show on home’ checkboxes
*Added “create all” button on settings page
*Added “automatically generate PDFs on publish and update” option on settings page
*changed blockquote code so it uses the ‘pre’ tag because it was the only way to get TCPDF to actually display anything since it doesn’t want to render blockquotes or tables properly
*added post_excerpt code to use “wp_trim_excerpt”, which doesn’t appear to be functioning anymore — then changed to manually extract 250 characters from the page content
*added option to run other plugin shortcodes to both settings and tool pages
*added option to convert embedded youtube videos into a link to that video
*added ‘format’ parameter to all time shortcodes for total custom date/time formatting
*added ‘length’ parameter to the post_excerpt shortcode to set character count of the excerpt
———————-
New stuff in the works for Kalin’s Post List version 2.0:
*add format parameter for total customization of all date/time shortcodes
*add length parameter to [post_excerpt] shortcode
*add offset parameter for [item_number] shortcode to start count at something other than 1
*add ‘increment’ param for [item_number] shortcode to allow counting by something other than 1
*Custom post type support
*”None” post support (use the plugin to simply insert plain HTML)
*support for listing pages/custom posts based on parent page
*post thumbnail/featured image shortcode
*shortcode for link to page/post PDF (requires PDF Creation Station plugin)

Using Kalin’s PDF Creation Station when wp-config.php is in a Non-Standard Location

If you are trying to use my PDF Creation Station WordPress plugin and you have moved your WordPress installation’s wp_config.php file to a different location, the creation script will fail. You can fix this easily (I’m assuming if you know enough to move around your wp_config.php file that you know a little about PHP) if you go into your plugin directory /kalins-pdf-creation-station/kalins_pdf_create.php and go to the line, require_once("../../../wp-config.php"); and simply change this to refer to your wp-config.php location.

Post List – I’m a WordPress Plugin Makin Machine

I released my latest WordPress plugin, Kalin’s Easy Edit Links, about an hour ago (I used it to add the link earlier in this sentence) and I’m now in process of building my third WordPress plugin, which I’m calling, Kalin’s Post List. It is basically a shortcode that you can insert into a post or page (or function-calls you can insert into a theme) that will display a customized list of posts. Hopefully development goes as well as my previous two plugins and I can have this out in a month or two. No promises, though.

My plan is to make this pretty feature-rich, so this plugin can be utilized as a related posts or random posts plugin. It will allow you to limit the results to certain categories or tags (will even set it so it can dynamically sense the category or tag of the current page), set the count, order by (there’s like a dozen different ways WordPress can return post database results), before list HTML and after list HTML. But I think the key to this plugin is going to be my plan to have shortcodes within the shortcode. There will be a setting for the actual list item HTML, which will allow the user to insert plugin-specific shortcodes that refer to the current post in the list, similar to how I structured the shortcodes in Kalin’s PDF Creation Station. This will allow you to completely customize the display to have a link to the post, show the excerpt, date, author, modified date, comment count, ID, whatever you want, and still be able to have any HTML you want injected around those items, as opposed to the way most plugins like this function where they have their own static HTML structure with a few options inserted.

Now I know what you’re thinking: “Sounds too complicated. Do you seriously expect me to write a bunch of HTML into a shortcode, then deal with shortcodes within that shortcode and keep track of half a dozen other options while I’m trying to write a post?”

This is why I’m going to add two important features: first, obviously, is default options that you can set on the settings page so if you’re reusing the same shortcode, you can just set them once and use a minimized shortcode in the actual post. However, if you want to use this plugin on different pages with different settings, there will be a shortcode generator engine on the settings page, so you can set all your settings through normal form controls then output them all to a textfield which you can easily copy and paste into your post. At the same time, I can even have an option to output PHP code for copying into your theme.

From what it looks like, this plugin will actually be pretty lightweight in terms of overall blog performance.  Often times plugins need to add hooks all over the place for catching this or that piece of data. All this plugin requires is a settings page and a single shortcode function. They will be fairly complex, of course, but will only run when they are specifically called.

I plan to use this myself on all my main index pages, for my MicroBlog page, as a related posts list at the bottom of every post, and as a recent posts and/or random posts sidebar widget.

My WordPress Plugin Ideas

Some WordPress plugins I might write

Website Conversion: I want to be able to upload a zip file of my old website and automatically convert each page into a new page or post. It would be easy to let the user set a string to mark the beginning and one to mark the end of the post and just pull it out. The only issue is trying to automatically pull out the title, description and keywords, since people use different SEO plugins, but perhaps I could set it to figure out which plugin they’re using and insert the proper metadata.

Link Finder: a tool to parse through all your pages/posts or even comments, searching for outgoing links and has the option to automatically add them to your blogroll and can output a customizable HTML list.

YouTube Finder: Something to search through all pages/posts for YouTube videos and puts them all in a list. I could add a user-facing interface to quickly switch between them so you could have a page with all the videos you’ve ever posted. I’ve worked with the YouTube API a couple times before, and found that you can do some pretty slick stuff if you’re willing to really pound on it. With Flash I could build a full-screen feature with popup navigation and autoplay options.

Post listing shortcode: A plugin that will add a shortcode you can use to put a post listing directly into another post, with options to show only certain tags or categories and display options like using either excerpt or the full post. This way I can easily make a page for my microblog, have a little intro at the top, then go straight into a list of posts that’s stripped down compared to my normal category pages that include post info and extra formatting that in this case is useless. I’ll also use it to do things like add links to the last 20 atheism posts on my atheism page.

Social Bookmark auto-post: I have a WordPress auto-post plugin but it seems buggy and doesn’t work exactly the way I’d like. I’ve had a twitter plugin but it had issues as well. I also tried the OnlyWire plugin, the only multi-site auto-posting plugin, but that was hella wonky with the way it tied into a desktop app which would randomly pop up CAPTCHA boxes throughout the day, and didn’t work at all on scheduled posts. Instead, I want to make a plugin that ties into the legitimate APIs of the major social bookmarking engines to automatically post links to your new blog entries in a manner that doesn’t violate their site policies.

Easy Edit Links – My New WordPress Plugin

So I’m making a new WordPress plugin that I’m calling Kalin’s Easy Edit Links, though I may change that before release. It’s just a little box that shows up in your page/post edit page that has a list of all pages, posts, categories, tags and links, with links to both the actual page and to the edit page.

Kalin's Edit Links Screenshot 1
Showing a list of posts with links and edit buttons

I figure this solves two hassles I have in making posts with WordPress. First, if I’m doing more than one post in a sitting, I want to be able to switch to the edit screen of the next post without waiting to load, then search through, the posts page. Second, I found myself constantly going back to my live site to find the link to a particular page so I could reference it. With this, I have it right there, ready to copy into my post. Google Chrome and Safari users can even drag and drop the link right into the post and it’s all ready to go. Firefox, for some reason converts the link into a relative link, which then breaks when it goes live 🙁 Imagine that, for once Safari does something better than FireFox. If anyone knows how to fix this in FireFox, please let me know. Internet Explorer can’t drag links at all, but at least you can copy and paste.

It seems like this plugin would be a processor hog since it needs to compile five different, potentially long lists, and needs to hit the database at least five times. However, I’ve built in a caching feature (see the debug output “not cached” in the image) that simply saves all it’s HTML to a WordPress option and loads it next time, giving you a little refresh button in the corner. When I write the settings page I might give the option for an automatic refresh on a timer, but I’m not sure if that’s even necessary.

Kalin's Edit Links Screenshot 1
Showing Categories

I should be releasing this plugin within a week or two, after I finish the settings menu.

I may even add a shortcode so you can add this little box into a post or into a sidebar… or perhaps I will simply copy this code and make a user-facing widget into a separate plugin.

I’m finding the WordPress platform quite enjoyable to work with and might just be switching my development focus away from Flash ActionScript toward PHP, HTML, CSS, JavaScript, jQuery and WordPress. An anarchist should be working with open-source technology.

Code is poetry.