Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

SiavashEbrahimi siaeb

🎯
Focusing
View GitHub Profile
@siaeb
siaeb / Actions.php
Created Aug 21, 2022
WordPress force user logout - destroy all user sessions
View Actions.php
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_scripts_cleaner.php
Last active Nov 25, 2022
Restrict WooCommerce Scripts
View woocommerce_scripts_cleaner.php
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',
@siaeb
siaeb / MediaLibraryFeatures.php
Created Feb 24, 2022
#WordPress_Feature Add File Size Column to Media Library Menu.
View MediaLibraryFeatures.php
class MediaLibraryFeatures {
private static $instance = null;
/**
* Get single instance of this class - Singleton
*
* @since 1.0
*/
public static function getInstance() {
@siaeb
siaeb / WooCommerce
Created Nov 21, 2021
WooCommerce : Append number of cart items into ajax response when add or delete product
View WooCommerce
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 / class-jdf.php
Created Jul 18, 2021
توابع کتابخانه JDF به صورت کلاس
View class-jdf.php
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 ]