Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Add compatibility with Custom Contact Forms #128

Closed
westonruter opened this issue May 3, 2016 · 7 comments
Closed

Add compatibility with Custom Contact Forms #128

westonruter opened this issue May 3, 2016 · 7 comments

Comments

@westonruter
Copy link
Contributor

See https://wordpress.org/support/topic/other-plugin-metashortcodes-does-not-show-in-editor

I use Custom Contact Form Plugin, and its shortcodes on pages. Forms do not show in Customizer > Forms, and the shortcode doesn't show in Editor.

customize__here_is_something_interesting___ _wordpress_develop

@westonruter
Copy link
Contributor Author

@bsusala Does the screenshot ☝️ depict what you're seeing and the problem you're experiencing?

@bsusala
Copy link

bsusala commented May 3, 2016

No, see image:
form

@westonruter
Copy link
Contributor Author

@bsusala thanks. The reason why the form doesn't appear here is because of #96. Since get_post() is (naturally) used to obtain the form post, there is no the_posts filter applied and so Customize Posts doesn't “see” the post being used in the current page.

You do see forms listed if this workaround is applied: tlovett1/custom-contact-forms@9090be7

However, it doesn't add much value as is.

Here's the panel:

forms panel

And the section:

form-section

But, even on the admin edit post screen for forms, you can't actually edit forms in that context either, right? It seems there's no UI for form editing outside the context of the metabox that opens on the edit post screen, and so the focus should be on the “Add Form” button in the editor.

For the Forms section, I suggest adding a plugin that just prevents the Forms post type from appearing in the Customizer at all:

add_action( 'wp_loaded', function() {
    $post_type_obj = get_post_type_object( 'ccf_form' );
    if ( $post_type_obj ) {
        $post_type_obj->show_in_customizer = false;
    }
} );

@bsusala
Copy link

bsusala commented May 3, 2016

Well, you are right. But UX-wise, there should be resolved the obvious "There is no form in Preview", which is not correct. Maybe changing the verbose: "There are forms, but they are editable through their original UI etc." :) Anyways, I am not so expert in forms and or plugins, so I do not know if other forms are editable in Editor, or though their plugin interfaces. So maybe keep any editable field from forms which makes sense (if any, like you did with title), and then suggest the user to go where appropiate. Also, if there is no relevant use case, maybe strip the Form Editing section altogether, until the time is right.

@westonruter
Copy link
Contributor Author

westonruter commented May 3, 2016

@bsusala the problem is that the Customize Posts isn't even aware that there are editable forms. The only way it knows about there being posts of a given post type is if they pass through the the_posts filter:

/**
* Create dynamic post settings and sections for posts queried in the page.
*
* @param array $posts Posts.
* @return array
*/
public function filter_the_posts_to_add_dynamic_post_settings_and_sections( array $posts ) {
foreach ( $posts as &$post ) {
$post_setting_id = WP_Customize_Post_Setting::get_post_setting_id( $post );
$this->component->manager->add_dynamic_settings( array( $post_setting_id ) );
$setting = $this->component->manager->get_setting( $post_setting_id );
if ( $setting instanceof WP_Customize_Post_Setting && ! $this->component->manager->get_section( $setting->id ) ) {
$section = new WP_Customize_Post_Section( $this->component->manager, $setting->id, array(
'panel' => sprintf( 'posts[%s]', $setting->post_type ),
'post_setting' => $setting,
) );
$this->component->manager->add_section( $section );
}
}
return $posts;
}

This will be remedied when we have a way to look deeper into when get_post() calls are made.

Can you confirm that you do see an “Add Form” button when you open a post/page to edit in the Customizer? But that clicking this button does nothing? Adding a UI via the Forms panel would be something that Custom Contact Forms would need to add support for. Fixing the button in the editor would be something Customize Posts could add support for, or rather upstream a fix for.

@bsusala
Copy link

bsusala commented May 3, 2016

I can see [Add Form]. I also have another button for a plugin named Calculated Fields Form. Both are doing nothing when clicked.

@westonruter
Copy link
Contributor Author

Merged upstream.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants