Skip to content

Instantly share code, notes, and snippets.

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

Al Amin dev-alamin

🏠
Working from home
View GitHub Profile
@dev-alamin
dev-alamin / woodmart-theme-germany-translation.txt
Created August 21, 2025 09:26
Translation file of Woodmart theme in Germany
# <!=Copyright (C) 2023 XTemos
# This file is distributed under the GNU General Public License version 3.0.=!>
msgid ""
msgstr ""
"Project-Id-Version: Woodmart 7.3.1\n"
"Report-Msgid-Bugs-To: http://xtemos.com\n"
"POT-Creation-Date: 2023-10-04 12:14:37+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
$products = [
['name' => 'Shirt', 'price' => 30, 'sales' => 100],
['name' => 'Jeans', 'price' => 50, 'sales' => 80],
['name' => 'Hat', 'price' => 20, 'sales' => 120],
['name' => 'Shoes', 'price' => 50, 'sales' => 200],
['name' => 'Socks', 'price' => 10, 'sales' => 50],
];
$posts = [
['title' => 'Learn PHP', 'date' => '2023-05-01'],
@dev-alamin
dev-alamin / wp-list-table.php
Created November 22, 2024 16:40
WP List Table with CRUD
if (!class_exists('WP_List_Table')) {
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}
class Address_List_Table extends WP_List_Table {
public function __construct() {
parent::__construct([
'singular' => 'address',
'plural' => 'addresses',
@dev-alamin
dev-alamin / gist:4a578b080eafa269f25529fc9140c273
Created October 7, 2024 05:53
PHP Method to export data into Excel Sheet
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
include get_template_directory() . '/vendor/autoload.php';
add_action('wp_head', function() {
// Create a new spreadsheet
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
@dev-alamin
dev-alamin / free_gelo_location_api_with_php_functions.php
Created July 30, 2024 06:26
Get free geolocation api with php functions. You will get Country, Country code, ISP etc.
/**
* Fetches the geolocation information for the client's IP address.
* Uses WordPress HTTP API if in a WordPress environment, otherwise uses cURL.
* Try to test in real server no in Localhost
* @see Adjust in 'wp_head' hook to quickly test
* @see add_action( 'wp_head', 'prefix_fetch_geolocation' );
* @return void
*/
function prefix_fetch_geolocation( $json_decode = null ) {
function ip_info($ip = NULL, $purpose = "location", $deep_detect = TRUE) {
$output = NULL;
if (filter_var($ip, FILTER_VALIDATE_IP) === FALSE) {
$ip = $_SERVER["REMOTE_ADDR"];
if ($deep_detect) {
if (filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP))
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
if (filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP))
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
/**
* Add custom package fields to product inventory options.
*/
function sdev_add_custom_package_fields() {
woocommerce_wp_checkbox( array(
'id' => '_package_product',
'label' => 'Is it a package type product?',
'description' => 'Check this box if it is a package type product',
//Take list of data from browser as an object in js or as an array in php
//Now copy object from browser and paste into your file
const authorList = document.querySelectorAll('#lct-widget-product_author li a');
const authorNames = Array.from(authorList).map(author => author.textContent.trim());
console.log(authorNames);
/**
* Autoloader Main function
*
* @param [type] $class
* @return void
*/
function xpovio_core_autoloader( $class ) {
$namespace = 'XpovioCore'; // Core namespace \ It could be ParentProject/SubProject;
$base_dir = __DIR__ . '/includes/';
@dev-alamin
dev-alamin / multiple-select-option.php
Created October 9, 2023 07:34
Multiple selection option
$(".chosen-select").chosen({
no_results_text: "Oops, nothing found!"
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/harvesthq/chosen/gh-pages/chosen.jquery.min.js"></script>
<link href="https://cdn.rawgit.com/harvesthq/chosen/gh-pages/chosen.min.css" rel="stylesheet"/>
<form action="http://httpbin.org/post" method="post">
<select data-placeholder="Begin typing a name to filter..." multiple class="chosen-select" name="test">
<option value=""></option>