Filter uncanny-automator-pro

uap_option_get_all_code_types

Filters all available code types for options, allowing for customization before they are retrieved.

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

Description

Allows developers to filter the available code types for Uncanny Automator Pro's WPCode integration. Modify this filter to include or exclude specific code type options before they are presented to the user, offering greater control over WPCode snippet management within Automator.


Usage

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

Parameters

$option (mixed)
This parameter holds the current array of code types available to be filtered.

Return Value

The filtered value.


Examples

// Example: Modify the available code types for Uncanny Automator Pro's WPCode integration.
// This filter allows developers to add or remove code types from the list presented to the user.
add_filter( 'uap_option_get_all_code_types', function( $option ) {

	// Let's assume the $option is an array of code types, like:
	// $option = [
	//     'php'     => __( 'PHP Snippet', 'uncanny-automator-pro' ),
	//     'html'    => __( 'HTML Snippet', 'uncanny-automator-pro' ),
	//     'css'     => __( 'CSS Snippet', 'uncanny-automator-pro' ),
	//     'js'      => __( 'JavaScript Snippet', 'uncanny-automator-pro' ),
	// ];

	// Example: Remove the 'js' code type if it exists.
	if ( isset( $option['js'] ) ) {
		unset( $option['js'] );
	}

	// Example: Add a new custom code type.
	// In a real scenario, this might be a custom integration you've built.
	$option['my_custom_type'] = __( 'My Custom Code', 'my-text-domain' );

	// Always return the modified $option.
	return $option;

}, 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

uncanny-automator-pro/src/integrations/wpcode/helpers/wpcode-pro-helpers.php:68
uncanny-automator-pro/src/integrations/wpcode/helpers/wpcode-pro-helpers.php:105
uncanny-automator-pro/src/integrations/wpcode/helpers/wpcode-pro-helpers.php:154
uncanny-automator-pro/src/integrations/wpcode/helpers/wpcode-pro-helpers.php:191
uncanny-automator-pro/src/integrations/wpcode/helpers/wpcode-pro-helpers.php:233
uncanny-automator-pro/src/integrations/wpcode/helpers/wpcode-pro-helpers.php:275

public function get_all_code_types( $args = array() ) {
		$defaults = array(
			'option_code'           => 'WPCODE_TYPES',
			'label'                 => esc_attr_x( 'Code type', 'insert-headers-and-footers', 'uncanny-automator-pro' ),
			'is_any'                => false,
			'is_all'                => false,
			'supports_custom_value' => false,
			'relevant_tokens'       => array(),
		);

		$args = wp_parse_args( $args, $defaults );

		$code_types = wpcode()->execute->get_options();

		$option = array(
			'option_code'           => $args['option_code'],
			'label'                 => $args['label'],
			'input_type'            => 'select',
			'required'              => true,
			'default_value'         => 'php',
			'options_show_id'       => false,
			'relevant_tokens'       => $args['relevant_tokens'],
			'options'               => $code_types,
			'supports_custom_value' => $args['supports_custom_value'],
		);

		return apply_filters( 'uap_option_get_all_code_types', $option );
	}

Scroll to Top