Skip to content

Instantly share code, notes, and snippets.

View cgdmohamed's full-sized avatar
🎯
Focusing

Moo cgdmohamed

🎯
Focusing
View GitHub Profile
@cgdmohamed
cgdmohamed / custom_functions.php
Created August 6, 2023 17:42
Sort elementor archive posts snippet
<?php
/**
* Elementor archive posts sort
*/
add_action( 'pre_get_posts', function ( $query ) {
// Only modify the query we want
if ( ! $query->is_main_query() || ! $query->is_archive() ) {
return;
}
@cgdmohamed
cgdmohamed / wc-cpp-ajax.php
Last active July 19, 2023 10:04
AJAX Uploading and removing profile picture woocommerce
<?php
/**
* Author: https://mo.hamed.dev
* This file handles uploading and removing custom profile pic with AJAX
* Please note, you have to add removing image AJAX request
*/
add_action('wp_enqueue_scripts', 'moodev_enqueue_scripts');
function moodev_enqueue_scripts()
{
@cgdmohamed
cgdmohamed / woocommerce-allow-one-product-per-category-in-cart.php
Created October 10, 2020 19:06 — forked from Garconis/woocommerce-allow-one-product-per-category-in-cart.php
WooCommerce | Limit one product per specific category in the cart at a time
<?php
// https://www.proy.info/woocommerce-allow-only-1-product-per-category/
// Allow only one(or pre-defined) product per category in the cart
// Alternatively, try plugin: https://wordpress.org/plugins/woo-cart-limit/
add_filter( 'woocommerce_add_to_cart_validation', 'allowed_quantity_per_category_in_the_cart', 10, 2 );
function allowed_quantity_per_category_in_the_cart( $passed, $product_id) {
$max_num_products = 1;// change the maximum allowed in the cart
$running_qty = 0;
@cgdmohamed
cgdmohamed / open_folder_in_PhpStorm_2020.bat
Created September 8, 2020 13:57 — forked from ibrahimhajjaj/open_folder_in_PhpStorm_2020.bat
windows add context open folder in PhpStorm 2020 on right click..
@echo off
SET PhpStormPath=C:\Program Files\JetBrains\PhpStorm 2020.2.1\bin\phpstorm64.exe
echo Adding file entries
@reg add "HKEY_CLASSES_ROOT\*\shell\PhpStorm" /t REG_SZ /v "" /d "Open in PhpStorm" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\PhpStorm" /t REG_EXPAND_SZ /v "Icon" /d "%PhpStormPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\PhpStorm\command" /t REG_SZ /v "" /d "%PhpStormPath% \"%%1\"" /f
echo Adding within a folder entries