Skip to content

Instantly share code, notes, and snippets.

View palpalani's full-sized avatar

Palaniappan P palpalani

View GitHub Profile
@palpalani
palpalani / Course_Tree.php
Last active December 21, 2015 17:29
MPTT for course
<?php
/**
* Course_Tree is a PHP class that provides an implementation of the modified preorder tree traversal algorithm making
* it easy for you to use MPTT in your PHP applications.
*
* It provides methods for adding nodes anywhere in the tree, deleting nodes, moving and copying nodes around the tree
* and methods for retrieving various information about the nodes.
*
* Course_Tree uses {@link http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-transactions.html MySQL transactions} making
#!/bin/bash
# this is a work in progress! NOT for production.
# requires wp-cli
# usage: wp-base-install
# or: ./wp-base-install.sh
# Bits of inspiration from https://gist.github.com/2853221
# to look at: http://www.servercobra.com/automated-wordpress-install-with-nginx-script/
.PHONY: install
install: clean wordpress phpunit wp-cli
git submodule init;
@echo "\n\nNOTICE: You may need to configure a MySQL database for your Wordpress installation. Just run:"
@echo " mysql -u root -p;"
@echo " CREATE DATABASE example_site; \n"
wordpress: latest.tar.gz
tar -zxvf latest.tar.gz;
#!/bin/sh
# WP-CLI Template
# @see http://wp-cli.org/
# install
curl http://wp-cli.org/installer.sh | bash
<?php
class Wedding
{
protected $start;
protected $end;
public function __construct($start = '2013-04-22 09:45', $end = '2013-04-22 10:15')
{
$this->start = $start;
@palpalani
palpalani / functions.php
Created September 27, 2012 05:50
WordPress: Releted posts by tags
/*
* List the related posts by current post tags.
*/
function m3_related_posts(){
$tags = wp_get_post_tags($post->ID);
if ($tags) {
echo 'Related Posts';
$first_tag = $tags[0]->term_id;
$args=array(
'tag__in' => array($first_tag),
@palpalani
palpalani / gist:3792337
Created September 27, 2012 05:36
WordPres: Latest posts list
/*
* List of recent posts
*/
function m3_last_posts(){
$args = array(
'no_found_rows' => 1,
'post_status' => 'publish',
'posts_per_page' => 5
);
$latest_posts = new WP_Query( $args );
@palpalani
palpalani / functions.php
Created September 27, 2012 05:33
WordPress: List popular posts by comment count
<?php
/*
* List popular posts by comment count
* This function used for Genesis custom theme, May be work with any theme.
*/
function m3_popular_posts(){
$args = array(
'no_found_rows' => 1,
'post_status' => 'publish',
'orderby' => 'comment_count',