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 / functions.php
Created September 9, 2019 09:53
Add Custom Notification
function custom_filter_notifications_get_registered_components( $component_names = array() ) {
// Force $component_names to be an array
if ( ! is_array( $component_names ) ) {
$component_names = array();
}
// Add 'insert_post_comment' component to registered components array
array_push( $component_names, 'insert_post_comment' );
C:\vagrant-local>vagrant up
__ __ __ __
\ V\ V\ V / Varying Vagrant Vagrants
\_/\_/\_/ v2.2.1-git::master
Docs: https://varyingvagrantvagrants.org/
Contribute: https://github.com/varying-vagrant-vagrants/vvv
Dashboard: http://vvv.test
Bringing machine 'default' up with 'virtualbox' provider...
@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")
);
@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 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 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
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 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
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 / xampp_php7_xdebug.md
Last active June 19, 2017 11:11
Install Xdebug for XAMPP