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)

[code language=”php”]add_filter( ‘the_title’, ‘wcmumbai_add_promo’, 10, 2);

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

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

return $title;
}
[/code]

Customizing the ‘login_message’ filter (Gist)

[code language=”php”]add_filter( ‘login_message’, ‘wcmumbai_login_message’ );

function wcmumbai_login_message( $message ) {

return "<p>Are you going to WC Mumbai? You should be!";

}[/code]

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

[code language=”php”]add_action( ‘admin_notices’,’wcmumbai_admin_notice’ );

function wcmumbai_admin_notice() {

echo ‘<div class="notice notice-info">Hello, WordCamp Mumbai!</div>’;

}
[/code]

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

[code language=”php”]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>’;
}
[/code]