Skip to content

Instantly share code, notes, and snippets.

@rugor
rugor / gist:5417915
Last active January 19, 2016 21:31
HTML: Starting Template #rugor #st
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>HTML 5 complete</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
/* http://meyerweb.com/eric/tools/css/reset/
@rugor
rugor / gist:5417924
Last active January 19, 2016 21:31
PHP: Wordpress functions.php remove comments from admin menu #rugor #st
// Remove Comments Menu
function remove_menus () {
global $menu;
$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
}
@rugor
rugor / gist:5417949
Last active January 19, 2016 21:30
PHP: Wordpress functions.php enable post thumbnails #rugor #st
// Enable thumbnails in Wordpress 3.0
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 220, 220, true ); // slideshow size 220 pixels wide by 220 pixels tall, hard crop mode
add_image_size( 'thumbnail-tall', 220, 450 ); // TALL THUMBNAIL
add_image_size( 'thumbnail-wide', 450, 220 ); // WIDE THUMBNAIL
@rugor
rugor / gist:5417954
Last active January 19, 2016 21:30
PHP: Wordpress functions.php add thumbnails to rss feed #rugor #st
// Use the thumbnails in the RSS feed
function diw_post_thumbnail_feeds($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<div>' . get_the_post_thumbnail($post->ID) . '</div>' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'diw_post_thumbnail_feeds');
@rugor
rugor / gist:5417958
Last active October 18, 2017 21:16
PHP: Wordpress functions.php remove default head stuffs #rugor #st
// Remove Crap in Head
remove_action( 'wp_head', 'feed_links_extra', 3 ); // Display the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); // Display the links to the general feeds: Post and Comment Feed
remove_action( 'wp_head', 'rsd_link' ); // Display the link to the Really Simple Discovery service endpoint, EditURI link
remove_action( 'wp_head', 'wlwmanifest_link' ); // Display the link to the Windows Live Writer manifest file.
remove_action( 'wp_head', 'index_rel_link' ); // index link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Display relational links for the posts adjacent to the current post.
@rugor
rugor / gist:5417960
Last active January 19, 2016 21:29
PHP: Wordpress functions.php remove inline comments style from head #rugor #st
// Remove Comments Inline Style from Head
function twentyten_remove_recent_comments_style() {
global $wp_widget_factory;
remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
}
add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
@rugor
rugor / gist:5417964
Last active January 19, 2016 21:29
PHP: Wordpress functions.php default none in media upload url box #rugor #st
// Default "none" in media upload url
update_option('image_default_link_type','none');
@rugor
rugor / gist:5417969
Created April 19, 2013 03:36
PHP: Wordpress functions.php remove aim yim and jabber fields replace with facebook twitter
// Remove AIM YIM and Jabber, replace with Facebook, Twitter
function extra_contact_info($contactmethods) {
unset($contactmethods['aim']);
unset($contactmethods['yim']);
unset($contactmethods['jabber']);
$contactmethods['facebook'] = 'Facebook';
$contactmethods['twitter'] = 'Twitter';
return $contactmethods;
@rugor
rugor / gist:5417972
Last active January 19, 2016 21:29
PHP: Wordpress functions.php make the html editor default in pages and posts #rugor #st
// Make the HTML Editor Default!
add_filter('wp_default_editor', create_function('', 'return "html";'));
@rugor
rugor / gist:5417979
Last active January 19, 2016 21:28
PHP: Wordpress functions.php specify number of words in post title #rugor #st
// Maximum 10 Words in Post Title !!!
function maxWord($title){
global $post;
$title = $post->post_title;
if (str_word_count($title) >= 10 ) //set this to the maximum number of words
wp_die( __('Error: your post title is over the maximum word count.') );
}
add_action('publish_post', 'maxWord');