Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Usage:
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
functions_that_do_stuff_live();
these_should_echo();
// IMPORTANT
$frag->store();
// YOU CANNOT FORGET THIS. If you do, the site will break.
add_action( 'bp_setup_nav', 'add_videos_subnav_tab', 100 );
function add_videos_subnav_tab() {
global $bp;
bp_core_new_subnav_item( array(
'name' => 'Videos',
'slug' => 'videos',
'parent_url' => trailingslashit( bp_loggedin_user_domain() . 'friends' ),
<?php # -*- coding: utf-8 -*-
/*
Plugin Name: All Actions List
Description: Lists all actions run during one request.
Version: 1.0
Required: 3.1
Author: Thomas Scholz
Author URI: http://toscho.de
License: GPL
*/
add_filter( 'tw_query_args', array( &$this, 'query_args' ), 10, 2 );
public function query_args( $args, $atts ) {
global $wpdb;
$args['post_type'] = $atts['post_type'];
$no_cache = $atts['no_cache'];
if ( $no_cache ) {
$args['no_cache'] = 1;
@subharanjanm
subharanjanm / adi_uid_issue.diff
Last active August 29, 2015 14:22
Active Directory Integration - Authentication failed issue - uid - loginattr - adLDAP
From b5818c205b382c001867a6ee5bd811cbe745f5cb Mon Sep 17 00:00:00 2001
From: Subharanjan Mantri <subharanjan@axelerant.com>
Date: Thu, 28 May 2015 14:15:44 +0530
Subject: [PATCH] Quick Fix for the LDAP id issue while authentication in
adLDAP.
---
.../plugins/active-directory-integration/ad_ldap/adLDAP.php | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
@subharanjanm
subharanjanm / testimonials-widget-get-template-part.php
Created June 8, 2015 14:09
Load different template for content as per conditions in Testimonials Widget ( testimonials_widget_get_template_part / tw_get_template_part )
/**
* Load different template for content as per conditions.
*
* @param $templates
* @param $slug
* @param $name
*
* @return mixed
*/
function load_alternate_template( $templates, $slug, $name ) {
add_filter( 'tw_cite_html', 'my_testimonials_widget_cite_html', 10, 3 );
function my_testimonials_widget_cite_html( $cite, $testimonial, $atts ) {
if ( ! empty( $testimonial['is-nurse'] ) ) {
$cite .= ', <b>' . $testimonial['is-nurse'] . '</b>';
}
return $cite;
}
if ( !function_exists( 'write_log' ) ) {
function write_log ( $log ) {
if ( true === WP_DEBUG ) {
error_log('---------------------------------');
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
@subharanjanm
subharanjanm / category-in-cite.diff
Created October 2, 2015 13:15
Display category inside testimonial's cite.
--- wp-content/plugins/testimonials-widget/templates/testimonial-cite.php (revision )
+++ wp-content/plugins/testimonials-widget/templates/testimonial-cite.php (revision )
@@ -62,6 +62,18 @@
$cite = apply_filters( 'tw_cite_html', $cite, $testimonial, $atts );
+$testimonial_category = '';
+$terms = get_the_terms( $testimonial['post_id'], 'category' );
+if ( $terms && ! is_wp_error( $terms ) ) {
+ $term_names = array();
@subharanjanm
subharanjanm / github_tree_slider.js
Created September 3, 2012 09:30 — forked from ryanb/github_tree_slider.js
This is how GitHub's new AJAX file browser works.
GitHub.TreeSlider = function () {
if (window.history && window.history.pushState) {
function a() {
if (e.sliding) {
e.sliding = false;
$(".frame-right").hide();
$(".frame-loading:visible").removeClass("frame-loading")
}
}
if (!($("#slider").length == 0 || !GitHub.shouldSlide)) if (!navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {