Skip to content

Instantly share code, notes, and snippets.

View kish2011's full-sized avatar
🏠
Working from home

Kishore Chandra Sahoo kish2011

🏠
Working from home
View GitHub Profile
@kish2011
kish2011 / gist:193e95473a54e1b39f88ed6f67eb6be5
Created January 12, 2017 06:45 — forked from cubehouse/gist:3839159
WordPress Fake Page Generator - Use in Theme/Plugin to create non-existant pages dynamically
// create fake page called "chat-room"
// modify function and variable names with "ABCD" to whatever you like
// modify variable $fakepage_ABCD_url to the fake URL you require
add_filter('the_posts','fakepage_ABCD_detect',-10);
function fakepage_ABCD_detect($posts){
global $wp;
global $wp_query;
global $fakepage_ABCD_detect; // used to stop double loading

Combine, Minify and Inline CSS In WordPress, in the correct order

Installation

Use copypasta to add to a sub-dir of mu-plugins or use Composer:

  "require": {
 "shelob9/css-inliner" : "*"
@kish2011
kish2011 / hide-edd-coupons.php
Created December 21, 2016 09:40 — forked from bekarice/hide-edd-coupons.php
Hide EDD Coupon fields and codes at checkout
/**
* Snippets to hide EDD coupon fields & codes during the checkout process - handy if you use URLs to apply discounts instead
* Tutorial: http://www.sellwithwp.com/easy-digital-downloads-hide-coupons/
*/
// Removes the field to enter a discount at checkout
remove_action( 'edd_checkout_form_top', 'edd_discount_field', -1 );
// Changes the discount code in the checkout summary to display "Discount applied - " instead of the code
<?php
/**
* Register Team Members metabox as repeatable group fields.
*/
function maintainn_team_members_metabox() {
$prefix = '_maintainn_team_';
$cmb_group = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => __( 'Team Members', 'maintainn-demo' ),
@kish2011
kish2011 / function.php
Last active October 16, 2016 06:02
if you want to use rtmedia for UM
//@see http://community.rtcamp.com/t/permalinks-with-ultimate-member/4778
//if you want to use rtmedia for UM
add_filter( 'author_link', 'rtmedia_for_um', 10, 3);
function rtmedia_for_um($link, $author_id, $author_nicename) {
if ( class_exists('UM_API') )
$link = str_replace('author', 'user', $link);
// get_author_posts_url: http://yoursite.com/author/user-name/ to http://yoursite.com/user/user-name/
@kish2011
kish2011 / is_blog.php
Created July 25, 2016 18:04 — forked from wesbos/is_blog.php
WordPress is_blog()
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
// bp-custom.php does not exist by default. If you don’t have a file located at /wp-content/plugins/bp-custom.php,
// @see https://codex.buddypress.org/themes/bp-custom-php/
// @see https://codex.buddypress.org/developer/loops-reference/the-activity-stream-loop/
// @see https://codex.buddypress.org/developer/function-examples/bp_ajax_querystring/
// Show activity to friends only :)
function bp_loop_querystring_for_friend_only_activity( $query_string, $object ) {
if ( ! empty( $query_string ) ) {
$query_string .= '&';
}
@kish2011
kish2011 / drupal-to-wordpress.sql
Created July 15, 2016 08:29 — forked from ryelle/drupal-to-wordpress.sql
Drupal to WordPress Migration
# DRUPAL-TO-WORDPRESS CONVERSION SCRIPT
# Changelog
# 10.02.2012 - Updated by Kelly Dwan !! THIS VERSION HAS NOT BEEN TESTED !!
# 07.29.2010 - Updated by Scott Anderson / Room 34 Creative Services http://blog.room34.com/archives/4530
# 02.06.2009 - Updated by Mike Smullin http://www.mikesmullin.com/development/migrate-convert-import-drupal-5-to-wordpress-27/
# 05.15.2007 - Updated by D’Arcy Norman http://www.darcynorman.net/2007/05/15/how-to-migrate-from-drupal-5-to-wordpress-2/
# 05.19.2006 - Created by Dave Dash http://spindrop.us/2006/05/19/migrating-from-drupal-47-to-wordpress/
@kish2011
kish2011 / class-virtualthemedpage-bc.php
Created May 17, 2016 08:19 — forked from brianoz/class-virtualthemedpage-bc.php
WordPress Virtual page with theme
<?php
/*
* Virtual Themed Page class
*
* This class implements virtual pages for a plugin.
*
* It is designed to be included then called for each part of the plugin
* that wants virtual pages.
*
* It supports multiple virtual pages and content generation functions.
function listify_get_job_listing_price_job_id( $job_id ) {
global $wpdb;
$order_itemmeta_sql = 'SELECT * FROM ' .
$wpdb->prefix . 'woocommerce_order_itemmeta WHERE
meta_key ="_job_id" AND meta_value=' .$job_id;
$order_itemmeta_results = $wpdb->get_row( $order_itemmeta_sql , OBJECT );
$order_items_sql = 'SELECT * FROM ' .
$wpdb->prefix . 'woocommerce_order_items WHERE