Skip to content

Instantly share code, notes, and snippets.

@BKeanu1989
Last active February 15, 2018 18:39
Show Gist options
  • Save BKeanu1989/9ad2ede770d8249950755c8660280dd6 to your computer and use it in GitHub Desktop.
Save BKeanu1989/9ad2ede770d8249950755c8660280dd6 to your computer and use it in GitHub Desktop.
write to log - wordpress debug log
if (!function_exists('write_log')) {
function write_log ( $log ) {
if ( true === WP_DEBUG ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
}
}
function reorderWordpressDatabase($databaseResults, $allowedKeys) {
// where order_item_id == too many problems TODO: ?
$filtered = array_filter($databaseResults, function($row) use ($allowedKeys) {
$filter = [];
foreach ($allowedKeys as $value) {
if(in_array($value, $row)) {
$filter[] = $row;
}
}
return $filter;
});
$reorderedFilteredData = array_column($filtered, 'meta_value', 'meta_key');
return $reorderedFilteredData;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment