Skip to content

Instantly share code, notes, and snippets.

View bueltge's full-sized avatar
Always interested

Frank Bültge bueltge

Always interested
View GitHub Profile
@bueltge
bueltge / gist:1218587
Created September 15, 2011 05:03
Add WordPress post thumbnail to feed
// show post thumbnails in feeds
function fb_post_thumbnail_2_feeds( $content ) {
if ( has_post_thumbnail( get_the_ID() ) )
$content = '<div>' . get_the_post_thumbnail( get_the_ID() ) . '</div>' . $content;
return $content;
}
add_filter( 'the_excerpt_rss', 'fb_post_thumbnail_2_feeds' );
add_filter( 'the_content_feed', 'fb_post_thumbnail_2_feeds' );
@bueltge
bueltge / gist:1242366
Created September 26, 2011 14:30
How to use AJAX with WordPress to post and process Javascript
<?php
/*
* Example of how to use AJAX with WordPress to post and process Javascript arrays of objects.
* Drop this in your WordPress theme's functions.php file and it will display the array of objects on page load in the admin
* REF: http://lists.automattic.com/pipermail/wp-hackers/2011-September/040834.html
* By: Mike Schinkel - http://about.me/mikeschinkel
*/
add_action( 'admin_init', 'mytheme_admin_init' );
function mytheme_admin_init() {
wp_enqueue_script('jquery');
@bueltge
bueltge / responsive-images.php
Created September 27, 2011 17:03 — forked from mattwiebe/responsive-images.php
Mobile First Responsive Images for WordPress
<?php
/*
Plugin Name: Mobile First Responsive Images
Description: Serve up smaller images to smaller screens.
Version: 0.1.1
Author: Matt Wiebe
Author URI: http://somadesign.ca/
*/
/**
@bueltge
bueltge / gist:1259892
Created October 3, 2011 18:46
Widget Basis
<?php
/**
* Widget
* @author
* @package
*/
// TODO: change 'Fb_Wp_Widget_Basis' to the name of your actual plugin
class Fb_Wp_Widget_Basis extends WP_Widget {
@bueltge
bueltge / class-taxonomy-helper.php
Created October 10, 2011 11:36
Helper Class To Add Custom Taxonomy To Post Permalinks
/**
* A helper class for registering and handling a custom rewrite tag for a custom taxonomy.
*
* @version 1.0.0
*/
class Add_Taxonomy_To_Post_Permalinks {
/**
* Stores the taxonomy slug that this class will be handling. Don't edit this.
*
@bueltge
bueltge / gist:1292097
Created October 17, 2011 07:08
Update User Data in WordPress, depending from domain
-- generic email addresses and new passwords for users
UPDATE wp_users
SET user_email = CONCAT(user_login, '@example.com'),
user_pass = MD5(CONCAT(RAND(), CAST(ID AS CHAR), user_login));
-- generic email addresses for commentors
UPDATE wp_comments
SET comment_author_email = CONCAT(CAST(comment_ID AS CHAR), '@example.com');
@bueltge
bueltge / widget-tut.php
Last active December 8, 2017 03:19 — forked from chrisguitarguy/widget-tut.php
An example of how to build your own WordPress widget
<?php
/*
Plugin Name: FB Widget Tutorial
Plugin URI:
Description: How to create WordPress Widgets.
Version: 13/03/2013
Author: Frank Bültge
Author URI: http://bueltge.de/
License: GPLv3
*/
@bueltge
bueltge / email-reminder.php
Created October 21, 2011 23:17 — forked from chrisguitarguy/email-reminder.php
Sends an email reminder if you haven't posted on your WordPress blog in a week
<?php
/*
Plugin Name: Reminder Emails
Plugin URI: http://www.christopherguitar.net/
Description: Sends a reminder email if you haven't posted in seven days.
Version: n/a
Author: Christopher Davis
Author URI: http://www.christopherguitar.net
License: GPL2, Creative Commons
*/
@bueltge
bueltge / script_deamon.php
Created November 13, 2011 17:07 — forked from franz-josef-kaiser/script_deamon.php
WordPress Plugin to check your DataBase for injected links
<?php
/**
Plugin Name: AntiScript deamon
Plugin URI: https://github.com/franz-josef-kaiser
Description: Removes script-links to spam sites from your post content after your site got hacked. Please go to <a href="tools.php?page=script_deamon.php">Tools &rarr; Remove Hack</a>. Thank you. Proudly brought to you by <a href="http://example.com">Franz Josef Kaiser</a>.
Version: 0.1
Author: Franz Josef Kaiser
Author URI: https://github.com/franz-josef-kaiser
License: GPL2
WP-Version: Tested in 2.7.1, 2.9.2, 3.0
@bueltge
bueltge / gist:1362660
Created November 13, 2011 20:44
Extract word from a string given a position in php
function extractWord($text, $position){
$words = explode(' ', $text);
$characters = -1;
foreach($words as $word){
$characters += strlen($word);
if($characters >= $position){
return $word;
}
}
return '';