Skip to content

Instantly share code, notes, and snippets.

View palimadra's full-sized avatar

Pali Madra palimadra

View GitHub Profile
@palimadra
palimadra / wp_code_highlighter
Created June 13, 2012 20:06
For WordPress use blockquote to format code in the posts
#content blockquote {
background-color:#F7F7F7;
background-position:initial initial;
background-repeat:initial initial;
border:1px solid #E6E6E6;
margin:5px 15px 15px;
padding:10px 20px 0 15px;
word-wrap:break-word;
}
@palimadra
palimadra / header.php
Created June 22, 2012 15:15
WordPress use a different style sheet for a particular page, category, posts,
<?php if ( is_page(‘My Page’) ) { ?>
<link rel=”stylesheet” href=”URL of style2.css” type=”text/css” media=”screen” />
<?php } else { ?>
<link rel=”stylesheet” href=”URL of style.css” type=”text/css” media=”screen” />
<?php } ?>
@palimadra
palimadra / auto-description-tag-wp
Created June 30, 2012 14:26
WordPress - Automatically generate meta description from content
function create_meta_desc() {
global $post;
if (!is_single()) { return; }
$meta = strip_tags($post->post_content);
$meta = strip_shortcodes($post->post_content);
$meta = str_replace(array("\n", "\r", "\t"), ' ', $meta);
$meta = substr($meta, 0, 125);
echo "<meta name='description' content='$meta' />";
}
add_action('wp_head', 'create_meta_desc');
@palimadra
palimadra / embedd-rss-feed
Created June 30, 2012 14:28
Display RSS feeds within WordPress
<?php
include_once(ABSPATH . WPINC . '/rss.php');
$feed = 'http://example.com/feed/';
$rss = fetch_feed($feed);
if (!is_wp_error( $rss ) ) :
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
if ($rss_items):
echo "<ul>\n";
foreach ( $rss_items as $item ) :
@palimadra
palimadra / remove-menu-items-admin-wordpress
Created July 1, 2012 17:07
Remove menu items from WordPress admin bar
function wps_admin_bar() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('about');
$wp_admin_bar->remove_menu('wporg');
$wp_admin_bar->remove_menu('documentation');
$wp_admin_bar->remove_menu('support-forums');
$wp_admin_bar->remove_menu('feedback');
$wp_admin_bar->remove_menu('view-site');
}
@palimadra
palimadra / change-dashboard-footer-wordpress
Created July 1, 2012 17:13
Change dashboard footer text
@palimadra
palimadra / custom-login-wordpress
Created July 1, 2012 17:15
Custom login form with full screen background
function login_enqueue_scripts(){
echo '
<div class="background-cover"></div>
<style type="text/css" media="screen">
.background-cover{
background:url('.get_bloginfo('template_directory').'/images/background) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
@palimadra
palimadra / change-dashboard-colors
Created July 1, 2012 17:19
Change WordPress dashboard colors
function custom_colors() {
echo '<style type="text/css">#wphead{background:#069}</style>';
}
add_action('admin_head', 'custom_colors');
@palimadra
palimadra / change-email-address-wordpress
Created July 1, 2012 17:21
Change WordPress default FROM email address
add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');
function new_mail_from($old) {
return 'admin@yourdomain.com';
}
function new_mail_from_name($old) {
return 'Your Blog Name';
}
@palimadra
palimadra / custom-error-messages-wordpress
Created July 1, 2012 17:24
Create custom help messagea
function my_admin_help($text, $screen) {
// Check we're only on my Settings page
if (strcmp($screen, MY_PAGEHOOK) == 0 ) {
$text = 'Here is some very useful information to help you use this plugin...';
return $text;
}
// Let the default WP Dashboard help stuff through on other Admin pages
return $text;
}