Skip to content

Instantly share code, notes, and snippets.

View bueltge's full-sized avatar
Always interested

Frank Bültge bueltge

Always interested
View GitHub Profile
@bueltge
bueltge / clipboard.js
Created May 13, 2016 09:44
clipboard.js
//@see http://blog.codeinside.eu/2016/05/12/copy-to-clipboard-with-javascript
function detectIE() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
// IE 10 or older => return version number
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
}
@bueltge
bueltge / metabox-register.php
Last active April 21, 2016 13:57
WordPress Antipattern, no good classes
// @see http://dnaber.de/blog/2015/wordpress-antipattern-filter-im-constructor-zuweisen/
class MetaBoxRegistrar {
private $metaBox;
public function __construct( MetaBoxInterface $metaBox ) {
$this->metaBox = $metaBox;
}
@bueltge
bueltge / change-read-access-posts.php
Created March 31, 2016 16:56
WP Members Add-on, that block read access for the role Author after login.
<?php
/**
* Plugin Name: WP Members Add-on, Change Read Access for role author
*/
! defined( 'ABSPATH' ) && exit;
register_activation_hook( __FILE__, function() {
if ( ! function_exists( 'wpmem_block' ) ) {
@bueltge
bueltge / RegularExpressionCheatSheet.md
Last active April 2, 2022 13:55
Regular Expression Cheat Sheet

Regular Expression Cheat Sheet - PCRE

Kudos/Source: https://github.com/niklongstone/regular-expression-cheat-sheet

Anchor Description Example Valid match Invalid
^ start of string or line ^foam foam bath foam
\A start of string in any match mode \Afoam foam bath foam
$ end of string or line finish$ finish finnish
\Z end of string, or char before last new line in any match mode finish\Z finish finnish
@bueltge
bueltge / wp-fix-enqueued-script-style-https.php
Last active February 21, 2021 23:13
Fix some badly enqueued scripts with no sense of HTTPS for the back end only.
<?php
/**
* Plugin Name: https Fix for enqueue scripts/styles
*/
// Fix some badly enqueued scripts with no sense of HTTPS for the back end only.
// Kudos to http://snippets.webaware.com.au/snippets/cleaning-up-wordpress-plugin-script-and-stylesheet-loads-over-ssl/
add_action( 'wp_print_scripts', 'fb_enqueueScriptsFix', 100 );
add_action( 'wp_print_styles', 'fb_enqueueStylesFix', 100 );
@bueltge
bueltge / wp-i18n-cheatsheet.md
Last active April 2, 2022 13:57
WordPress i18n Cheatsheet

WordPress i18n CheatSheet

Whenever I write plugins or themes, there is one thing that needs a little extra attention and is quite frankly hard to get right: Translatable text. This list should helps me to find the right way fast.

Props to Alex Kirk, there list it inside a quiz.

You want to output the username in a sentence.

Assume that the $username has been escaped using esc_html().

@bueltge
bueltge / mlp-addon-site-link-admin-bar.php
Created November 28, 2015 13:46
MultilingualPress Add-on that get a Dropdown Language Menu
@bueltge
bueltge / mlp-addon-custom-wigdet.php
Last active October 18, 2015 17:04
MultilingualPress Add on as example to create a custom language switcher widget.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: MultilingualPress Add on as example to create a custom language switcher widget.
* Description: This is a simple add-on for the MultilingualPress plugin to create a language switcher widget, that is only visible if there are relationship.
* Author: Inpsyde GmbH
* Author URI: http://inpsyde.com
* Version: 2015-10-19
* Text Domain: multilingualpressaddon
* Domain Path: /languages
* License: GPLv2+
@bueltge
bueltge / mlp-filter-site.php
Last active September 16, 2015 07:17
MultilingualPress Add on to filter non public sites.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: MultilingualPress Add on to hide Non-public Sites
* Description: This is a simple add-on for the MultilingualPress plugin to hide non-public sites (i.e., languages) from translation lists such as the Language Switcher widget or the Quicklinks.
* Author: Inpsyde GmbH
* Author URI: http://inpsyde.com
* Version: 2015-09-16
* License: GPLv2+
* Network: true
*/
@bueltge
bueltge / mlp-site-link-admin-bar.php
Last active June 8, 2018 19:33
MultilingualPress Alternative Title to Admin Bar Site links