Skip to content

Instantly share code, notes, and snippets.

View roose's full-sized avatar
🐢
Looking for a job

roose roose

🐢
Looking for a job
View GitHub Profile
@roose
roose / gist:1933047
Created February 28, 2012 15:17
Remove menu in Wordpress admin menu
<?php
function remove_menus () {
global $menu;
$restricted = array(__('Links'), __('Posts'));
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
}
@roose
roose / gist:1933030
Created February 28, 2012 15:14
Excerpt more string & length
<?php
function go_excerpt( $more ) {
return '...';
}
add_filter( 'excerpt_more', 'go_excerpt' );
function go_excerpt_length( $length ) {
return 30;
}
add_filter( 'excerpt_length', 'go_excerpt_length' );
@roose
roose / exclude_thumbnail_from_gallery.php
Created February 28, 2012 15:09
Exclude post thumbnail from wordpress native gallery
@roose
roose / gist:1021488
Created June 12, 2011 12:04
Wordpress latest tweet
<?php
require_once(ABSPATH . 'wp-includes/class-snoopy.php');
$tweet = get_option("lasttweet");
$url = "http://twitter.com/statuses/user_timeline/mr_roose.json?count=20";
if ($tweet['lastcheck'] < ( mktime() - 60 ) ) {
$snoopy = new Snoopy;
$result = $snoopy->fetch($url);
if ($result) {
$twitterdata = json_decode($snoopy->results,true);
@roose
roose / gist:997878
Last active September 25, 2015 22:48
Disable automatic generated Wordpress headers
<?php
/**
* Disable automatic generated Wordpress headers
*/
// Disabling XMLRPC
add_filter('xmlrpc_enabled', '__return_false');
// Remove WordPress Admin Bar
remove_action('init', 'wp_admin_bar_init');
@roose
roose / gist:997874
Created May 29, 2011 15:42
WordPress Sitemap template file
<?php
/*
Template Name: Sitemap
*/
?>
<?php get_header(); ?>
<div id="content">
<div id="entry">
<div class="post">
@roose
roose / gist:997870
Created May 29, 2011 15:38
WordPress search form template
<form action="<?php bloginfo('url'); ?>" id="searchform" method="get">
<div>
<input type="text" onblur="if (this.value == '') {this.value = 'Search';}" onfocus="if (this.value == 'Search') {this.value = '';}" id="s" name="s" value="Search"/>
<input type="submit" value="" id="ss"/>
</div>
</form>
@roose
roose / russian_comments_number.php
Created May 29, 2011 15:36
WordPress, retrieve the amount of comments a post has with russian plural form.
<?php
/**
* Retrieve the amount of comments a post has with russian plural form.
*
* @uses apply_filters() Calls the 'get_comments_number' hook on the number of comments
*
* @param int $post_id The Post ID
* @return int The number of comments a post has
*/
@roose
roose / pagination.php
Created May 29, 2011 15:32
WordPress pagination, based on WP-Pagenavi
<?php
### Function: Page Navigation
function wp_pagination($before = '', $after = '') {
global $wpdb, $wp_query;
if (!is_single()) {
$request = $wp_query->request;
$posts_per_page = intval(get_query_var('posts_per_page'));
$paged = intval(get_query_var('paged'));
$numposts = $wp_query->found_posts;