Tag Archives: WordPress

Finally updated Kalin’s PDF Creation Station WordPress plugin after three years

I’ve been saying I wanted to do this for a long time now, particularly as WordPress had classified my plugin as abandoned after three years of no updates and the TCPDF engine I use has been steadily updated. So today I released a new version of Kalin’s PDF Creation Station, version 3.2. I added a couple little new features, like now you can specify which type of name you want with your post_author shortcodes instead of being stuck with the login name. I also added a couple options to the post_thumb shortcode so you can select a size or set it to try to scrape the post and pull out the first image it finds. I wanted it to be a bit more advanced than that, like being able to specify exact sizes instead of just “small”, “medium” etc, but WordPress doesn’t seem to want to let me do that even though it says it can in the documentation. I also wanted to be able to have an option to randomly select an image scraped from the post instead of just the first image, but that would have taken a lot more work and I figured it wasn’t worth the effort.

Most importantly, though, is the upgrade to the TCPDF engine. I’ve been told this new version is much faster, so hopefully it will be more reliable as well and allow you to create much larger documents, as the old version seemed to conk out if you tried to compile more than 100 or so posts into a single PDF. I was hoping it would have better handling of images and fewer of those weird empty spaces in the final PDF. I think it may do better with the empty spaces, but the image support is still spotty. I’m not sure if that’s the fault of TCPDF or WordPress. It seems like both systems have been steadily updated so I’m not sure why this is still a problem.

I was also working on a plugin called Advanced Post List, which is a fork of Kalin’s Post List, but we both seemed to have burnt out on that one for some reason, even though I made the same two shortcode changes to that plugin that I did to Creation Station so I may wind up updating Kalin’s Post List as well. These plugins did always bring in a lot of traffic to my site, even if the visitors aren’t here to read my stories or opinions, it’s nice to have someone coming here for something.

Kalinbooks redesign

So you may notice a new design to the site. I finally got rid of the old theme that I was using–it was a theme I thought was pretty good looking but I had modified it heavily and the original was developed before featured images and menus, so I finally decided to upgrade to WordPress’ own 2014 theme. It’s not perfect but I think it’s an improvement, for one, because it modifies itself for mobile use. I kinda like the way they did it, just moving things around based on window width.

So I’ve been debating over so many different aspects of link placement, what links should go where. I’ve got so many, I don’t know how anyone deals with a single-sidebar website. Should I list fiction above true stories? What all should I put in the About Kalinbooks page? Will people be confused by the fact that I have an anarchism page and an anarchism blog category? How do I portray the fact that I’m covering anarchism, atheism, web development, science fiction every once in a while BDSM and sex with a couple recipes thrown in for fun, without confusing the reader? How are people just looking for one subject supposed to find anything? Or is that not the best idea? Maybe I should put the overall site as a lower priority and focus on promoting individual articles and posts… in which case I would need to paying attention to promotion… blechh.

I read recently that to be a successful blogger you should spend %80 of your time promoting your blog and only %20 writing if you want to really make it. That seems so sad to me. We should have designed the internet and our social networks to bubble up the best content naturally. With all the bloggers focusing %80 of their time on promotion, they only have a fifth of the capacity to create quality blogs. So instead, I’ve just been focusing on the site all these years, telling myself that one day I’d start promoting it, when I have the time. I know no one’s really reading this site right now, but I’m sure that would change with some real work on promotion… because right now I do nearly none.

Thank You and Sorry to My Plugin Users

So in the last six months or so I’ve gotten much worse about answering the frequent comments left on this site regarding my three WordPress plugins, PDF Creation Station, Easy Edit Links and Post List. I want to thank everyone who has left praise for my creations and say that I’m thrilled at the lack of complaints considering what a learning curve they have and the fact that they’ve actually got a fair number of little bugs that I’ve never taken care of because they don’t affect me  when I use them on my own website. I can’t believe Post List and Edit Links are both at a five star rating as of this post.

