Skip to content

Instantly share code, notes, and snippets.

View palpalani's full-sized avatar

Palaniappan P palpalani

View GitHub Profile
@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',
@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: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),
<?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;
#!/bin/sh
# WP-CLI Template
# @see http://wp-cli.org/
# install
curl http://wp-cli.org/installer.sh | bash
.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/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/
@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
@palpalani
palpalani / wp-pligg-connect.php
Last active November 21, 2019 21:34
PliggConnect for WordPress Integrating Pligg with WordPress
<?php
/*
I've managed to get Pligg to use WordPress authentication and user database.
I recently got Pligg using Pubcookie and that formed the basis of this work, however they are very different.
I've only tested this with Pligg. I believe future versions may have a better approach for external authentication so I can't guarantee this will work with future versions.
This approach is very "hacky". I've also been slightly lazy. It assumes that you will use WordPress' login, logout and register pages. This will break the existing login, logout and register forms in Pligg. The ultimate solution would allow the Pligg forms to login and logout also on WordPress and the register form to create new users in WordPress.
@palpalani
palpalani / wpconnect.php
Last active April 2, 2019 04:32
PliggConnect for WordPress WordPress and Pligg bridge plugin.
<?php
/*
* 1. create wp plugin for pligg
* 2. create file wpconnect.php at pligg root
*/
$pligg_url = '';
$pligg_path = '';
/*