Skip to content

Instantly share code, notes, and snippets.

View mjangda's full-sized avatar

Mohammad Jangda mjangda

View GitHub Profile
@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() {
?>
@mjangda
mjangda / custom-metadata_custom-display-and-sanitize.php
Created November 5, 2010 13:50
Creates a custom field in WordPress using Custom Metadata Manager and uses custom display and sanitize callbacks
<?php
x_add_metadata_field('x_fieldCustomList2', array( 'post' ), array(
'label' => 'Post Action Items (With Links!)'
, 'display_callback' => 'fieldCustomList2_display'
, 'sanitize_callback' => 'fieldCustomList2_sanitize'
));
function fieldCustomList2_display( $field_slug, $field, $object_type, $object_id, $value ) {
$value = (array) $value;
$field_class = sprintf( 'field-%s', $field_slug );
@mjangda
mjangda / custom-metadata-column.php
Created November 6, 2010 04:43
Various code samples for Custom Metadata Manager
<?php
x_add_metadata_field( 'field-1', 'post', array(
'display_column' => true
) );
?>
@mjangda
mjangda / github-post-receive-pull.php
Created November 16, 2010 06:47
Quick and dirty script that can auto-pull to keep your repo up-to-date any time something is pushed to the remote repo
<?php
// Edit these to match your environment settings
define( 'BASE_PATH', '/home/username/webapps' );
// This is the path to the git executable
define( 'GIT_PATH', get_full_path( '/git/bin/git' ) );
// Edit this array so the key matches the github repo name and the value is path of the repo relative to the BASE_PATH
$repository_paths = array(
'test' => '/git-test'
@mjangda
mjangda / clone-edit-flow.sh
Created November 16, 2010 14:02
Snippets for git-ifying your live WordPress plugin
cd /home/username/webapps/wordpress/wp-content/plugins/
git clone git@github.com:danielbachhuber/Edit-Flow.git