Skip to content

Instantly share code, notes, and snippets.

View rheinardkorf's full-sized avatar

Rheinard Korf rheinardkorf

View GitHub Profile
@rheinardkorf
rheinardkorf / enable-wp-oauth-ui.php
Last active November 12, 2017 21:33
Enable the WP API OAuth Server consumer UI to create key pairs without using WP CLI.
<?php
/*
Plugin Name: Enable OAuth UI
Plugin URI: https://gist.github.com/rheinardkorf/dab0f0f46b814e1a7d1d
Description: Allows you to create consumer key pairs without WP CLI and the ability to name them for each APP. Must have WP API Oauth Server plugin active.
Version: 0.1
Author: Rheinard Korf
Author URI: https://gist.github.com/rheinardkorf/
License: GPL2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@rheinardkorf
rheinardkorf / developer_login.php
Last active January 11, 2016 01:16
WordPress auto-login
<?php
/*
* Auto-login script to save having to manually login when developing a WP site.
*
* Place in wp-content/mu-plugins and remember to add to .gitignore for safety
*
* Add the DEV_GET_PARAMETER to the url to activate the script and login for you
* e.g. http://localhost:8080/?dev
*/
<?php
class MyPlugin {
/**
* Add this at top of your plugin class constructor or whichever method in your class you use to bootstrap your plugin.
* e.g. public static function bootstrap()
*/
public static function bootstrap() {
if ( version_compare( '5.3', phpversion(), '>' ) ) {
@rheinardkorf
rheinardkorf / onename-verify.txt
Created January 11, 2016 04:57
OneName Verify
Verifying that +rheinardkorf is my blockchain ID. https://onename.com/rheinardkorf
@rheinardkorf
rheinardkorf / chrometabs.rb
Created February 22, 2016 23:53
Chrome Tabs to Markdown - Ruby script to grab all open Chrome tabs and present the Markdown links and reference table. Works extra nice as a TextExpander snippet!!
#! /usr/bin/ruby
# A different implementation to Brett Terpstra's Markdown Service Tools: "md - Links - Chrome Tabs"
# This version looks at all tabs across all open Chrome windows.
# This version produces output as a list of links as well as a reference table including title tags.
# $KCODE = 'u'
UNICODE_COMPETENT = ((RUBY_VERSION)[0..2].to_f > 1.8)
unless UNICODE_COMPETENT # lower than 1.9
class String
@rheinardkorf
rheinardkorf / chrometabs.swift
Last active February 23, 2016 13:30
Chrome Tabs to Markdown - Redo of https://gist.github.com/rheinardkorf/faf652ef9dba66b2e555, but this time using Swift. Again, best used as a TextExpander snippet.
#!/usr/bin/swift
// @author: Rheinard Korf
import Foundation
// We need this struct to make life easier
struct TabItem {
var title: String
var name: String
var link: String
@rheinardkorf
rheinardkorf / loading-wp-editor-instance.php
Created April 18, 2016 00:55
Example of loading WP Editor scripts outside of normal context. No need for dummy editor hackery.
<?php
// Hook in the editor's `enqueue_scripts` function
add_action( 'some_footer_action', array( '_WP_Editors', 'enqueue_scripts' ) );
// Some function that's going to render in the page footer
function some_footer_render_function() {
do_action( 'some_footer_action' );
}
@rheinardkorf
rheinardkorf / 0_reuse_code.js
Created September 20, 2016 06:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@rheinardkorf
rheinardkorf / slack-sso.php
Last active September 30, 2016 00:28
Very basic implementation of a Slack SSO plugin.
<?php
/*
Plugin Name: Slack SSO
Plugin URI: https://gist.github.com/rheinardkorf/91431d6e8e7b5070730352321876d5d3
Description: Sign into your WordPress site with Slack.
Version: 0.1-alpha
Author: Rheinard Korf
Author URI: https://gist.github.com/rheinardkorf/91431d6e8e7b5070730352321876d5d3
License: GPL2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
<?php
/**
* Whitelist embedded links in the REST API responses
*
* This is often useful if you want to only get specified resources embedded along with the
* main resources, rather than the "all of nothing" approach of passing `?_embed` to the API request.
*
* You can either pass a comma seperated list of relationships or an array of string via the `_embed_include` query param.
*