Anyone working with Wordpress will be familiar with Contact Form 7, a wonderful piece of work that Takayuki Miyoshi keeps religiously up-to-date.
It struck me that one thing that would be useful if, like me, you make complex forms, is a visual preview. (possibly even a visual editor but let's not run before...)
Now, as I say it's a wonderful piece of work so 5 minutes hacking came up with this:
Adding this to the $panels array in edit-contact-form.php
'preview-panel' => array(
'title' => __( 'Preview', 'contact-form-7' ),
'callback' => 'wpcf7_editor_panel_preview' ),
makes a new tab, Preview.
Adding this to editor.php
function wpcf7_editor_panel_preview( $post ) {
$preview_code = $post->form_do_shortcode();
echo (do_shortcode($preview_code));
}
produces the goods.
Now there's a few things wrong with this which is where I need help (I'm way above my pay grade here)
- I should be able to put these in using hooks rather than a crude hack (or a fork)
I should be able to call the function that produce the shortcode directly rather than relying on the use of
do_shortcode()
The submit button is active (not good) and the preview only works after the form is saved and the shortcode generated.
Can anyone help me with this?