Skip to content

Instantly share code, notes, and snippets.

View mattbeck's full-sized avatar

Matt Beck mattbeck

View GitHub Profile
@mattbeck
mattbeck / drupal-t-keybinding.json
Created April 5, 2019 17:05
Drupal t() keybinding for Sublime
[
{
"keys": ["ctrl+super+t"],
"command": "insert_snippet",
"args": {
"contents": "<?php echo t('$SELECTION');?>"
},
"context":
[
{ "key": "selection_empty", "operator": "equal", "operand": false }
<html>
<head>
<!-- Written by Matt Beck. [email protected] -->
<title>Roll Fate Dice</title>
<style>
body{
background: #e0dfd0;
text-align: center;
font-family: helvetica;
max-width: 100%;
@mattbeck
mattbeck / gist:54a61278fdbf4873762c
Created September 21, 2014 06:15
force relative urls in content
add_filter('the_content', 'my_content_filter');
function my_content_filter($content){
$content = str_ireplace('http://url-to-strip.com','',$content);
return $content;
}
@mattbeck
mattbeck / gist:1604156ada969dea9947
Last active August 29, 2015 14:03
Markdown Handling index.php
<?php
$query_string = $_SERVER['QUERY_STRING'];
$uri = filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_STRING);
$uri = str_ireplace('?'.$query_string, "", $uri);
$uri = rtrim($uri, '/'); // strip trailing slashes
if($uri !== ""){
// Check if matching markdown file exists
$mdfilename = $uri.'.md';
if(!file_exists(getcwd().$mdfilename)){
// 404
@mattbeck
mattbeck / gist:e4cd732bbf94ff2c865f
Last active January 30, 2018 07:13
Sample WordPress Data Import Plugin
<?php
/**
* Plugin Name: Run-Once Data Importer
* Description: This plugin will add custom field data to a predefined set of posts
* Version: 1.0
* Author: mattbeck
*/
register_activation_hook( __FILE__, 'runonce_data_import' );