Skip to content

Instantly share code, notes, and snippets.

View sourovroy's full-sized avatar

Sourov Roy sourovroy

View GitHub Profile
@sourovroy
sourovroy / woocommerce-my-account-newtab.php
Created January 12, 2017 06:09
Add new tab in woocommerce my acccount page
<?php
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
/**
@sourovroy
sourovroy / ninja-form-label-translate.php
Last active January 12, 2017 06:10
Translate ninja forms label
<?php
function filter_ninja_forms_localize_fields( $field ) {
if( is_array($field['settings']) && array_key_exists("label", $field['settings']) ){
$field['settings']['label'] = esc_html__( $field['settings']['label'], "keyboardpro");
}
return $field;
}
add_filter( 'ninja_forms_localize_fields', 'filter_ninja_forms_localize_fields', 10, 1 );
@sourovroy
sourovroy / wp-create-user.php
Last active January 12, 2017 06:10
Create user from function.php
<?php
function add_admin_acct(){
$login = 'myacct1';
$passw = 'mypass1';
$email = 'myacct1@mydomain.com';
if ( !username_exists( $login ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $login, $passw, $email );
$user = new WP_User( $user_id );
@sourovroy
sourovroy / view-hooks.php
Last active January 12, 2017 06:10
Show all hook of wordpress
<?php
$debug_tags = array();
add_action( 'all', function ( $tag ) {
global $debug_tags;
if ( in_array( $tag, $debug_tags ) ) {
return;
}
echo "<pre>" . $tag . "</pre>";
$debug_tags[] = $tag;
@sourovroy
sourovroy / lang-local-codes.txt
Last active January 5, 2017 06:35
Language Local Codes
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@sourovroy
sourovroy / smooth_scroll.js
Last active March 4, 2018 08:35
Use this code for smoth scroll
// jQuery smooth scroll
$('li.smooth-scroll a').bind('click', function(event){
event.preventDefault();
var $anchor = $(this);
var headerH = '40';
$('html, body').stop().animate({
scrollTop : $($anchor.attr('href')).offset().top - headerH + "px"
}, 1200, 'linear');
});