Filter
uncanny-automator
automator_recipe_main_objectstructuremiscellaneous
Filters the miscellaneous settings for a recipe's main object structure before saving.
add_filter( 'automator_recipe_main_objectstructuremiscellaneous', $callback, 10, 2 );
Description
Filters the Miscellaneous object before it's assigned to the recipe. Developers can use this hook to modify or extend the miscellaneous data associated with a recipe, such as adding custom settings or information. The hook passes the Miscellaneous object and the recipe object for manipulation.
Usage
add_filter( 'automator_recipe_main_objectstructuremiscellaneous', 'your_function_name', 10, 2 );
Parameters
-
$miscellaneous(mixed) - This parameter contains miscellaneous data related to the recipe's structure, likely used for further processing or display.
-
$this(mixed) - This parameter contains data related to miscellaneous settings or configurations for the automator recipe.
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to hook into the automator_recipe_main_objectstructuremiscellaneous filter.
*
* This example adds a custom property to the Miscellaneous object that can be used
* in recipe configurations.
*
* @param Uncanny_Automator_ProIntegrationsLoopable_JSONStructureMiscellaneous $miscellaneous The Miscellaneous object.
* @param Uncanny_Automator_ProCore_ServicesRecipe_Structure $this The main recipe structure object.
*
* @return Uncanny_Automator_ProIntegrationsLoopable_JSONStructureMiscellaneous The modified Miscellaneous object.
*/
add_filter( 'automator_recipe_main_objectstructuremiscellaneous', 'my_custom_automator_misc_properties', 10, 2 );
function my_custom_automator_misc_properties( $miscellaneous, $recipe_structure ) {
// In a real scenario, you'd likely have a custom class or logic here
// to define and add your custom property. For demonstration, we'll
// simply add a public property to the existing object.
// Example: Add a property to store a custom identifier for this integration.
$miscellaneous->custom_integration_id = 'my_unique_integration';
// You could also potentially add methods or modify existing ones if needed,
// though direct modification of the passed object's properties is common.
// For example, if the $miscellaneous object had a method like 'add_setting':
// $miscellaneous->add_setting( 'my_custom_setting', 'default_value' );
return $miscellaneous;
}
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/recipe/structure.php:191
private function hydrate_properties() {
$this->is_recipe_on = 'publish' === self::$post['post_status'];
$this->title = self::$post['post_title'];
$this->recipe_type = isset( self::$meta['uap_recipe_type'] ) ? self::$meta['uap_recipe_type'] : '';
$stats = new StructureStats( $this );
$miscellaneous = new StructureMiscellaneous( $this );
$triggers = new StructureTriggersTriggers( $this );
$actions = new StructureActionsActions( $this, self::$meta );
$this->stats = apply_filters( 'automator_recipe_main_objectstructurestats', $stats, $this );
$this->miscellaneous = apply_filters( 'automator_recipe_main_objectstructuremiscellaneous', $miscellaneous, $this );
$this->triggers = apply_filters( 'automator_recipe_main_objectstructuretriggers', $triggers, $this );
// @see Conditions_Pluggable::register_hooks().
$this->actions = apply_filters( 'automator_recipe_main_objectstructureactions', $actions, $this ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
return $this;
}