Sortable Columns

<?php

/* ~~~~~~~~~~~~~~~~~~ Columns ~~~~~~~~~~~~~~~~~~ */

/* Add Columns */
function bz_add_columns($defaults){
if($_GET['post_type'] != 'bz_league') return $defaults;
$defaults['bz_league_start_date'] = __('Start Date');
return $defaults;
}

/* Get Column Data */
function bz_get_column_data($column,$id){
switch($column){
case 'bz_league_start_date':
echo get_post_meta($id,'bz_league_start_date',true);
break;
}
}

function bz_client_name_column_register_sortable($columns){
$columns['bz_league_start_date'] = 'bz_league_start_date';
return $columns;
}

function bz_client_name_column_orderby($vars){
if(isset($vars['orderby']) && 'bz_league_start_date' == $vars['orderby']){
$vars = array_merge($vars,array(
'meta_key' => 'bz_league_start_date',
'orderby' => 'meta_value'
));
}
return $vars;
}

add_filter('manage_bz_league_posts_columns','bz_add_columns');
add_action('manage_bz_league_posts_custom_column','bz_get_column_data',10,2);
add_filter('manage_edit-bz_league_sortable_columns','bz_client_name_column_register_sortable');
add_filter('request','bz_client_name_column_orderby');

?>

List directories

<?php

foreach(glob($_SERVER['DOCUMENT_ROOT'] . '/pathtoparentdir/*', GLOB_ONLYDIR) as $dir){
$dir = basename($dir);
echo $dir . '<br>';
}

?>

In class actions

<?php

//Use to call a method of your class
add_action('switch_theme', array( &$this, 'my_method_name'), 1, 2);

//Use to call a static method of your class
add_action('switch_theme','MyClassName::my_static_method_name');

?>

Zip Directory Recursively

<?php

$file = tempnam("tmp","zip");
zip_directory('/home/mydirectorypath',$file);

header('Content-Type: application/zip');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename="myzip.zip"');

readfile($file);
unlink($file);

function zip_directory($source,$tempfile){
if(!extension_loaded('zip') || !file_exists($source)) return false;
$zip = new ZipArchive();
if(!$zip->open($tempfile,ZIPARCHIVE::CREATE)) return false;
$source = str_replace('\','/',realpath($source));
if(is_dir($source) === true){
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
foreach($files as $file){
$file = str_replace('\', '/', realpath($file));
if(is_dir($file) === true) $zip->addEmptyDir(str_replace($source . '/','', $file . '/'));
else if(is_file($file) === true) $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
}
}
elseif(is_file($source) === true) $zip->addFromString(basename($source), file_get_contents($source));
return $zip->close();
}

?>