Limiting input tag to numbers without using html 5 type=”number”

The reason for this post is due to the fact that not all major browsers support HTML input types yet.

 

This example limits the input to numbers.

<input onkeypress=’return event.charCode >= 48 && event.charCode<=57′>

 

This example limits the input to numbers, but, decimal works.

<input onkeypress=’return (event.charCode >= 48 && event.charCode<=57) || event.charCode==46′ >

Adminer

I have been doing MySQL database administration and applications for a long time now and I can’t believe that I’ve never heard of Adminer before.

Adminer is a PHP database manager.  As near as I can tell, it contains all of the same functionality of phpMyAdmin, but, seems to be quicker.

I recently came across this and have been using it exclusively ever since.  Prior to this, I have always just used phpMyAdmin.

If you have not yet tried to use this single page database manager, I strongly recommend giving it a try.

 

https://www.adminer.org/

Checking WordPress User Capabilities

Recently I spent some time trying to determine user capabilities while developing some plugins. I figured I’d put what I learned here for future reference.

In order to check a current user’s capabilities (i.e. are they an admin?) use the function;
current_user_can( capability )

An example would be:

if (current_user_can(‘manage_options’)) {
// User is an administrator.
/* Do something */
}

If you want to check a particular user, use the function;
user_can(id, capability).

This works exactly like the previous example, however, it takes an ID as a paramter.

An example would be:

if (user_can($id, ‘manage_options’)){
// User is an administrator
/* Do something
}

For a complete list of roles and capabilities, please reference this site.

Database Plugin for MySQL

I am working on a new plugin for WordPress which is intended to give you capabilities similar to those in phpMyEdit. I have been waiting for a while for someone to design a table editor for MySQL that plugs in to WordPress. Turns out, that someone is going to be me.

As soon as I have something tangible, I will post it so that others can play with it.