Skip to content

Instantly share code, notes, and snippets.

View mjangda's full-sized avatar

Mohammad Jangda mjangda

View GitHub Profile
@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 / widget.recent-comments-ef.php
Created August 26, 2010 03:43
Patched version of the "Recent Comments" widget for WordPress to hide editorial comments
<?php
/**
* Recent_Comments_EF widget class
*
* Patched for Edit Flow
*
* @since 2.8.0
*/
class WP_Widget_Recent_Comments_EF extends WP_Widget {
@mjangda
mjangda / SanitizeString.cs
Created September 8, 2010 15:36
Sanitizes a given string into a slug-friendly form.
/// <summary>
/// Cleans up a given string into a slug-friendly form.
/// Strips special characters and replaces spaces with hyphens.
///
/// Given something like "The Quick Fox Don't Like No Guff!" return "The-Quick-Fox-Dont-Like-No-Guff"
///
/// Borrowed from WordPress.
/// </summary>
/// <param name="str">The string to be sanitized</param>
/// <returns>A sanitized string</returns>
@mjangda
mjangda / jQuery.html.js
Created September 28, 2010 13:52
Adds a custom event to the default jQuery html event when the value is changed
// Redefines jQuery.fn.html() to add custom events that are triggered before and after a DOM element's innerHtml is changed
// html-change-pre is triggered before the innerHtml is changed
// html-change-post is triggered after the innerHtml is changed
;
(function($) {
var eventName = 'html-change';
// Save a reference to the original html function
jQuery.fn.originalHtml = jQuery.fn.html;
// Let's redefine the html function to include a custom event
jQuery.fn.html = function() {