Filter uncanny-automator

automator_addons_feed_data

Filters the data array before it's used to display addons in the feed for potential modification.

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

Description

Filters the data fetched for the Automator Add-ons feed before it's returned. Developers can modify this array to add, remove, or alter addon information, affecting which add-ons are displayed or their presented details. The filter expects an array of addon data.


Usage

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

Parameters

$feed (mixed)
This parameter contains the raw data of the addons feed that will be processed and filtered.

Return Value

The filtered value.


Examples

/**
 * Example function to filter the automator_addons_feed_data hook.
 * This example adds a custom 'developer' field to each addon in the feed
 * if it's not already present, and also limits the number of addons returned.
 *
 * @param array $feed The original feed data for automator addons.
 * @return array The filtered feed data.
 */
add_filter( 'automator_addons_feed_data', function( $feed ) {

	// Ensure we have an array to work with
	if ( ! is_array( $feed ) ) {
		return $feed;
	}

	$filtered_addons = [];
	$addon_limit = 5; // Let's only display the first 5 addons in this example
	$count = 0;

	foreach ( $feed as $addon_key => $addon_data ) {

		// Stop if we've reached our limit
		if ( $count >= $addon_limit ) {
			break;
		}

		// Add a custom field if it doesn't exist
		if ( ! isset( $addon_data['developer'] ) ) {
			$addon_data['developer'] = 'My Awesome Company';
		}

		// Add the potentially modified addon data to our filtered list
		$filtered_addons[ $addon_key ] = $addon_data;
		$count++;
	}

	// Return the filtered array of addons
	return $filtered_addons;

}, 10, 1 );

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/services/addons/data/class-external-feed.php:140

private function format_feed_data( $feed ) {
		foreach ( $feed as $key => $addon ) {
			// Get the plugin file path using the Info service
			$feed[ $key ]['plugin_file'] = Plugin_Info::get_addon_plugin_file( $addon );
		}

		$filtered_feed = apply_filters( 'automator_addons_feed_data', $feed );
		return empty( $filtered_feed ) || ! is_array( $filtered_feed )
			? $feed
			: $filtered_feed;
	}

Scroll to Top