Filter uncanny-automator

automator_google_sheets_disable_tokens_html

Filter to disable tokens HTML. Filters whether tokens HTML is displayed for Google Sheets integrations, allowing for its disabling.

add_filter( 'automator_google_sheets_disable_tokens_html', $callback, 10, 1 );

Description

Control whether HTML tags are stripped from values before sending them to Google Sheets. This filter fires when preparing data for sheet updates or adding new rows. Returning `false` preserves HTML, while returning `true` (the default) removes it, ensuring cleaner data entry in your spreadsheets.


Usage

add_filter( 'automator_google_sheets_disable_tokens_html', 'your_function_name', 10, 1 );

Return Value

boolean


Examples

/**
 * Example of how to disable HTML stripping for Google Sheets tokens.
 *
 * By default, the Automator plugin strips HTML from tokens before sending them
 * to Google Sheets. This filter allows you to disable that behavior if needed.
 *
 * For instance, if you have a token that contains HTML that you want to preserve
 * in your Google Sheet, you can use this filter.
 */
add_filter( 'automator_google_sheets_disable_tokens_html', function( $disable_html ) {
	// We want to disable HTML stripping.
	// The default is 'true' (meaning disable tokens HTML).
	// By returning 'false', we are telling the plugin *not* to disable
	// the stripping of HTML from tokens.
	return false;
}, 10, 1 ); // Priority 10, accepts 1 argument

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/integrations/google-sheet/actions/sheet-updaterecord-v2.php:195
src/integrations/google-sheet/actions/sheet-add-row-v2.php:123

private function get_activated_row_values( $row_repeater, $recipe_id, $user_id, $args ) {
		$row_values = array();

		/**
		 * Filter to disable tokens HTML.
		 *
		 * @param boolean true to disable tokens HTML.
		 * @return boolean
		 *
		 * @example
		 * add_filter( 'automator_google_sheets_disable_tokens_html', '__return_false' );
		 */
		$strip_html = apply_filters( 'automator_google_sheets_disable_tokens_html', true );

		foreach ( (array) $row_repeater as $field ) {
			$cell_value = null; // Pass null to avoid overwriting the cell value.

			if ( true === $field['COLUMN_UPDATE'] ) {
				// Parse tokens in individual field value before any processing.
				$cell_value = $strip_html
					? wp_strip_all_tags( $field['GS_COLUMN_VALUE'] )
					: $field['GS_COLUMN_VALUE'];
			}

			// Add the value to our request body.
			$row_values[] = $cell_value;
		}

		return wp_json_encode( array( $row_values ) );  // Wrapping as array for API Backwards compatibility.
	}

Internal Usage

Found in src/integrations/google-sheet/actions/sheet-updaterecord-v2.php:193:

* add_filter( 'automator_google_sheets_disable_tokens_html', '__return_false' );

Found in src/integrations/google-sheet/actions/sheet-add-row-v2.php:121:

* add_filter( 'automator_google_sheets_disable_tokens_html', '__return_false' );
Scroll to Top