Skip to content

Instantly share code, notes, and snippets.

View amirhp-com's full-sized avatar
🔥

Amirhossein Hosseinpour amirhp-com

🔥
View GitHub Profile
@amirhp-com
amirhp-com / index.php
Last active November 10, 2024 23:55
WooCommerce: Display In-Stock Products First
<?php
/**
* WooCommerce: Display In-Stock Products First
* https://www.linkedin.com/posts/activity-7254955257355456515-ypfV
*
* This code snippet reorders products in WooCommerce to show
* in-stock items first, followed by out-of-stock items. It uses
* the 'posts_clauses' filter to modify the default product query.
*
* Usage:
@siaeb
siaeb / WooCommerce.php
Created February 9, 2023 08:10
WooCommerce Get All orders IDs for a given product ID.
/**
* Get All orders IDs for a given product ID.
*
* @param integer $product_id (required)
* @param array $order_status (optional) Default is 'wc-completed'
*
* @return array
*/
public function getOrderIdsByProductId($product_id, $order_status = ['wc-completed', 'wc-processing']) {
global $wpdb;
@siaeb
siaeb / woocommerce_scripts_cleaner.php
Last active February 12, 2023 08:40
Restrict WooCommerce Scripts
function woo_scripts_cleaner() {
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
$woo_styles = [
'woocommerce_frontend_styles',
'woocommerce-general',
'woocommerce-layout',
'woocommerce-smallscreen',
'woocommerce_fancybox_styles',
'woocommerce_chosen_styles',
@amirhp-com
amirhp-com / index.js
Last active July 9, 2024 05:58
Remove Google Map "FOR DEVELOPMENT PURPOSES ONLY" Watermark !
/*
📝 Remove "For Development Only" Watermark on GOOGLE MAP 😁
👤 SCRIPT BY AmirhpCom ( https://amirhp.com/) 👑
➕ Add this code on your project and edit langID,mapCanvas variables
*/
var langID = "en-US", mapCanvas = "#map-canvas", $ = jQuery;
setInterval(function () {googlemap_remap();}, 10);
function googlemap_remap() {
$(`${mapCanvas}>div:last-of-type`).hide(); //hide top message says this is for dev only
var gimg = $(`img[src*="maps.googleapis.com/maps/vt?"]:not(.gmf)`);
@jeffsmonteiro
jeffsmonteiro / gist:451da98e6beb1a6601665b1696ebbfa2
Created August 6, 2019 02:36
Woocommerce jQuery Events List
(WIP) This file contains a list with Woocommerce jquery events
Usage: you can fire functions when some event happen
Example:
$(document.body).on('woocommerce_event', function(){
// do stuff
});
Events
@aminrasouli
aminrasouli / IRAN City
Last active August 30, 2021 11:42
Iran's province and city php class
<?php
/**
* Iran's province and city php class
* @author Amin Rasouli <[email protected]>
* @version 1.0
*/
class City
{
@MoienTajik
MoienTajik / iranian-phone-numbers-regex.md
Last active September 1, 2024 14:53
Regex For Iranian Mobile Phone Numbers

Regex For Iranian Phone Numbers

This regex supports all kinds of Iranian mobile phone numbers :

^(\+98|0)?9\d{9}$


Regex Visualized

@Niq1982
Niq1982 / flywheel-local-xdebug-vscode.md
Last active December 17, 2022 09:33
WordPress debugging with XDebug on Flywheel Local & VSCode

Flywheel Local configuration

Flywheel Local has XDebug installed by default if you choose “Custom” instead of “Preferred” when setting up a new local environment. If you don’t know which your current site is running, you can detect it by going to ”Site Setup” tab. If you can change the PHP version there, you have the “Custom” environment running. If not, just export your site, import it back and choose “Custom”.

Now that we have the right environment, remember what PHP version you are running, open the right PHP settings file (for example /Local Sites/my_site/conf/php/7.0.3/php.ini) and add these lines in the [Xdebug] section:

xdebug.remote_enable=1
xdebug.remote_autostart=1

Save the php.ini and restart your site container in Flywheel to apply new settings.

@dertajora
dertajora / upload_via_ftp.php
Created October 5, 2017 09:33
Upload file Via FTP using PHP
// FTP access parameters
$host = 'xxx';
$usr = 'xxx';
$pwd = 'xxx';
// file to move:
// $local_file = 'D:/xampp/htdocs/absen_folder/log_script.txt';
// $local_file = 'D:\xampp\htdocs\absen_folder\log_script.txt';
$local_file = 'cek.txt';
$ftp_path = 'derta.co.id/htdocs/tes_derta/'.date('Y-m-d').'/cek.txt';