And I just remembered as I was writing this, that Advanced Post List exists. This is a plugin that someone developed that is based off my Post List code. I remember he contacted me a year or two ago and asked my permission to do this, which of course he didn’t need, but was just being polite. I tried out his version and it didn’t work and I told him that if he got it working and he hadn’t removed any notable features, I’d officially deprecate my Post List plugin and send all my users to his. Then I never heard from him again and figured he’d abandoned the project. Turns out he just did a release earlier this month and has far exceeded my user base and still has nearly a five star rating.

So I need to get my local development version of WordPress up and running so I can install his plugin and make sure it works properly, then replace my plugin with a pointer to his, then I will be done with Post List support forever but the functionality will live on. The best of both worlds. One of the beauties of the open-source arena.

And I know I said I’d get back to working on Creation Station as someone pointed out a bug with disappearing images that I was able to reproduce on my own site, and the PDF engine, TCPDF, has probably come out with updates that need to be added. But frankly, I just have other priorities. I wish someone else would take my Creation Station code and start calling it their own. As far as I know it’s still the best PDF plugin for WordPress and it’s sad that it’s not being developed or actively supported anymore.

And I abandoned Easy Edit Links a long time ago because the WordPress core came out with a solution that solves the same problem… even though Easy Edit Links works better.

So anyway, I’m going back to work on my latest novel, so I’m sorry everyone who has asked a support question and is waiting for a reply. I will probably get back to you at some point, but I may start going through them in batches once a month or so, so I apologize for that.

But I must say, it has been pretty great doing these plugins. Definitely one of the proudest moments of my career, even though I don’t think I made more than two hundred bucks in donations total between all three of them. Most of the code I have written professionally was, in one form or another, designed to get money from people, so it feels good to have supported a community like WordPress.

Customize or Remove Header and Footer in PDF Creation Station

Occasionally folks have asked me if they can remove or customize the headers and footers in my WordPress plugin, PDF Creation Station. Unfortunately I’m trying to focus more on my fiction writing right now so I’m on a development hiatus and haven’t been adding to this plugin. However, if you can hack some simple PHP, someone left this comment explaining how to do it yourself.

Thanks for the info Luis!

yes you can!, i´ve done it on mine, $objTcpdf->SetPrintHeader(false); $objTcpdf->SetPrintFooter(false);

this lines are to remove the header or footer and have to be written on kalins_pdf_create.php somewhere around lines 218 – 220

