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 / gist:5685040
Last active July 14, 2016 02:59
WordPress - Add link to plugin_row_meta
<?php
define( 'PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
function my_plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status ) {
if ( PLUGIN_BASENAME == $plugin_file )
$plugin_meta[] = '<a href="#">Test: plugin_row_meta</a>';
return $plugin_meta;
}
add_filter( 'plugin_row_meta', 'my_plugin_row_meta', 10, 4 );
@lloc
lloc / gist:5622253
Created May 21, 2013 18:49
Simplest Custom Post Type ever
<?php
function simple_cpt_init() {
register_post_type( 'simple' );
}
add_action( 'init', 'simple_cpt_init' );
@lloc
lloc / wpautop.php
Last active December 17, 2015 12:39
Symptome bekämpfen...
<?php
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
<?php
define( 'MYPLUGIN_MIN_PHP', '5.2' );
define( 'MYPLUGIN_MIN_WP', '2.8' );
function myplugin_activate () {
$error = '';
$phpversion = phpversion();
if ( version_compare( MYPLUGIN_MIN_PHP, $phpversion, '>' ) )
$error .= sprintf( "Minimum PHP version required is %s, not %s.\n", MYPLUGIN_MIN_PHP, $phpversion );
<?php
add_shortcode( 'countryinfo', function ( $atts ) {
$params = shortcode_atts( [ 'lang' => 'de', 'country' => 'DE', 'username' => 'USERNAME' ], $atts );
$url = add_query_arg( $params, 'http://ws.geonames.org/countryInfo' );
$result = wp_remote_get( $url );
if ( is_wp_error( $result ) ) {
return $result->get_error_message();
}
<?php
$url = 'http://ws.geonames.org/search?q=london&maxRows=10&username=USERNAME';
$xml = simplexml_load_file( $url );
echo "Ausgabe des SimpleXML-Objects:\n";
print_r( $xml );
$json = file_get_contents( $url . '&type=json' );
<?php
$name = 'scg_' . md5( $href );
if ( false === ( $value = get_transient( $name ) ) ) {
$response = wp_remote_get( $href );
if ( !is_wp_error( $response ) ) {
$value = trim( $response['body'] );
if ( !empty( $value ) )
set_transient( $name, $value, 86400 );
}
@lloc
lloc / menu-msls-3.php
Created July 19, 2012 08:31
Code zum Artikel "Multisite Language Switcher ins Menü einbauen" Part 3
<?php
function my_msls_link_create() {
return new MyMenuMslsItem();
}
add_filter( 'msls_link_create', 'my_msls_link_create' );
class MyMenuMslsItem extends MslsLink {
protected $format_string = '<img src="{src}" alt="{alt}"/> <strong>{txt}</strong>';