Skip to content

Instantly share code, notes, and snippets.

Avatar

Jan Beck jancbeck

  • Austria
View GitHub Profile
@jancbeck
jancbeck / acf_register_fields.php
Last active Aug 29, 2015
How to search for the title of a related custom post type in the WordPress admin using ACF Pro
View acf_register_fields.php
<?php if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'group_558c7f75de508',
'title' => 'Stories',
'fields' => array (
array (
'key' => 'field_558c7fe4df0bc',
'label' => 'Select artist',
'name' => 'select_artist',
@jancbeck
jancbeck / highlight.php
Created Oct 30, 2014
Code Highlight Plugin for Kirby CMS v2
View highlight.php
<?php
require_once('highlight/geshi.php');
kirbytext::$pre[] = function($kirbytext, $value) {
return preg_replace_callback('!```(.*?)```!is', function($code){
$code = @$code[1];
$lines = explode("\n", $code);
View snippet.video.php
<?php
/**
* Move this file to /site/snippets/ and rename it video.php
*/
// stop without videos
if(empty($videos)) return;
// set some defaults
@jancbeck
jancbeck / kirbytext.extended.php
Last active Aug 29, 2015 — forked from tysongach/kirbytext.extended.php
A Kirbytext extension that lets you add HTML5 figure tags for videos and images.
View kirbytext.extended.php
<?php
class kirbytextExtended extends kirbytext {
function __construct($text=false, $markdown=true, $smartypants=true) {
parent::__construct($text, $markdown, $smartypants);
// define custom tags
$this->addTags('figure');
@jancbeck
jancbeck / install.md
Last active Feb 2, 2017
Documenting the process of setting up my local environment for web design and development (OS X 10.9 Mavericks)
View install.md

User Home Directory

Restore home folder from backup. You better have a backup.

Important files and folders:

  • ~/.bash_profile
  • ~/.ssh/
  • ~/Library/Preferences/
@jancbeck
jancbeck / html
Created Mar 2, 2013
Starting Template for HTML files
View html
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8" />
<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement) /* removes no-js class */</script>
<title>Untitled Document</title>
</head>
@jancbeck
jancbeck / query_google_spreadsheets.php
Last active Dec 12, 2015
This function takes a (public) spreadsheet key and optionally sheet name and returns a clean 2-dimensional array of the table. Had to use CURL for my projects. You may use file_get_contents or fopen.
View query_google_spreadsheets.php
<?php
function query_google_spreadsheets( $key, $query, $sheet_name = '' ) {
// queries a spreadsheet url and returns a clean array
$sheet_url = 'https://spreadsheets.google.com/tq?key='. $key .'&tq='. $query .'&sheet='. $sheet_name;
$str = file_get_contents( $sheet_url );
// clean json string
$str = str_replace( "// Data table response\ngoogle.visualization.Query.setResponse(", '', $str );
$str = rtrim( $str, ');' );
@jancbeck
jancbeck / wp-role-bodyclass.php
Last active Jun 6, 2020
WordPress: Add user role class to body tag
View wp-role-bodyclass.php
<?php
// Add role class to body
function add_role_to_body($classes) {
foreach (wp_get_current_user()->roles as $user_role) {
$classes[] = 'role-'. $user_role;
}
return $classes;
});
add_filter('body_class','add_role_to_body');
You can’t perform that action at this time.