or search in the tcpdf.php file for –> public function Footer() { function and there you can add some text or change the black line

for example to add some text on the left side of the footer i add

$textofoot = utf8_decode(‘CONFIDENCIAL: La información aqui contenida,es para la evaluación del cliente.’);

$this->writeHTML($textofoot);

Kalin’s Post List version 3.1

Today I released version 3.1 of Kalin’s Post List WordPress Plugin. This, unfortunately, is mostly a cleanup release. I’ve decided to stop forward development on this plugin because I don’t seem to have any problem finding good programming jobs, so I don’t feel the need to expand my portfolio so much anymore and really need to focus on my story writing, which is still my first love. I do, however, intend to continue addressing bugs, maintaining current WordPress compatibility, and answering user questions.

If you have any interest in continuing forward development on this plugin, by all means, feel free. I’ll offer any advice or help I can.

There were a number of little bugs that I had to fix:

  • removed contextual help and added a link to the same help page on my website. this help menu was causing a problem with a small number of users who had XML support issues in their PHP installation. The help page is still available in the plugin source files
  • added [post_content] shortcode back into the documentation after I accidentally deleted it
  • removed global $post object from comments callback. Fixes bug where an extra post was being added to the page when this shortcode was used
  • Did same thing for php_function callback to fix the same issue. using php_function now requires you to pass in the necessary information through the shortcode parameter
  • removed a bunch of orderby options because they had stopped working in recent WordPress core upgrades
There were some features I really wanted to add, but decided not to dedicate the time:
  • custom taxonomy support
  • ability to list by author
  • ability to list comments as though they were posts
  • ability to select post status, so you can list only future posts or exclude private posts, etc.
  • ability to export all your presets to a JSON string or file, so you could save all your presets to your local computer, just in case your WordPress crashed or you needed to transfer them to a new blog.
  • advanced sorting to allow orderby to work for post slug or category
  • multi-level listing, such as ability to list off categories/tags/parents with sub-posts listed below each

When Atheism and Anarchism Coincide (Post List Test)

Today I released the new version 3.0 of Post List, my WordPress plugin that allows you to build presets that you can then refer to by shortcode in your posts, or add to your theme with a PHP snippet. Also, new in version 3.0 is a widget. I’ve added one called “recent posts” to my left sidebar, though I’m not sure if I’m gonna keep it. I’ve also added a bunch of cool features to Kalin’s Post List, like a shortcode to call a custom PHP function, post comments, tags, cats, and parent shortcodes, and a preview feature so you don’t need to make a test post to see what your list will look like.

One other feature I’ve added is the ability to require that all your selected tags or categories be included in every post, as opposed to the default behavior which only requires each post to have one of the selected tags or categories. This makes it so you can make lists of overlapping things, so just as a test to show you, I thought I’d give you a dynamically generated list of my blog posts that fall under both the atheism and anarchism categories.

Thou Shalt Not Lie - 02-23-2014
Faith • Equality • Family - 11-05-2012
Glass Houses Can be a Great Strategy - 10-12-2012
How do I Kill the Negativity? - 04-03-2012
Republican Dominated Florida Legislature Passes Bill Allowing Prayer In School | Addicting Info - 03-03-2012
Why is Breast Cancer not Scary? - 10-06-2010
Crime is not Logical - 09-07-2010
Thoughts on Dual Perspectives and the Hoarders TV Show - 08-08-2010
True Story About Isaac Zamora: Middle Finger Vengeance - 08-02-2010
20 Logical Fallacies - 07-26-2010
Why Most Americans Support Terrorism - 05-23-2010
Everything is OK series - 05-22-2010

Injecting Custom PHP Functions into Kalin’s Post List

In version 3.0 of Kalin’s post List WordPress Plugin, I added a new feature that adds even more customizability, the [php_function] shortcode which you can use to call any user-defined PHP function you have created. In version 3.1 of the plugin, I changed it slightly.

Here’s how to use it.

First, add this line into your wp-config.php file:

define("KALINS_ALLOW_PHP", true);

It will need to go above the line that says “That’s all, stop editing! Happy blogging.” This is for security, just to be on the safe side. I don’t believe there are any major security issues with this, but if I’m wrong, this ensures that no blog will be put at risk without permission.

Next, create your function. I put mine in my wp-config.php file, but you could probably put it in other locations. You can name your function whatever you want, as long as it’s unique. Your function may have one or two parameters. The first one (new in version 3.1) will always be the $post object for the current post in the list. If you can’t get all the necessary information from the $post object, the second parameter will be your optional custom param. If you require more than one custom parameter, you will need to pass it in as a delimited list or JSON string. The parameter will be a string, so if you need numbers or booleans, you will need to run a conversion on them.

Now that your function is ready, you can call it with the shortcode [php_function name=”function_name” param=””]. Replace the ‘name’ parameter with the name of the function. Replace the ‘param’ parameter with the function parameter(s).

As of version 3.1, this function no longer runs in a pseudo wordpress loop, so you cannot use the global $post object, but you now use the first parameter of your function, which should be the correct $post object.

The other option for getting post info is to actually pass it in through the ‘param’ parameter by use of a shortcode within the shortcode. For example, if you wanted a function called ‘myFunction’ to receive the post’s author as its parameter, you would use the shortcode: [php_function name=”myFunction” param=”[post_author]”]. The internal shortcode can even have its own parameters if you want. A shortcode with parameters inside a shortcode parameter that all runs inside a shortcode. 🙂

—————————-

So here is an example of something simple you can do with this feature. If you copy this code into your wp-config.php, it will output an edit link only if the currently logged in user is the author of the post. You can then refer to this function in your post list with the shortcode: [php_function name=”postListEditLink”].

define("KALINS_ALLOW_PHP", true);
function postListEditLink($post){
	$user = wp_get_current_user();
	$wpurl = get_blogInfo("wpurl");
	if($post->post_author == $user->ID){
		return '<a href="' .$wpurl .'/wp-admin/post.php?post=' .$post->ID .'&action=edit" >edit</a>';
	}else{
		return "";
	}
}

Customize/Translate the word ‘page’ in Kalin’s PDF Creation Station

I had someone make a request of my PDF Creation Station WordPress plugin to be able to customize the word ‘page’ which appears before the number at the bottom of each page. I may add a field onto the settings pages for this, but in the meantime, you can customize/translate this word by adding the following code into your wp-config.php file:

define("KALINS_PDF_PAGE_TRANSLATION", "page translation");

Doing this should keep the translation even after I upgrade the plugin.

 

Change the Order of the Post List in Kalin’s PDF Creation Station

A couple people have asked for the ability to change how the posts are ordered on the Tool page of my PDF Creation Station WordPress plugin so they don’t have to spend so long reordering them before creating. I ultimately would like to create an Ajax script to refresh the list from an ‘order by’ dropdown box. That’s a little complex and time-consuming so I think there are more important things for me to be doing, so in the meantime, for version 3.0, I’ve added a way for anyone with a little PHP experience to change how the posts are ordered. If you look into kalins_pdf_tool_page.php, currently on line 16 you will see this code:

if(defined("KALINS_PDF_POST_ORDER")){
	$customList = get_posts('numberposts=-1&post_type=any&orderby=' .KALINS_PDF_POST_ORDER_BY ."&order=" .KALINS_PDF_POST_ORDER);
	$postList = get_posts('numberposts=-1&orderby=' .KALINS_PDF_POST_ORDER_BY ."&order=" .KALINS_PDF_POST_ORDER);
}else{
	$customList = get_posts('numberposts=-1&post_type=any');
	$postList = get_posts('numberposts=-1');
}

You can see that the code is referring to two constants called KALINS_PDF_POST_ORDER_BY and KALINS_PDF_POST_ORDER. All you need to do is define both these constants in your wp-config.php file. Doing this will keep the setting constant even after upgrading to new versions of the plugin.

define("KALINS_PDF_POST_ORDER_BY", "order type");
define("KALINS_PDF_POST_ORDER", "ASC");

You may replace “ASC” with “DESC” to reverse the order. Replace order type with any of these possible values:

  • 'author' – Sort by the numeric author IDs.
  • 'category' – Sort by the numeric category IDs.
  • 'content' – Sort by content.
  • 'date' – Sort by creation date.
  • 'ID' – Sort by numeric post ID.
  • 'menu_order' – Sort by the menu order. Only useful with pages and attachments.
  • 'mime_type' – Sort by MIME type. Only useful with attachments.
  • 'modified' – Sort by last modified date.
  • 'name' – Sort by stub.
  • 'parent' – Sort by parent ID.
  • 'password' – Sort by password.
  • 'rand' – Randomly sort results.
  • 'status' – Sort by status.
  • 'title' – Sort by title.
  • 'type' – Sort by type.

Customize Display of Comments in Kalin’s Post List and PDF Creation Station

In version 3.0 of  PDF Creation Station WordPress plugin, and version 3.0 of  Post List, I added a shortcode for post comments that looks like : [post_comments before=”” after=””]. Naturally the biggest issue with this is that some folks want a specific formatting and perhaps other special handling such as removing pingbacks, customizing name/date formatting or dealing with nested comments. Here’s how you can add your own function to handle post comments in the PDF.

Currently in kalins-pdf-creation-station.php, or kalins-post-list.php, you will see a function called commentCallback($matches). This is currently what processes the comments shortcode. You will see the first thing it does is check to see if you have defined your own comment callback function:

if(defined("KALINS_PDF_COMMENT_CALLBACK")){//remove this if statement if you copy this function to use it as a custom comments function
return call_user_func(KALINS_PDF_COMMENT_CALLBACK);
}

So the first thing you want to do to create your custom comment function is copy this whole function into your wp-config.php file and give it a unique name. You could probably put it somewhere else and this would still work. Then remove the if statement that checks for your custom callback (very important to prevent infinite loop). Then you simply modify it to display the comments however you want.

The final step is to also put this code into your wp-config.php file and replace the name of the function:

define('KALINS_PDF_COMMENT_CALLBACK', 'my_function_name');

Doing this should give you your custom comments display and should remain in effect even after upgrading to a new version of this plugin.