Skip to content

Instantly share code, notes, and snippets.

View siaeb's full-sized avatar
🎯
Focusing

SiavashEbrahimi siaeb

🎯
Focusing
View GitHub Profile
@siaeb
siaeb / class-jdf.php
Created July 18, 2021 13:11
توابع کتابخانه JDF به صورت کلاس
class JDF {
/* In the name of Allah = بسم اللّه الرّحمن الرّحیم */
/**
* @فارسی : توابع زمان و تاریخ هجری شمسی (جلالی) در پی اچ پی
* @name: Hijri_Shamsi,Solar(Jalali) Date and Time Functions
* @Author : Reza Gholampanahi & WebSite : http://jdf.scr.ir
* @License: GNU/LGPL _ Open Source & Free : [all public functions]
* @Version: 2.70 =>[ 1395/11/22 = 1438/05/12 = 2017/02/10 ]
@siaeb
siaeb / WooCommerce
Created November 21, 2021 17:44
WooCommerce : Append number of cart items into ajax response when add or delete product
add_filter( 'woocommerce_add_to_cart_fragments', 'siaeb_change_cart_fragments' );
function siaeb_change_cart_fragments($args) {
$args['items'] = [
'count' => WC()->cart->get_cart_contents_count(),
];
return $args;
}
@siaeb
siaeb / MediaLibraryFeatures.php
Created February 24, 2022 08:33
#WordPress_Feature Add File Size Column to Media Library Menu.
class MediaLibraryFeatures {
private static $instance = null;
/**
* Get single instance of this class - Singleton
*
* @since 1.0
*/
public static function getInstance() {
@siaeb
siaeb / Actions.php
Created August 21, 2022 06:22
WordPress force user logout - destroy all user sessions
add_action('admin_init', 'wpt_force_logout', 15);
function wpt_force_logout() {
$action = isset($_GET['action']) ? strtolower($_GET['action']) : false;
if (!$action || 'wpt-logout' !== $action) {
return;
}
$user_id = isset($_GET['user_id']) ? absint($_GET['user_id']) : false;
if (!$user_id || empty(trim($user_id))) {
return;
@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',