Skip to content

Instantly share code, notes, and snippets.

View mjangda's full-sized avatar

Mohammad Jangda mjangda

View GitHub Profile
@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 / widget-post-save.js
Created September 9, 2010 20:21
Hook into the WordPress widget save javascript callback
jQuery(document).ajaxSuccess(function(e, xhr, settings) {
var widget_id_base = 'mywidget';
if(settings.data.search('action=save-widget') != -1 && settings.data.search('id_base=' + widget_id_base) != -1) {
alert('yay!');
// do other stuff
}
});
@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() {
@mjangda
mjangda / edit-flow_usergroups_caps.php
Created October 12, 2010 01:58
Add necessary caps to admin and editor roles to manage usergroups
add_action( 'admin_init', 'ef_usergroups_cap_fix' );
function ef_usergroups_cap_fix() {
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
// Add necessary capabilities to allow management of usergroups and post subscriptions
// edit_post_subscriptions - administrator + editor
@mjangda
mjangda / transition-everything.css
Created October 14, 2010 16:25
Add transitions TO EVERYTHING ON YOUR PAGE!
* {
-webkit-transition: 1s;
-moz-transition: 1s; /* Firefox 4+ */
-ms-transition: 1s; /* IE doesn't actually support transitions, but we'll humour Microsoft */
-o-transition: 1s; /* Opera 10.5 */
transition: 1s;
}
@mjangda
mjangda / edit-flow_reviewer-add-on.php
Created October 15, 2010 14:32
Add-on for Edit Flow that let's you set a "Reviewer" usergroups for individual users. All notifications related to that user go their assigned usergroup.
<?php
/*
Plugin Name: Edit Flow - Reviewer Add-on
Plugin URI: http://editflow.wordpress.com
Description: An add-on for Edit Flow that allows you to assign review groups for users that will be notified any time a user updates a post.
Author: Mohammad Jangda
Version: 0.1
Author URI: http://www.digitalize.ca
Copyright 2009-2010 Mohammad Jangda
@mjangda
mjangda / edit-flow_queued-posts.php
Created October 17, 2010 16:26
Doing a WordPress loop with a custom status
<h3>Upcoming Posts</h3>
<ul>
<?php
global $post;
$myposts = get_posts( array( 'post_status' => 'queued' ) );
foreach($myposts as $post) : setup_postdata($post); ?>
<li><?php the_title(); ?></li>
<?php endforeach; ?>
</ul>
@mjangda
mjangda / publis-preview.php
Created October 19, 2010 17:25
Stub for a the Public Preview plugin
<?php
/*
Plugin Name: Public Preview
Plugin URI: http://digitalize.ca
Description: Enables unauthenticated users to preview posts with a secret link!
Author: Mohammad Jangda
Version: 0.1
Author URI: http://digitalize.ca/
*/
@mjangda
mjangda / wp-publish-confirm.php
Created October 22, 2010 18:29
WordPress confirm on publish
<?php
/*
Plugin Name: Confirm On Publish
Description: Prompts you to confirm if you want to publish or update a post
*/
add_action( 'load-post.php', 'x_confirm_before_publish' );
function x_confirm_before_publish() {
?>