Add_UOTC_Integration::migrate_tin_canny_reporting()


Source

File: src/integrations/uncanny-tincanny/add-uotc-integration.php

	public function migrate_tin_canny_reporting() {
		if ( 'yes' === get_option( 'automator_tin_canny_trigger_moved' ) ) {
			return;
		}

		global $wpdb;
		$current_triggers = $wpdb->get_results( "SELECT post_id FROM $wpdb->postmeta WHERE meta_value = 'MODULEINTERACTION' AND meta_key = 'code'" );
		if ( empty( $current_triggers ) ) {
			update_option( 'automator_tin_canny_trigger_moved', 'yes', false );

			return;
		}
		foreach ( $current_triggers as $t ) {
			$trigger_id = $t->post_id;
			update_post_meta( $trigger_id, 'integration', 'UOTC' );
			update_post_meta( $trigger_id, 'integration_name', 'Tin Canny Reporting' );
		}

		update_option( 'automator_tin_canny_trigger_moved', 'yes', false );

	}