Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/wpforms-.../src/Forms/Fields/Traits
File: ProField.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace WPForms\Forms\Fields\Traits;
[2] Fix | Delete
[3] Fix | Delete
use WPForms\Admin\Education\Helpers;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Trait ProField.
[7] Fix | Delete
*
[8] Fix | Delete
* Mostly educational things for the Pro field in the Lite plugin.
[9] Fix | Delete
*
[10] Fix | Delete
* @since 1.9.4
[11] Fix | Delete
*/
[12] Fix | Delete
trait ProField {
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Is it the Pro plugin?
[16] Fix | Delete
*
[17] Fix | Delete
* @since 1.9.4
[18] Fix | Delete
*
[19] Fix | Delete
* @var boolean
[20] Fix | Delete
*/
[21] Fix | Delete
protected $is_pro = false;
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Whether the field is a Pro field.
[25] Fix | Delete
*
[26] Fix | Delete
* @since 1.9.4
[27] Fix | Delete
*
[28] Fix | Delete
* @var boolean
[29] Fix | Delete
*/
[30] Fix | Delete
protected $is_pro_field = true;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Addon slug.
[34] Fix | Delete
*
[35] Fix | Delete
* @since 1.9.4
[36] Fix | Delete
*
[37] Fix | Delete
* @var string
[38] Fix | Delete
*/
[39] Fix | Delete
protected $addon_slug;
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Whether the Addon is initialized.
[43] Fix | Delete
*
[44] Fix | Delete
* @since 1.9.4
[45] Fix | Delete
*
[46] Fix | Delete
* @var boolean
[47] Fix | Delete
*/
[48] Fix | Delete
protected $is_addon_initialized = false;
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* Whether the field is disabled.
[52] Fix | Delete
*
[53] Fix | Delete
* @since 1.9.4
[54] Fix | Delete
*
[55] Fix | Delete
* @var boolean
[56] Fix | Delete
*/
[57] Fix | Delete
protected $is_disabled_field = true;
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Addon educational data.
[61] Fix | Delete
*
[62] Fix | Delete
* @since 1.9.4
[63] Fix | Delete
*
[64] Fix | Delete
* @var array
[65] Fix | Delete
*/
[66] Fix | Delete
protected $addon_edu_data = [];
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Init Pro Field.
[70] Fix | Delete
*
[71] Fix | Delete
* @since 1.9.4
[72] Fix | Delete
*/
[73] Fix | Delete
private function init_pro_field(): void {
[74] Fix | Delete
[75] Fix | Delete
$this->is_pro = wpforms()->is_pro();
[76] Fix | Delete
$this->is_addon_initialized = ! empty( $this->addon_slug ) && wpforms_is_addon_initialized( $this->addon_slug );
[77] Fix | Delete
$this->is_disabled_field = $this->is_disabled_field();
[78] Fix | Delete
[79] Fix | Delete
// Add hooks.
[80] Fix | Delete
add_filter( 'admin_init', [ $this, 'admin_init_pro_field' ] );
[81] Fix | Delete
add_filter( 'wpforms_builder_field_option_class', [ $this, 'filter_field_option_class' ], 10, 2 );
[82] Fix | Delete
add_filter( "wpforms_admin_builder_ajax_save_form_field_$this->type", [ $this, 'filter_save_form_field_data' ], 10, 3 );
[83] Fix | Delete
add_filter( 'wpforms_field_data', [ $this, 'filter_frontend_field_data' ], PHP_INT_MAX, 2 );
[84] Fix | Delete
add_filter( 'wpforms_helpers_form_pro_fields', [ $this, 'filter_form_pro_fields' ], PHP_INT_MAX, 2 );
[85] Fix | Delete
add_filter( 'wpforms_helpers_form_addons_edu_data', [ $this, 'filter_form_addons_edu_data' ], PHP_INT_MAX, 2 );
[86] Fix | Delete
add_filter( 'wpforms_field_preview_display_duplicate_button', [ $this, 'filter_field_preview_display_duplicate_button' ], 10, 2 );
[87] Fix | Delete
add_filter( 'wpforms_field_preview_class', [ $this, 'filter_field_preview_class' ], 10, 2 );
[88] Fix | Delete
add_filter( 'wpforms_entry_save_data', [ $this, 'filter_entry_save_data' ], 10, 3 );
[89] Fix | Delete
add_filter( 'wpforms_pro_admin_entries_table_facades_columns_get_field_columns_forbidden_fields', [ $this, 'filter_field_columns_forbidden_fields' ], 10, 2 );
[90] Fix | Delete
add_filter( 'wpforms_pro_admin_entries_export_configuration', [ $this, 'filter_entries_export_configuration' ] );
[91] Fix | Delete
add_filter( "wpforms_pro_admin_entries_edit_is_field_displayable_$this->type", [ $this, 'filter_is_field_displayable' ], 10, 3 );
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Init Pro field on the ` admin_init ` hook.
[96] Fix | Delete
*
[97] Fix | Delete
* @since 1.9.4
[98] Fix | Delete
*/
[99] Fix | Delete
public function admin_init_pro_field(): void {
[100] Fix | Delete
[101] Fix | Delete
$this->addon_edu_data = $this->get_field_addon_edu_data();
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* Get the Pro field options tab CSS class.
[106] Fix | Delete
*
[107] Fix | Delete
* @since 1.9.4
[108] Fix | Delete
*
[109] Fix | Delete
* @param string|mixed $css_class CSS class.
[110] Fix | Delete
* @param array $field Field data.
[111] Fix | Delete
*
[112] Fix | Delete
* @return string
[113] Fix | Delete
* @noinspection PhpMissingParamTypeInspection
[114] Fix | Delete
*/
[115] Fix | Delete
public function filter_field_option_class( $css_class, $field ): string {
[116] Fix | Delete
[117] Fix | Delete
$css_class = (string) $css_class;
[118] Fix | Delete
[119] Fix | Delete
if ( $field['type'] !== $this->type ) {
[120] Fix | Delete
return $css_class;
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
$css_class .= empty( $this->is_disabled_field ) ? '' : ' wpforms-field-is-pro';
[124] Fix | Delete
[125] Fix | Delete
return trim( $css_class );
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
/**
[129] Fix | Delete
* Filter field data before saving the form.
[130] Fix | Delete
*
[131] Fix | Delete
* @since 1.9.4
[132] Fix | Delete
*
[133] Fix | Delete
* @param array $field_data Field data.
[134] Fix | Delete
* @param array $form_data Forms data.
[135] Fix | Delete
* @param array $saved_form_data Saved form data.
[136] Fix | Delete
*
[137] Fix | Delete
* @noinspection PhpMissingParamTypeInspection
[138] Fix | Delete
* @noinspection PhpUnusedParameterInspection
[139] Fix | Delete
*/
[140] Fix | Delete
public function filter_save_form_field_data( $field_data, $form_data, $saved_form_data ) {
[141] Fix | Delete
[142] Fix | Delete
if ( empty( $this->is_disabled_field ) ) {
[143] Fix | Delete
return $field_data;
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
$field_id = $field_data['id'] ?? '';
[147] Fix | Delete
[148] Fix | Delete
// Prevent changes in the field data if it's a Pro field in Lite.
[149] Fix | Delete
// The settings are disabled in the Form Builder, but users can still hijack the data.
[150] Fix | Delete
// Therefore, return the saved field data if it exists.
[151] Fix | Delete
return $saved_form_data['fields'][ $field_id ] ?? $field_data;
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
/**
[155] Fix | Delete
* Filter form pro fields array.
[156] Fix | Delete
*
[157] Fix | Delete
* @since 1.9.4
[158] Fix | Delete
*
[159] Fix | Delete
* @param array|mixed $pro_fields Pro fields array.
[160] Fix | Delete
* @param array $field Field data.
[161] Fix | Delete
*/
[162] Fix | Delete
public function filter_form_pro_fields( $pro_fields, array $field ): array {
[163] Fix | Delete
[164] Fix | Delete
$pro_fields = is_array( $pro_fields ) ? $pro_fields : [];
[165] Fix | Delete
[166] Fix | Delete
if ( isset( $field['type'] ) && $field['type'] === $this->type ) {
[167] Fix | Delete
$pro_fields[] = $field;
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
return $pro_fields;
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
/**
[174] Fix | Delete
* Filter the form addons educational data array.
[175] Fix | Delete
*
[176] Fix | Delete
* @since 1.9.4
[177] Fix | Delete
*
[178] Fix | Delete
* @param array|mixed $addons_edu_data Addons educational data.
[179] Fix | Delete
* @param array $field Field data.
[180] Fix | Delete
*/
[181] Fix | Delete
public function filter_form_addons_edu_data( $addons_edu_data, array $field ): array {
[182] Fix | Delete
[183] Fix | Delete
$addons_edu_data = is_array( $addons_edu_data ) ? $addons_edu_data : [];
[184] Fix | Delete
[185] Fix | Delete
if ( ! isset( $field['type'] ) || $field['type'] !== $this->type || empty( $this->addon_edu_data ) ) {
[186] Fix | Delete
return $addons_edu_data;
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
$addon = $this->addon_edu_data['slug'] ?? '';
[190] Fix | Delete
$addons_edu_data[ $addon ] = $this->addon_edu_data;
[191] Fix | Delete
[192] Fix | Delete
return $addons_edu_data;
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
/**
[196] Fix | Delete
* Get the Pro field options notice.
[197] Fix | Delete
*
[198] Fix | Delete
* @since 1.9.4
[199] Fix | Delete
*
[200] Fix | Delete
* @noinspection HtmlUnknownAttribute
[201] Fix | Delete
*/
[202] Fix | Delete
private function get_field_options_notice(): string {
[203] Fix | Delete
[204] Fix | Delete
if ( empty( $this->is_disabled_field ) ) {
[205] Fix | Delete
return '';
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
[ $name, $title, $content, $button_label, $button_utm ] = $this->get_field_options_notice_texts();
[209] Fix | Delete
[210] Fix | Delete
$action = $this->addon_edu_data['action'] ?? 'upgrade';
[211] Fix | Delete
$button_class = 'education-action-button';
[212] Fix | Delete
$button_attr = '';
[213] Fix | Delete
[214] Fix | Delete
if ( $action !== 'upgrade' ) {
[215] Fix | Delete
$button_class = 'education-modal';
[216] Fix | Delete
$button_attr = sprintf(
[217] Fix | Delete
'data-nonce="%1$s" data-path="%2$s" data-url="%3$s" data-message="%4$s" data-field-type="%5$s" data-name="%6$s"',
[218] Fix | Delete
esc_attr( wp_create_nonce( 'wpforms-admin' ) ),
[219] Fix | Delete
$this->addon_edu_data['path'] ?? '',
[220] Fix | Delete
$this->addon_edu_data['url'] ?? '',
[221] Fix | Delete
$action === 'incompatible' ? $this->addon_edu_data['message'] : '',
[222] Fix | Delete
esc_attr( $this->type ),
[223] Fix | Delete
esc_attr( $name )
[224] Fix | Delete
);
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
return sprintf(
[228] Fix | Delete
'<div class="wpforms-field-option-field-title-notice">
[229] Fix | Delete
<div class="wpforms-alert-info wpforms-alert wpforms-educational-alert">
[230] Fix | Delete
<h4>%1$s</h4>
[231] Fix | Delete
<p>%2$s</p>
[232] Fix | Delete
<button class="wpforms-btn wpforms-btn-sm wpforms-btn-blue %3$s" data-action="%4$s" %6$s data-license="%7$s" data-utm-content="%8$s">%5$s</button>
[233] Fix | Delete
</div>
[234] Fix | Delete
</div>',
[235] Fix | Delete
$title,
[236] Fix | Delete
esc_html( $content ),
[237] Fix | Delete
esc_attr( $button_class ),
[238] Fix | Delete
esc_attr( $action ),
[239] Fix | Delete
esc_html( $button_label ),
[240] Fix | Delete
$button_attr,
[241] Fix | Delete
esc_attr( $this->addon_edu_data['license_level'] ?? 'pro' ),
[242] Fix | Delete
esc_attr( $button_utm )
[243] Fix | Delete
);
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
/**
[247] Fix | Delete
* Get the Pro field options notice texts.
[248] Fix | Delete
*
[249] Fix | Delete
* @since 1.9.4
[250] Fix | Delete
*/
[251] Fix | Delete
private function get_field_options_notice_texts(): array {
[252] Fix | Delete
[253] Fix | Delete
$action = $this->addon_edu_data['action'] ?? 'upgrade';
[254] Fix | Delete
$addon_name = $this->addon_edu_data['title'] ?? '';
[255] Fix | Delete
$name = $this->name;
[256] Fix | Delete
[257] Fix | Delete
$titles = [
[258] Fix | Delete
'upgrade' => sprintf( /* translators: %1$s - Field name. */
[259] Fix | Delete
esc_html__( '%1$s is a Pro Feature', 'wpforms-lite' ),
[260] Fix | Delete
$name
[261] Fix | Delete
),
[262] Fix | Delete
'incompatible' => esc_html__( 'Incompatible Addon', 'wpforms-lite' ),
[263] Fix | Delete
];
[264] Fix | Delete
[265] Fix | Delete
$contents = [
[266] Fix | Delete
'upgrade' => sprintf( /* translators: %1$s - Field name. */
[267] Fix | Delete
esc_html__( 'Upgrade to gain access to the %1$s field and dozens of other powerful features to help you build smarter forms and grow your business.', 'wpforms-lite' ),
[268] Fix | Delete
$name
[269] Fix | Delete
),
[270] Fix | Delete
'install' => sprintf( /* translators: %1$s - Addon name. */
[271] Fix | Delete
esc_html__( 'You have access to the %1$s, but it\'s not currently installed.', 'wpforms-lite' ),
[272] Fix | Delete
$addon_name
[273] Fix | Delete
),
[274] Fix | Delete
'activate' => sprintf( /* translators: %1$s - Addon name. */
[275] Fix | Delete
esc_html__( 'You have access to the %1$s, but it\'s not currently activated.', 'wpforms-lite' ),
[276] Fix | Delete
$addon_name
[277] Fix | Delete
),
[278] Fix | Delete
'incompatible' => sprintf( /* translators: %1$s - Addon name. */
[279] Fix | Delete
esc_html__( 'The %1$s is not compatible with this version of WPForms and requires an update.', 'wpforms-lite' ),
[280] Fix | Delete
$addon_name
[281] Fix | Delete
),
[282] Fix | Delete
];
[283] Fix | Delete
[284] Fix | Delete
$button_labels = [
[285] Fix | Delete
'upgrade' => esc_html__( 'Upgrade to Pro', 'wpforms-lite' ),
[286] Fix | Delete
'install' => esc_html__( 'Install Addon', 'wpforms-lite' ),
[287] Fix | Delete
'activate' => esc_html__( 'Activate Addon', 'wpforms-lite' ),
[288] Fix | Delete
'incompatible' => esc_html__( 'Update Addon', 'wpforms-lite' ),
[289] Fix | Delete
];
[290] Fix | Delete
[291] Fix | Delete
// If it's not an upgrade action, use the addon data.
[292] Fix | Delete
if ( $action !== 'upgrade' ) {
[293] Fix | Delete
$name = $addon_name;
[294] Fix | Delete
$utm_name = $this->addon_edu_data['utm_content'];
[295] Fix | Delete
} else {
[296] Fix | Delete
$edu_fields = wpforms()->obj( 'education_fields' );
[297] Fix | Delete
$edu_field = $edu_fields ? $edu_fields->get_field( $this->type ) : null;
[298] Fix | Delete
$utm_name = $edu_field['name_en'] ?? $this->type; // Fallback to the field type.
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
$button_utm = sprintf(
[302] Fix | Delete
'AI Form - %1$s notice',
[303] Fix | Delete
esc_html( $utm_name )
[304] Fix | Delete
);
[305] Fix | Delete
[306] Fix | Delete
return [
[307] Fix | Delete
$name,
[308] Fix | Delete
$titles[ $action ] ?? $titles['upgrade'],
[309] Fix | Delete
$contents[ $action ] ?? $contents['upgrade'],
[310] Fix | Delete
$button_labels[ $action ] ?? $button_labels['upgrade'],
[311] Fix | Delete
$button_utm,
[312] Fix | Delete
];
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
/**
[316] Fix | Delete
* Determine if the field is disabled.
[317] Fix | Delete
*
[318] Fix | Delete
* @since 1.9.4
[319] Fix | Delete
* @since 1.9.9.3 The method access modifier is changed from private to protected.
[320] Fix | Delete
*/
[321] Fix | Delete
protected function is_disabled_field(): bool {
[322] Fix | Delete
[323] Fix | Delete
// It is a Pro field in Lite OR the addon is not initialized.
[324] Fix | Delete
return ! ( $this->is_pro && ( empty( $this->addon_slug ) || $this->is_addon_initialized ) );
[325] Fix | Delete
}
[326] Fix | Delete
[327] Fix | Delete
/**
[328] Fix | Delete
* Get a preview option.
[329] Fix | Delete
*
[330] Fix | Delete
* @since 1.9.4
[331] Fix | Delete
*
[332] Fix | Delete
* @param string $option Option name.
[333] Fix | Delete
* @param array $field Field data.
[334] Fix | Delete
* @param array $args Additional arguments.
[335] Fix | Delete
* @param bool $do_echo Echo or return.
[336] Fix | Delete
*
[337] Fix | Delete
* @noinspection ReturnTypeCanBeDeclaredInspection
[338] Fix | Delete
* @noinspection PhpMultipleClassDeclarationsInspection
[339] Fix | Delete
*/
[340] Fix | Delete
public function field_preview_option( $option, $field, $args = [], $do_echo = true ) {
[341] Fix | Delete
[342] Fix | Delete
// Hide remaining elements, prevent incompatible addon field elements from being displayed.
[343] Fix | Delete
if ( $option === 'hide-remaining' && ! empty( $this->is_disabled_field ) ) {
[344] Fix | Delete
echo '<div class="wpforms-field-hide-remaining"></div>';
[345] Fix | Delete
[346] Fix | Delete
return;
[347] Fix | Delete
}
[348] Fix | Delete
[349] Fix | Delete
parent::field_preview_option( $option, $field, $args, $do_echo );
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
/**
[353] Fix | Delete
* Get the Pro field preview badge.
[354] Fix | Delete
*
[355] Fix | Delete
* @since 1.9.4
[356] Fix | Delete
*/
[357] Fix | Delete
private function get_field_preview_badge(): string {
[358] Fix | Delete
[359] Fix | Delete
if ( empty( $this->is_disabled_field ) ) {
[360] Fix | Delete
return '';
[361] Fix | Delete
}
[362] Fix | Delete
[363] Fix | Delete
$action = $this->addon_edu_data['action'] ?? '';
[364] Fix | Delete
[365] Fix | Delete
if ( $action === 'incompatible' ) {
[366] Fix | Delete
return Helpers::get_badge( esc_html__( 'Update required', 'wpforms-lite' ) , 'lg', 'inline', 'red' );
[367] Fix | Delete
}
[368] Fix | Delete
[369] Fix | Delete
// If it's an addon field in Pro AND the addon is not initialized, show the ADDON badge.
[370] Fix | Delete
if ( in_array( $action, [ 'install' ,'activate' ], true ) ) {
[371] Fix | Delete
return Helpers::get_badge( 'Addon', 'lg', 'inline', 'orange' );
[372] Fix | Delete
}
[373] Fix | Delete
[374] Fix | Delete
return Helpers::get_badge( 'Pro', 'lg', 'inline', 'green' );
[375] Fix | Delete
}
[376] Fix | Delete
[377] Fix | Delete
/**
[378] Fix | Delete
* Get the addon educational data of the field.
[379] Fix | Delete
*
[380] Fix | Delete
* @since 1.9.4
[381] Fix | Delete
*
[382] Fix | Delete
* @return array
[383] Fix | Delete
*/
[384] Fix | Delete
private function get_field_addon_edu_data(): array {
[385] Fix | Delete
[386] Fix | Delete
if ( empty( $this->addon_slug ) || ! empty( $this->is_addon_initialized ) || ! is_admin() ) {
[387] Fix | Delete
return [];
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
$addons = Helpers::get_edu_addons();
[391] Fix | Delete
[392] Fix | Delete
return $addons[ 'wpforms-' . $this->addon_slug ] ?? [];
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
/**
[396] Fix | Delete
* Filter frontend field data to prevent rendering Pro fields in Lite.
[397] Fix | Delete
*
[398] Fix | Delete
* @since 1.9.4
[399] Fix | Delete
*
[400] Fix | Delete
* @param array|mixed $field Field data.
[401] Fix | Delete
* @param array $form_data Form data.
[402] Fix | Delete
*
[403] Fix | Delete
* @return array
[404] Fix | Delete
* @noinspection PhpMissingParamTypeInspection
[405] Fix | Delete
* @noinspection PhpUnusedParameterInspection
[406] Fix | Delete
*/
[407] Fix | Delete
public function filter_frontend_field_data( $field, $form_data ): array { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
[408] Fix | Delete
[409] Fix | Delete
$field = (array) $field;
[410] Fix | Delete
$type = $field['type'] ?? '';
[411] Fix | Delete
[412] Fix | Delete
// If it's not a Pro field or the field type doesn't match, return the field data as is.
[413] Fix | Delete
if ( empty( $this->is_pro_field ) || $type !== $this->type ) {
[414] Fix | Delete
return $field;
[415] Fix | Delete
}
[416] Fix | Delete
[417] Fix | Delete
// If it's a Pro field in Lite OR,
[418] Fix | Delete
// the addon is not initialized,
[419] Fix | Delete
// return an empty array to prevent rendering.
[420] Fix | Delete
if ( ! empty( $this->is_disabled_field ) ) {
[421] Fix | Delete
return [];
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
return $field;
[425] Fix | Delete
}
[426] Fix | Delete
[427] Fix | Delete
/**
[428] Fix | Delete
* Disallow the field preview "Duplicate" button.
[429] Fix | Delete
*
[430] Fix | Delete
* @since 1.9.4
[431] Fix | Delete
*
[432] Fix | Delete
* @param bool|mixed $display Display switch.
[433] Fix | Delete
* @param array $field Field settings.
[434] Fix | Delete
*
[435] Fix | Delete
* @return bool
[436] Fix | Delete
* @noinspection PhpMissingParamTypeInspection
[437] Fix | Delete
*/
[438] Fix | Delete
public function filter_field_preview_display_duplicate_button( $display, $field ): bool {
[439] Fix | Delete
[440] Fix | Delete
if ( $field['type'] !== $this->type || empty( $this->is_disabled_field ) ) {
[441] Fix | Delete
return (bool) $display;
[442] Fix | Delete
}
[443] Fix | Delete
[444] Fix | Delete
return false;
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
/**
[448] Fix | Delete
* Add a class to the field preview container.
[449] Fix | Delete
*
[450] Fix | Delete
* @since 1.9.4
[451] Fix | Delete
*
[452] Fix | Delete
* @param string|mixed $css_class CSS class.
[453] Fix | Delete
* @param array $field Field settings.
[454] Fix | Delete
*
[455] Fix | Delete
* @return string
[456] Fix | Delete
* @noinspection PhpMissingParamTypeInspection
[457] Fix | Delete
*/
[458] Fix | Delete
public function filter_field_preview_class( $css_class, $field ): string {
[459] Fix | Delete
[460] Fix | Delete
$css_class = (string) $css_class;
[461] Fix | Delete
[462] Fix | Delete
if ( $field['type'] !== $this->type || empty( $this->is_disabled_field ) ) {
[463] Fix | Delete
return $css_class;
[464] Fix | Delete
}
[465] Fix | Delete
[466] Fix | Delete
return trim( $css_class . ' wpforms-field-is-pro' );
[467] Fix | Delete
}
[468] Fix | Delete
[469] Fix | Delete
/**
[470] Fix | Delete
* Filter entry save data.
[471] Fix | Delete
*
[472] Fix | Delete
* @since 1.9.5
[473] Fix | Delete
*
[474] Fix | Delete
* @param array|mixed $fields Entry fields data.
[475] Fix | Delete
* @param array $entry Entry data.
[476] Fix | Delete
* @param array $form_data Form data.
[477] Fix | Delete
*
[478] Fix | Delete
* @return array
[479] Fix | Delete
* @noinspection PhpUnusedParameterInspection
[480] Fix | Delete
*/
[481] Fix | Delete
public function filter_entry_save_data( $fields, array $entry, array $form_data ): array { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
[482] Fix | Delete
[483] Fix | Delete
$fields = (array) $fields;
[484] Fix | Delete
[485] Fix | Delete
// If it's not a disabled Pro field, return the fields as is.
[486] Fix | Delete
if ( empty( $this->is_disabled_field ) ) {
[487] Fix | Delete
return $fields;
[488] Fix | Delete
}
[489] Fix | Delete
[490] Fix | Delete
// Remove disabled Pro fields from the entry fields.
[491] Fix | Delete
foreach ( $fields as $field_id => $field ) {
[492] Fix | Delete
if ( isset( $field['type'] ) && $field['type'] === $this->type ) {
[493] Fix | Delete
unset( $fields[ $field_id ] );
[494] Fix | Delete
}
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
return $fields;
[498] Fix | Delete
}
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function