Skip to content

Instantly share code, notes, and snippets.

View hemraj7171's full-sized avatar

Hemraj Adhikari hemraj7171

  • Web Experts Nepal(WEN)
  • Kathmandu,Nepal
View GitHub Profile
@hemraj7171
hemraj7171 / gist:fff3de7e5bfeb90647932b96feb0bff5
Created July 21, 2018 04:25
Change WooCommerce password strength level checkout page/my account page
/**
* Put this code into your functions.php file
* 3 = Strong (default)
* 2 = Medium
* 1 = Weak
* 0 = Very Weak / Anything
*/
function raj_woocommerce_pass_strength( $strength ) {
return 2;
}
@hemraj7171
hemraj7171 / functions.php
Created July 21, 2018 04:21
Remove password strength Woocommerce
//Just put this code into your functions.php file
//removing default Woocommerce password strenght
function raj_remove_password_strength() {
if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) {
wp_dequeue_script( 'wc-password-strength-meter' );
}
}
add_action( 'wp_print_scripts', 'raj_remove_password_strength', 100 );
@hemraj7171
hemraj7171 / add_billing_address_on_registration_page.php
Created November 18, 2017 05:46
Add Billing fields in registration page WooCommerce
/**
* Add billing fields
*
*/
function my_custom_function(){
global $woocommerce;
$checkout = $woocommerce->checkout();
//print_r($checkout);
$checkout_fields = $checkout->checkout_fields['billing'];
unset( $checkout_fields['billing_email']);
@hemraj7171
hemraj7171 / detect-browsers.js
Created June 30, 2017 10:34
Check Safari and Firefox Browser using JavaScript
//Check Safari
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
alert('Its Safari');
}
//Check Firefox
if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1){
// Do Firefox-related activities
alert('Its Fire Chaa...Firefox');
}
@hemraj7171
hemraj7171 / detect-mac-device.js
Last active June 30, 2017 10:39
Detect MAC Device using JavaScript
if(navigator.userAgent.indexOf('Mac') > 0) {
alert("I am MAC");
}
@hemraj7171
hemraj7171 / do-js-stuffs-after-cart-update.js
Created May 24, 2017 06:03
Do JS Stuffs even after cart Update
$( document.body ).on( 'updated_cart_totals', function(){
//re-do your jquery
});
@hemraj7171
hemraj7171 / migration-query.sql
Last active May 24, 2017 06:04
WordPress Migration Query, Move site from one hosting to another
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsite.com', 'http://www.newsite.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldsite.com','http://www.newsite.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldsite.com', 'http://www.newsite.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.oldsite.com', 'http://www.newsite.com');
@hemraj7171
hemraj7171 / short_array_with_custom_key_valu.php
Created April 13, 2017 11:15
Short Array with Custom Key Value in PHP
$array1 = Array
(
'hemraj' => Array
(
'name' => 'hemraj',
'age' => '26',
),
'bishnu' => Array
(
'name' => 'bishnu',
@hemraj7171
hemraj7171 / instruction.txt
Created March 2, 2017 10:54
Simple site loader js/css/html, Simple page loader before page load
1. Add following div just after <body> tag
<div class="top-loader-wrapper">
<div class="cssload-container">
<div class="cssload-speeding-wheel"></div>
</div>
</div>
2. Include jquery
3. Add style at head for the icon design
.top-loader-wrapper {
z-index: 9999999;
@hemraj7171
hemraj7171 / functions.php
Created February 27, 2017 11:07
Add read more button after post excerpt in WordPress
<?php
/**
* Excerpt customization
*/
function wp_excerpt_more( $more ) {
return ' <span>...</span><a class="more-link" href="'. get_permalink() . '">Read More ></a>';
}
add_filter( 'excerpt_more', 'wp_excerpt_more' );
?>