Cleverness – WordPress Resources

To-Do List v. 2.2.5

The language files were not commited to the SVN properly in yesterday’s version. This version is just to correct that.


To-Do List Plugin v. 2.24

* Removed site title from email subject
* Added ability to change From value for email
* Added French translation by Thibault Guerpillon


To-Do List Plugin v. 2.2.3

Download To-Do List Plugin v2.2.8Last Updated 12-06-2010

This version of the To-Do List plugin had added default values to the assign and progress variables. This is an attempt to fix the problem users on Windows servers have had adding items. I’ve also added success or fail messages to the function that emails the assigned task to a user.


To-Do List Plugin v. 2.2.2

Download To-Do List Plugin v2.2.8Last Updated 12-06-2010

* Added Assign ability to Individual view
* HTML is now allowed in tasks
* Added error message displays for inserting, updating, and deleting items


To-Do List Plugin v. 2.2.1

Download To-Do List Plugin v2.2.8Last Updated 12-06-2010

This update to the To-Do List Plugin includes an updated Spanish translation by Ricardo, a bug fix involving multiple individual lists, and a change to the way the shortcode and widget display individual lists. If a user is logged in, they will see their own list using the shortcode or widget. Non-logged in users currently see all items. I plan to add a setting to the widget soon where you can choose what shows to non-logged in users.

Also, some of the text in the plugin has been reported as being unable to translate. I’ve looked through my code, but can’t see why that’s so. If you have any experience in this matter and want to help, please take a look at the code.


To-Do List Version 2.2

Download To-Do List Plugin v2.2.8Last Updated 12-06-2010

Version 2.2 of the To-Do List Plugin is out.

New in this version are the option to sort by assigned user and the Master list feature.

The Master list can be selected on the settings page under List View. This feature allows you to have one main list that individual users cannot edit, but they can check or uncheck items on it. Changes to the main list affect all users. You only want to give regular users the ability to View and Complete posts, otherwise they will be able to edit the main list.


To-Do List Plugin Bug Fix ver. 2.1.5

Download To-Do List Plugin v2.2.8Last Updated 12-06-2010

A new version of the To-Do List Plugin has been released.

There was a typo in the code that showed the assigned user in the widget that was preventing it from displaying.


Get Categories Author has Posted in for Custom Post Types

I needed to list all the categories of a custom post type that an author had posted in.

I found code to do that with regular posts in the wordpress.org forums and I modified it to use with custom post types.

Be sure to replace customposttype with the name of your custom post type.

Place this into your theme file where you want the list to appear.

<?php
$author = get_the_author_meta('ID');

$categories = $wpdb->get_results("
SELECT DISTINCT(terms.term_id) as ID, terms.name, terms.slug
FROM $wpdb->posts as posts
LEFT JOIN $wpdb->term_relationships as relationships ON posts.ID = relationships.object_ID
LEFT JOIN $wpdb->term_taxonomy as tax ON relationships.term_taxonomy_id = tax.term_taxonomy_id
LEFT JOIN $wpdb->terms as terms ON tax.term_id = terms.term_id
WHERE 1=1 AND (
	posts.post_status = 'publish' AND
	posts.post_author = '$author' AND
	tax.taxonomy = 'customposttype' )
ORDER BY terms.name ASC
");
?>
<ul>
<?php foreach( $categories as $category ) : ?>
	<li>
		<a href="<?php echo get_term_link( $category->name, 'customposttype' ); ?>" title="<?php echo $category->name ?>"><?php echo $category->name ?></a>
	</li>
<?php endforeach; ?>
</ul>

New To-Do List Plugin Version

Updated the To-Do List Plugin with an updated German translation by Ascobol.


Limit Number of Posts Per User in WordPress

This code will limit the number of posts a user can make.

At first, I was trying to limit each user to one post and I had that working. Then I realized that I needed to have different numbers of posts for different users, so I created an option in a user’s profile that only people with the right capability (manage_options) can edit. I’ll be changing this in the future for that number to be automatically changed depending on a user’s subscription type, but I needed this for testing purposes.

The option in the profile shows up under the contact info section, which I know is an odd place, but it was the easiest place to put it.

Put the following into your functions.php file:

// limit number of posts per user
// provided by cleverness.org
if ( !current_user_can('manage_options') ) {
	$default = 1; // default number of posts
	$count_posts = 0;
	global $wpdb;
	$poststable = $wpdb->prefix.'posts';
	$postlimit = get_user_meta($current_user->id, 'postlimit', true);
	if ( $postlimit == '' ) $postlimit = $default;
	$query = "SELECT COUNT(*) FROM $poststable WHERE post_author = '$current_user->id' AND (post_status = 'pending' OR post_status = 'draft' OR post_status = 'publish' ) ";
	$count_posts = $wpdb->get_var($query);
	if ($count_posts >= $postlimit) {
		if ( $_SERVER['REQUEST_URI'] == '/wp-admin/post-new.php' )
			Header("Location: index.php");//redirects to dashboard
		if ( is_admin() ){
			$stylesheet =  get_stylesheet_directory_uri() . '/css/limitposts.css';
   			wp_register_style('limitpost_admin_css', $stylesheet, false, '1', 'screen');
   			wp_enqueue_style('limitpost_admin_css');
			}
	}
}

// add post limit option to profile
add_filter('user_contactmethods','hide_profile_fields',10,1);

function hide_profile_fields( $contactmethods ) {
	if( current_user_can( 'manage_options' ) )
		$contactmethods['postlimit'] = 'Post Limit';
  	return $contactmethods;
}

Create a file called limitposts.css, put the following into it, and save it in a directory called css in your theme folder (you can change where you save it, but be sure to change the location in functions.php).

#menu-posts .wp-first-item + li {
	display: none;
}

If you want to use this for custom post types, change:

if ( $_SERVER['REQUEST_URI'] == '/wp-admin/post-new.php' )

to:

if ( $_SERVER['REQUEST_URI'] == '/wp-admin/post-new.php?post_type=customposttype' )

and change the id name in your CSS:

#menu-posts-customposttype .wp-first-item + li {
	display: none;
}

Be sure to replace customposttype with the name of your custom post type.