Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splitting up wpcf7_autop_or_not for mail and form usage #1340

Closed
Zodiac1978 opened this issue Dec 19, 2023 · 1 comment · Fixed by #1344
Closed

Splitting up wpcf7_autop_or_not for mail and form usage #1340

Zodiac1978 opened this issue Dec 19, 2023 · 1 comment · Fixed by #1344
Assignees
Milestone

Comments

@Zodiac1978
Copy link

The filter wpcf7_autop_or_not has a default value of true (via Constant) and is defined here:

/**
* Returns true if wpcf7_autop() is applied.
*/
function wpcf7_autop_or_not() {
return (bool) apply_filters( 'wpcf7_autop_or_not', WPCF7_AUTOP );
}

But it is used for two places:

The mail body:

/**
* Filter callback that applies auto-p to HTML email message body.
*/
function wpcf7_mail_html_body_autop( $body ) {
if ( wpcf7_autop_or_not() ) {
$body = wpcf7_autop( $body );
}
return $body;
}

And the display of the form itself:

/**
* Replaces all form-tags in the form template with corresponding HTML.
*
* @return string Replaced form content.
*/
public function replace_all_form_tags() {
$manager = WPCF7_FormTagsManager::get_instance();
$form = $this->prop( 'form' );
if ( wpcf7_autop_or_not() ) {
$form = $manager->replace_with_placeholders( $form );
$form = wpcf7_autop( $form );
$form = $manager->restore_from_placeholders( $form );
}
$form = $manager->replace_all( $form );
$this->scanned_form_tags = $manager->get_scanned_tags();
return $form;
}

There are many add-on plugins which set this filter to false. I think this is because they need this either disabled for the mail OR the form, but not for both. Therefore producing unwanted side effects.

Here you can find all those add-ons which are setting this to false:
https://wpdirectory.net/search/01HJ0SSW2M68K12YT21JYB4K9Y

I would recommend splitting up this filter and have one for just the mail and one for the form to prevent side effects when you only want to tackle one location.

What do you think?

@takayukister
Copy link
Collaborator

I think you have a point. I'll add a parameter to the filter to make the usage distinguishable.

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

Successfully merging a pull request may close this issue.

2 participants