Skip to content

Instantly share code, notes, and snippets.

View sbressler's full-sized avatar

Scott Bressler sbressler

View GitHub Profile
@sbressler
sbressler / burrito-builder.markdown
Created February 13, 2020 13:46
Burrito Builder
@sbressler
sbressler / sample_plugin.php
Created October 19, 2010 08:39
Sample plugin to demonstrate the basics of WordPress actions and filters, as well as storing plugin settings
<?php
/*
Plugin Name: Sample Plugin
Plugin URI: http://www.scottbressler.com/blog/plugins/
Description: Sample plugin to demonstrate the basics of WordPress actions and filters, as well as storing plugin settings. This plugin adds content to the end of posts. This can be achieved when publishing the post or each time the post is displayed, as specified by the plugin's settings. The text appended is also specified in the settings.
Version: 1.1
Author: Scott Bressler
Author URI: http://www.scottbressler.com/blog/
License: GPL2
*/
@sbressler
sbressler / add_to_end.php
Created October 13, 2010 16:13
Sample plugin to add content to the end of posts using some simple WordPress hooks (filters and actions). This can be achieved when displaying the post or when publishing the post. Modify the class's constant "append_string" to change what is appended to
<?php
/*
Plugin Name: Add to end of posts
Plugin URI: http://www.scottbressler.com/blog/plugins/
Description: Sample plugin to add content to the end of posts using some simple WordPress hooks (filters and actions). This can be achieved when displaying the post or when publishing the post. Modify the class's constant "append_string" to change what is appended to posts. Modify "append_on_publish" to toggle whether text should be appended when publishing a post or when displaying the post.
Author: Scott Bressler
Version: 1.0
Author URI: http://www.scottbressler.com/blog/
*/
@sbressler
sbressler / facebook_opengraph_metadata.php
Created April 22, 2010 03:28
How to add Open Graph metadata to posts in WordPress
<?php
/**
* Add Open Graph metadata to Post pages, including og:site_name, og:title, and og:image, if one exists.
*/
function add_opengraph_meta() {
if ( !is_single() ) // Only add this metadata to Post pages
return;
global $post;
@sbressler
sbressler / disallow_publishing.php
Created April 10, 2010 00:08
How to disallow publishing in WordPress for all users of a certain roles
<?php
$disallowed_roles = array( 'copy-editor',
'editor',
'contributor' );
function is_user_disallowed() {
global $disallowed_roles;
foreach( $disallowed_roles as $disallowed_role) {
if ( current_user_can( $disallowed_role ) ) {
<?php
// Just an example. Probably doesn't work.
// Add a dropdown with the blog users to $fields
function add_media_credit($fields, $post) {
$fields['media-credit'] = array(
'label' => __('Credit:'),
'input' => 'html',
'html' => wp_dropdown_users( array( 'echo' => 0,
'selected' => $post->post_author,