Skip to content

Instantly share code, notes, and snippets.

View timoanttila's full-sized avatar
💭
Looking for new opportunities

Timo Anttila timoanttila

💭
Looking for new opportunities
View GitHub Profile

Keybase proof

I hereby claim:

  • I am timoanttila on github.
  • I am timoanttila (https://keybase.io/timoanttila) on keybase.
  • I have a public key whose fingerprint is F660 5B16 201B B8C5 162C FFEF A84A 0933 3381 FC1E

To claim this, I am signing this object:

@timoanttila
timoanttila / directorist
Last active October 26, 2022 09:05
Directorist - Business Directory Plugin
Wordpress plugin Directorist creates all new entities to the `wp_posts` table. I had to find all the sub-merchants in the database backup and here is the SQL statement I used to get all the necessary information.
SELECT ID, post_title, post_content, post_name, post_modified, post_date,
(SELECT meta_value FROM wp_postmeta WHERE meta_key = '_email' AND post_id = wp_posts.ID) dirEmail,
(SELECT meta_value FROM wp_postmeta WHERE meta_key = '_phone' AND post_id = wp_posts.ID) dirPhone1,
(SELECT meta_value FROM wp_postmeta WHERE meta_key = '_phone2' AND post_id = wp_posts.ID) dirPhone2,
(SELECT meta_value FROM wp_postmeta WHERE meta_key = '_fax' AND post_id = wp_posts.ID) dirFax,
(SELECT meta_value FROM wp_postmeta WHERE meta_key = '_address' AND post_id = wp_posts.ID) dirAddress,
(SELECT meta_value FROM wp_postmeta WHERE meta_key = '_zip' AND post_id = wp_posts.ID) dirZip,
(SELECT meta_value FROM wp_postmeta WHERE meta_key = '_website' AND post_id = wp_posts.ID) dirWebsite,
@timoanttila
timoanttila / wc_delete_products
Created November 24, 2021 15:18
Delete all products in WooCommerce
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'));
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'));
DELETE FROM wp_posts WHERE post_type IN ('product','product_variation');
@timoanttila
timoanttila / server_conf
Last active November 24, 2021 14:25
Things to do after new Debian / Ubuntu server
apt update -y
apt install ca-certificates apt-transport-https software-properties-common -y
add-apt-repository ppa:ondrej/php -y
add-apt-repository ppa:ondrej/nginx-mainline -y
apt update -y
curl -sSL https://packages.sury.org/nginx-mainline/README.txt | sudo bash -x
apt install php8.1-fpm php8.1-gd php8.1-common php8.1-curl nginx nginx-core nginx-common nginx nginx-full mariadb-server fail2ban libnginx-mod-brotli -y
apt upgrade -y
#
# Verify captcha
$post_data = http_build_query(
array(
'secret' => CAPTCHA_SECRET,
'response' => $_POST['g-recaptcha-response'],
'remoteip' => $_SERVER['REMOTE_ADDR']
)
);
$opts = array('http' =>