Skip to content

Instantly share code, notes, and snippets.

View iworks's full-sized avatar
🐛
Bug hunting!

Marcin Pietrzak iworks

🐛
Bug hunting!
View GitHub Profile
<?php
/**
* filter field named "foo"
*/
add_filter(
'orphan_replace_acf',
function( $filter, $value, $post_id, $field ) {
/**
* check by field name
*/
@iworks
iworks / get.gravatars.sh
Last active May 31, 2024 09:05
WordCamp Kraków 2024 get.gravatars.sh
#!/usr/bin/env bash
#
# emails list, one per line
#
list=./list.txt
#
# gravatar size
#
size=2500
#
@iworks
iworks / class-paczkomaty-inpost.php.diff
Created April 8, 2024 10:23
class/paczkomaty-inpost.php - fix
50c50
< add_action( 'save_post', [ $this, 'save_product_data' ], 1, 3 );
---
> add_action( 'save_post', [ $this, 'save_product_data' ], 1 );
875,877c875,878
< public function save_product_data( $post_id, $post, $update ) {
< if ( isset( $post ) && 'product' === $post->post_type && $post_id ) {
< $product = wc_get_product( $post_id );
---
> public function save_product_data() {
@iworks
iworks / sierotki-add-form-to-protected-tags.php
Created March 15, 2024 09:25
Sierotki: add the FORM tag to protected tags
<?php
/*
Plugin Name: Sierotki: add the FORM tag to protected tags
Plugin URI: http://iworks.pl/szybki-wordpress-obrazki-leniwe-ladowanie
Description: Added the FORM HTML tag to protected tags, to avoid orphans replacements.
Version: 1.0.0
Author: Marcin Pietrzak
Author URI: http://iworks.pl/
License: GPLv2 or later
*/
@iworks
iworks / change-orphans-set.php
Created March 5, 2023 06:09
Zmiana domyślnych sierotek
<?php
/**
* Zmiana domyślnych sierotek
*
* https://wordpress.org/support/topic/zmiana-domyslnych-sierotek/
*
* Chcę zamienić całą listę domyślnych sierotek na tylko te zaproponowane
* przeze mnie (a, i, o, u, w, z ).
*
@iworks
iworks / .htaccess
Created January 27, 2023 10:29
.htaccess example with mod_deflate, mod_expires & mod_rewrite for WordPress
<ifmodule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
@iworks
iworks / wp_get_attachment_image_attributes.php
Created September 12, 2022 10:39
Add post title as a alt for thumbnail
<?php
add_filter(
'wp_get_attachment_image_attributes',
function( $attr, $attachment, $size ) {
if ( ! is_singular() ) {
return $attr;
}
if ( isset( $attr['alt'] ) && ! empty( $attr['alt'] ) ) {
return $attr;
}
@iworks
iworks / class-iworks-default-gallery-link.php
Created July 22, 2022 04:27
iWorks Default Gallery Link
@iworks
iworks / book.post.type.php
Created March 11, 2022 13:05
WordPress - custom post type - book
<?php
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'book',
array(
'labels' => array(
'name' => __( 'Books', 'book-post-type' ),
'singular_name' => __( 'Book', 'book-post-type' )
),
'public' => true,
@iworks
iworks / class-iworks-random-slug.php
Created March 2, 2022 11:12
iWorks Random Post Slug
<?php
/*
Plugin Name: iWorks Random Post Slug
Plugin URI: http://iworks.pl/
Description: Create random post slug.
Version: 1.0.0
Author: Marcin Pietrzak
Author URI: http://iworks.pl/
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html