Skip to content

Instantly share code, notes, and snippets.

@cdrx
Forked from helgatheviking/editor_meta.php
Created July 31, 2012 13:24
Show Gist options
  • Save cdrx/3217016 to your computer and use it in GitHub Desktop.
Save cdrx/3217016 to your computer and use it in GitHub Desktop.
wpalchemy metaboxes VS. wordpress wp_editor() for older versions of PHP
<div class="my_meta_control">
<?php $mb->the_field('test_editor');
$settings = array(
'textarea_rows' => '10',
'media_buttons' => 'false',
'tabindex' =>2
);
$val = html_entity_decode($mb->get_the_value());
$id = $mb->get_the_name();
wp_editor($val, $id , $settings );
?>
</div>
<?php
// Define a constant for the WPAlchemy directory uri
define('WPALCHEMY', get_stylesheet_directory_uri() . '/WPAlchemy');
// Require WP_Alchemy Meta Box Class
require_once( dirname(__FILE__) . '/WPAlchemy/MetaBox.php');
// include css to help style our custom meta boxes
// this should be a global stylesheet used by all similar meta boxes
if (is_admin()) wp_enqueue_style('custom_meta_css', WPALCHEMY .'/meta.css');
$editor_metabox = new WPAlchemy_MetaBox(array
(
'id' => '_editor_meta', // underscore prefix hides fields from the custom fields area
'title' => _('Sample WP_Editor'),
'template' => dirname(__FILE__) . '/WPAlchemy/editor_meta.php'
));
//recreate the default filters on the_content
add_filter( 'meta_content', 'wptexturize' );
add_filter( 'meta_content', 'convert_smilies' );
add_filter( 'meta_content', 'convert_chars' );
//use my override wpautop
if(function_exists('override_wpautop')){
add_filter( 'meta_content', 'override_wpautop' );
} else {
add_filter( 'meta_content', 'wpautop' );
}
add_filter( 'meta_content', 'shortcode_unautop' );
add_filter( 'meta_content', 'prepend_attachment' );
<div class="my_meta_control">
<?php $mb->the_field('test_editor');
$settings = array(
'textarea_rows' => '10',
'media_buttons' => 'false',
'tabindex' =>2
);
$val = html_entity_decode($mb->get_the_value(), ENT_QUOTES, 'UTF-8');
$id = $mb->get_the_name();
wp_editor($val, $id , $settings );
?>
</div>
@cdrx
Copy link
Author

cdrx commented Jul 31, 2012

This should work on older versions of php where html_entity_decode does not default to UTF-8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment