Skip to content

Instantly share code, notes, and snippets.

View florianziegler's full-sized avatar
💭
👨‍💻

Florian Ziegler florianziegler

💭
👨‍💻
View GitHub Profile
@florianziegler
florianziegler / utc-time-zones-offset-minutes
Created September 3, 2014 16:48
Array of UTC-based timezones, key => time zone, value => time offset in seconds
{
'UTC-12' => '-43200',
'UTC-11' => '-39600',
'UTC-10' => '-36000',
'UTC-9.5' => '-34200',
'UTC-9' => '-32400',
'UTC-8' => '-28800',
'UTC-7' => '-25200',
'UTC-6' => '-21600',
'UTC-5' => '-18000',
@florianziegler
florianziegler / google-maps-api-supported-languages
Last active April 22, 2016 19:25
Array of all the languages the Google Maps API supports (as of April 2016)
{
'العربيّة (ar)' => 'ar',
'български (bg)' => 'bg',
'Bengali (bn)' => 'bn',
'català (ca)' => 'ca',
'česky (cs)' => 'cs',
'dansk (da)' => 'da',
'Deutsch (de)' => 'de',
'Ελληνικά (el)' => 'el',
'English (en)' => 'en',
<?php // Change the default client email message
function my_custom_mail_message( $mail_message, $user_name ) {
$mail_message = 'Nice!&#10;&#10;Now I have my own mail message.&#10;&#10;';
$mail_message .= 'I can even automatically end the message with the current username:&#10;' . $user_name;
return $mail_message;
}
@florianziegler
florianziegler / list-of-all-gutenberg-blocks.php
Created December 10, 2019 11:36
List of all Gutenberg block types, including WooCommerce blocks
/**
* Complete list of block type slugs as of WordPress 5.3 and WooCommerce Blocks 2.5.3
*/
$block_types = array(
// Common blocks
'core/paragraph',
'core/image',
'core/heading',
'core/gallery',
'core/list',
@florianziegler
florianziegler / picu-collection-list-with-thumbnail.php
Created February 25, 2022 15:14
Change the output of the picu_collection_list shortcode to include a random images as thumbnail
/**
* Change the output of the picu_collection_list shortcode
*
* @param string $collection_list The original html output
* @param object $query The query of returned collections
* @param array $atts The shortcode attributes
* @param string $content The content between the shortcode tags
*/
function my_picu_collection_list( $collection_list, $query, $atts, $content ) {
@florianziegler
florianziegler / number-of-conescutive-days-of-posting-in-kirby.php
Last active November 7, 2022 06:43
Get the number of consecutive days of posting in Kirby
// Get number of consecutive days of posting
$num = 1;
$p = $pages->listed()->last();
while( $p ) {
// published = date/time field, substr to only get day accuracy
$date = date_create( substr( $p->published(), 0, 10 ) );
$p = $p->prevListed();
$date_prev = date_create( substr( $p->published(), 0, 10 ) );
$diff = date_diff( $date, $date_prev );
@florianziegler
florianziegler / random-picu-collection-image-as-background.php
Created July 19, 2023 10:55
Use a random picu collection image as background
/**
* Use a random collection image as background.
*
* @param string $custom_styles CSS code; Make sure to add your code to the string and not overwrite it.
*/
function my_picu_delivery_random_collection_background( $custom_styles ) {
$post = get_post();
$delivery_option = get_post_meta( $post->ID, '_picu_collection_delivery_option', true );
if ( $delivery_option == 'upload' AND ( 'delivery-draft' == $post->post_status OR 'delivered' == $post->post_status ) ) {
@florianziegler
florianziegler / picu-csv-proof-file.php
Created February 7, 2024 14:41
picu .csv Proof File
/**
* Create .csv proof file content
*
* Puts the email in the first column, selected filenames in the follwing columns,
* each recipient on a new line.
*
* @param string $proof_file_content The original proof file content
* @param int $post_id The collection post ID
* @return string The filtered proof file content
*/