Things I've Tagged ‘Plugins’

Page 1 of 1

WordPress Admin Customization

Update: I’ve made some modifications to this plugin that ultimately make it work better. I won’t be updating the code in this overview to reflect the changes, but have uploaded a new version for download. One of the changes I made was to create an options page that will let you switch off dashboard widgets. Some of the others were necessitated by the recent WordPress 3.4 update.

We’re all creatures of habit, in many ways. We like to work in the same environment, with the same sets of tools, year after year, and we’re accustomed to living that way. In the online world, we’re not supposed to be like that, but we are. We arrange our desktops just so on a new system, we like our folder structure a certain way, and we like to work with familiar technology.

That’s not to say that we shouldn’t be adapting constantly.

I’m no different in my habits and preferences, and so there are a couple of things I like to do when I install WordPress for the first time. These are just a few of the things that help me get acclimated, and also to customize the experience for myself and whatever client I’m installing this for.

First things first, I’m going to set up a plugin to handle all of this functionality rather than add it to a theme’s functions.php file. That way I’m not wedded to the theme, or trying to transfer functions over when I change my mind.

 * @package CUSTOM_Site_Functionality
 * @version 1.5
Plugin Name: Custom Admin
Plugin URI:
Description: Custom admin functionality.
Author: Mike Mattner
Version: 1.5
Author URI:

