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
<?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 );
@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' );
@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 / 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 );
@lloc
lloc / remove-quick-edit-link.php
Last active December 18, 2015 12:19
Remove quick edit link
@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 / 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: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
);
});