Skip to content

Instantly share code, notes, and snippets.

View antoniofrignani's full-sized avatar
👨‍💻

Antonio Frignani antoniofrignani

👨‍💻
View GitHub Profile
@antoniofrignani
antoniofrignani / gist:2867475
Created June 4, 2012 09:38
[WP] - Display DB queries, time spent and memory consumption
// http://wpsnipp.com/index.php/functions-php/display-db-queries-time-spent-and-memory-consumption/
function performance( $visible = false ) {
$stat = sprintf( '%d queries in %.3f seconds, using %.2fMB memory',
get_num_queries(),
timer_stop( 0, 3 ),
memory_get_peak_usage() / 1024 / 1024
);
echo $visible ? $stat : "<!-- {$stat} -->" ;
}
@antoniofrignani
antoniofrignani / gist:2867473
Created June 4, 2012 09:37
[WP] - Remove the screen options tab with screen_options hook
// http://wpsnipp.com/index.php/functions-php/remove-the-screen-options-tab-with-screen_options_show_screen-hook/
function remove_screen_options(){
return false;
}
add_filter('screen_options_show_screen', 'remove_screen_options');
@antoniofrignani
antoniofrignani / gist:2867466
Created June 4, 2012 09:36
[WP] - Add HTML to feature image metabox
// http://wpsnipp.com/index.php/functions-php/add-html-to-feature-image-metabox/
add_filter( 'admin_post_thumbnail_html', 'add_featured_image_html');
function add_featured_image_html( $html ) {
return $html .= '<p>This is some sample text that can be displayed within the feature image box.</p>';
}
@antoniofrignani
antoniofrignani / gist:2867440
Created June 4, 2012 09:34
[WP] - Change publish metabox text for custom post type
// http://wpsnipp.com/index.php/functions-php/change-publish-metabox-text-for-custom-post-type/
function wps_translation_mangler($translation, $text, $domain) {
global $post;
if ($post->post_type == 'events') {
$translations = &get_translations_for_domain( $domain);
if ( $text == 'Scheduled for: <b>%1$s</b>') {
return $translations->translate( 'Event Date: <b>%1$s</b>' );
}
if ( $text == 'Published on: <b>%1$s</b>') {
@antoniofrignani
antoniofrignani / gist:2867436
Created June 4, 2012 09:33
[WP] - Update: Automatically create media_buttons for shortcode selection
// http://wpsnipp.com/index.php/functions-php/update-automatically-create-media_buttons-for-shortcode-selection/
add_action('media_buttons','add_sc_select',11);
function add_sc_select(){
global $shortcode_tags;
/* ------------------------------------- */
/* enter names of shortcode to exclude bellow */
/* ------------------------------------- */
$exclude = array("wp_caption", "embed");
echo '&nbsp;<select id="sc_select"><option>Shortcode</option>';
@antoniofrignani
antoniofrignani / gist:2867425
Created June 4, 2012 09:31
[WP] - Add featured thumbnail to admin post / page columns
// http://wpsnipp.com/index.php/functions-php/updated-add-featured-thumbnail-to-admin-post-page-columns/
if (function_exists( 'add_theme_support' )){
add_filter('manage_posts_columns', 'posts_columns', 5);
add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2);
add_filter('manage_pages_columns', 'posts_columns', 5);
add_action('manage_pages_custom_column', 'posts_custom_columns', 5, 2);
}
function posts_columns($defaults){
$defaults['wps_post_thumbs'] = __('Thumbs');
@antoniofrignani
antoniofrignani / gist:2361168
Created April 11, 2012 18:27
Sample HTML page with Twitter's Bootstrap, Ryan Fait's Sticky Footer, and a full-width footer
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="author" content="Martin Bean" />
<title>Twitter&rsquo;s Bootstrap with Ryan Fait&rsquo;s Sticky Footer</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<style>
html, body {
height: 100%;