class CUSTOM_Site_Functionality {
   static $instance;
   var $plugin_url;
   public function __construct() {
      self::$instance = $this;
      define('PLUGIN_URL',plugin_dir_url( _FILE_ ));
      $this->plugin_url = PLUGIN_URL . "directory";

   public function init() {
       /*....WordPress hooks to activate custom functions here.....*/
   /*....functions will be placed here.....*/


$mm = new CUSTOM_Site_Functionality;

Alright, so we have our initial class and constructor set up, ready to go so we can start to add some customization functions. First and foremost, I’m not a big fan of the typefaces in use by default, so I try to grab something I like just a little bit better. In this case PT Sans served through the Google Fonts API.

// Google Fonts Code
public function add_google_fonts() {
echo '<script type="text/javascript">
      WebFontConfig = {
         google: { 
              families: [\'PT+Sans:400,400italic,700,700italic\']
      (function() {
         var wf = document.createElement(\'script\');
         wf.src = (\'https:\' == document.location.protocol ? \'https\' : \'http\') +
         wf.type = \'text/javascript\';
         wf.async = \'true\';
         var s = document.getElementsByTagName(\'script\')[0];
         s.parentNode.insertBefore(wf, s);

Now, this function alone isn’t particularly useful, but as you’ll see I add this to any page I want to use that font on. Below, I’m adding the javascript to whatever I’ll be adding to the head tags of the admin screen right along side of a custom style sheet I’m adding.

One of the first things I used to install was an admin theme plugin called Fluency; however, since the maturation of the 3.x versions of WordPress, Fluency is no longer compatible and that’s a damn shame. I’ve tried my best to replicate that look, and so I add this function to call my stylesheet.

/************* CUSTOM ADMIN *****************/  
public function cc_custom_css() {
   echo '<link rel="stylesheet" href="' . $this->plugin_url . '/assets/css/admin.css">';

After adding that, I also like to change the footer text. In most cases I use this to brand the admin page a little bit for clients.

//add attributions to footer.
public function modify_footer_admin () {
   echo 'Your custom text.';

Now that the admin theme is set, I add the necessary code to change the look of the login screen to match it. On top of that, there are a couple of other changes I make (and I cannot remember where I ever got these from, but the login_url and login_title function are not mine originally), but I also change the logo link and title to match your site so that it is no longer branded WordPress.

/************* CUSTOM LOGIN PAGE *****************/
 // calling your own login css so you can style it 
 public function cc_login_css() {
   echo '<link rel="stylesheet" href="' . $this->plugin_url . '/assets/css/login.css">';

// changing the logo link from to your site 
 public function cc_login_url() { return get_bloginfo('url'); }

// changing the alt text on the logo to show your site name 
public function cc_login_title() { return get_option('blogname'); }

On the dashboard of the admin, there are far too many useless widgets, at least in most of my use cases. This function will eliminate EVERYTHING. You don’t want that, so you should pick and choose which ones you want or don’t want.

// disable default dashboard widgets
public function disable_default_dashboard_widgets() {	    
   remove_meta_box('dashboard_right_now', 'dashboard', 'core');// Right Now
   remove_meta_box('dashboard_recent_comments', 'dashboard', 'core'); // Comments
   remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');// Incoming Links
   remove_meta_box('dashboard_plugins', 'dashboard', 'core');// Plugins Widget
   remove_meta_box('dashboard_quick_press', 'dashboard', 'core');// Quick Press
   remove_meta_box('dashboard_recent_drafts', 'dashboard', 'core');// Recent Drafts
   remove_meta_box('dashboard_primary', 'dashboard', 'core');// WordPress Blog
   remove_meta_box('dashboard_secondary', 'dashboard', 'core');// WordPress News

Now place the following actions and filters in the init() function to hook them to various WordPress functions.

//custom admin styling
add_action( 'admin_head', array($this,'cc_custom_css') ); //admin css
add_action( 'admin_menu', array($this,'disable_default_dashboard_widgets') );//disable some default dashboard widgets
remove_all_actions('in_admin_footer',1001); //remove footer text
add_filter('admin_footer_text', array($this,'modify_footer_admin')); //add footer attribution
// calling it only on the login page
add_action('login_head', array($this,'cc_login_css') );           //add login css
add_filter('login_headerurl', array($this,'cc_login_url') );      //change login url
add_filter('login_headertitle', array($this,'cc_login_title') );  //change login title

Anyway, I could go on and on about my admin customizations, but this is the place I start every time. It’s basic, and simple to modify. Frankly, if you’re using this, you should know what you’re doing, otherwise it won’t be too useful for you.

I’m providing it as a simple download, so use it, modify it, and improve it if you like.

View Project At GitHub

Upgrade to WordPress 3.3

I actually had not been following the latest WordPress developments too closely, and so I was quite pleasantly surprised by what the upgrade to WordPress 3.3 offered in terms of looks and functionality. But…

There were a few things that I had some issues with. First, I absolutely hate that the toolbar is on by default and apparently can’t be turned off without losing some important functionality. The toolbar is my least favorite feature of all the newer WordPress features. It’s ugly and intrusive. Why are you guys so focused on pushing this thing? Is it because of I get it’s usefulness in that context, perhaps, but with the implementation it gets in my way more often than not.

I create custom plugins for all of my WordPress installations with some custom functionality and admin modifications appropriate to their contexts. Apparently a few of those were sloppily built because as soon as I upgraded, they promptly broke. There was just one line I screwed up in regards to calling a function within a class (typo), but it was something I didn’t notice as I never really ran those plugins through rigorous testing.

One of my favorite plugins for modifying the administration screen is Dean Robinson’s Fluency Admin. Unfortunately the update seems to not be compatible with it. Not one to be deterred, I went about modifying the new admin css to look at least passingly like Fluency.

If you were interested in doing the same, you could run this code through your functions.php file in a pinch, or better yet add it in a plugin:

function like_fluency_css() {
    echo '<style>
*,body {font-family: helvetica, sans-serif;} 
        img#header-logo{display: none;} 
        #adminmenu div.wp-menu-image {float: left;width: 1px;height: 28px;} 
        #adminmenu .wp-menu-image a{display: none;} 
        #wp-admin-bar-wp-logo{display: none;}
        #adminmenuback, #adminmenuwrap {background-color: #222;border-color: #444;border-right-color: #ddd;}
        #adminmenu li.wp-menu-separator {display: none;}
        #adminmenu div.separator {border-color: #0e6ac8;}
        #adminmenu, .folded #adminmenu, #adminmenu .wp-submenu .wp-submenu-head {border-top-color: #444;border-bottom-color: #000;}
        #adminmenu a {color:#fff;}
        #adminmenu .wp-submenu a {color:#777;}
        #adminmenu a:hover, #adminmenu>a:focus, #adminmenu ul.wp-submenu a:hover {color: #fff;}
        #adminmenu>a, #adminmenu>a, #adminmenu>a:focus {background-color: #000;text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);}
        #adminmenu li.wp-not-current-submenu:hover>a {border-top-color: #000;border-bottom-color: #000;}
        #adminmenu li.wp-not-current-submenu .wp-menu-arrow {border-top-color: #000;border-bottom-color: #000;background: #000;}
        #adminmenu li.wp-not-current-submenu .wp-menu-arrow div {background: #000;border-color: #000;}
        #collapse-menu {color: rgba(255,255,255,0.3);}
        #collapse-menu:hover {color: rgba(255,255,255,1.0);}
        #collapse-menu:hover #collapse-button {border-color: rgba(255,255,255,0.4);background-color: #333;background-image: -moz-linear-gradient(center bottom , #333, #444);}
        #collapse-button {border-color: rgba(255,255,255,0.2);background-color: #000;background-image: -moz-linear-gradient(center bottom , #111, #000);}
        #adminmenu .awaiting-mod, #adminmenu .update-plugins, #sidemenu a .update-plugins, #rightnow .reallynow {background-color: #464646;box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);color: #FFFFFF;}
        .folded #adminmenu .wp-submenu-head {border-bottom-color: #ccc;border-top-color: #ccc;}
        .folded #adminmenu li.wp-has-current-submenu, .folded #adminmenu {border-bottom-color: #6D6D6D;border-top-color: #808080;}
add_action('admin_head', 'like_fluency_css'); //remove logo from admin

There will be more in the days to come, but for now, I’m happy with the progress the team continues to make, and thanks for a great, free product!

Weather? Here’s Your Weather

So, I got bored one day and decided that I wanted to make a weather widget for WordPress. Sort of. I thought that I needed one for a WordPress theme I was thinking about making. As per my previous experience, I couldn’t quite find one that fit the bill, and some were just downright cumbersome in implementation. A veritable nightmare.

When I first started development, I wasn’t too keen on what API/xml data feeds to use, so I went with the ever popular XML data feed. Development was a bear because the terms of use were incredibly restrictive. You had to display their logo, which is fine, but then you HAD to display four links that were meant to generate click-throughs for them in some fashion; and all of this had to be visible near the weather data itself. Ok, I said to myself, I can deal with that, even if it makes the whole thing ugly.

This whole thing is kind of funny to me. But hey, you have to monetize that data.

Two weeks later, they decided to end the free XML data service in favor of a different API model. I thought, “Excellent, I can finally develop something free of the cumbersome links and logos I was required to use before!” Not so fast. This service cost several hundred dollars a year. Not so good for me if I’m creating a plugin. Then I discovered Yahoo! Weather, ironically enough, powered by’s data.

Ok, get to it already, jerk.

Fine, fine, fine. I simply thought that background information would be useful for you. With the previous version of this plugin, the version using Weather’s data, you were required to register with in order to obtain a key that would allow you to access the data, and I had to build that in to the plugin. This version will work fine without it. Yay! Simplification!

However, your site is limited in the number of requests that can be made in a given day. So if you have a high traffic site you’ll run into issues if you’re constantly requesting data from Yahoo. I had to build in data caching in order to keep those requests down, so now you’ll only access the API once or twice every hour to update data and that should take care of the problem. So, it’s not instant, but probably good enough.

At the moment this plugin is a little hit and miss. I don’t plan on doing much more with it, but feel free to fork this, modify it, whatever.

Download From the WordPress Repository

So, enjoy the fruits of my labor!

WordPress Site Funtionality: Plugin or Functions.php?

If you’re developing websites using WordPress as your CMS, you’ve probably had to decide whether or not to create a plugin for that site’s functionality or to just dump it into your theme’s functions.php file. My solution used to be the latter, but lately I’ve found the former to be superior for one simple reason: themes are less permanent and more likely to be changed after you’ve passed it off to the client than a plugin. Hell, even I change my theme frequently enough for it to be an issue.

That news is likely old hat to you, but it took me a while to really see things that way. I’m not much of a serious developer, and so I don’t have extensive training or knowledge of programming models and logic, but I’ve always had an interest in it. Unfortunately, using object oriented programming wasn’t something that I understood how to do. Don’t get me wrong, I get the model, and how useful it is, I just never knew how to implement it logically, efficiently, and usefully.

I found, though, that as WordPress progressed, it was going to become quite useful to understand OOP on at least a basic level.

As it stands, I’m becoming heavily invested in developing for WordPress, and when I create a site now, I am generally going to be modifying the user experience in such a way as to require the creation of a plugin. This is to make sure clients aren’t doing something that breaks the site, or to shut down some unneeded functionality mostly, but occasionally I’m adding some handy widgets and custom post types.

Bottom line: if you need some Theme dependent functionality, the obvious choice is to keep it in the functions.php file, otherwise create a plugin to preserve that functionality across themes.

Creating the Recent Custom Posts WordPress Widget

I recently found myself needing a way to display the most recent posts from multiple custom post types in multiple widgetized areas of a site I was working on.

Because I needed to do this quickly, and I assumed this need was common, I was on the lookout for an already well written and developed plugin that would do the job. I ran across a widget plugin from New2WP1 that allowed you to display the most recent posts from a single custom post type. Unfortunately, it wasn’t a multi-widget and you could only select one post type, so the plugin wasn’t suitable.

My first thought was that I could easily turn the plugin into a multi-widget capable plugin, but when I started to work on it, I realized that any modifications I made could easily be overwritten on the next update. Additionally, when I began work on turning it into a multi-widget plugin, it became exceedingly obvious that I would probably need to start from scratch.

That’s when I decided to develop a plugin of my own, based on the structure of what I saw in the plugin from New2WP, that would fit my needs, and hopefully the needs of others.

Where to Begin

Visit the Widgets API reference at the WordPress codex for a better overview of this information.

Once I figured out that I needed to turn the widget into one that could be used in multiple widgetized areas, I started to research like mad to find out what it would take to accomplish this. One trip over to the WordPress codex was enough to send me in the right direction.

It was basically as simple as this default usage code implies:

class My_Widget extends WP_Widget {
	function My_Widget() {
		// widget actual processes

	function form($instance) {
		// outputs the options form on admin

	function update($new_instance, $old_instance) {
		// processes widget options to be saved

	function widget($args, $instance) {
		// outputs the content of the widget


However, converting the existing plugin to this wasn’t as simple as the above code implies. The old plugin was built as a function, and its structure made it quite a bit more difficult to tie into the WordPress Widgets API.

Based on what I learned from New2WP’s plugin, and the WordPress Codex, I proceeded to build out my own plugin.

The Recent Custom Posts Plugin

I started by creating the directory /mm-recent-cpt/, the file mm-recent-cpt.php, and readme.txt file for future upload to the WordPress plugin directory.

In the php file I added the plugin header:

 * Plugin Name: Recent Custom Posts
 * Plugin URI:
 * Description: Multi-widget for displaying recent posts of custom post types.
 * Version: 1.0
 * Author: Mike Mattner
 * Author URI:
 * Tags: custom post types, post types, latest posts, sidebar widget, plugin
 * License: GPL

This allows WordPress to gather information about your plugin. If you just put that file into the plugins directory right now, you’ll have a plugin that does nothing, but it will show up in the list.

The structure of this widget is fairly simple because of the Widgets API. You’ll create a class that extends the WP_Widget class, essentially making it a breeze to create this plugin. I named my class mm_recent_posts. In order to get things moving, you need to initialize the plugin. In most cases you’ll use add_action to get your class or function working.

The function I’m calling with add_action returns register_widget, which takes the $widget_class argument. According to the Codex, $widget_class is the name of a class that extends WP_Widget.

So, this is my basic structure:

add_action( 'widgets_init', 'init_mm_recent_posts' );
function init_mm_recent_posts() { return register_widget('mm_recent_posts'); }

class mm_recent_posts extends WP_Widget {
    /** constructor */
    function mm_recent_posts() {
       parent::WP_Widget( 'widget_recent_cpt', $name = 'Recent Custom Posts' );

    function widget($args, $instance) {
       // outputs the content of the widget

    function update($new_instance, $old_instance) {
       // processes widget options to be saved
    function form($instance) {
       // outputs the options form on admin


The above is fairly self-explanatory as far as what each function’s purpose is. The constructor function mm_recent_posts() is designed to give a little information about the widget. You could use something along these lines to get it up and running: parent::WP_Widget('my_widget_base', 'My Widget title', array('description' => 'Very simple widget example', 'class' => 'my-widget-class'));.

Pretty easy, right?

The Plugin

The plugin I created is fairly straightforward. It is essentially just an extension of the original Recent Posts widget that comes with WordPress by default–except that this doesn’t overwrite that.

If this looks like something you could use, feel free to download, use, and modify till you’re blue in the face.

Download From WordPress Plugin Directory

I’ve now uploaded the plugin to the WordPress plugin directory. I hope you’ll find it to be useful.

I’m working on getting this added to the WordPress plugin repository The plugin can also be downloaded from the WordPress plugin repository. If you have any questions, comments, or modifications, let me know in the comments. I can’t guarantee that this will work with all plugins, particularly the Custom Post Type UI plugin, but I will say that I’ve used it, and it works for me. I apologize if my code isn’t up to snuff.

Also, welcome Stumblers! Thanks for stopping by. Hopefully you’ll find my little plugin to be useful.

  1. This is a fine plugin, it just needs to be multi-widget capable to be more useful.