Skip to content

Instantly share code, notes, and snippets.

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

Jakub Novák kubiqsk

🏠
Working from home
View GitHub Profile
@kubiqsk
kubiqsk / alternative-menu-title.php
Last active February 26, 2024 20:20
Alternative menu item title
<?php
add_filter( 'wp_nav_menu_objects', function( $items, $args ){
if( $args->theme_location == 'main_nav' || $args->menu->term_id == 6 ){
foreach( $items as &$item ){
if( $item->auto_listed ){
$custom_menu_title = get_field( 'custom_menu_title', $item->ID );
if( $custom_menu_title ){
$item->title = $custom_menu_title;
}
@kubiqsk
kubiqsk / convert-webp.php
Created July 15, 2023 13:37
PHP snippet to convert all WebP images back to original formats - works only with WordPress plugin Images to WebP
<?php
function convertWebPImages( $directory = '.' ){
$files = glob( $directory . '/*.webp' );
foreach( $files as $file ){
$original_file = substr( $file, 0, -5 );
$original_ext = pathinfo( $original_file, PATHINFO_EXTENSION );
if( ! file_exists( $original_file ) ){
$webp = imagecreatefromwebp( $file );
if( $webp !== false ){
@kubiqsk
kubiqsk / date.format.js
Created July 25, 2022 07:20
PHP date() formatting in JavaScript
/*
# this will create new .format() function for Date object
# there is auto localization from Intl, but you can also set language as a 2nd argument
# all possible values were tested and compared on Apache server with PHP 8 date() function
# you can find minified version in the first comment
# examples:
new Date().format('d.m.Y H:i:s') // 25.07.2022 09:11