Skip to content

Instantly share code, notes, and snippets.

View autocircled's full-sized avatar

Moktadir Rahman autocircled

  • TIC Limited
  • Rajshahi, bangladesh
  • 15:18 (UTC +06:00)
View GitHub Profile
@autocircled
autocircled / bd-districts.php
Created August 22, 2024 15:16
For woocommerce checkout
<?php
add_filter('woocommerce_states', 'stylish_woocommerce_states');
function stylish_woocommerce_states($states) {
$states['BD'] = array(
'BD-05' => 'Bagerhat - বাগেরহাট',
'BD-01' => 'Bandarban - বান্দরবান',
'BD-02' => 'Barguna - বরগুনা',
'BD-06' => 'Barishal - বরিশাল',
'BD-07' => 'Bhola - ভোলা',
'BD-03' => 'Bogura - বগুড়া',
function qw( $data ) {
if ( true === WP_DEBUG ) {
$backtrace = debug_backtrace();
$backtrace = array_shift( $backtrace );
$output['backtrace'] = $backtrace['file'] . ':' . $backtrace['line'];
$output['data'] = $data;
error_log( print_r( $output, true ) );
@autocircled
autocircled / functions.php
Created December 23, 2024 11:20
WordPress Child Theme Cache Buster
define('DSK_VERSION', '1.1.4');
$cache_buster = DSK_VERSION;
if ( defined( 'WP_DEBUG' ) && WP_DEBUG) {
$cache_buster = date("YmdHi", filemtime( get_stylesheet_directory() . '/css/main.css'));
}
function my_scripts_and_styles(){
global $cache_buster;
wp_enqueue_style( 'main-style', get_stylesheet_directory_uri() . '/css/main.css', array( 'woodmart-style' ), $cache_buster, 'all' );
}
@autocircled
autocircled / logger.js
Created January 17, 2025 06:18
use console.log with stack trace
const logger = new Proxy((...message) => {
console.log(...message);
}, {
apply(target, thisArg, argumentsList) {
const stack = new Error().stack.split('\n').slice(2, 4).join('\n');
console.log('Logger called with arguments:', argumentsList);
console.log('Stack Trace:\n', stack);
return target(...argumentsList);
}
});
<?php
function write_log( ...$data ) {
if ( true === WP_DEBUG ) {
$backtrace = debug_backtrace();
$backtrace = array_shift( $backtrace );
$output['backtrace'] = $backtrace['file'] . ':' . $backtrace['line'];
foreach ( $data as $key => $value ) {
@autocircled
autocircled / wp-cronjob.php
Created March 29, 2025 05:51
WordPress custom scheduled event
public static function init() {
add_action( 'init', array( __CLASS__, 'trtrtr') );
add_action( 'weweweaaewa', array( __CLASS__, 'rererere') );
add_filter( 'cron_schedules', array( __CLASS__, 'ac_custom_cron_schedules') );
}
public static function ac_custom_cron_schedules( $schedules ) {
$schedules['every_minute'] = array(
'interval' => 60, // 60 সেকেন্ড = 1 মিনিট