-
-
Save cdrx/3217016 to your computer and use it in GitHub Desktop.
wpalchemy metaboxes VS. wordpress wp_editor() for older versions of PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should work on older versions of php where html_entity_decode does not default to UTF-8