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 / disable CORS.md
Created February 4, 2023 22:46
Disable CORS

Chrome

Start chrome with --disable-web-security option.

Firefox

Install "Allow CORS" extension

@Lovor01
Lovor01 / PHP_parent.md
Created February 2, 2023 10:41
PHP parent path bug

include, require and parent folder (..)

At least on windows with Apache, include and require don't work when path starts with ... To fix this, use

require __DIR__ . '../directory/file.php';
@Lovor01
Lovor01 / terms.md
Last active January 23, 2023 18:31
Select all terms of custom taxonomy

Terms of custom taxonomy impression-category

wp.data.select('core').getEntityRecords('taxonomy', 'impression-category', {_fields: 'id,name', per_page: -1, orderby: 'name', order: 'asc'})

@Lovor01
Lovor01 / FSE.md
Last active January 20, 2023 11:29
Full site editing essential docs

domReady (klasika)

// check document is ready
var domReady = function(callback) {
	document.readyState === "interactive" || document.readyState === "complete" ? callback() : document.addEventListener("DOMContentLoaded", callback);
};
@Lovor01
Lovor01 / add separator.md
Created January 17, 2023 20:27
Add separator in WordPress menu

Add separator in WordPress menu

add_action('admin_menu', function () { global $menu; $menu[44] = ['', 'read', '', '', 'wp-menu-separator']; });

@Lovor01
Lovor01 / clean-disk-space.md
Created January 16, 2023 01:14
Remove node_modules
npm composer
install update
@Lovor01
Lovor01 / Solution.md
Last active January 11, 2023 22:35
Incompatibility - node 18

Incompatibility - node 18 and legacy webpack server

In case of error message

Set NODE_OPTIONS environment variable

"start": "set NODE_OPTIONS=--openssl-legacy-provider && wp-scripts start --webpack-copy-php"

@Lovor01
Lovor01 / catch_variation.md
Created October 18, 2022 22:01
Catch block variation and enqueue assets

How to catch block variation and optimize assets

use pre_render_block hook

/**
 * catch block variation 'apply-to-program' and enqueue assets!
 */
add_filter( 'pre_render_block', function($pre_render, $parsed_block, $parent_block ) {
	if ($parsed_block['blockName'] === 'makeiteasy/call-to-action' && $parsed_block['attrs']['blockType'] === 3)