Accept only specified arguments in a function or class method

There are times that I’ve needed to limit input into a class method or function while using the extract() function. Problems arise at times from rogue argument keys that aren’t necessarily needed. Here’s a simple way to use the awesomeness of extract(), but dictate its output to the parameters of your allowed vars.

$allowed_vars('foo', 'bar', 'foobar'); 

# Set allowed vars as $ variables

# Extract only allowed vars from user-submitted arguments
# EXTR_IF_EXISTS will only convert array keys of foo, bar, and foobar
extract($args, EXTR_IF_EXISTS);

The beginning of all understanding is classification

Understanding a problem is the foundation of programming. Classification is the logical, yet, overlooked starting point of most projects. Many times, I find that my inefficiency and lack of productivity stems from a low morale or fatigue. This is typically birthed by a deficiency of direction and understanding of how to accomplish a task.

When I find myself in a vacuum of zero productivity, I typically break down problems and tasks in an outline program. I focus on creating small, realistic tasks in a logical progression that won’t overwhelm my psyche. I recently discovered WorkFlowy. It’s a simple way to systematize thoughts, ideas, contingencies, projected anomalies, scenarios, etc. in a searchable, navigable outline form.

When you starting seeing your coworkers as binary entities, just do something to get back to firing on all cylinders. A good place to start is classify and reclassify, then classify again until you get it right. If classification is the beginning of understanding, iteration of classification is certainly a close second.

Author: Hayden White

Re-order WordPress Admin Sub-menu Items

If you’re wanting to push your custom sub-menu link to the top of the list within a WordPress menu, you can use this code to ensure that you’re always the alpha sub-menu item.

function custom_menu_order(){
    global $submenu;
    $find_page = 'themes.php';
    $find_sub = 'Widgets';
    foreach($submenu as $page => $items):
        if($page == $find_page):
            foreach($items as $id => $meta):
                if($meta[0] == $find_sub):
                    $submenu[$find_page][0] = $meta;
                    unset ($submenu[$find_page][$id]);
add_action('_admin_menu', 'custom_menu_order');

View the SE thread where I originally posted this.