Easy Embed WordPress Plugin

The WordPress editor doesn’t always play nice with HTML (especially if you switch back and forth between the Visual and HTML editor). This problem has bugged me for a while, and I finally sat down and built a simple plugin to solve it. There are other solutions out there, but I find this method to be the easiest to use. After installing the plugin, all that is required is to create a custom field (you can name it anything), place your code in the new custom field. This could be HTML, video embed codes, Paypal forms, etc. Then place the following shortcode into your post where you want your special code to go:

[easyembed field="name-of-custom-field"]

The field property should be the name of the custom field you created. The shortcode above would display the contents of a custom field with the name “easy”

Download Easy Embed from the WordPress plugin directory.

View the code below:

<?php

/*
Plugin Name: Easy Embed
Plugin URI: http://wordpress.org/#
Description: Allows the embedding of any code and protects it from being modified by the WordPress editor
Author: Alex Mansfield
Version: 1.0
Author URI: http://alexmansfield.com/
*/

function am_easy_embed($array) {
extract(shortcode_atts(array('field' => 'custom'), $array));
global $post;
$html = get_post_meta($post->ID, $field, true);
return $html;
}
add_shortcode('easyembed', 'am_easy_embed');

?>
  • PublishedJuly 29, 2010
  • UpdatedJanuary 16, 2011
  • Posted InPlugins
  • Tested With3.0

Sanitary Theme 0.3

I’ve made a number of improvements since version 0.2. Although I’m sure there are plenty more improvements that could be made, I figure it’s about time I released update. Below is the changelog.

Download Sanitary 0.3

(more…)

  • PublishedJuly 28, 2010
  • Posted InThemes
  • Tested With3.0