Uname: Linux p3plzcpnl499967.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
Software: Apache
PHP version: 8.2.30 [ PHP INFO ] PHP os: Linux
Server Ip: 208.109.40.231
Your Ip: 216.73.216.26
User: nayff91c5tsx (10005085) | Group: nayff91c5tsx (10005085)
Safe Mode: OFF
Disable Function:
NONE

name : form-manager.php
<?php

namespace JET_ABAF\Formbuilder_Plugin;

use JET_ABAF\Plugin;

defined( 'ABSPATH' ) || exit; // Exit if accessed directly.

class Form_Manager {

	use Forms_Callable_Trait;

	private static $instance = false;

	public function default_form_data() {
		return array(
			'post_title'  => 'Booking Form',
			'post_type'   => 'jet-form-builder',
			'post_status' => 'publish',
		);
	}

	public function insert_form( $form_type ) {
		$order_post_type = Plugin::instance()->settings->get( 'related_post_type' );

		$form = $this->prepare_form_data( $form_type, array(
			'order_post_type' => $order_post_type
		) );

		$post_id = wp_insert_post( $form );

		if ( ! $post_id || is_wp_error( $post_id ) ) {
			return false;
		} else {
			return array(
				'id'    => $post_id,
				'title' => $form['post_title'],
				'link'  => get_edit_post_link( $post_id, 'url' ),
			);
		}
	}

	public function prepare_form_data( $name, $args_user_func = array() ) {
		$map = $this->form_types_map();

		if ( ! isset( $map[ $name ] ) ) {
			return $this->default_form_data();
		}
		$form = call_user_func( $map[ $name ], $args_user_func );

		return array_merge( $this->default_form_data(), $form );
	}

	public static function instance() {
		if ( false === self::$instance ) {
			self::$instance = new self();
		}

		return self::$instance;
	}


}
© 2026 GrazzMean