Bbpress_Tokens::parse_bbpress_tokens( $value,  $pieces,  $recipe_id,  $trigger_data,  $user_id,  $replace_args )


Parameters Parameters

$value

(Required)

$pieces

(Required)

$recipe_id

(Required)

$trigger_data

(Required)

$user_id

(Required)

$replace_args

(Required)


Top ↑

Return Return

(mixed)


Source Source

File: src/integrations/bbpress/tokens/bbpress-tokens.php

	public function parse_bbpress_tokens( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args ) {
		if ( $pieces ) {
			if ( in_array( 'BBFORUMS', $pieces ) || ( in_array( 'BBPOSTAREPLY', $pieces ) ) ) {
				if ( $trigger_data ) {
					foreach ( $trigger_data as $trigger ) {
						$trigger_id     = $trigger['ID'];
						$trigger_log_id = $replace_args['trigger_log_id'];
						$meta_key       = $pieces[2];
						if ( $meta_key === 'BBFORUMS' || $meta_key === 'BBFORUMS_URL' ) {
							$forum_ID = Automator()->helpers->recipe->get_form_data_from_trigger_meta( 'BBFORUMS_ID', $trigger_id, $trigger_log_id, $user_id );
							$forum    = get_post( $forum_ID );
							$value    = $forum->post_title;
							if ( $meta_key === 'BBFORUMS_URL' ) {
								$value = get_permalink( $forum->ID );
							}
						} elseif ( $meta_key === 'BBTOPIC' || $meta_key === 'BBTOPIC_URL' || $meta_key === 'BBTOPIC_CONTENT' ) {
							$topic_ID = Automator()->helpers->recipe->get_form_data_from_trigger_meta( 'BBTOPIC_ID', $trigger_id, $trigger_log_id, $user_id );
							$topic    = get_post( $topic_ID );
							$value    = $topic->post_title;
							if ( $meta_key === 'BBTOPIC_URL' ) {
								$value = get_permalink( $topic->ID );
							} elseif ( $meta_key === 'BBTOPIC_CONTENT' ) {
								$value = $topic->post_content;
							}
						} else {
							$value = Automator()->helpers->recipe->get_form_data_from_trigger_meta( $meta_key, $trigger_id, $trigger_log_id, $user_id );
						}

						if ( ! empty( $value ) ) {
							$value = maybe_unserialize( $value );
						}
					}
				}
			}
		}

		return $value;
	}