Filter uncanny-automator

automator_ignore_wpautop_list

Filters a list of meta keys that automator should ignore the wpautop filter for.

add_filter( 'automator_ignore_wpautop_list', $callback, 10, 3 );

Description

Filters a list of meta keys that should bypass wpautop formatting. Developers can add or remove meta keys from this list to control how content is displayed within specific recipe actions, preventing unwanted paragraph tags in emails or other contexts.


Usage

add_filter( 'automator_ignore_wpautop_list', 'your_function_name', 10, 3 );

Parameters

$list (mixed)
This parameter contains a list of email-related meta keys that should be excluded from `wpautop` formatting.
$content (mixed)
This parameter is an array that is intended to store a list of email-related placeholders that should be ignored by the `wpautop` function.
$meta_key (mixed)
This parameter contains the content that is being processed by the action.

Return Value

The filtered value.


Examples

/**
 * Filters the list of meta keys for which wpautop should be ignored.
 *
 * This example adds a custom meta key 'MY_CUSTOM_EMAIL_ACTION' to the list
 * of actions that should bypass wpautop formatting. This is useful if
 * a custom email action in the automator plugin should not have paragraph
 * tags automatically added to its content.
 *
 * @param array  $list    The current list of meta keys to ignore wpautop.
 * @param mixed  $content The content associated with the meta key.
 * @param string $meta_key The meta key being processed.
 * @return array The modified list of meta keys.
 */
add_filter( 'automator_ignore_wpautop_list', function( $list, $content, $meta_key ) {
    // Add our custom meta key to the list if it's not already there.
    if ( ! in_array( 'MY_CUSTOM_EMAIL_ACTION', $list, true ) ) {
        $list[] = 'MY_CUSTOM_EMAIL_ACTION';
    }

    // You could also add conditional logic based on $content or $meta_key if needed.
    // For example, if you only wanted to ignore wpautop for a specific meta_key
    // under certain content conditions.

    return $list;
}, 10, 3 );

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/core/lib/recipe-parts/actions/trait-action-parser.php:318

private function validate_if_email( $content, $meta_key ) {
		if ( 0 === preg_match( '/EMAIL/', $meta_key ) ) {
			return false;
		}

		$list = array(
			'EMAILFROM',
			'EMAILFROMNAME',
			'EMAILTO',
			'EMAILCC',
			'EMAILBCC',
			'AFFILIATEWPACCEMAIL',
			'AFFILIATEWPPAYMENTEMAIL',
			'EDDCUSTOMER_EMAIL',
			'MCFROMEMAILADDRESS',
			'POSTCOMMENTEREMAIL',
			'POSTAUTHOREMAIL',
			'SENDREGEMAIL',
			'WPJMAPPLICATIONEMAIL',
			'WPJMRESUMEEMAIL',
			'WPJMJOBOWNEREMAIL',
			'MCFROMEMAILADDRESS',
		);

		$list = apply_filters( 'automator_ignore_wpautop_list', $list, $content, $meta_key );

		if ( in_array( $meta_key, $list, true ) ) {
			return true;
		}

		if ( is_array( $content ) ) {
			foreach ( $content as $email ) {
				return is_email( $email );
			}
		}
	}

Scroll to Top