HEX
Server: LiteSpeed
System: Linux server315.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: globfdxw (6114)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/globfdxw/public_html/wp-content/plugins/wpforms-pdf/src/Notifications/Fields/Divider.php
<?php

namespace WPFormsPDF\Notifications\Fields;

/**
 * Class Divider field.
 *
 * @since 1.0.0
 */
class Divider {

	/**
	 * Class constructor.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function __construct() {

		$this->hooks();
	}

	/**
	 * Register hooks.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	public function hooks(): void {

		add_filter(
			'wpforms_pdf_notifications_fields_field_message_html_divider',
			[ $this, 'field_row_html_value' ],
			100,
			7
		);
	}

	/**
	 * Get field message HTML markup static.
	 *
	 * It includes the field label and value.
	 *
	 * @since 1.0.0
	 *
	 * @param string $field_markup Field HTML markup.
	 * @param array  $field        Field data.
	 * @param array  $form_data    Form data.
	 * @param array  $template     Template data.
	 *
	 * @return string
	 * @noinspection PhpUnusedParameterInspection
	 */
	public static function field_row_html_value_static( string $field_markup, array $field, array $form_data, array $template ): string {

		$template_slug = $template['slug'] ?? '';

		// Process the listed templates only.
		$templates = [ 'document-application', 'document-table' ];

		if ( ! in_array( $template_slug, $templates, true ) ) {
			return $field_markup;
		}

		$field_description = ! empty( $field['description'] ) ? '<p>' . $field['description'] . '</p>' : '';

		$field_template = sprintf(
			'%1$stemplates/pdf/elements/field-row-divider-pagebreak',
			WPFORMS_PDF_PATH
		);

		// Regenerate the section divider field row.
		return wpforms_render(
			$field_template,
			[
				'field_type'        => $field['type'] ?? '',
				'field_label'       => $field['label'] ?? '',
				'field_description' => $field_description,
			],
			true
		);
	}

	/**
	 * Get field message HTML markup.
	 *
	 * It includes the field label and value.
	 *
	 * @since 1.0.0
	 *
	 * @param string|mixed $field_markup Field HTML markup.
	 * @param array        $field        Field data.
	 * @param array        $form_data    Form data.
	 * @param array        $template     Template data.
	 *
	 * @return string
	 */
	public function field_row_html_value( $field_markup, array $field, array $form_data, array $template ): string {

		$field_markup = (string) $field_markup;

		return self::field_row_html_value_static( $field_markup, $field, $form_data, $template );
	}
}