Skip to content

Instantly share code, notes, and snippets.

View gbyat's full-sized avatar

Gabriele Lässer gbyat

View GitHub Profile
@gbyat
gbyat / countries-list-de.html
Last active September 16, 2019 09:58
Countries List EN | DE | IT | ES | FR
<select name="countries">
<optgroup label="A">
<option value="AF">Afghanistan</option>
<option value="EG">&Auml;gypten</option>
<option value="AX">&Aring;landinseln</option>
<option value="AL">Albanien</option>
<option value="DZ">Algerien</option>
<option value="AS">Amerikanisch-Samoa</option>
<option value="VI">Amerikanische Jungferninseln</option>
<option value="UM">Amerikanische &Uuml;berseeinseln</option>
@gbyat
gbyat / ppp-sanitize-file-names.php
Last active September 12, 2017 16:32
Sanitize File Names like Titles in WordPress
<?php
/*
Plugin Name: Sanitize File Names
Description: extend file name sanitization
Author: Gabriele Lässer
Version: 1.0
*/
function pppf_extend_filename_sanitization( $title ) {
@gbyat
gbyat / ppp-posttags-select-only.php
Last active June 2, 2016 10:13
WordPress Plugin: Authors may only assign existing post_tags not add new
<?php
/*
* Plugin Name: PPP Posttags Select Only
* Plugin URI: http://gby.at
* Description: Authors may only assign existing post_tags not add new
* Author: Gabriele Laesser
* Author URI: http://www.xisign.com
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Version: 1.0
@gbyat
gbyat / ppp-amp-random-image.php
Last active April 22, 2016 21:05
WordPress Plugin Expamle AMP Random Image
<?php
/*
* Plugin Name: PPP Random AMP Image (needs AMP plugin to work!)
* Description: Add random category image to amp articles without post_thumbnail. Install and activate <a href="https://de.wordpress.org/plugins/amp/">AMP Plugin</a> first
*
*/
function pppf_add_media_taxonomy() {
$labels = array(
<?php
/******************************************
* edit form for new and existing terms
* param term_id has no value by default
******************************************/
function pppf_term_edit_form( $term_id = '' ) {
wp_nonce_field( 'ppp_update_term', 'ppp_update_term_nonce' );
$my_checkbox = $term_id != '' ? get_term_meta( $term_id, 'my_checkbox', true ) : '';
@gbyat
gbyat / custom-fields-for-variations.php
Last active July 28, 2020 22:54
WooCommerce Custom Fields for Variations
<?php
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 3 );
//Save variation fields
add_action( 'woocommerce_save_product_variation', 'save_variable_fields', 10, 2 );
function variable_fields( $loop, $variation_data, $variation ) {
// Text Field
$text_field = get_post_meta( $variation->ID, '_text_field', true );
@gbyat
gbyat / typographic-quotes.php
Last active August 29, 2015 14:04
Typographic Quotes in WordPress
/***********************************
* use in your theme functions.php
* or wordpress plugin
* correct quotes in multilingual sites
* http://codex.wordpress.org/Quicktags_API
***********************************/
function pptf_add_german_quotes() {
if (wp_script_is('quicktags')) {
?>
@gbyat
gbyat / aspect-ratio.css
Last active August 29, 2015 13:55
Keep min-width, max-width and aspect ratio width jQuery
body {
margin:0;
padding:0;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
@gbyat
gbyat / latest-and-first.php
Last active March 24, 2024 17:41
get latest and first post in WordPress
/******************************************
* get latest post
* use in loop if ( is_latest() ) { stuff; }
******************************************/
function is_latest() {
global $post;
$loop = get_posts( 'numberposts=1' );
$latest = $loop[0]->ID;
return ( $post->ID == $latest ) ? true : false;
}