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.

Egypt protests: People are being hauled out by police and beaten – audio | World news | guardian.co.uk

If you believe police are the good guys, please listen to this audio. I know it’s Egypt and we in America will all say it’s too far away to be relevant but the fundamental attitudes and philosophies of police are the same here as they are over there.

Egypt protests: People are being hauled out by police and beaten – audio | World news | guardian.co.uk.

Also check out this video. Crazy stuff.

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)