Created
May 26, 2012 20:19
-
-
Save goldenapples/2795190 to your computer and use it in GitHub Desktop.
Rich text editors for Gravity Forms
This file contains 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 | |
/* | |
Plugin Name: Rich Text editors for Gravity Forms | |
Description: Converts the textarea fields in Gravity Forms to WordPress rich text editors | |
Author: Nathaniel Taintor | |
Author URI: http://goldenapplesdesign.com | |
Version: 1.0 | |
License: GPLv2 | |
*/ | |
/* | |
* Gravity Forms filter to allow the post body and textarea inputs to use the wp_editor | |
* visual editor. To use wp_editor instead of default textarea, just set css class | |
* to "richtext" | |
* | |
* @uses wp_editor() Requires WordPres >= 3.3.0 for this function | |
* | |
* see http://codex.wordpress.org/Function_Reference/wp_editor for arguments to | |
* pass to the wp_editor() function. At the very minimum, you probably will need | |
* to pass some styles in 'editor_css'; otherwise the gravityforms styles and your | |
* theme styles will likely override some of the styles applied to the editor | |
* buttons and text. | |
* | |
*/ | |
add_action( 'gform_field_input', 'gforms_wp_editor', 10, 5 ); | |
function gforms_wp_editor( $input, $field, $value, $lead_id, $form_id ) { | |
if( $field["cssClass"] == 'richtext' ) { | |
ob_start(); | |
wp_editor( $value, "input_{$form_id}_{$field['id']}", | |
array( | |
'media_buttons' => false, | |
'textarea_name' => "input_{$field['id']}" | |
) ); | |
$input = ob_get_clean(); | |
} | |
return $input; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I would change the test with the following:
if( $field["useRichTextEditor"] == '1' ) {