Give_Donate_Form::create PHP Method

create() public method

Creates a donation form
Since: 1.5
public create ( array $data = [] ) : mixed
$data array Array of attributes for a donation form.
return mixed False if data isn't passed and class not instantiated for creation, or New Form ID.
    public function create($data = array())
    {
        if ($this->id != 0) {
            return false;
        }
        $defaults = array('post_type' => 'give_forms', 'post_status' => 'draft', 'post_title' => esc_html__('New Donation Form', 'give'));
        $args = wp_parse_args($data, $defaults);
        /**
         * Fired before a donation form is created
         *
         * @param array $args The post object arguments used for creation.
         */
        do_action('give_form_pre_create', $args);
        $id = wp_insert_post($args, true);
        $donation_form = WP_Post::get_instance($id);
        /**
         * Fired after a donation form is created
         *
         * @param int   $id   The post ID of the created item.
         * @param array $args The post object arguments used for creation.
         */
        do_action('give_form_post_create', $id, $args);
        return $this->setup_donation_form($donation_form);
    }