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 / add-rel-nofollow-checkbox.php
Created February 14, 2017 12:41 — forked from danielbachhuber/add-rel-nofollow-checkbox.php
Add a 'Add rel="nofollow" to link' checkbox to the WordPress link editor
<?php
/**
* Add a 'Add rel="nofollow" to link' checkbox to the WordPress link editor
*
* @see https://danielbachhuber.com/tip/rel-nofollow-link-modal/
*/
add_action( 'after_wp_tiny_mce', function(){
?>
<script>
@bueltge
bueltge / wp-plugin-security-testing-cheatsheet.md
Created August 22, 2016 12:12
WordPress Plugin Security Testing Cheat Sheet

WordPress Plugin Security Testing Cheat Sheet

This cheat sheet was compiled by Dewhurst Security to record the knowledge gained when testing WordPress plugins for security issues for our clients. The security documentation provided by WordPress and found online for plugin security is sparse, outdated or unclear. This cheat sheet is intended for Penetration Testers who audit WordPress plugins or developers who wish to audit their own WordPress plugins.

This is a living document, feedback in the form of Issues or Pull Requests is very much welcomed.

Cross-Site Scripting (XSS)

@bueltge
bueltge / keybase.md
Last active August 18, 2016 19:39
keybase.md

Keybase proof

I hereby claim:

  • I am bueltge on github.
  • I am bueltge (https://keybase.io/bueltge) on keybase.
  • I have a public key whose fingerprint is 5EA5 319F D531 1C84 7094 2FE4 1A56 7625 5969 6D2D

To claim this, I am signing this object:

@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