Skip to content

Instantly share code, notes, and snippets.

View mjangda's full-sized avatar

Mohammad Jangda mjangda

View GitHub Profile
@mjangda
mjangda / wp-events-widgets.php
Created June 4, 2010 16:30
Utility functions and a sample widget to display the next event
<?php
function events_get_next_event() {
global $wpdb;
$events_table = $wpdb->prefix . 'events';
$date_now = current_time('timestamp');
$query = $wpdb->prepare("SELECT * FROM $events_table WHERE thetime > %s ORDER BY thetime ASC LIMIT 1", $date_now);
$event = $wpdb->get_row($query);
@mjangda
mjangda / gleesays.html
Created June 7, 2010 15:09
An easy way to add some sweet lookin' Glee quotes to your blog
<div style="text-align: center; font-size: 10px">
<img src="http://gleesays.com/quote/" alt="Glee Quote!" />
<br />
<a href="http://gleeksunited.wordpress.com">Powered by Gleeks United</a>
</div>
@mjangda
mjangda / co-authors-plus_author-template-fix.php
Created June 22, 2010 13:44
A fix for Author Templates for the Co-Authors Plus WordPress plugin where the author's name and bio are incorrect
<?php
// Add this to your author.php template between the first the_post() call and where the bio is outputted.
if( is_author() ) {
global $wp_query;
// Get the id of the author whose page we're on
$author_id = $wp_query->get( 'author' );
// Check that the the author matches the first author of the first post
if( $author_id != get_the_author_meta( 'ID' ) ) {
@mjangda
mjangda / cross-browser-word-wrap.css
Created June 23, 2010 17:22
A cross-browser method to wrap really long strings using CSS
/** Disclaimer: this is not my code. I found this on pastebin and wanted to put it somewhere for easy reference. Thank you anonymous CSS god! **/
.selector {
/** Word Wrap **/
/** This will wrap really long strings, e.g. URLs, though without hyphenation **/
word-wrap: break-word; /* CSS 3 + IE */
white-space: -moz-pre-wrap; /* FF */
white-space: -o-pre-wrap; /* Opera */
}
@mjangda
mjangda / gist-noscript-embed.html
Created July 14, 2010 23:56
Proposed noscript support for embedded gists.
<script src="http://gist.github.com/384113.js?file=console-error.js"></script>
<noscript><a href="http://gist.github.com/384113#file_console_error.js">View on gist.github.com</a></noscript>
@mjangda
mjangda / get_current_post_type.php
Created July 15, 2010 13:55
Get the current post_type context in the WordPress admin.
<?php
/**
* Gets the current global post type if one is set
*/
function x_get_current_post_type() {
global $post, $typenow, $current_screen;
if( $post && $post->post_type )
$post_type = $post->post_type;
elseif( $typenow )
@mjangda
mjangda / glee-season2-countdown.html
Created July 22, 2010 15:03
Add a sweet countdown clock to your blog to count down to the return of Glee Season 2!
<div style="text-align: center; font-size: 10px">
<img src="http://digitalize.ca/glee/countdown/countdown.php" alt="Glee Countdown: It's back on September 21, 2010 at 8pm EST!" />
<br />
<a href="http://gleeksunited.wordpress.com" target="_blank">Powered by Gleeks United</a>
</div>
@mjangda
mjangda / glee-season2-countdown-horizontal.html
Created July 22, 2010 15:05
Add a sweet countdown clock to your blog to count down to the return of Glee Season 2! The Horizontal Version!
<div style="text-align: center; font-size: 10px">
<img src="http://digitalize.ca/glee/countdown/countdown-h.php" alt="Glee Countdown: It's back on September 21, 2010 at 8pm EST!" />
<br />
<a href="http://gleeksunited.wordpress.com" target="_blank">Powered by Gleeks United</a>
</div>
@mjangda
mjangda / recent-comments-fix.php
Created August 22, 2010 19:40
Fix to hide editorial comments from Recent Comments widget
<?php
if ( !$comments = wp_cache_get( 'widget_recent_comments', 'widget' ) ) {
$comments_count = 5;
$comments = $wpdb->get_results("SELECT $wpdb->comments.* FROM $wpdb->comments JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_status = 'publish' AND comment_type IN ('comment', '', 'trackback', 'pingback') ORDER BY comment_date_gmt DESC LIMIT $comments_count");
wp_cache_add( 'widget_recent_comments', $comments, 'widget' );
}
@mjangda
mjangda / example.html
Created August 25, 2010 20:23
A sweet way to get around Facebook's caching of animated GIFs
<img src="" id="loading" alt="Loading..." />
<a href="#" onclick="showLoading(); return false;">Show Loading</a>
|
<a href="#" onclick="hideLoading(); return false;">Hide Loading</a>
<script>
var loadingUrl = 'http://www.example.com/images/loading-{0}.png');
var loading = loadingAnimator('loading', loadingUrl, { states: 12 });