UOA_SENDWEBHOOK::maybe_migrate_wp_webhooks()

Migrate all existing wp -> webhook actions.


Return Return

(void)


Source Source

File: src/integrations/webhooks/actions/uoa-sendwebhook.php

	public function maybe_migrate_wp_webhooks() {

		$option_key = 'automator_wpwebhooks_action_moved';

		if ( 'yes' === get_option( $option_key ) ) {
			return;
		}

		global $wpdb;

		$current_actions = $wpdb->get_results(
			$wpdb->prepare(
				"SELECT post_id FROM $wpdb->postmeta WHERE meta_value = %s AND meta_key = %s",
				'WPSENDWEBHOOK',
				'code'
			)
		);

		if ( empty( $current_actions ) ) {
			update_option( $option_key, 'yes', false );
			return;
		}

		foreach ( $current_actions as $action ) {
			$action_id = $action->post_id;
			update_post_meta( $action_id, 'integration', 'WEBHOOKS' );
			update_post_meta( $action_id, 'integration_name', 'Webhooks' );
		}

		update_option( $option_key, 'yes', false );

	}