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; | |
} | |
Hello,
I would change the test with the following:
if( $field["useRichTextEditor"] == '1' ) {
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rad! Code largely works on current Gravity Forms, I have run into an issue with pasted text:
I can include rich text if I manually type out content into the post content field, however if I paste in content directly, it looks fine and is formatted properly before submitting the form, but the output results in completely blank content (not just no styles, no content at all). I can then go in the admin area and edit the post, no content in the post body.
Anyone have any idea what might be stripping cut and pastes like that? Thanks!