Skip to content

Instantly share code, notes, and snippets.

@bainternet
bainternet / somefile.php
Created March 10, 2014 14:07
allow other mine types upload
<?php
add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
// add your extension to the array
$existing_mimes['swf'] = 'application/x-shockwave-flash';
$existing_mimes['doc'] = 'application/msword';
$existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
$existing_mimes['pdf'] = 'application/pdf';
// add as many as you like
// removing existing file types
@bainternet
bainternet / new_gist_file.js
Created April 1, 2014 12:07
Contact form7 adwords tracking
on_sent_ok: "jQuery(String.fromCharCode(60)+'img/'+String.fromCharCode(62)).attr('height','1').attr('width','1').css('border-style','none').attr('src','REPLACE_THIS_WITH_YOUR_NOSCRIPT_SRC').appendTo('body');"
@bainternet
bainternet / gist:10577652
Last active August 29, 2015 13:59 — forked from webaware/gist:6260468
Add to cart with quantity from shop loop with ajax
<?php
/**
* start the customisation
*/
function custom_woo_before_shop_link() {
add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2);
add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop');
}
add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link');
<?php
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
<?php
/*
* Add "Formats" dropdown to TinyMCE Editor
*/
function matt2015_mce_formats($buttons) {
array_unshift($buttons, 'styleselect');
return $buttons;
}
add_filter('mce_buttons_2', 'matt2015_mce_formats');
function asanaRequest($methodPath, $httpMethod = 'GET', $body = null)
{
$apiKey = 'ASANA_API_KEY_HERE'; /// Get it from http://app.asana.com/-/account_api
$url = "https://app.asana.com/api/1.0/$methodPath";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ;
curl_setopt($ch, CURLOPT_USERPWD, $apiKey);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@bainternet
bainternet / post-commit
Last active August 29, 2015 14:19 — forked from brunohq/post-commit
#!/bin/bash
apikey=$(git config user.asana-key)
if [ $apikey == '' ] ; then exit 0; fi
comment=$(git log --pretty=oneline -n1)
taskid_pattern='.*#([0-9]*).*'
if [[ $comment =~ $taskid_pattern ]]; then
taskid=${BASH_REMATCH[1]}
apikey=$(git config user.asanakey)
#!/usr/bin/env python
"""
To use this you have to include the task ID on the commit message.
Example: Fixing typo, #9283764018
You can as well close a task within the commit message.
Example: Improving the docs, closes #9823761989
"""
<?php
$apikey = ""; // Your API key
$workspace = ''; // your project's workspace ID
$project = ''; // your project's ID
$tasks = array(
'Task 1',
'Task 2',
'Task 3'
// etc
<?php
/**
Plugin Name: CLI Export Multisite
*/
if ( ! defined( 'WP_CLI' ) ) return;
use \WP_CLI\Utils;
/**