Skip to content

Instantly share code, notes, and snippets.

View Lovor01's full-sized avatar

Lovro Hrust Lovor01

  • makeITeasy
  • Zagreb
View GitHub Profile
@Lovor01
Lovor01 / WP CLI migration.md
Last active January 17, 2022 22:18
Prepare database for migration

Prepare database for migration

wp search-replace 'http://example.com' 'http://example.test' --export=piranesi.sql --skip-columns=guid --skip-tables=wp_users
//get post or page slug
get_post_field( 'post_name' ) // second parameter of post ID could be added
//set automatic updates: https://wordpress.org/support/article/configuring-automatic-background-updates/
//Windows!
mysqldump --user=root --all-databases --result-file=name
//without result-file (using > filename) output goes to UTF16LE, which mysql cannot load!!!
1. Create new column in table wp_terms
2. add filter get_terms_orderby which returns 't.<created column>', where created column is created column in wp_terms

Remove emojis!

Newer solution

/**
 * Disable the emoji's
 */
function disable_emojis() {
	remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
@Lovor01
Lovor01 / block-editor-cheatsheet.js
Last active March 8, 2023 22:29 — forked from bfintal/cheatsheet.js
Block editor (Gutenberg) Cheat Sheet
// get current post categories
wp.data.select('core/editor').getEditedPostAttribute('categories')
wp.data.select('core/editor').getCurrentPostAttribute('categories')
// Get the data of a block
wp.data.select( 'core/editor' ).getBlocks()[0]
// Update attributes of another block
// wp.data.dispatch( 'core/editor' ).updateBlockAttributes( clientID, attributes )
wp.data.dispatch( 'core/editor' ).updateBlockAttributes( '10d88a6d-95d6-4e07-8293-5f59c83a26c0', { heading: 'New Heading' } )
@Lovor01
Lovor01 / Create Symbolic link win powershell.md
Last active April 12, 2024 21:33
Create Symbolic link in powershell
// https://stackoverflow.com/questions/54203925/remove-embedded-stylesheet-for-gutenberg-editor-on-the-back-end
add_filter( 'block_editor_settings' , 'remove_guten_wrapper_styles' );
public function remove_guten_wrapper_styles( $settings ) {
unset($settings['styles'][0]);
return $settings;
}
@Lovor01
Lovor01 / Core secrets.md
Last active April 20, 2024 10:35
Block editor secrets

Core secrets

Block scripts and styles enqueueing

registration

wp-includes/blocks.php - register_block_from_metadata

enqueueing

@Lovor01
Lovor01 / functions.md
Last active February 15, 2022 11:30 — forked from rfmeier/functions.php
Sanitize callback for WordPress register_meta() function.

Sanitize callback for WordPress register_meta() function.

<?php //* do not include php tag

/**
 * Callback for WordPress register_meta() sanitize parameter.
 *
 * Sanitize the 'sample_count' meta value before saved to the database.
 *
 * @see https://codex.wordpress.org/Function_Reference/register_meta