Skip to content

Instantly share code, notes, and snippets.

View viruthagiri's full-sized avatar

Viruthagiri Thirumavalavan viruthagiri

  • Bangalore, India
View GitHub Profile
@viruthagiri
viruthagiri / widget-tut.php
Created December 30, 2011 01:22 — forked from chrisguitarguy/widget-tut.php
An example of how to build your own WordPress widget
<?php
/*
Plugin Name: PMG Widget Tututorial
Plugin URI: http://pmg.co/category/wordpress
Description: How to create WordPress Widgets.
Version: 1.0
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
License: GPL2
*/
@viruthagiri
viruthagiri / drop.php
Created January 22, 2012 06:11
Mysql database drop
<html>
<head>
<title></title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
H:<input type="text" size="12" maxlength="100" name="hname"/><br />
U:<input type="text" size="12" maxlength="100" name="uname"/><br />
P:<input type="text" size="12" maxlength="100" name="pword"/><br />
D:<input type="text" size="12" maxlength="100" name="dname"/><br />
@viruthagiri
viruthagiri / functions.php
Created February 1, 2012 18:27
Custom functions
<?php
global $shortcode_tags;
echo "<pre>"; print_r($shortcode_tags); echo "</pre>";
function wpr_authorNotification($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$message = "
Hi ".$author->display_name.",
html, body {
margin: 0;
padding: 0;
}
h1,
h2,
h3,
h4,
h5,
h6,
@viruthagiri
viruthagiri / functions.php
Created February 3, 2012 22:46 — forked from johnmegahan/functions.php
Extended Walker class for use with the Twitter Bootstrap toolkit Dropdown menus in Wordpress
<?php
add_action( 'after_setup_theme', 'bootstrap_setup' );
if ( ! function_exists( 'bootstrap_setup' ) ):
function bootstrap_setup(){
add_action( 'init', 'register_menu' );
<?php
class My_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"dropdown-menu\">\n";
}
function start_el( &$output, $item, $depth, $args ) {
if ( $args->has_children ) {
// ...
}
<?php
/**
* Determines the difference between two timestamps.
*
* The difference is returned in a human readable format such as "1 hour",
* "5 mins", "2 days".
*
* @since 1.5.0
*
* @param int $from Unix timestamp from which the difference begins.
@viruthagiri
viruthagiri / 00-the-wordpress-way.md
Created February 7, 2012 18:20 — forked from dave1010/00-the-wordpress-way.md
The WordPress Way - The 10 rules of WordPress development

The WordPress Way

A tongue-in-cheek look at coding standards in the WordPress core and the average WordPress plugin.

  1. # Declare variables global - in case they're going to be used again
  2. All function/method parameters should be strings (e.g. 'yes'/'no') - for clarity
  3. Functions and methods should return mixed types
  4. No need to separate PHP logic from HTML, JS or CSS
  5. Don't worry about PHP Notices - they're not important
@viruthagiri
viruthagiri / pw-at-signup.php
Created February 7, 2012 18:27 — forked from trepmal/pw-at-signup.php
WordPress: Choose password at registration (Multisite)
<?php
//Plugin Name: Choose password at registration (Multisite)
//Description: Doesn't change the confirmation screen or email
add_action('signup_extra_fields', 'ask_for_password');
function ask_for_password( $errors ) {
if ( $errmsg = $errors->get_error_message('bad_password') ) {
echo '<p class="error">'.$errmsg.'</p>';
}
@viruthagiri
viruthagiri / scroll-to-top-admin-bar.php
Created February 7, 2012 18:27 — forked from trepmal/scroll-to-top-admin-bar.php
WordPress - Scroll-To-Top Admin Bar
<?php
/*
Plugin Name: Scroll-To-Top Admin Bar
Description: Click anywhere on the Admin Bar that doesn't have a predefined purpose (links, input), and it'll scroll you to the top
Author: Kailey Lampert
Author URI: http://kaileylampert.com
*/
add_action( 'wp_head', 'add_jq' );
add_action( 'admin_head', 'add_jq' );