$21 GRAYBYTE WORDPRESS FILE MANAGER $38

SERVER : premium267.web-hosting.com #1 SMP Wed Jun 4 13:01:13 UTC 2025
SERVER IP : 69.57.162.29 | ADMIN IP 216.73.217.134
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/home/njinenkb/jaccul.org/wp-content/plugins/sureforms/inc/abilities/forms/

HOME
Current File : /home/njinenkb/jaccul.org/wp-content/plugins/sureforms/inc/abilities/forms//duplicate-form.php
<?php
/**
 * Duplicate Form Ability.
 *
 * @package sureforms
 * @since 2.5.2
 */

namespace SRFM\Inc\Abilities\Forms;

use SRFM\Inc\Abilities\Abstract_Ability;
use SRFM\Inc\Duplicate_Form as Duplicate_Form_Handler;
use SRFM\Inc\Helper;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Duplicate_Form ability class.
 *
 * Duplicates an existing SureForms form with all its fields and metadata.
 *
 * @since 2.5.2
 */
class Duplicate_Form extends Abstract_Ability {
	/**
	 * Constructor.
	 *
	 * @since 2.5.2
	 */
	public function __construct() {
		$this->id          = 'sureforms/duplicate-form';
		$this->label       = __( 'Duplicate SureForms Form', 'sureforms' );
		$this->description = __( 'Duplicate an existing SureForms form with all its fields, metadata, and settings. The new form is created as a draft.', 'sureforms' );
		$this->capability  = 'manage_options';
		$this->gated       = 'srfm_abilities_api_edit';
	}

	/**
	 * {@inheritDoc}
	 *
	 * @since 2.5.2
	 */
	public function get_annotations() {
		return [
			'readonly'      => false,
			'destructive'   => false,
			'idempotent'    => false,
			'priority'      => 2.0,
			'openWorldHint' => false,
			'instructions'  => 'Confirm which form is being duplicated and the intended title suffix with the user.',
		];
	}

	/**
	 * {@inheritDoc}
	 *
	 * @since 2.5.2
	 */
	public function get_input_schema() {
		return [
			'type'                 => 'object',
			'additionalProperties' => false,
			'properties'           => [
				'form_id'      => [
					'type'        => 'integer',
					'description' => __( 'The ID of the form to duplicate.', 'sureforms' ),
				],
				'title_suffix' => [
					'type'        => 'string',
					'description' => __( 'Suffix to append to the duplicated form title.', 'sureforms' ),
					'default'     => ' (Copy)',
				],
			],
			'required'             => [ 'form_id' ],
		];
	}

	/**
	 * {@inheritDoc}
	 *
	 * @since 2.5.2
	 */
	public function get_output_schema() {
		return [
			'type'       => 'object',
			'properties' => [
				'original_form_id' => [ 'type' => 'integer' ],
				'new_form_id'      => [ 'type' => 'integer' ],
				'new_form_title'   => [ 'type' => 'string' ],
				'edit_url'         => [ 'type' => 'string' ],
				'shortcode'        => [ 'type' => 'string' ],
			],
		];
	}

	/**
	 * Execute the duplicate-form ability.
	 *
	 * @param array<string,mixed> $input Validated input data.
	 * @since 2.5.2
	 * @return array<string,mixed>|\WP_Error
	 */
	public function execute( $input ) {
		$form_id      = Helper::get_integer_value( $input['form_id'] ?? 0 );
		$title_suffix = ! empty( $input['title_suffix'] ) ? sanitize_text_field( Helper::get_string_value( $input['title_suffix'] ) ) : ' (Copy)';

		$result = Duplicate_Form_Handler::get_instance()->duplicate_form( $form_id, $title_suffix );

		if ( is_wp_error( $result ) ) {
			return $result;
		}

		$result['shortcode'] = sprintf( '[sureforms id="%d"]', Helper::get_integer_value( $result['new_form_id'] ?? 0 ) );

		return $result;
	}
}


Current_dir [ WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
1 Jan 1970 12.00 AM
root / root
0
create-form.php
12.281 KB
3 May 2026 12.43 PM
njinenkb / njinenkb
0644
delete-form.php
3.042 KB
3 May 2026 12.43 PM
njinenkb / njinenkb
0644
duplicate-form.php
2.968 KB
3 May 2026 12.43 PM
njinenkb / njinenkb
0644
form-field-schema.php
4.899 KB
3 May 2026 12.43 PM
njinenkb / njinenkb
0644
form-metadata.php
8.978 KB
3 May 2026 12.43 PM
njinenkb / njinenkb
0644
get-form-stats.php
4.413 KB
3 May 2026 12.43 PM
njinenkb / njinenkb
0644
get-form.php
4.937 KB
3 May 2026 12.43 PM
njinenkb / njinenkb
0644
get-shortcode.php
2.335 KB
3 May 2026 12.43 PM
njinenkb / njinenkb
0644
list-forms.php
5.389 KB
3 May 2026 12.43 PM
njinenkb / njinenkb
0644
update-form.php
13.964 KB
3 May 2026 12.43 PM
njinenkb / njinenkb
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF Static GIF