Uname:Linux webm009.cluster131.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64

403WebShell
403Webshell
Server IP : 146.59.209.152  /  Your IP : 216.73.216.152
Web Server : Apache
System : Linux webm009.cluster131.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User : monpetu ( 144298)
PHP Version : 7.4.33
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/monpetu/www/ipprint/wp-content/plugins/sureforms/inc/abilities/forms/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/monpetu/www/ipprint/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;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit