Skip to content

Instantly share code, notes, and snippets.

View voboghure-dev's full-sized avatar
🏠
Working from home

Tapan Kumer Das voboghure-dev

🏠
Working from home
View GitHub Profile
@voboghure-dev
voboghure-dev / gist:150654069be06d31b4942d64d5d07ed0
Created May 16, 2024 14:38
Prevent creating spam new user in WordPress
// Blacklist woocommerce customer registration
function blacklisted_user( $errors, $sanitized_user_login, $user_email ) {
// Blacklist email domains
$blacklist = ['tmomail.net', 'vtext.com', 'txt.att.net'];
$email_parts = explode( '@', $user_email );
if ( is_numeric( $email_parts[0] ) ) {
// If the user email first part is numeric, add an error message
$errors->add( 'blacklist_error', '<strong>ERROR</strong>: This email is not allowed to register on this site.' );
/**
* For test and debug, log function to view any data in wp-content/debug.log
* uses: log_it($variable);
*
*/
if ( ! function_exists( 'log_it' ) ) {
function log_it( $message ) {
if ( WP_DEBUG === true ) {
if ( is_array( $message ) || is_object( $message ) ) {
error_log( "\r\n" . print_r( $message, true ) );
$ npx npm-check-updates -u
$ npm install
@voboghure-dev
voboghure-dev / Change file and folder permission
Created October 29, 2021 17:03
Linux command to change file and folder permission recursively
// from current folder and all its sub folder
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
/*
* Set up your Git configuration
*/
git config --global user.email "you@yourdomain.com"
git config --global user.name "Your Name"
git config --global core.editor "nano"
@voboghure-dev
voboghure-dev / functions.php
Last active February 23, 2021 03:52
Use a checkbox in checkout page to chose customer send a mail for subscription
/**
* Add WooCommerce Checkbox checkout
*/
function tkd_add_checkout_checkbox() {
woocommerce_form_field( 'checkout-checkbox', array( // CSS ID
'type' => 'checkbox',
'class' => array('form-row mycheckbox'), // CSS Class
'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
$arrayOne = Array
(
"_wvs_pro_swatch_option" => Array
(
"default_to_button" => "yes",
"default_to_image" => "yes",
"default_image_type_attribute" => "",
"pa_color" => Array
(
"default_type" => "select",
/** Register custom product type */
add_action( 'init', 'register_gwp_bundle_product_type' );
function register_gwp_bundle_product_type () {
class WC_Product_gwp_bundle extends WC_Product {
public function __construct( $product ) {
$this->product_type = 'gwp_bundle';
parent::__construct( $product );
}
}
<?php
/**
* Simple excel writer class with no external dependencies, drop it in and have fun
* @author Matt Nowack
* @license Unlicensed
* @version 1.0
*/
class Excel {
private $col;
<?php
/**
* Function: convert_number
*
* Description:
* Converts a given integer (in range [0..1T-1], inclusive) into
* alphabetical format ("one", "two", etc.)
*
* @int
*