I recently had the task of working on a leaderboard for a project at work. I used ASP.NET for the project and found I was having problems getting the rank to work correctly when the gridview went to the next page of results.
I started using Quick Cache on a site recently and some of the publishers (setup as editors) wanted to be able to clear the cache manually to ensure their posts went live right away. So I wrote a quick script to handle that. I’ll probably release a plugin for this eventually, but for now…here’s the code:
function check_publish(){global$current_user,$post;$capability='publish_';// Check current post type...if we have one availableif($post->post_type!=''){// Set the capability we are looking for to publish_<post_type>s$capability.=$post->post_type.'s';}else{// Set the default capability to publish_posts$capability.='posts';}// Check if the user has rights to publish a postreturn current_user_can($capability);}
add_filter('ws_plugin__qcache_ms_user_can_see_admin_header_controls','check_publish');
This will include the Clear Cache button in the admin section of WordPress.
I came up with an object-oriented way of working with my plugin’s options for my work projects.
Creation
So then all I have to do in my class is create an instance of this: $options = new My_Plugin_Options('my_plugin_options_name');
Accessing
It will store all of your plugin options in 1 record in the database as an array. You can easily access one of the options by doing this: $this->options->my_first_option
Saving
After updating all the options, we need to save them at once. $this->options->save();
My Setup
I’ve created a folder inside wp-content/plugins for some code that I use on multiple plugins/themes at work. I don’t have the plugin declaration at the top of the main file, so it doesn’t get recognized as something needing activation. All I do is require the main file in my plugins and themes and that file includes the rest of my classes; the Options class being one of them. I’ve also created a couple classes for dealing with custom post types and taxonomies.
I was searching online for a quick solution to retrieving a list of users from WordPress by role. I found a solution but decided to check the core user functions for a better alternative. As of WordPress 3.1, you can use the handy get_users() function.
Old Way
You had to create your own function that used the WP_User_Search() object.
function getUsersWithRole($role){$wp_user_search=new WP_User_Search($usersearch,$userspage,$role);return$wp_user_search->get_results();}$editors= getUsersWithRole('editor');
I’ve started to play around with WordPress 3.0 Beta 2 and the new menu system it has. While playing around with it, I thought it might be nice to include a dropdown box of menu choices on a settings page for a theme. So I made a function similar to that of the dropdown box for categories (wp_dropdown_categories). I called this one wp_dropdown_nav_menus.
If you want to use this in your code, please change the prefix of the function from wp_ to something more useful for your purpose. Just in case WordPress comes out with a function similar to this one.
Alright troops…who’s gonna be first to test out the latest and greatest Event Viewer for Windows Mobile?
I’m not going to say its perfect, because the only person to test it has been me! If you don’t like it, then just don’t tell your friends about it. If you do like it, by all means get your developer friends to use it in their Windows Mobile applications.