Skip to content

Instantly share code, notes, and snippets.

View golchha21's full-sized avatar

Ulhas Vardhan Golchha golchha21

View GitHub Profile
<?php
/**
* WooCommerce Extra Feature
* --------------------------
*
* Add custom fee to cart automatically
*
*/
function woo_add_cart_fee() {
<?php
/**
* Plugin Name: WooCommerce - List Products by Attributes
* Plugin URI: http://www.remicorson.com/list-woocommerce-products-by-attributes/
* Description: List WooCommerce products by attributes using a shortcode, ex: [woo_products_by_attributes attribute="colour" values="red,black" per_page="5"]
* Version: 1.0
* Author: Remi Corson
* Author URI: http://remicorson.com
* Requires at least: 3.5
* Tested up to: 3.5
<?php
/**
* A very simple autoloader
*/
class Autoloader
{
/**
* Only use this class statically.
* @ignore
<?php
$files = array_slice($argv, 1);
foreach ($files as $file) {
$picture = file_get_contents($file);
$size = getimagesize($file);
// base64 encode the binary data, then break it into chunks according to RFC 2045 semantics
$base64 = chunk_split(base64_encode($picture));
<?php
/**
* Enclose embedded media in a div.
*
* Wrapping all flash embeds in a div allows for easier
* styling with CSS media queries.
*
* @todo Document parameters.
*
* @access private
<?php /* This function attaches the image to the post in the database, add it to functions.php */
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
@golchha21
golchha21 / gist:5267587
Last active December 15, 2015 13:29 — forked from wycks/gist:2315295
<?php
// rewrite /wp-content/themes/theme-name/css/ to /css/
// rewrite /wp-content/themes/theme-name/js/ to /js/
// rewrite /wp-content/themes/theme-name/img/ to /img/
// rewrite /wp-content/plugins/ to /plugins/
function roots_flush_rewrites() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}