Skip to content

Instantly share code, notes, and snippets.

@bainternet
bainternet / contact-form-7-curPage-tag.php
Created August 9, 2011 06:25
add current page url tag to content form 7
<?php
/*
* add this to your theme's functions.php file
*/
wpcf7_add_shortcode('sourceurl', 'wpcf7_sourceurl_shortcode_handler', true);
function wpcf7_sourceurl_shortcode_handler($tag) {
if (!is_array($tag)) return '';
$name = $tag['name'];
if (empty($name)) return '';
@bainternet
bainternet / custom-cf7-tags.php
Created August 9, 2011 12:59
custom contact form 7 tags
<?php
//contact form 7 extras
//author email
wpcf7_add_shortcode('expert_email', 'wpcf7_expert_email_shortcode_handler', true);
function wpcf7_expert_email_shortcode_handler($tag) {
if (!is_array($tag)) return '';
$name = $tag['name'];
if (empty($name)) return '';
@bainternet
bainternet / gist:1164863
Created August 23, 2011 11:08
WordPress run once class
<?php
/*
* run Once class
*
*/
if (!class_exists('run_once')){
class run_once{
function run($key){
$test_case = get_option('run_once');
if (isset($test_case[$key]) && $test_case[$key]){
@bainternet
bainternet / nocn.php
Created September 15, 2011 23:05
Function to get terms only if they have posts by post type
<?php
/**
* Function to get terms only if they have posts by post type
* @param $taxonomy (string) taxonomy name eg: 'post_tag','category'(default),'custom taxonomy'
* @param $post_type (string) post type name eg: 'post'(default),'page','custom post type'
*
*
* Usage:
* list_terms_by_post_type('post_tag','custom_post_type_name');
@bainternet
bainternet / 1.php
Created September 16, 2011 22:10
How to create Custom Taxonomy Search Drop Down for specific Post Type
<?php
/*
Plugin Name: display_custom_search_form
Plugin URI: http://en.bainternet.info
Description: display_custom_search_form by shortcode
Version: 1.0
Author: Bainternet
Author URI: http://en.bainternet.info
*/
@bainternet
bainternet / gist:1252025
Created September 29, 2011 21:45
Install WordPress On clean centos
#Install the required system packages
yum -y install mysql-server httpd php php-mysql unzip wget
#update php since WordPress 3.2.1 needs php5.2 and up
rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
yum --enablerepo=webtatic install php php-common php-eaccelerator php-mysql php-devel -y
#to install git uncomment this next line
#yum install --enablerepo=webtatic git-all -y
@bainternet
bainternet / gist:1347400
Created November 8, 2011 10:04 — forked from seedprod/gist:272610
WordPress Loop Shortcode
// The Loop
/*
* Usage: loop category="news" query="" pagination="false"
*/
<?php
add_shortcode("loop", "myLoop");
function myLoop($atts, $content = null) {
extract(shortcode_atts(array(
@bainternet
bainternet / wysiwyg-meta-box.php
Created November 16, 2011 12:22 — forked from retgef/wysiwyg-meta-box.php
How to add a Wordpress WYSIWYG editor to a meta box.
<?php
define('WYSIWYG_META_BOX_ID', 'my-editor');
define('WYSIWYG_EDITOR_ID', 'myeditor'); //Important for CSS that this is different
define('WYSIWYG_META_KEY', 'extra-content');
add_action('admin_init', 'wysiwyg_register_meta_box');
function wysiwyg_register_meta_box(){
add_meta_box(WYSIWYG_META_BOX_ID, __('WYSIWYG Meta Box', 'wysiwyg'), 'wysiwyg_render_meta_box', 'post');
}
@bainternet
bainternet / gist:1376124
Created November 18, 2011 10:39
user_specific_content limit comments
<?php
//get comments and comment form as a var
global $post;
$comments = get_comments('post_id='.$post->ID);
$com = '';
foreach($comments as $comment) :
$com .= '<div class="com_container">
<div class="com_author">'.$comment->comment_author . '</div>
<div class="com_content">' . $comment->comment_content.'</div>
</div>';
@bainternet
bainternet / gist:1565093
Created January 5, 2012 12:42
include lyte_video
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript" src="/fancybox/lyte_video.jQuery.min.js"></script>