31. Jan 2024 |

Empty actionscheduler_logs quickly

Just these cli commands help you out.

wp db query "SELECT * FROM wp_actionscheduler_logs LIMIT 1"

wp db query "DELETE FROM wp_actionscheduler_logs"

wp db query "DELETE FROM wp_actionscheduler_actions WHERE status = 'complete'"– you can modify this as you want.

19. Dec 2023 |

Sooduskoodid

Minu uus hobiprojekt Sooduskoodid. Panin üles 01.12.23. Vaatame, mis sellest saab. Hetkel tundub, et on üsna hästi vastu võetud.

01.01.24 seisuga võib öelda, et 1. kuu on läinud päris hästi. Search Console ütleb, et detsembris 248 klikki, Analyticsist ~2600 külastajat (peamiselt sotsiaalmeedia kaudu).

Lehte vahepeal täiendanud ka erinevate funktsionaalsustega, mis kahjuks väga välja ei paista 🙂

Veel aasta viimasel õhtul tegin tagasiside nupud kupongidele koos cache’is istuva rate limiteriga, et ise ka teaksin, mis koodid töötavad ja mis mitte. Loodan, need lähiajal Livewire komponentideks teha, et lehte uuesti ei laetaks. Siis oleks juba nagu päris.

8. Oct 2023 |

Kuutasuta pangakaart – säästa 23 eurot aastas

Revolut Standard paketiga saab kuutasuta pangakonto ja tasuta pangakaardi. Kui füüsilist kaarti ei soovi ja tahad näiteks ainult Apple Pay või Google Pay kaudu maksta, siis seda pangakaarti ei pea isegi tellima. Revolut pangakaart on kuutasuta aga maksta tuleb ühekordne saatmiskulu.

Kuigi LHV ja Coop Pank võimaldavad mõlemad kuutasuta arvelduskontot, siis (füüsilised) pangakaardid on neil siiski kuutasuga (1 eur/kuu).

Võrdluseks, näiteks SEB Panga kõige odavam arvelduskonto on 1.95 eur/kuus (23.40 eur/aasta) ja selle eest saab näpuotsaga tehinguid.

Miks mul seda vaja on?

Kasutan Revolut pangakaarti püsikorralduste jaoks. Spotify, Delfi jms lähevad kõik sellelt ja raha kannan sinna püsikorraldusega täpselt vajalikus summas täpselt arve kuupäeval. Nii on igasugustest tellimustest parem ülevaade ja raha ei võeta mu igapäevaselt maksekaardilt.

7. Aug 2023 |

WPML and WP-CLI – how to delete products

Whey I tried to delete products using WP-CLI then products only in default language were deleted. Products in other languages could not be deleted using wp post delete. I used the following command:

wp post delete $(wp wc product list --user=1 --format=ids --per_page=10) --force

More information about deleting WooCommerce products using wp-cli can be found there.

In order to delete products in all languages this needs to be checked: WPML → Settings → “When deleting a post, delete translations as well”.

24. Jun 2023 |

Ülikool lõpetatud

Ma ei ole siin pikalt koolist kirjutanud aga kool on saanud läbi. Sügissemestril (01.2023) kaitsesin lõputöö ja üleeile (22.06.23) oli lõpuaktus.

Arendaja töökogemuse sain kahes teenusettevõttes (Net Group, Lumav Commerce) aga leidsin, et teenusettevõttes arendajana töötamine mulle ei sobi. Toote-ettevõttes töötamise kogemust mul ei ole. Hetkel toimetan enda projektidega (mõned e-poed, üks API teenus, mõned hobiprojektid).

7. May 2023 |

wp cli delete orders older than…

Overview of WooCommerce CLI can be found here and examples here.

Delete shop order by ID, need to add user id that has permissions to delete orders.

wp wc shop_order delete <id> --user=1

Delete orders where date is older than…

for id in $(wp db query "SELECT id FROM wp_posts WHERE post_date < '2021-01-01' AND post_type='shop_order'" --skip-column-names); do wp wc shop_order delete $id --user=1 --force=1; done

21. Mar 2023 |

wp cli to delete unattached images

Yes, I did it. I imported new images with every product import so now I have 15000+ images in my media library.

for id in $(wp db query "SELECT id FROM wp_posts WHERE post_date <= '2023-03-20' AND post_date >= '2023-03-15' AND post_type='attachment' AND post_parent=0 AND post_author NOT IN(1,4)" --skip-column-names); do wp post delete --force $id; done

This is the wp cli command that does the job. I found it here.

Just to see how many images will be deleted you can use following query:

wp db query "SELECT COUNT(id) FROM wp_posts WHERE post_date <= '2023-03-20' AND post_date >= '2023-03-01' AND post_type='attachment' AND post_parent = 0 AND post_author NOT IN (1,4)"

You can modify post_author IDs and date ranges as you like. For testing you can as LIMIT parameter to the query.

21. Mar 2023 |

Use specific php version in cli

In Zone webhosting I have several apps under one account. WordPress websites use PHP 7.4 (as WP does not support php 8). But my Laravel apps use PHP 8.

I can choose php version for server. For example:

laravel-app.mydomain.com – this uses php 8.0
wordpress.mydomain.com – this uses php 7.4

If I need to use command line interface (cli) then php version is always the same that I have set for my main domain settings. If I need to use specific PHP version in cli then I need PHPRC prefix before command of export PHPRC in the beginning of the bash script.

#!/bin/bash
export PHPRC=/etc/opt/zone/php80-cgi
php80-cli -v

 

3. Nov 2022 |

Disable xdebug and fix Postman output

At some point var_dump in Postman started printing HTML instead of json and made debugging experience worse. I used php artisan serve and suspected that my CLI php is using xdebug. This advice I found helpful.

sudo phpdismod -s cli xdebug – to disable xdebug

sudo phpenmod -s cli xdebug – to enable xdebug

This is how you can disable and enable xdebug from command line. After this that <pre> thing should go away from Postman responses.