WP-Cat2Calendar

WP-Cat2Calendar is a plugin which can organize posts into a calendar by category. It supports a shortcode so you can create a lot of calendars with different settings for different posts or pages on your blog. Every day in the calendar will list the posts published on that day for the selected categories.

Features

  • Simple and powerful. You don’t need a lot of settings to start using it. Just insert a shortcode into your post!
  • Highly customizable through CSS. Plugin provides example CSS which can be used for demo purposes and can be switched off in the plugin’s settings so you can define your own CSS for your calendars without being stuck to the excessive styles which the most plugins use, slowing down your website.
  • The starting day of the week depends on WordPress settings.
  • Monthly/Yearly navigation which can be shown through a shortcode option. You can choose to display only a specified month/year with or without a navigation bar or to show a current month/year only.
  • Include/Exclude author/category support.
  • Future posts support (Shows any future post by direct link, filter works using the is_single WordPress function. It doesn’t affects any other pages so if your website’s visitors don’t know a direct link to the future post it remains invisible to them as usual. I know it’s a little messy and I will limit it to the categories used in shortcode in future releases.)
  • WP_Rewrite support. (Pretty URL’s will look like http://example.com/my-post/cdate/2009-10 instead of http://example.com/index.php?p=1&cdate=2009-10. It’s depends on permalinks WordPress settings.)

Installation

WP-Cat2Calendar requires WordPress 2.6 or higher.

  • Download and extract the plugin onto your computer
  • Fill in the plugin extraction directory/folder to your blog’s plugins directory (usually wp-content/plugins)
  • Activate the plugin

Usage

Use WP-Cat2Calendar shortcode in your post/page to add a calendar.

You can add a calendar using the php lines:

$options = array(...);
echo wp_cat2calendar($options);

Options

  • cat_id – a comma separated list of category ID’s.
    1.0 – 1.0.1 – uncategorized by default.
    1.0.2 – all categories by default.
  • author_id – a comma separated list of author ID’s. (all authors by default)
    since: 1.0.2
    You also can use a special keyword post_author which will be replaced with a post author ID where shortcode is placed.
    WordPress bug (still in 2.8.5) at wp-includes/query.php line 1979 in exclusion so you can exclude only one author, but you can include multiple.
  • year – year you want to display in calendar (current year by default)
  • month – month you want to display in calendar (current month by default)
  • show_nav – show/hide month/year navigation, 0 or 1 (0 by default)
  • show_date – show/hide selected month/year title, 0 or 1 (0 by default). Have no affect if navigation is shown.
  • allow_change_date – allow user to navigate through a calendar even if navigation is hidden and user has direct link. Has no affect if navigation is shown.

Examples

[WP-Cat2Calendar cat_id="3,4" show_nav="1" year="2009" month="10"]

Show a calendar of posts for WordPress categories with ID 3 and 4 with navigation and the start date for a calendar will be October, 2009.

[WP-Cat2Calendar cat_id="1" show_nav="1"]

Show a calendar of posts for WordPress category ID 1 with navigation and the start date for a calendar will be current date.

[WP-Cat2Calendar author_id="1, 2, 3" cat_id="-4,-5"]

Show a calendar of posts posted by users with ID 1, 2, 3 for all WordPress categories excluding categories with ID 4 and 5.

[WP-Cat2Calendar author_id="-post_author"]

Show a calendar of posts posted by any user except a posts which belongs to the author of post where shortcode is placed.

[WP-Cat2Calendar author_id="post_author"]

Show a calendar of posts posted by the author of post where shortcode is placed.

Screenshots

Change log

1.0.4

  • URL Rewrite conflict with other plugins is solved
  • Design and behaviour were reworked. Now it shows posts list with excerpts when cursor is over.

1.0.3

  • Localizable navigation date format
  • Months localization through WordPress
  • Title attribute added to the post links
  • Current date fix (wrong timezone)
  • URL Rewrite fixes, now it correctly works and even outside WordPress loop
  • Default theme changes
  • Contextual help update
  • Plugin’s direct call protection

1.0.2

  • author_id option added
  • include/exclude author/category support
  • insignificant code improvements and IE8 fixes in default.css

1.0.1

WP 2.6 related fix for default css

1.0

Initial release


Download

Download latest

Available on the WordPress Plugin Directory.

36 Comments to “WP-Cat2Calendar”

  1. Edgar says:

    Hey Andrew!
    Awesome!! Thanks for changing the months in Spanish!

  2. Brian says:

    sounds promising :)

  3. [...] I’ve been reworked wp-cat2calendar to something new, hope so you like it. (first [...]

  4. [...] Eklenti Ana Sayfası Etiketler: WP-Cat2Calendar, WP-Cat2Calendar eklentisi, WP-Cat2Calendar eklentisi indir, WP-Cat2Calendar indir Paylaş [...]

  5. Camilo says:

    Hello again!! Really liked these last changes!! I’m just having a few issues (WP 2.9.1:
    - the function “wp_cat2calendar_future_posts” is exposing my drafts and pending review posts!!
    - I can’t get the permalinks in cat2cal to work, it just gives me a 404 page when navigating through months
    - the function wp_trim_excerpt really sucks! I had a similar problem with it not working correctly recently, it just uses the text you pass to it – the whole post_content in this case. My solution was creating a modified version of this function:

    $text = strip_shortcodes( $text );
    $text = str_replace(']]>', ']]>', $text);
    $text = strip_tags($text);
    $words = explode(' ', $text, $length + 2);
    if (count($words) > $length) {
    if (count($words) == $length + 2) {
    array_pop($words);
    array_pop($words);
    $more = apply_filters('excerpt_more', $more);
    $more = '' . $more . '';
    array_push($words, $more);
    }
    $text = implode(' ', $words);
    }
    return $text;

    - because of the bug above, I noticed the javascript animation is not resizing the table cells properly – they are displayed “ginormously”, but it gets fixed after you hover the mouse over them. You can see an example at http://www.afroreggae.org.br/agenda/ (in portuguese, but you can get the idea)

    Again, thanks for this great plugin, really saved my life!

  6. Camilo says:

    Oh, forgot something! In the refactored function wp_trim_excerpt, I defined “$length” and “$more” in the function parameters, so they weren’t defined in my previous comment!

  7. and says:

    Camilo, thanks for your feedback!

    I’ll check wp_trim_excerpt, I thought it’s old and stable function, shit happens :)
    Looks like permalinks of future posts working only for admins or for post owner, I’m checking it now.

    You should look to default.css to solve a problem of huge cells on your website because there should be a popups with events over the calendar, not a resizing cells. (see screenshot #1 on this page).

  8. Camilo says:

    Hey Andrew! Glad to help, your plugin helps me!
    Just to explain another thing about that modified function in my earlier comment: it’s the same function as wp_trim_excerpt, without the ‘if’ statement. If you pass a length of 20 to it, instead of making the 21st word be a ‘…’, it checks if the 21st is the last word and if it is, just use it instead of cutting it off (in case you were wandering).
    Anyway, I removed my css to use the default bundled one and it was almost right, except that the “tooltip” was getting cut off (z-index wise) when too close to some elements with relative position (if I hover a day close to the top of the table, the top of the tooltip gets cut off; if I hover a day on the left, the left of the tooltip gets cut off). The website I implemented cat2cal is full of CSS positioning.
    So I decided to re-adapt my old code instead, but the javascript implemented gets in my way, I can achieve something similar using CSS or implement my own javascript. Can you make it optional? I worked around it by using wp_deregister_script.

  9. and says:

    Hey Camilo! Yeah, I’ve seen that popup is cutted off when it’s too close to the sidebar on your website. (I just linked default.css to your page using firebug ;) )

    Also I’ve noticed that you’ve got an images in your calendar, looks like you’ve rewritten something because trim_excerpt should strip tags.

    Well, I think so I can make a two options:

    1. output only post titles like it was before.
    2. output titles + post excerpts in popup. (I think I should also rework javascript)
    3. any idea how to display it better?

    But I really don’t like the old output method when the list of posts was inside a table cell, it looks ugly if u have a long titles or too much posts in a one day.

  10. Camilo says:

    Hello!
    Actually, the images are displayed inside the calendar because these posts don’t have an explicit excerpt, so wp_trim_excerpt is called with the post content as a parameter. But wp_trim_excerpt doesn’t create a decent excerpt unless you pass an empty string to it and simulate being in the loop – it just applies a filter that nothing’s hooked to. That’s why I had to create a similar function without the “if ( ” == $text )” statement!
    If you go to that website’s front page, you can see that everything in the “highlights” area has a “…” (post titles and their excerpts). I’ve used that modified wp_trim_excerpt to achieve this, works great!
    I’m also not very fond of posts inside the table cells, I’m looking for a good tooltip jQuery plugin, but I still haven’t found a decent one! I’ll try to avoid making my own so I don’t have to mantain it just for this project (it’s not something I use a lot).

  11. and says:

    Thanks for explanation, it was obvious about wp_trim_excerpt, but anyway thank you. I just have not so much free time lately so when I’ll find a minute I fix this stuff. Actually I still can use wp_trim_excerpt because my plugin temporary overrides global variable $post when displaying posts, so I just should rewrite condition in my plugin to make it works like it should be.

  12. Camilo says:

    OK, thanks for everything!
    It turns out my client preferred when titles were being shown, so I just worked the code to get it back the way it was before, but now showing a tooltip for the description when hovering over the post title.
    Anyway, the only issue I can’t work around without changing your code is in “wp_cat2calendar_future_posts”, which (like I said earlier) exposes my drafts and pending review posts, so anyone who tries a bit of guessing (and is not logged in) can access them. I actually discovered this when a spam bot left a comment in one of those!
    Thanks for the patience!

  13. Camilo says:

    Hey, turns out I could work around “wp_cat2calendar_future_posts”. Just remove your filter and add another one with the hack (basic WP!). Anyway, here is a fix:

    function wp_cat2calendar_future_posts($posts)
    {
    global $wp_query, $wpdb;

    if(is_single() && count($posts) == 0)
    {
    $_posts = $wpdb->get_results($wp_query->request);
    foreach ($_posts as $_p) {
    if ($_p->post_status == 'future') {
    $posts[] = $_p;
    }
    }
    }

    return $posts;
    }

  14. and says:

    LOL, nice story about a bot :D

    About a permalinks, I think you should update the plugin to latest version (if it’s not updated to 1.0.4 yet) and re-activate it (deactivate + activate). There was a problem with WP_Rewrite in an early versions. I’m using it on one of my websites along with other of my plugins which are uses permalinks too and there are no problems.

    And also there can be any other plugins on your WordPress which uses permalinks not properly and just flushes the rules of cat2cal. Btw, I’m not sure that I’m using it properly but it works at least for two of my plugins which works on one WordPress installation. Documentation about a WP_Rewrite is not so clear and some of samples didn’t work properly for me when I tried to use it in a few of my plugins, there was just a conflict between them, one plugin flushed the rules of each other.

    I’m not sure that it’s a good idea add a rules on every init but it works and if I’m adding it only on plugin activation then another plugin can be activated and just flush my rules so I’m not sure that everything so clear there.

    I’ve rewritten wp_trim_excerpt function and future posts filter that you gave me, it’s already committed to plugin’s SVN. In addition, it won’t generate an excerpt for a password protected posts anymore.

    I think this plugin will be better in the future. That’s great that you writing a responses, it’s very important for me. Thank you!

  15. Camilo says:

    Hey!
    I’ve also played with permalinks a few times, they can be quite a pain! I don’t think there is a plugin conflict here. Like you, I don’t fully understand how to play with the permalinks, but my (wild) guess is that you’re not making use of the filter “generate_rewrite_rules”. Here’s an example code I’ve used in a function:

    global $wp_rewrite;

    $wp_rewrite->rules = array_merge(
    array( $this->slugUsergroup . '/(.+)/' . $this->slugHighlights . '/(.+)/?$' => 'index.php?' . $this->slugUsergroup . '=$matches[1]&' . $this->slugMethod . '=$matches[2]' )
    , $wp_rewrite->rules
    );

    $wp_rewrite->rules = array_merge(
    array( $this->slugUsergroup . '/(.+)/' . $this->slugHighlights . '/?$' => 'index.php?' . $this->slugUsergroup . '=$matches[1]&' . $this->slugMethod . '=0' )
    , $wp_rewrite->rules
    );

    Oddly, I just noticed I never returned any value from this function (even though it’s a filter) and, believe me, I worked hard to get this one to work. Just look at the end of this page: http://codex.wordpress.org/Custom_Queries . Just be sure to add the rules to the beggining of the array, or you may have trouble when another rule matches before yours.
    I guess the rules always have to be added, like everything else WP has to load before it spits something out. But, then again, maybe you should just flush when you save the options in your page or when WP calls it.
    If you’d like a suggestion on a feature you could implement, you should consider looking at the hCalendar microformat ( http://microformats.org/wiki/hcalendar ). It’s ridiculously easy to implement, it’s an open standard and it’s a move towards semantic web!
    Well, thank you for your time!

  16. and says:

    Thanks for experience sharing. I think it will be better just open someone’s plugin and look how it’s implemented there. I’m sure that someone already forced WP_Rewrite to work.

Leave a comment


This entry was posted by and on Saturday, October 24th, 2009 at 15:16.

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.