Archive for May, 2012

Page 1 of 1


#Matt Yglesias, #Wisdom

A recent comprehensive survey of state licensing practices by the Institute for Justice reveals little consistency or coherent purpose behind most licensing. Nevada, Louisiana, Florida, and the District of Columbia, for example, all require aspiring interior designers to undergo 2,190 hours of training and apprenticeship and pass an exam before practicing. In the other 47 states, meanwhile, there’s no legal training requirement. My friends and co-workers living in D.C.’s Virginia and Maryland suburbs appear to get on fine with unlicensed interior decorators, and all across America, amateurs have decorated their own homes without imperiling public safety.

Matt Yglesias


This is part of the reason why I feel government intrusion can be detrimental to our interests. There’s such a fine balance to be struck here, because it seems much of this licensing is set up to either protect entrenched interests at the expense of entrepreneurs, and simultaneously protect practitioners from frivolous lawsuits, while giving the impression to consumers that it’s about their protection. In some cases yes, but in most cases–as shown above–perhaps not.



#php, #Plugins, #WordPress

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: http://mikemattner.com
Description: Custom admin functionality.
Author: Mike Mattner
Version: 1.5
Author URI: http://mikemattner.com/
*/

class CUSTOM_Site_Functionality {
   static $instance;
   var $plugin_url;
	
   public function __construct() {
      self::$instance = $this;
      $this->init();
      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\') +
              \'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js\';
         wf.type = \'text/javascript\';
         wf.async = \'true\';
         var s = document.getElementsByTagName(\'script\')[0];
         s.parentNode.insertBefore(wf, s);
      })();
      </script>';
}

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() {
   $this->add_google_fonts();
   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() {
   $this->add_google_fonts();
   echo '<link rel="stylesheet" href="' . $this->plugin_url . '/assets/css/login.css">';
 }

// changing the logo link from wordpress.org 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