Filter uncanny-automator

uap_option_get_all_jetpack_tags

Filters all Jetpack tags for CRM display and modification.

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

Description

Fires after Jetpack tags are retrieved for use in Jet CRM options. Developers can use this filter to modify the array of tags, potentially adding, removing, or altering tag data before it's presented to the user. This hook is crucial for customizing the available Jetpack tags within Jet CRM.


Usage

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

Parameters

$option (mixed)
This parameter is the option code used to retrieve all Jetpack tags.

Return Value

The filtered value.


Examples

/**
 * Filter the Jetpack tags for the Ultimate Affiliate Program.
 *
 * This function adds a custom tag to the list of Jetpack tags that can be used
 * within the Ultimate Affiliate Program for things like custom tokens or
 * reporting.
 *
 * @param array $option The original array of Jetpack tags.
 * @return array The modified array of Jetpack tags.
 */
function my_custom_jetpack_tags( $option ) {
	// Ensure $option is an array before proceeding.
	if ( ! is_array( $option ) ) {
		return $option;
	}

	// Add a custom tag to the list.
	$custom_tag = array(
		'value' => 'my_custom_jetpack_lead_source',
		'label' => __( 'My Custom Jetpack Lead Source', 'my-textdomain' ),
	);

	// Append the custom tag to the existing options.
	if ( isset( $option['options'] ) && is_array( $option['options'] ) ) {
		$option['options'][] = $custom_tag;
	} else {
		// If 'options' key doesn't exist or is not an array, initialize it.
		$option['options'] = array( $custom_tag );
	}

	// You might also want to add it to relevant_tokens if that's applicable.
	// For this example, let's assume we're adding it to the options list only.

	return $option;
}
add_filter( 'uap_option_get_all_jetpack_tags', 'my_custom_jetpack_tags', 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/integrations/jet-crm/helpers/jet-crm-helpers.php:96

public function get_all_jetpack_tags( $option_code, $is_any = false, $tokens = array(), $tag_type = ZBS_TYPE_CONTACT, $empty_val = false ) {

		global $wpdb;
		$all_tags = $wpdb->get_results( $wpdb->prepare( "SELECT `ID`,`zbstag_name` FROM `{$wpdb->prefix}zbs_tags` WHERE zbstag_objtype = %d", $tag_type ) );
		$tags     = array();

		if ( ! empty( $all_tags ) ) {
			foreach ( $all_tags as $tag ) {
				$tags[ $tag->ID ] = $tag->zbstag_name;
			}
		}

		if ( true === $is_any ) {
			$tags = array( '-1' => esc_html__( 'Any tag', 'uncanny-automator' ) ) + $tags;
		}

		if ( true === $empty_val ) {
			$tags = array( '0' => esc_html__( 'Select a tag', 'uncanny-automator' ) ) + $tags;
		}

		$option = array(
			'option_code'           => $option_code,
			'label'                 => esc_attr__( 'Tag', 'uncanny-automator' ),
			'input_type'            => 'select',
			'required'              => true,
			'options_show_id'       => false,
			'relevant_tokens'       => $tokens,
			'options'               => $tags,
			'supports_custom_value' => true,
		);

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

Scroll to Top