Filter uncanny-automator

automator_setup_wizard_view_path

Filters the path to the view file for a specific step in the Automator setup wizard.

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

Description

Filters the path to the setup wizard view file. Developers can use this hook to override the default view path for specific setup wizard steps, allowing for custom template modifications or additions to the wizard's interface. This hook fires before the view file is included.


Usage

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

Parameters

$view (mixed)
This parameter holds the file path to the view template being loaded for the setup wizard.
$step (mixed)
This parameter holds the file path to the view that will be rendered for the current setup wizard step.

Return Value

The filtered value.


Examples

add_filter( 'automator_setup_wizard_view_path', 'my_custom_automator_wizard_view', 10, 2 );

/**
 * Custom function to change the view path for a specific step in the Uncanny Automator setup wizard.
 *
 * This example demonstrates how to conditionally change the view path for the setup wizard.
 * For instance, if the current step is 'step-2', we might want to load a custom template
 * located in our theme's directory.
 *
 * @param mixed $view The current view path.
 * @param mixed $step The current step in the setup wizard.
 *
 * @return mixed The modified or original view path.
 */
function my_custom_automator_wizard_view( $view, $step ) {
    // Check if the current step is a specific one we want to modify.
    // In this example, let's assume we have a custom view for 'step-3'.
    if ( isset( $step['step'] ) && 'step-3' === $step['step'] ) {
        // Define the path to our custom view.
        // This could be in a theme, a plugin, or a child theme.
        // For realism, let's assume a custom template in the theme's root.
        $custom_view_path = get_template_directory() . '/automator-views/custom-step-3-view.php';

        // Check if our custom view file actually exists.
        if ( file_exists( $custom_view_path ) ) {
            return $custom_view_path; // Return the path to our custom view.
        }
    }

    // If we don't want to modify the view for this step, or our custom view doesn't exist,
    // return the original view path.
    return $view;
}

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/admin/setup-wizard/src/views/welcome.php:21

<?php if ( ! is_file( $view ) ) : ?>

			<?php $view = $this->get_view_path() . sprintf( '%s.php', 'step-1' ); ?>

		<?php endif; ?>

		<?php require apply_filters( 'automator_setup_wizard_view_path', $view, array( 'step' => $step ) ); ?>

	</div>

</div>

<?php $this->set_has_tried_connecting( false ); ?>

Internal Usage

Found in uncanny-automator-pro/src/core/setup-wizard/setup-wizard.php:67:

add_filter( 'automator_setup_wizard_view_path', array( $this, 'overwrite_step_1_template_path' ), 10, 1 );
Scroll to Top