Skip to content

Instantly share code, notes, and snippets.

View lloc's full-sized avatar
🏠
Working from home

Dennis Ploetner lloc

🏠
Working from home
View GitHub Profile
@lloc
lloc / nginx.conf
Last active August 29, 2015 14:05
...
http {
...
log_format mine '$uri - $blogid : $http_host';
...
}
@lloc
lloc / sort-array-like-object.js
Created June 6, 2014 12:56
Sort an array-like object with underscore.js
var i, key, pairs,
obj = {'4': 'alpha', '2': 'beta', '5': 'gamma', '1': 'delta', '3': 'epsilon'};
for (key in obj) {
console.log(key + ': ' + obj[key]);
}
pairs = _.pairs(obj);
obj = _.sortBy(pairs, function (item) { return item[1]; });
<?php
/*
Plugin Name: WordPress serves JSON
Description: Serve your content as JSON or JSONP in a simple manner (based on an example by Jon Cave - http://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/).
Plugin URI: https://gist.github.com/lloc/8933914
Author: realloc
Author URI: http://lloc.de/
*/
namespace LLOC\realloc;
@lloc
lloc / gist:6751900
Last active December 24, 2015 05:39
Beispiel Lokalisierung von JavaScript in WordPress
jQuery(document).ready(function($) {
$('#message-box').html(
objectL10n.str_hello_world
);
});
@lloc
lloc / gist:6715833
Last active December 24, 2015 00:19
WordPress: How to include CSS and JS in a smart way
<?php
function my_enqueue_scripts() {
wp_enqueue_style( 'my-style', get_stylesheet_uri() );
wp_enqueue_script(
'my-script',
get_template_directory_uri() . '/js/script.js',
array( 'jquery' ),
false,
true
@lloc
lloc / gist:6650222
Created September 21, 2013 12:37
Install WordPress Coding Standards for PHP_CodeSniffer in Ubuntu
# Install PHP_CodeSniffer
sudo apt-get install php-codesniffer
# Install the WordPress Coding Standards
sudo git clone git://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git \
$(pear config-get php_dir)/PHP/CodeSniffer/Standards/WordPress
# Now your can check your files like this
phpcs --standard=WordPress your-file.php
@lloc
lloc / gist:6240884
Created August 15, 2013 13:37
Add existing nav-menus to an select created by the "Advanced Custom Fields"-plugin #WordPress #ACF
<?php
namespace WPSE\realloc;
function my_site_menu( $field ) {
$field['choices'] = array();
$menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) );
if ( is_array( $menus ) ) {
foreach( $menus as $menu ) {
$field['choices'][$menu->name] = $menu->name;
@lloc
lloc / proxy.py
Last active April 26, 2019 10:00
Configure GitHub for a connection trough a proxy with a pacfile
#!/usr/bin/env python
"""
The config.ini contains something like:
[Proxy]
proxy = http://YOURPROXY/proxy.pac
user = YOURUSER
pass = YOURPASS
local = proxy.pac
@lloc
lloc / remove-quick-edit-link.php
Last active December 18, 2015 12:19
Remove quick edit link
@lloc
lloc / gist:5685045
Last active December 17, 2015 22:49
WordPress - Add link to plugin_action_links
<?php
define( 'PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
function my_plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) {
if ( PLUGIN_BASENAME == $plugin_file )
$actions[] = '<a href="#">Test: plugin_action_links</a>';
return $actions;
}
add_filter( 'plugin_action_links', 'my_plugin_action_links', 10, 4 );