Skip to content

Instantly share code, notes, and snippets.

View imvaskii's full-sized avatar
🎯
Focusing

Bhaskar imvaskii

🎯
Focusing
View GitHub Profile
@imvaskii
imvaskii / gist:18472b788ac32c4b16524cf2c25a5d87
Created October 6, 2017 04:07 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@imvaskii
imvaskii / gist:4fe71965e996073da4b6
Created November 27, 2015 04:01 — forked from jruck/gist:4270084
WP: Minimal wp_oembed_get
// Minimal YouTube & Vimeo embeds
function wp_oembed_get( $url, $args = '' ) {
if(preg_match("/youtube.com\/watch\?v=([^&]+)/i", $url, $aMatch)){
return '<iframe width="640" height="360" src="http://www.youtube.com/embed/' . $aMatch[1] . '?loop=1&modestbranding=1&rel=0&showinfo=0&autohide=1" frameborder="0" allowfullscreen></iframe>';
}
if(preg_match("/youtube.com\/watch\?feature=player_embedded&v=([^&]+)/i", $url, $aMatch)){
return '<iframe width="640" height="360" src="http://www.youtube.com/embed/' . $aMatch[1] . '?loop=1&modestbranding=1&rel=0&showinfo=0&autohide=1" frameborder="0" allowfullscreen></iframe>';
}
@imvaskii
imvaskii / gist:a2cd67897d3b20bebacf
Created November 12, 2015 04:41 — forked from grandmanitou/gist:8863248
Place multiple markers with infowindow on Google Maps API v3, use external links to trigger click and center map on desired location.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?language=fra&amp;sensor=false"></script>
<script type="text/javascript">
var map;
var Markers = {};
var infowindow;
var locations = [
[
'Samsung Store Madeleine',
'<strong>Samsung Store Madeleine</strong><p>5 Boulevard Malesherbes, 75008 Paris<br>10h – 20h</p>',
48.8701925,
@imvaskii
imvaskii / custom-search-acf-wordpress.php
Created October 30, 2015 01:23 — forked from charleslouis/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}
@imvaskii
imvaskii / woocommerce-alter-cart-total.php
Created October 6, 2015 04:22 — forked from jplhomer/woocommerce-alter-cart-total.php
Programmatically alter the WooCommerce cart discount total (and apply a new discount) before it's calculated through the woocommerce_calculate_totals hook. Add this code to your Wordpress functions.php file.
<?php
/**
* Programmatically alter the WooCommerce cart discount total (and apply a new discount) before it's calculated
* through the woocommerce_calculate_totals hook.
*
* For example, if you want to apply an arbitrary discount after a certain number of products in the cart,
* you can loop through that number and increment it as needed.
*
* In this example, I increment the discount by $8.85 after every 15 products added to the cart.
*
@imvaskii
imvaskii / upload-and-parse-csv-file.php
Created September 30, 2015 07:16 — forked from plasticbrain/upload-and-parse-csv-file.php
PHP: Upload and parse CSV file
<form action="" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" name="btn_submit" value="Upload File" />
<?php
$fh = fopen($_FILES['file']['tmp_name'], 'r+');
$lines = array();
while( ($row = fgetcsv($fh, 8192)) !== FALSE ) {
$lines[] = $row;
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
<?php
/**
* Plugin Name: T5 AJAX Editor
*/
namespace T5AjaxEditor;
class Controller implements Event_Handler
{
<?php
/**
* This changes logging to only log fatal errors. This file should go in your mu-plugins directory.
*/
// Set the error logging to only log fatal errors
error_reporting( E_ERROR );
// Optional: change the location of your error log, it might be wise to put it outside your WP content dir.
// If you don't change it, the default place for this log is debug.log in your WP_CONTENT_DIR.
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
$fields['billing']['billing_city']['label'] = 'City';
$fields['billing']['billing_phone']['required'] = false;
$fields['order']['order_comments']['placeholder'] = 'My new placeholder';
//removing fields
unset($fields['order']['order_comments']);
//adding custom fields
$fields['shipping']['shipping_phone'] = array(
'label' => __('Phone', 'woocommerce'),