Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/wpforms-.../includes/admin
File: settings-api.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Settings API.
[2] Fix | Delete
*
[3] Fix | Delete
* @since 1.3.7
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
use WPForms\Admin\Education\Helpers as EducationHelpers;
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Settings output wrapper.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 1.3.9
[12] Fix | Delete
*
[13] Fix | Delete
* @param array $args Arguments.
[14] Fix | Delete
*
[15] Fix | Delete
* @return string
[16] Fix | Delete
*/
[17] Fix | Delete
function wpforms_settings_output_field( array $args ): string {
[18] Fix | Delete
[19] Fix | Delete
// Define default callback for this field type.
[20] Fix | Delete
$callback = ! empty( $args['type'] ) && function_exists( 'wpforms_settings_' . $args['type'] . '_callback' ) ? 'wpforms_settings_' . $args['type'] . '_callback' : 'wpforms_settings_missing_callback';
[21] Fix | Delete
[22] Fix | Delete
// Allow custom callback to be provided via arg.
[23] Fix | Delete
if ( ! empty( $args['callback'] ) && function_exists( $args['callback'] ) ) {
[24] Fix | Delete
$callback = $args['callback'];
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
// Store returned markup from callback.
[28] Fix | Delete
$field = $callback( $args );
[29] Fix | Delete
[30] Fix | Delete
// Allow arg to bypass standard field wrap for custom display.
[31] Fix | Delete
if ( ! empty( $args['wrap'] ) ) {
[32] Fix | Delete
return $field;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
// Default class names.
[36] Fix | Delete
$class = [
[37] Fix | Delete
'wpforms-setting-row',
[38] Fix | Delete
"wpforms-setting-row-{$args['type']}",
[39] Fix | Delete
'wpforms-clear',
[40] Fix | Delete
];
[41] Fix | Delete
[42] Fix | Delete
// Row attributes.
[43] Fix | Delete
$wrapper_attributes = wpforms_html_attributes(
[44] Fix | Delete
'wpforms-setting-row-' . wpforms_sanitize_key( $args['id'] ),
[45] Fix | Delete
! empty( $args['class'] ) ? array_merge( $class, (array) $args['class'] ) : $class,
[46] Fix | Delete
! empty( $args['data_attributes'] ) && is_array( $args['data_attributes'] ) ? $args['data_attributes'] : [],
[47] Fix | Delete
! empty( $args['is_hidden'] ) ? [ 'style' => 'display:none;' ] : []
[48] Fix | Delete
);
[49] Fix | Delete
[50] Fix | Delete
// Build standard field markup and return.
[51] Fix | Delete
$output = "<div {$wrapper_attributes}>";
[52] Fix | Delete
[53] Fix | Delete
if ( ! empty( $args['name'] ) && empty( $args['no_label'] ) ) {
[54] Fix | Delete
$output .= '<span class="wpforms-setting-label">';
[55] Fix | Delete
$output .= '<label for="wpforms-setting-' . wpforms_sanitize_key( $args['id'] ) . '">' . esc_html( $args['name'] );
[56] Fix | Delete
[57] Fix | Delete
// Add education badge, if needed.
[58] Fix | Delete
// The badge should be added after the label text, but before the label closing tag.
[59] Fix | Delete
if ( ! empty( $args['education_badge'] ) ) {
[60] Fix | Delete
$output .= wp_kses( $args['education_badge'], [ 'span' => [ 'class' => [] ] ] );
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
$output .= '</label>';
[64] Fix | Delete
$output .= '</span>';
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
$output .= '<span class="wpforms-setting-field">';
[68] Fix | Delete
$output .= $field;
[69] Fix | Delete
[70] Fix | Delete
if ( ! empty( $args['desc_after'] ) ) {
[71] Fix | Delete
$output .= '<div class="wpforms-clear">' . $args['desc_after'] . '</div>';
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
$output .= '</span>';
[75] Fix | Delete
$output .= '</div>';
[76] Fix | Delete
[77] Fix | Delete
return $output;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* Missing Callback.
[82] Fix | Delete
*
[83] Fix | Delete
* If a function is missing for settings, callbacks alert the user.
[84] Fix | Delete
*
[85] Fix | Delete
* @since 1.3.9
[86] Fix | Delete
*
[87] Fix | Delete
* @param array $args Arguments passed by the setting.
[88] Fix | Delete
*
[89] Fix | Delete
* @return string
[90] Fix | Delete
*/
[91] Fix | Delete
function wpforms_settings_missing_callback( array $args ): string {
[92] Fix | Delete
[93] Fix | Delete
return sprintf(
[94] Fix | Delete
/* translators: %s - ID of a setting. */
[95] Fix | Delete
esc_html__( 'The callback function used for the %s setting is missing.', 'wpforms-lite' ),
[96] Fix | Delete
'<strong>' . wpforms_sanitize_key( $args['id'] ) . '</strong>'
[97] Fix | Delete
);
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
/**
[101] Fix | Delete
* Settings content field callback.
[102] Fix | Delete
*
[103] Fix | Delete
* @since 1.3.9
[104] Fix | Delete
*
[105] Fix | Delete
* @param array $args Arguments.
[106] Fix | Delete
*
[107] Fix | Delete
* @return string
[108] Fix | Delete
*/
[109] Fix | Delete
function wpforms_settings_content_callback( array $args ): string {
[110] Fix | Delete
[111] Fix | Delete
return ! empty( $args['content'] ) ? $args['content'] : '';
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* Settings license field callback.
[116] Fix | Delete
*
[117] Fix | Delete
* @since 1.3.9
[118] Fix | Delete
*
[119] Fix | Delete
* @param array $args Settings arguments.
[120] Fix | Delete
*
[121] Fix | Delete
* @return string
[122] Fix | Delete
* @noinspection HtmlUnknownTarget
[123] Fix | Delete
* @noinspection PhpUnusedParameterInspection
[124] Fix | Delete
*/
[125] Fix | Delete
function wpforms_settings_license_callback( array $args ): string { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
[126] Fix | Delete
[127] Fix | Delete
$output = '<p>' . esc_html__( 'You\'re using WPForms Lite - no license needed. Enjoy!', 'wpforms-lite' ) . ' 🙂</p>';
[128] Fix | Delete
$output .=
[129] Fix | Delete
'<p>' .
[130] Fix | Delete
sprintf(
[131] Fix | Delete
wp_kses( /* translators: %s - WPForms.com upgrade URL. */
[132] Fix | Delete
__( 'To unlock more features consider <strong><a href="%s" target="_blank" rel="noopener noreferrer" class="wpforms-upgrade-modal">upgrading to PRO</a></strong>.', 'wpforms-lite' ),
[133] Fix | Delete
[
[134] Fix | Delete
'a' => [
[135] Fix | Delete
'href' => [],
[136] Fix | Delete
'class' => [],
[137] Fix | Delete
'target' => [],
[138] Fix | Delete
'rel' => [],
[139] Fix | Delete
],
[140] Fix | Delete
'strong' => [],
[141] Fix | Delete
]
[142] Fix | Delete
),
[143] Fix | Delete
esc_url( wpforms_admin_upgrade_link( 'settings-license', 'Upgrade to WPForms Pro text Link' ) )
[144] Fix | Delete
) .
[145] Fix | Delete
'</p>';
[146] Fix | Delete
$output .=
[147] Fix | Delete
'<p class="discount-note">' .
[148] Fix | Delete
wp_kses(
[149] Fix | Delete
__( 'As a valued WPForms Lite user you receive <strong>50% off</strong>, automatically applied at checkout!', 'wpforms-lite' ),
[150] Fix | Delete
[
[151] Fix | Delete
'strong' => [],
[152] Fix | Delete
]
[153] Fix | Delete
) .
[154] Fix | Delete
'</p>';
[155] Fix | Delete
[156] Fix | Delete
$output .= '<hr><p>' . esc_html__( 'Already purchased? Simply enter your license key below to enable WPForms PRO!', 'wpforms-lite' ) . '</p>';
[157] Fix | Delete
$output .= '<p>';
[158] Fix | Delete
$output .= '<input type="password" spellcheck="false" id="wpforms-settings-upgrade-license-key" placeholder="' . esc_attr__( 'Paste license key here', 'wpforms-lite' ) . '" value="">';
[159] Fix | Delete
$output .= '<button class="wpforms-btn wpforms-btn-md wpforms-btn-blue" id="wpforms-settings-connect-btn">' . esc_html__( 'Verify Key', 'wpforms-lite' ) . '</button>';
[160] Fix | Delete
$output .= '</p>';
[161] Fix | Delete
[162] Fix | Delete
/**
[163] Fix | Delete
* Filter license settings HTML output.
[164] Fix | Delete
*
[165] Fix | Delete
* @since 1.7.9
[166] Fix | Delete
*
[167] Fix | Delete
* @param string $output HTML markup to be rendered in place of license settings.
[168] Fix | Delete
*/
[169] Fix | Delete
return (string) apply_filters( 'wpforms_settings_license_output', $output );
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
/**
[173] Fix | Delete
* Settings text input field callback.
[174] Fix | Delete
*
[175] Fix | Delete
* @since 1.3.9
[176] Fix | Delete
*
[177] Fix | Delete
* @param array $args Settings arguments.
[178] Fix | Delete
*
[179] Fix | Delete
* @return string
[180] Fix | Delete
*/
[181] Fix | Delete
function wpforms_settings_text_callback( array $args ): string {
[182] Fix | Delete
[183] Fix | Delete
if ( ! in_array( $args['type'], [ 'text', 'password' ], true ) ) {
[184] Fix | Delete
$args['type'] = 'text';
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
$default = isset( $args['default'] ) ? esc_html( $args['default'] ) : '';
[188] Fix | Delete
$value = wpforms_setting( $args['id'], $default );
[189] Fix | Delete
$id = wpforms_sanitize_key( $args['id'] );
[190] Fix | Delete
[191] Fix | Delete
$output = '<input type="' . esc_attr( $args['type'] ) . '" id="wpforms-setting-' . $id . '" name="' . $id . '" value="' . esc_attr( $value ) . '">';
[192] Fix | Delete
[193] Fix | Delete
if ( ! empty( $args['desc'] ) ) {
[194] Fix | Delete
$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
return $output;
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
/**
[201] Fix | Delete
* Settings password input field callback.
[202] Fix | Delete
*
[203] Fix | Delete
* @since 1.8.4
[204] Fix | Delete
*
[205] Fix | Delete
* @param array $args Setting field arguments.
[206] Fix | Delete
*
[207] Fix | Delete
* @return string
[208] Fix | Delete
*/
[209] Fix | Delete
function wpforms_settings_password_callback( array $args ): string {
[210] Fix | Delete
[211] Fix | Delete
return wpforms_settings_text_callback( $args );
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
/**
[215] Fix | Delete
* Settings number input field callback.
[216] Fix | Delete
*
[217] Fix | Delete
* @since 1.5.3
[218] Fix | Delete
*
[219] Fix | Delete
* @param array $args Setting field arguments.
[220] Fix | Delete
*
[221] Fix | Delete
* @return string
[222] Fix | Delete
* @noinspection HtmlUnknownAttribute
[223] Fix | Delete
*/
[224] Fix | Delete
function wpforms_settings_number_callback( array $args ): string {
[225] Fix | Delete
[226] Fix | Delete
$default = isset( $args['default'] ) ? esc_html( $args['default'] ) : '';
[227] Fix | Delete
$id = 'wpforms-setting-' . wpforms_sanitize_key( $args['id'] );
[228] Fix | Delete
$attr = [
[229] Fix | Delete
'value' => wpforms_setting( $args['id'], $default ),
[230] Fix | Delete
'name' => wpforms_sanitize_key( $args['id'] ),
[231] Fix | Delete
];
[232] Fix | Delete
$data = ! empty( $args['data'] ) ? $args['data'] : [];
[233] Fix | Delete
[234] Fix | Delete
if ( ! empty( $args['attr'] ) ) {
[235] Fix | Delete
$attr = array_merge( $attr, $args['attr'] );
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
$output = sprintf(
[239] Fix | Delete
'<input type="number" %s>',
[240] Fix | Delete
wpforms_html_attributes( $id, [], $data, $attr )
[241] Fix | Delete
);
[242] Fix | Delete
[243] Fix | Delete
if ( ! empty( $args['desc'] ) ) {
[244] Fix | Delete
$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
return $output;
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
/**
[251] Fix | Delete
* Settings select field callback.
[252] Fix | Delete
*
[253] Fix | Delete
* @since 1.3.9
[254] Fix | Delete
*
[255] Fix | Delete
* @param array $args Arguments.
[256] Fix | Delete
*
[257] Fix | Delete
* @return string
[258] Fix | Delete
*/
[259] Fix | Delete
function wpforms_settings_select_callback( array $args ): string { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
[260] Fix | Delete
[261] Fix | Delete
$default = isset( $args['default'] ) ? esc_html( $args['default'] ) : '';
[262] Fix | Delete
$value = wpforms_setting( $args['id'], $default );
[263] Fix | Delete
$id = wpforms_sanitize_key( $args['id'] );
[264] Fix | Delete
$select_name = $id;
[265] Fix | Delete
$class = ! empty( $args['choicesjs'] ) ? 'choicesjs-select' : '';
[266] Fix | Delete
$choices = ! empty( $args['choicesjs'] );
[267] Fix | Delete
$data = isset( $args['data'] ) ? (array) $args['data'] : [];
[268] Fix | Delete
$attr = isset( $args['attr'] ) ? (array) $args['attr'] : [];
[269] Fix | Delete
[270] Fix | Delete
if ( $choices && ! empty( $args['search'] ) ) {
[271] Fix | Delete
$data['search'] = 'true';
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
if ( ! empty( $args['placeholder'] ) ) {
[275] Fix | Delete
$data['placeholder'] = $args['placeholder'];
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
$size_attr = '';
[279] Fix | Delete
[280] Fix | Delete
if ( $choices && ! empty( $args['multiple'] ) ) {
[281] Fix | Delete
$attr[] = 'multiple';
[282] Fix | Delete
$select_name = $id . '[]';
[283] Fix | Delete
$size_attr = ' size="1"';
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
foreach ( $data as $name => $val ) {
[287] Fix | Delete
$data[ $name ] = 'data-' . sanitize_html_class( $name ) . '="' . esc_attr( $val ) . '"';
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
$data = implode( ' ', $data );
[291] Fix | Delete
$attr = implode( ' ', array_map( 'sanitize_html_class', $attr ) );
[292] Fix | Delete
[293] Fix | Delete
$output = $choices ? '<span class="choicesjs-select-wrap">' : '';
[294] Fix | Delete
$output .= '<select id="wpforms-setting-' . $id . '" name="' . $select_name . '" class="' . $class . '"' . $data . $attr . $size_attr . '>';
[295] Fix | Delete
[296] Fix | Delete
foreach ( $args['options'] as $option => $name ) {
[297] Fix | Delete
if ( empty( $args['selected'] ) ) {
[298] Fix | Delete
$selected = selected( $value, $option, false );
[299] Fix | Delete
} else {
[300] Fix | Delete
$selected = is_array( $args['selected'] ) && in_array( $option, $args['selected'], true ) ? 'selected' : '';
[301] Fix | Delete
}
[302] Fix | Delete
$output .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
$output .= '</select>';
[306] Fix | Delete
$output .= $choices ? '</span>' : '';
[307] Fix | Delete
[308] Fix | Delete
if ( ! empty( $args['desc'] ) ) {
[309] Fix | Delete
$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
return $output;
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
/**
[316] Fix | Delete
* Settings checkbox field callback.
[317] Fix | Delete
*
[318] Fix | Delete
* @since 1.3.9
[319] Fix | Delete
*
[320] Fix | Delete
* @param array $args Arguments.
[321] Fix | Delete
*
[322] Fix | Delete
* @return string
[323] Fix | Delete
*/
[324] Fix | Delete
function wpforms_settings_checkbox_callback( array $args ): string {
[325] Fix | Delete
[326] Fix | Delete
$value = wpforms_setting( $args['id'] );
[327] Fix | Delete
$id = wpforms_sanitize_key( $args['id'] );
[328] Fix | Delete
$checked = ! empty( $value ) ? checked( 1, $value, false ) : '';
[329] Fix | Delete
$disabled = ! empty( $args['disabled'] ) ? ' disabled' : '';
[330] Fix | Delete
[331] Fix | Delete
$output = '<input type="checkbox" id="wpforms-setting-' . $id . '" name="' . $id . '" ' . $checked . $disabled . '>';
[332] Fix | Delete
[333] Fix | Delete
if ( ! empty( $args['desc'] ) ) {
[334] Fix | Delete
$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
[335] Fix | Delete
}
[336] Fix | Delete
[337] Fix | Delete
if ( ! empty( $args['disabled_desc'] ) ) {
[338] Fix | Delete
$output .= '<p class="disabled-desc">' . wp_kses_post( $args['disabled_desc'] ) . '</p>';
[339] Fix | Delete
}
[340] Fix | Delete
[341] Fix | Delete
return $output;
[342] Fix | Delete
}
[343] Fix | Delete
[344] Fix | Delete
/**
[345] Fix | Delete
* Settings radio field callback.
[346] Fix | Delete
*
[347] Fix | Delete
* @since 1.3.9
[348] Fix | Delete
*
[349] Fix | Delete
* @param array $args Arguments.
[350] Fix | Delete
*
[351] Fix | Delete
* @return string
[352] Fix | Delete
*/
[353] Fix | Delete
function wpforms_settings_radio_callback( array $args ): string {
[354] Fix | Delete
[355] Fix | Delete
$default = isset( $args['default'] ) ? esc_html( $args['default'] ) : '';
[356] Fix | Delete
$value = wpforms_setting( $args['id'], $default );
[357] Fix | Delete
$id = wpforms_sanitize_key( $args['id'] );
[358] Fix | Delete
$output = '';
[359] Fix | Delete
$x = 1;
[360] Fix | Delete
[361] Fix | Delete
foreach ( $args['options'] as $option => $name ) {
[362] Fix | Delete
[363] Fix | Delete
$checked = checked( $value, $option, false );
[364] Fix | Delete
$output .= '<span class="wpforms-settings-field-radio-wrapper">';
[365] Fix | Delete
$output .= '<input type="radio" id="wpforms-setting-' . $id . '[' . $x . ']" name="' . $id . '" value="' . esc_attr( $option ) . '" ' . $checked . '>';
[366] Fix | Delete
$output .= '<label for="wpforms-setting-' . $id . '[' . $x . ']" class="option-' . sanitize_html_class( $option ) . '">';
[367] Fix | Delete
$output .= esc_html( $name );
[368] Fix | Delete
$output .= '</label>';
[369] Fix | Delete
$output .= '</span>';
[370] Fix | Delete
[371] Fix | Delete
++$x;
[372] Fix | Delete
}
[373] Fix | Delete
[374] Fix | Delete
if ( ! empty( $args['desc'] ) ) {
[375] Fix | Delete
$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
return $output;
[379] Fix | Delete
}
[380] Fix | Delete
[381] Fix | Delete
/**
[382] Fix | Delete
* Email template endpoint field callback.
[383] Fix | Delete
*
[384] Fix | Delete
* @since 1.8.5
[385] Fix | Delete
*
[386] Fix | Delete
* @param array $args Field arguments.
[387] Fix | Delete
*
[388] Fix | Delete
* @return string
[389] Fix | Delete
*/
[390] Fix | Delete
function wpforms_settings_email_template_callback( array $args ): string {
[391] Fix | Delete
[392] Fix | Delete
$id = wpforms_sanitize_key( $args['id'] );
[393] Fix | Delete
$is_pro = wpforms()->is_pro();
[394] Fix | Delete
$output = '';
[395] Fix | Delete
$x = 1;
[396] Fix | Delete
$education_args = [
[397] Fix | Delete
'name' => esc_html__( 'Email Templates', 'wpforms-lite' ),
[398] Fix | Delete
'plural' => '1',
[399] Fix | Delete
'action' => 'upgrade',
[400] Fix | Delete
];
[401] Fix | Delete
[402] Fix | Delete
foreach ( $args['options'] as $option => $attrs ) {
[403] Fix | Delete
$checked = checked( $args['value'], $option, false );
[404] Fix | Delete
$has_education = ! $is_pro && isset( $attrs['is_pro'] ) && $attrs['is_pro'];
[405] Fix | Delete
$class = [ 'wpforms-settings-field-radio-wrapper', 'wpforms-card-image' ];
[406] Fix | Delete
$data = [];
[407] Fix | Delete
[408] Fix | Delete
// Add class and data attributes for education modal, if needed.
[409] Fix | Delete
if ( $has_education ) {
[410] Fix | Delete
$class[] = 'education-modal'; // This class is used for JS.
[411] Fix | Delete
$data = $education_args; // This data is used for JS.
[412] Fix | Delete
}
[413] Fix | Delete
[414] Fix | Delete
$output .= '<span ' . wpforms_html_attributes( '', $class, $data ) . '>';
[415] Fix | Delete
$output .= '<input type="radio" id="wpforms-setting-' . $id . '[' . $x . ']" name="' . $id . '" value="' . esc_attr( $option ) . '" ' . $checked . '>';
[416] Fix | Delete
$output .= '<label for="wpforms-setting-' . $id . '[' . $x . ']" class="option-' . sanitize_html_class( $option ) . '">';
[417] Fix | Delete
$output .= esc_html( $attrs['name'] );
[418] Fix | Delete
[419] Fix | Delete
// Add class and data attributes for education modal, if needed.
[420] Fix | Delete
if ( $has_education ) {
[421] Fix | Delete
$output .= EducationHelpers::get_badge( 'Pro' );
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
$output .= '<span class="wpforms-card-image-overlay">';
[425] Fix | Delete
$output .= '<span class="wpforms-btn-choose wpforms-btn wpforms-btn-md wpforms-btn-orange">';
[426] Fix | Delete
$output .= esc_html__( 'Choose', 'wpforms-lite' ) . '</span>';
[427] Fix | Delete
[428] Fix | Delete
// Only add the preview action button if provided.
[429] Fix | Delete
if ( ! empty( $attrs['preview'] ) ) {
[430] Fix | Delete
$output .= '<a href="' . esc_url( $attrs['preview'] ) . '" class="wpforms-btn-preview wpforms-btn wpforms-btn-md wpforms-btn-light-grey" target="_blank">';
[431] Fix | Delete
$output .= esc_html__( 'Preview', 'wpforms-lite' );
[432] Fix | Delete
$output .= '</a>';
[433] Fix | Delete
}
[434] Fix | Delete
[435] Fix | Delete
$output .= '</span>';
[436] Fix | Delete
$output .= '</label>';
[437] Fix | Delete
$output .= '</span>';
[438] Fix | Delete
[439] Fix | Delete
++$x;
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
if ( ! empty( $args['desc'] ) ) {
[443] Fix | Delete
$output .= '<p class="desc">' . wp_kses_post( $args['desc'] ) . '</p>';
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
return $output;
[447] Fix | Delete
}
[448] Fix | Delete
[449] Fix | Delete
/**
[450] Fix | Delete
* Settings toggle field callback.
[451] Fix | Delete
*
[452] Fix | Delete
* @since 1.7.4
[453] Fix | Delete
*
[454] Fix | Delete
* @param array $args Arguments.
[455] Fix | Delete
*
[456] Fix | Delete
* @return string
[457] Fix | Delete
*/
[458] Fix | Delete
function wpforms_settings_toggle_callback( array $args ): string { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
[459] Fix | Delete
[460] Fix | Delete
$value = ! empty( $args['value'] ) ? $args['value'] : wpforms_setting( $args['id'] );
[461] Fix | Delete
$id = wpforms_sanitize_key( $args['id'] );
[462] Fix | Delete
$class = ! empty( $args['control-class'] ) ? $args['control-class'] : '';
[463] Fix | Delete
$class .= ! empty( $args['is-important'] ) ? ' wpforms-important' : '';
[464] Fix | Delete
$input_attr = ! empty( $args['input-attr'] ) ? $args['input-attr'] : '';
[465] Fix | Delete
[466] Fix | Delete
$default_args = [
[467] Fix | Delete
'control-class' => $class,
[468] Fix | Delete
];
[469] Fix | Delete
[470] Fix | Delete
$args = wp_parse_args( $args, $default_args );
[471] Fix | Delete
[472] Fix | Delete
$output = wpforms_panel_field_toggle_control(
[473] Fix | Delete
$args,
[474] Fix | Delete
'wpforms-setting-' . $id,
[475] Fix | Delete
$id,
[476] Fix | Delete
! empty( $args['label'] ) ? $args['label'] : '',
[477] Fix | Delete
$value,
[478] Fix | Delete
$input_attr
[479] Fix | Delete
);
[480] Fix | Delete
[481] Fix | Delete
$desc_on = ! empty( $args['desc'] ) ? $args['desc'] : '';
[482] Fix | Delete
$desc_on = ! empty( $args['desc-on'] ) ? $args['desc-on'] : $desc_on;
[483] Fix | Delete
$desc_off = ! empty( $args['desc-off'] ) ? $args['desc-off'] : '';
[484] Fix | Delete
[485] Fix | Delete
$output .= sprintf(
[486] Fix | Delete
'<p class="desc desc-on wpforms-toggle-desc%1$s">%2$s</p>',
[487] Fix | Delete
empty( $value ) && ! empty( $desc_off ) ? ' wpforms-hidden' : '',
[488] Fix | Delete
wp_kses_post( $desc_on )
[489] Fix | Delete
);
[490] Fix | Delete
[491] Fix | Delete
if ( ! empty( $desc_off ) ) {
[492] Fix | Delete
$output .= sprintf(
[493] Fix | Delete
'<p class="desc desc-off wpforms-toggle-desc%1$s">%2$s</p>',
[494] Fix | Delete
empty( $value ) ? '' : ' wpforms-hidden',
[495] Fix | Delete
wp_kses_post( $desc_off )
[496] Fix | Delete
);
[497] Fix | Delete
}
[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