Skip to content

Instantly share code, notes, and snippets.

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

Chetan Satasiya chetansatasiya

🏠
Working from home
View GitHub Profile
@chetansatasiya
chetansatasiya / get-malichimp-list-data.php
Created June 5, 2017 09:03
MailChimp API 3.0 and WordPress HTTP API
<?php
// Enter MailChimp API key and List Id.
$api_key = 'YOUR API KEY';
$list_id = 'YOUR LIST ID';
$dc = substr($api_key,strpos($api_key,'-')+1); // datacenter, it is the part of your api key - us5, us8 etc
$args = array(
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( 'user:'. $api_key )
@chetansatasiya
chetansatasiya / mailchimp-get-subscriber-email-from-list.php
Created June 5, 2017 09:05
Get all subscribers emails from a list
<?php
$api_key = 'YOUR API KEY';
$list_id = 'YOUR LIST ID';
$dc = substr($api_key,strpos($api_key,'-')+1); // us5, us8 etc
$args = array(
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( 'user:'. $api_key )
)
);
@chetansatasiya
chetansatasiya / xampp_php7_xdebug.md
Last active June 19, 2017 11:11
Install Xdebug for XAMPP
@chetansatasiya
chetansatasiya / functions.php
Created June 19, 2017 11:13
How to Change the Login Logo in WordPress
<?php
function custom_loginlogo() {
echo '<style type="text/css">h1 a {background-image: url('.get_bloginfo('template_directory').'/images/login_logo.png) !important; }
</style>';
}
add_action('login_head', 'custom_loginlogo');
@chetansatasiya
chetansatasiya / functions.php
Created June 19, 2017 11:17
How to Change the Login Logo URL in WordPress
<?php
add_filter( 'login_headerurl', 'custom_loginlogo_url' );
function custom_loginlogo_url($url) {
return 'http://www.wordpress.com';
}
@chetansatasiya
chetansatasiya / functions.php
Last active October 30, 2017 12:30
Fetch remote URL image and set to featured image in given postid in WordPress
<?php
function set_featured_image($url,$post_id) {
$attachment_id = media_sideload_image( $url, $post_id, '', 'id' );
if ( ! is_wp_error( $attachment_id ) ) {
set_post_thumbnail( $post_id, $attachment_id );
}
}
@chetansatasiya
chetansatasiya / functions.php
Created February 9, 2018 12:34
Woocommerce add coupon code in new order admin email
<?php
add_filter('woocommerce_get_order_item_totals','cs_add_discount',10,3);
function cs_add_discount($total_rows, $order, $tax_display) {
if ( $order->get_total_discount() > 0 ) {
$coupons = $order->get_used_coupons();
$total_rows['couponused'] = array(
'label' => __( 'Coupon code:', 'woocommerce' ),
'value' => '' . implode(",",$coupons), );
}
@chetansatasiya
chetansatasiya / functions.php
Created February 9, 2018 12:36
Disable the WooCommerce 3.+ default lightbox
<?php
add_action( 'after_setup_theme', 'cs_remove_woo_gallery_lightbox', 100 );
function cs_remove_woo_gallery_lightbox() {
remove_theme_support( 'wc-product-gallery-lightbox' );
}
@chetansatasiya
chetansatasiya / functions.php
Created March 13, 2018 12:56
Woo Menu Cart
<?php
function cs_wcmenucart($menu, $args) {
global $woocommerce;
$viewing_cart = __('View your shopping cart', 'your-theme-slug');
$start_shopping = __('Start shopping', 'your-theme-slug');
$cart_url = $woocommerce->cart->get_cart_url();
$shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
$cart_contents_count = $woocommerce->cart->cart_contents_count;
@chetansatasiya
chetansatasiya / functions.php
Created April 10, 2018 19:52
Convert one timezone to another timezone
<?php
function convert_time_one_timezone_to_other_timezone( $current_timezone = '', $time = '', $convert_to_timezone = 'EST' ) {
$utc_date = DateTime::createFromFormat(
'G:i',
"$time",
new DateTimeZone("$current_timezone")
);