Automator_DB_Handler_Triggers::get_meta( string $meta_key, int $trigger_id, int $trigger_log_id, int|null $user_id = null )


Parameters Parameters

$meta_key

(string) (Required)

$trigger_id

(int) (Required)

$trigger_log_id

(int) (Required)

$user_id

(int|null) (Optional)

Default value: null


Top ↑

Return Return

(mixed|string)


Source Source

File: src/core/lib/utilities/db/class-automator-db-handler-triggers.php

	public function get_meta( string $meta_key, int $trigger_id, int $trigger_log_id, int $user_id = null ) {
		if ( empty( $meta_key ) || empty( $trigger_id ) || empty( $trigger_log_id ) ) {
			return '';
		}

		global $wpdb;
		$tbl        = Automator()->db->tables->trigger_meta;
		$meta_value = $wpdb->get_var(
			$wpdb->prepare(
			//phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
				"SELECT meta_value FROM {$wpdb->prefix}$tbl
						WHERE 1=1
						AND user_id = %d
						AND meta_key = %s
						AND automator_trigger_id = %d
						AND automator_trigger_log_id = %d
						LIMIT 0,1",
				$user_id,
				$meta_key,
				$trigger_id,
				$trigger_log_id
			)
		);

		if ( ! empty( $meta_value ) ) {
			return maybe_unserialize( $meta_value );
		}

		return '';
	}