Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Lovor01's full-sized avatar
🏠
Working from home

Lovro Hrust Lovor01

🏠
Working from home
  • makeITeasy
  • Zagreb
View GitHub Profile
@Lovor01
Lovor01 / malware.md
Last active March 15, 2024 13:16
WordPress Malware detection

A list of WordPress malware tools

@Lovor01
Lovor01 / Replace.php
Created October 21, 2023 16:31
Replace srcset
<?php
/**
* add sizeSlug attribute where it is missing and update image src accordingly
*/
// alternative only for fixing sizeSlug:
// wp search-replace '(<!-- wp:image\s{(?!.*"sizeSlug")[^}]*)' '$1,\"sizeSlug\":\"full\"' gr8_posts --regex --regex-delimiter='/' --include-columns=post_content --log=C:\Users\Admin\Downloads\replace.log --precise
@Lovor01
Lovor01 / wp.md
Created September 29, 2023 10:08
WP recepies

Install plugin

wp plugin install create-block-theme --activate
@Lovor01
Lovor01 / unregister ctrl+k.js
Created September 23, 2023 20:47
WordPress: Unregister shortcut key ctrl+k (cmd+k)
wp.domReady( () => {
const unsubscribe = wp.data.subscribe( () => {
const command = wp.data.select( 'core/keyboard-shortcuts' ).getShortcutKeyCombination( 'core/commands' );
if ( command && command.character === 'k' ) {
wp.data.dispatch( 'core/keyboard-shortcuts' ).unregisterShortcut( 'core/commands' );
unsubscribe();
}
@Lovor01
Lovor01 / docker-compose.yml
Created September 14, 2023 18:11
Create WordPress environment in Docker
services:
db:
# We use a mariadb image which supports both amd64 & arm64 architecture
image: mariadb:latest
# If you really want to use MySQL, uncomment the following line
#image: mysql:8.0.27
command: '--default-authentication-plugin=mysql_native_password'
volumes:
- db_data:/var/lib/mysql
restart: always
@Lovor01
Lovor01 / Remove-remote.md
Last active October 3, 2023 21:28
Remove file/directory from remote repository

Remove remote file or directory

// file
git rm package-lock.json --cached
// directory
git rm -r directory --cached

then commit changes

@Lovor01
Lovor01 / regex.md
Created July 8, 2023 09:11
WP CLI search replace regex

Use regex to replace (windows, powershell)

wp search-replace '(<!-- wp:image\s{[^}]*)' '$1,"sizeSlug":"full"' wp_posts --regex --regex-delimiter='/' --dry-run
@Lovor01
Lovor01 / i18n.md
Last active May 22, 2023 10:56
WordPress i18n

for block plugins

 wp i18n make-pot ./ languages/makeiteasy-back-to-top.pot
@Lovor01
Lovor01 / Database_cmd.md
Last active August 27, 2023 10:52
Database mysql/mariadb command line

Export database

mysqldump <database> --password <password> --user <user> --default-character-set=utf8 > <file>

on windows, use --result-file=<file> as default export is in UTF16

(or mariadb-dump)

Import database

@Lovor01
Lovor01 / Debug react HMR.md
Created February 5, 2023 22:33
Debugging react hot reload

Check server

Open: server url/webpack-dev-server to check if it is working