Skip to content

Instantly share code, notes, and snippets.

View mralaminahamed's full-sized avatar
💻
Always available

Al Amin Ahamed mralaminahamed

💻
Always available
View GitHub Profile
<?php
// Function to track and set post views
function set_post_views($post_id) {
if (!is_single()) return; // Only track on single post views
$count_key = 'post_views_count';
$count = get_post_meta($post_id, $count_key, true);
if ($count == '') {
$count = 0;
delete_post_meta($post_id, $count_key);
add_post_meta($post_id, $count_key, '0');
@mralaminahamed
mralaminahamed / gist:5b65ee92429137fcf9c0946a86dade86
Created September 27, 2025 07:49 — forked from marrisonlab/gist:2d2b1e2423312076256e9def70ff931a
Display Dokan Vendor meta in single product page and loop
/**
* Snippet unificato Dokan + Vendor
* Funziona sia con ID utente generico che con loop prodotto
* WPCode: PHP Snippet → Run Everywhere
*/
if ( ! function_exists( 'sn_get_product_from_context' ) ) {
function sn_get_product_from_context() {
global $product;
if ( isset( $product ) && is_object( $product ) ) return $product;

Our lives are increasingly intertwined with technology, the storage space on our devices becomes a valuable commodity. Mac users often find themselves grappling with the perennial issue of managing storage space efficiently. Accumulated files, applications, and system clutter can clog up your Mac's storage, slowing down performance and hindering productivity.

In this guide, we'll use the built-in Terminal app to free up space on your Mac without using any third-party software.

1. Empty the Trash

Start by emptying the Trash. Even though this can be done through the Finder, you can also do it via Terminal using the rm command.

sudo rm -rf ~/.Trash/*

@mralaminahamed
mralaminahamed / class.php
Created March 5, 2025 19:42 — forked from igorbenic/class.php
How to create a Custom WooCommerce Email | https://www.ibenic.com/create-custom-woocommerce-email
<?php
/**
* Class Custom_WC_Email
*/
class Custom_WC_Email {
/**
* Custom_WC_Email constructor.
@mralaminahamed
mralaminahamed / config.php
Created February 17, 2025 01:17 — forked from Niloys7/config.php
one click demo import (OCDI) is not adding elementor global options
/**
* Function to perform setup after importing data.
* This function assigns the front page and the posts page (blog page) based on the imported demo.
* @param array $selected_import The selected import data.
* @link https://www.codeixer.com/addressing-the-issue-of-one-click-demo-import-not-add-elementor-global-options/
*/
function cdx_after_import_setup( $selected_import ) {
// Import Elementor kit data.
<?php
// Enable Development mode
define( 'WP_DEVELOPMENT_MODE', 'plugin' );
define( 'WP_ENVIRONMENT_TYPE', 'development' );
define( 'CONCATENATE_SCRIPTS', false );
define( 'COMPRESS_SCRIPTS', false );
define( 'COMPRESS_CSS', false );
define('ENFORCE_GZIP', true);
define('SAVEQUERIES', true);
@mralaminahamed
mralaminahamed / update-order-status-allow-list.php
Last active October 23, 2024 10:52
Add custom order statuses to the whitelist.
<?php
/**
* Add custom order statuses to the whitelist.
*
* @param array $whitelist The default whitelist of allowed status transitions.
*
* @return array Modified whitelist including custom statuses.
@mralaminahamed
mralaminahamed / update_phpstorm_eap.sh
Last active October 2, 2024 14:33 — forked from DarkaOnLine/php-storm-eap-update.sh
This script automates the process of updating PhpStorm EAP version. It downloads the latest EAP build and installs it on your system.
#!/usr/bin/env bash
#####################################################################
# PhpStorm EAP Updater Script
#
# This script automates the process of updating PhpStorm EAP version.
# It fetches the latest EAP build information, allows the user to choose
# the download format, and installs it on your system.
#
# Usage:
@mralaminahamed
mralaminahamed / wp-config.php
Last active September 26, 2024 03:52
Debugging PHP code is part of any project for wordpress (including plugin or theme), but WordPress comes with specific debug systems designed to simplify the process as well as standardize code across the core, plugins, and themes. This page describes the various debugging tools on WordPress and how to be more productive in your coding, as well …
<?php
// ** Database settings - You can get this info from your web host ** //
define( 'DB_NAME', 'database_name_here' );
define( 'DB_USER', 'username_here' );
define( 'DB_PASSWORD', 'password_here' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );
/**#@+
@mralaminahamed
mralaminahamed / dokan-order-meta-updater.php
Last active September 18, 2024 08:00
Updates the _dokan_vendor_id meta for specified WooCommerce orders where the vendor ID is not set.
<?php
/**
* Plugin Name: Dokan Order Meta Updater
* Plugin URI: https://gist.github.com/mralaminahamed
* Description: Updates the _dokan_vendor_id meta for specified WooCommerce orders where the vendor ID is not set.
* Version: 1.0.0
* Author: Al Amin Ahamed
* Author URI: https://gist.github.com/mralaminahamed/aa44e373ad2d069febf036ba39d1c915
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt