Form_Edit_Page_Handler::maybe_add_duplicate_button( string $output, int $post_id, string $new_title, string $new_slug, WP_Post $post )

Displays a button to duplicate a form when applicable.

Description

Parameters

$output

(string) (Required) Sample permalink HTML markup.

$post_id

(int) (Required) Post ID.

$new_title

(string) (Required) New sample permalink title.

$new_slug

(string) (Required) New sample permalink slug.

$post

(WP_Post) (Required) Post object.

Return

(string) Sample permalink HTML, possibly including the additional button.

Source

File: src/db-objects/forms/form-edit-page-handler.php

	public function maybe_add_duplicate_button( $output, $post_id, $new_title, $new_slug, $post ) {
		$prefix = $this->form_manager->get_prefix();

		if ( $prefix . 'form' !== $post->post_type || 'auto-draft' === $post->post_status ) {
			return $output;
		}

		$nonce_action = $prefix . 'duplicate_form_' . $post->ID;
		$url = wp_nonce_url( admin_url( 'admin.php?action=' . $prefix . 'duplicate_form&form_id=' . $post->ID . '&_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), $nonce_action );

		return $output . ' <a class="button button-small" href="' . esc_url( $url ) . '">' . esc_html( _x( 'Duplicate Form', 'action', 'torro-forms' ) ) . '</a>';
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.