Filter uncanny-automator

automator_mail_wpautop

Filters the output of wpautop for automator mail, allowing customization before email content is sent.

add_filter( 'automator_mail_wpautop', $callback, 10, 2 );

Description

Filters whether the WordPress auto paragraph function `wpautop` is applied to email content within Uncanny Automator. Developers can use this to disable or modify `wpautop` behavior for specific email actions, controlling how rich text is formatted.


Usage

add_filter( 'automator_mail_wpautop', 'your_function_name', 10, 2 );

Parameters

$this (mixed)
This parameter contains the value of the `wpautop` property from the `$this` object, which indicates whether WordPress's `wpautop` formatting should be applied.
$this (mixed)
This parameter represents the value of the `wpautop` property of the current object.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to use the 'automator_mail_wpautop' filter.
 *
 * This filter allows you to control whether wpautop should be applied
 * to the mail content generated by the Automator plugin. By default,
 * it's usually true. This example demonstrates how to disable wpautop
 * for a specific scenario, perhaps if you're manually handling paragraph
 * formatting or using HTML mail.
 *
 * @param bool $apply_wpautop The current value of whether wpautop should be applied.
 * @param object $this The object instance triggering this filter (likely an Automator Action object).
 * @return bool The modified value indicating whether wpautop should be applied.
 */
add_filter( 'automator_mail_wpautop', function( $apply_wpautop, $automator_object ) {

	// Check if the current Automator object is of a specific type
	// or if a certain condition is met within the object.
	// For this example, let's assume we want to disable wpautop
	// if the mail is being sent as part of a "Welcome Email" automation.
	// You would need to inspect $automator_object to find a suitable property.
	// Let's assume $automator_object->get_recipe_id() and a specific ID means welcome email.
	if ( isset( $automator_object->recipe_id ) && $automator_object->recipe_id === 123 ) {
		// If it's the welcome email automation, disable wpautop.
		return false;
	}

	// For all other cases, return the original value.
	return $apply_wpautop;

}, 10, 2 );

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:64
src/core/lib/recipe-parts/actions/trait-action-parser.php:280

public function is_wpautop() {
		return apply_filters( 'automator_mail_wpautop', $this->wpautop, $this );
	}


Scroll to Top