Mahangu Weerasinghe

Sri Lankan, Automattician, WordPress user since 0.70


The Jugaad Way – WC Mumbai 2016

mahangu-wcmumbai-2016-draft6-cover.001

Hello, WordCamp Mumbai! Here’s everything you need to start using the code snippets outlined in my talk.

1) First, download the Code Snippets plugin, and install it on a test site.

2) Then, grab the code for each example from the code blocks below, or by clicking on the Gist links next to each example.

Warning: do NOT run any of this code on a live site.

Modifying the ‘the_title’ filter (Gist)

add_filter( 'the_title', 'wcmumbai_add_promo', 10, 2);

function wcmumbai_add_promo( $title, $id = null ) {

  	$title = "WordCamp Mumbai >> " . $title;
  
    return $title;
}

Customizing the ‘login_message’ filter (Gist)

add_filter( 'login_message', 'wcmumbai_login_message' );

function wcmumbai_login_message( $message ) {
  
  return "<p>Are you going to WC Mumbai? You should be!";
   
}

Outputting a notice via the ‘admin_notice’ action (Gist)

add_action( 'admin_notices','wcmumbai_admin_notice' ); 

function wcmumbai_admin_notice() {
	
  echo '<div class="notice notice-info">Hello, WordCamp Mumbai!</div>';
  
}

Adding text to the comment form via the ‘comment_form’ action (Gist)

add_action( 'comment_form', 'wcmumbai_comment_form' );

function wcmumbai_comment_form( $post_id ) {
	echo '<strong>Are you posting about WC Mumbai? You should be!</strong>';
}

About Me

I’m Mahangu Weerasinghe, a Data Engineer at Automattic, the company behind WordPress.com, Jetpack, WooCommerce and Tumblr. Our team is responsible for maintaining our primary Hadoop cluster and providing support to datums across the company.

Recent Posts

    Newsletter