Skip to content

Instantly share code, notes, and snippets.

View seebeen's full-sized avatar
💭
🦔

Sibin Grašić seebeen

💭
🦔
View GitHub Profile
@seebeen
seebeen / qty-limits.php
Last active February 11, 2024 19:23
WooCommerce - Change quantity args for products across frontend
<?php
/**
* @var array<int, array{
* input_value: int,
* max_value: int,
* min_value: int,
* step: int,
* }|null> $product_args Array of qty data or null for default - keyed by product ID
*/
@seebeen
seebeen / archive-functions.zsh
Created November 8, 2023 08:30
Archiving functions
# Function to store files into a tar.gz archive using pigz with compression level 1
storeit() {
local tarfile=$1
local pathtotar=$2
local cpus=${3:-12} # Default to 12 CPUs if not specified
# Count the total number of files and total size for progress bar
local totalsize=$(du -sb "$pathtotar" | awk '{print $1}')
# Archive and compress with progress bar
@seebeen
seebeen / delete-old-non-featured-images.php
Last active October 16, 2021 11:09
WordPress - Remove images older than three months
@seebeen
seebeen / SMTP.php
Created July 2, 2021 10:15
WordPress PHPMailer SMTP
<?php
namespace Extremis\Core;
use PHPMailer\PHPMailer\PHPMailer;
class SMTP
{
public function __construct()
{
@seebeen
seebeen / queries.sql
Created March 31, 2021 16:05
Useful WP SQL Queries #WordPress
/*
list all meta keys and count them
*/
SELECT meta_key, COUNT(*) FROM `wp_postmeta` group by meta_key ORDER BY `COUNT(*)` DESC
@seebeen
seebeen / porto-fix.php
Last active March 23, 2021 14:21
Porto Indian stupidity #wordpress #shitty-indian-code
<?php
function porto_check_theme_options() {
// check default options
global $porto_settings;
// ob_start();
// include PORTO_ADMIN . '/theme_options/default_options.php';
// $options = ob_get_clean();
// $porto_default_settings = json_decode( $options, true );
// Begin Indian code fix
@seebeen
seebeen / autosave-attachment.php
Created March 19, 2021 10:42
WordPress add attachment to auto-save
<?php
add_action('save_post', 'add_attachment_to_autosave');
function add_attachment_to_autosave( $post )
{
if( !wp_is_post_autosave($post) ) :
return;
endif;
@seebeen
seebeen / basic-stuff.php
Created March 12, 2021 21:40
[WooCommerce Product Manipulation] WooCommerce Product manipulation basics #wordpress #woocommerce
<?php
$product_id = 202;
$product_sku = 'SIFRA-1245';
/*
This won't work because update_post_meta does not trigger necessary additions to product lookup tables and transients
*/
update_post_meta($product_id, '_sku', $product_sku);
@seebeen
seebeen / RecentComments.php
Created February 28, 2021 15:46
WP recent comments + POST link
<?php
namespace Oblak\Addons;
use WP_Comment;
use WP_Comment_Query;
class RecentComments
{
private static ?array $comments = null;