Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/wpforms-.../src/Frontend
File: Frontend.php
[2000] Fix | Delete
$strings['css_vars'] = array_keys( $this->css_vars_obj->get_vars() );
[2001] Fix | Delete
[2002] Fix | Delete
return $strings;
[2003] Fix | Delete
}
[2004] Fix | Delete
[2005] Fix | Delete
/**
[2006] Fix | Delete
* Hook at fires at a later priority in wp_footer.
[2007] Fix | Delete
*
[2008] Fix | Delete
* @since 1.0.5
[2009] Fix | Delete
* @since 1.7.0 Load wpforms_settings on the confirmation page for a non-ajax form.
[2010] Fix | Delete
*/
[2011] Fix | Delete
public function footer_end(): void {
[2012] Fix | Delete
[2013] Fix | Delete
if (
[2014] Fix | Delete
( empty( $this->forms ) && empty( $_POST['wpforms'] ) && ! $this->assets_global() ) || // phpcs:ignore WordPress.Security.NonceVerification.Missing
[2015] Fix | Delete
$this->amp_obj->is_amp()
[2016] Fix | Delete
) {
[2017] Fix | Delete
return;
[2018] Fix | Delete
}
[2019] Fix | Delete
[2020] Fix | Delete
$strings = $this->get_strings();
[2021] Fix | Delete
[2022] Fix | Delete
/*
[2023] Fix | Delete
* Below we do our own implementation of wp_localize_script in an effort
[2024] Fix | Delete
* to be better compatible with caching plugins which were causing
[2025] Fix | Delete
* conflicts.
[2026] Fix | Delete
*/
[2027] Fix | Delete
echo "<script type='text/javascript'>\n";
[2028] Fix | Delete
echo "/* <![CDATA[ */\n";
[2029] Fix | Delete
echo 'var wpforms_settings = ' . wp_json_encode( $strings ) . "\n";
[2030] Fix | Delete
echo "/* ]]> */\n";
[2031] Fix | Delete
echo "</script>\n";
[2032] Fix | Delete
[2033] Fix | Delete
/**
[2034] Fix | Delete
* Fires after the end of the footer.
[2035] Fix | Delete
*
[2036] Fix | Delete
* @since 1.0.6
[2037] Fix | Delete
*
[2038] Fix | Delete
* @param array $forms Forms being shown.
[2039] Fix | Delete
*/
[2040] Fix | Delete
do_action( 'wpforms_wp_footer_end', $this->forms ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
[2041] Fix | Delete
}
[2042] Fix | Delete
[2043] Fix | Delete
/**
[2044] Fix | Delete
* Shortcode wrapper for the outputting a form.
[2045] Fix | Delete
*
[2046] Fix | Delete
* @since 1.0.0
[2047] Fix | Delete
*
[2048] Fix | Delete
* @param array|mixed $atts Shortcode attributes provided by a user.
[2049] Fix | Delete
*
[2050] Fix | Delete
* @return string
[2051] Fix | Delete
*/
[2052] Fix | Delete
public function shortcode( $atts ): string {
[2053] Fix | Delete
[2054] Fix | Delete
$atts = (array) $atts;
[2055] Fix | Delete
$defaults = [
[2056] Fix | Delete
'id' => false,
[2057] Fix | Delete
'title' => false,
[2058] Fix | Delete
'description' => false,
[2059] Fix | Delete
];
[2060] Fix | Delete
[2061] Fix | Delete
$atts = shortcode_atts( $defaults, shortcode_atts( $defaults, $atts, 'output' ), 'wpforms' );
[2062] Fix | Delete
[2063] Fix | Delete
ob_start();
[2064] Fix | Delete
[2065] Fix | Delete
$this->css_vars_obj->output_css_vars_for_shortcode( $atts );
[2066] Fix | Delete
[2067] Fix | Delete
$this->output( $atts['id'], $atts['title'], $atts['description'] );
[2068] Fix | Delete
[2069] Fix | Delete
return (string) ob_get_clean();
[2070] Fix | Delete
}
[2071] Fix | Delete
[2072] Fix | Delete
/**
[2073] Fix | Delete
* Inline a script to check if our main js is loaded and display a warning message otherwise.
[2074] Fix | Delete
*
[2075] Fix | Delete
* @since 1.6.4.1
[2076] Fix | Delete
*/
[2077] Fix | Delete
public function missing_assets_error_js(): void {
[2078] Fix | Delete
[2079] Fix | Delete
/**
[2080] Fix | Delete
* Disable missing assets error js checking.
[2081] Fix | Delete
*
[2082] Fix | Delete
* @since 1.6.6
[2083] Fix | Delete
*
[2084] Fix | Delete
* @param bool $skip False by default, set to True to disable checking.
[2085] Fix | Delete
*/
[2086] Fix | Delete
$skip = (bool) apply_filters( 'wpforms_frontend_missing_assets_error_js_disable', false );
[2087] Fix | Delete
[2088] Fix | Delete
if ( $skip || ! wpforms_current_user_can() ) {
[2089] Fix | Delete
return;
[2090] Fix | Delete
}
[2091] Fix | Delete
[2092] Fix | Delete
if ( empty( $this->forms ) && ! $this->assets_global() ) {
[2093] Fix | Delete
return;
[2094] Fix | Delete
}
[2095] Fix | Delete
[2096] Fix | Delete
if ( $this->amp_obj->is_amp() ) {
[2097] Fix | Delete
return;
[2098] Fix | Delete
}
[2099] Fix | Delete
[2100] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[2101] Fix | Delete
printf( $this->get_missing_assets_error_script(), $this->get_missing_assets_error_message() );
[2102] Fix | Delete
}
[2103] Fix | Delete
[2104] Fix | Delete
/**
[2105] Fix | Delete
* Get missing assets error script.
[2106] Fix | Delete
*
[2107] Fix | Delete
* @since 1.6.4.1
[2108] Fix | Delete
*
[2109] Fix | Delete
* @return string
[2110] Fix | Delete
*/
[2111] Fix | Delete
private function get_missing_assets_error_script(): string {
[2112] Fix | Delete
[2113] Fix | Delete
return "<script>
[2114] Fix | Delete
( function() {
[2115] Fix | Delete
function wpforms_js_error_loading() {
[2116] Fix | Delete
[2117] Fix | Delete
if ( typeof window.wpforms !== 'undefined' ) {
[2118] Fix | Delete
return;
[2119] Fix | Delete
}
[2120] Fix | Delete
[2121] Fix | Delete
const forms = document.querySelectorAll( '.wpforms-form' );
[2122] Fix | Delete
[2123] Fix | Delete
if ( ! forms.length ) {
[2124] Fix | Delete
return;
[2125] Fix | Delete
}
[2126] Fix | Delete
[2127] Fix | Delete
const error = document.createElement( 'div' );
[2128] Fix | Delete
[2129] Fix | Delete
error.classList.add( 'wpforms-error-container' );
[2130] Fix | Delete
error.setAttribute( 'role', 'alert' );
[2131] Fix | Delete
error.innerHTML = '%s';
[2132] Fix | Delete
[2133] Fix | Delete
forms.forEach( function( form ) {
[2134] Fix | Delete
if ( form.querySelector( '.wpforms-error-container' ) ) {
[2135] Fix | Delete
return;
[2136] Fix | Delete
}
[2137] Fix | Delete
[2138] Fix | Delete
const formError = error.cloneNode( true ),
[2139] Fix | Delete
formErrorId = form.id + '-error';
[2140] Fix | Delete
[2141] Fix | Delete
formError.setAttribute( 'id', formErrorId );
[2142] Fix | Delete
[2143] Fix | Delete
form.insertBefore( formError, form.firstChild );
[2144] Fix | Delete
form.setAttribute( 'aria-invalid', 'true' );
[2145] Fix | Delete
form.setAttribute( 'aria-errormessage', formErrorId );
[2146] Fix | Delete
} );
[2147] Fix | Delete
}
[2148] Fix | Delete
[2149] Fix | Delete
if ( document.readyState === 'loading' ) {
[2150] Fix | Delete
document.addEventListener( 'DOMContentLoaded', wpforms_js_error_loading );
[2151] Fix | Delete
} else {
[2152] Fix | Delete
wpforms_js_error_loading();
[2153] Fix | Delete
}
[2154] Fix | Delete
}() );
[2155] Fix | Delete
</script>";
[2156] Fix | Delete
}
[2157] Fix | Delete
[2158] Fix | Delete
/**
[2159] Fix | Delete
* Get a missing assets error message.
[2160] Fix | Delete
*
[2161] Fix | Delete
* @since 1.6.4.1
[2162] Fix | Delete
*
[2163] Fix | Delete
* @return string
[2164] Fix | Delete
* @noinspection HtmlUnknownTarget
[2165] Fix | Delete
*/
[2166] Fix | Delete
private function get_missing_assets_error_message(): string {
[2167] Fix | Delete
[2168] Fix | Delete
$message = sprintf(
[2169] Fix | Delete
wp_kses( /* translators: %s - URL to the troubleshooting guide. */
[2170] Fix | Delete
__( 'Heads up! WPForms has detected an issue with JavaScript on this page. JavaScript is required for this form to work properly, so this form may not work as expected. See our <a href="%s" target="_blank" rel="noopener noreferrer">troubleshooting guide</a> to learn more or contact support.', 'wpforms-lite' ),
[2171] Fix | Delete
[
[2172] Fix | Delete
'a' => [
[2173] Fix | Delete
'href' => [],
[2174] Fix | Delete
'target' => [],
[2175] Fix | Delete
'rel' => [],
[2176] Fix | Delete
],
[2177] Fix | Delete
]
[2178] Fix | Delete
),
[2179] Fix | Delete
'https://wpforms.com/docs/getting-support-wpforms/'
[2180] Fix | Delete
);
[2181] Fix | Delete
[2182] Fix | Delete
$message .= '<p>';
[2183] Fix | Delete
$message .= esc_html__( 'This message is only displayed to site administrators.', 'wpforms-lite' );
[2184] Fix | Delete
$message .= '</p>';
[2185] Fix | Delete
[2186] Fix | Delete
return $message;
[2187] Fix | Delete
}
[2188] Fix | Delete
[2189] Fix | Delete
[2190] Fix | Delete
/**
[2191] Fix | Delete
* Render the single field.
[2192] Fix | Delete
*
[2193] Fix | Delete
* @since 1.7.7
[2194] Fix | Delete
*
[2195] Fix | Delete
* @param array $form_data Form data.
[2196] Fix | Delete
* @param array $field Field data.
[2197] Fix | Delete
*/
[2198] Fix | Delete
public function render_field( array $form_data, array $field ): void {
[2199] Fix | Delete
[2200] Fix | Delete
if ( ! has_action( "wpforms_display_field_{$field['type']}" ) ) {
[2201] Fix | Delete
return;
[2202] Fix | Delete
}
[2203] Fix | Delete
[2204] Fix | Delete
/**
[2205] Fix | Delete
* Modify Field before render.
[2206] Fix | Delete
*
[2207] Fix | Delete
* @since 1.4.0
[2208] Fix | Delete
*
[2209] Fix | Delete
* @param array $field Current field.
[2210] Fix | Delete
* @param array $form_data Form data and settings.
[2211] Fix | Delete
*/
[2212] Fix | Delete
$field = (array) apply_filters( 'wpforms_field_data', $field, $form_data ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
[2213] Fix | Delete
[2214] Fix | Delete
if ( empty( $field ) ) {
[2215] Fix | Delete
return;
[2216] Fix | Delete
}
[2217] Fix | Delete
[2218] Fix | Delete
$this->rendered_fields[] = $field['id'];
[2219] Fix | Delete
[2220] Fix | Delete
// Get field attributes. Deprecated; Customizations should use
[2221] Fix | Delete
// field properties instead.
[2222] Fix | Delete
$attributes = $this->get_field_attributes( $field, $form_data );
[2223] Fix | Delete
[2224] Fix | Delete
// Add properties to the field, so it's available everywhere.
[2225] Fix | Delete
$field['properties'] = $this->get_field_properties( $field, $form_data, $attributes );
[2226] Fix | Delete
[2227] Fix | Delete
/**
[2228] Fix | Delete
* Core actions on this hook:
[2229] Fix | Delete
* Priority / Description
[2230] Fix | Delete
* 5 Field opening container markup.
[2231] Fix | Delete
* 15 Field label.
[2232] Fix | Delete
* 20 Field description (depending on position).
[2233] Fix | Delete
*
[2234] Fix | Delete
* @since 1.3.7
[2235] Fix | Delete
*
[2236] Fix | Delete
* @param array $field Field.
[2237] Fix | Delete
* @param array $form_data Form data.
[2238] Fix | Delete
*/
[2239] Fix | Delete
do_action( 'wpforms_display_field_before', $field, $form_data ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
[2240] Fix | Delete
[2241] Fix | Delete
/**
[2242] Fix | Delete
* Individual field classes use this hook to display the actual
[2243] Fix | Delete
* field form elements.
[2244] Fix | Delete
* See `field_display` methods in /includes/fields.
[2245] Fix | Delete
*
[2246] Fix | Delete
* @since 1.3.7
[2247] Fix | Delete
*
[2248] Fix | Delete
* @param array $field Field.
[2249] Fix | Delete
* @param array $attributes Field attributes.
[2250] Fix | Delete
* @param array $form_data Form data.
[2251] Fix | Delete
*/
[2252] Fix | Delete
do_action( "wpforms_display_field_{$field['type']}", $field, $attributes, $form_data ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
[2253] Fix | Delete
[2254] Fix | Delete
/**
[2255] Fix | Delete
* Core actions on this hook:
[2256] Fix | Delete
* Priority / Description
[2257] Fix | Delete
* 3 Field error messages.
[2258] Fix | Delete
* 5 Field description (depending on position).
[2259] Fix | Delete
* 15 Field closing container markup.
[2260] Fix | Delete
* 20 Pagebreak markups (close previous page, open next).
[2261] Fix | Delete
*
[2262] Fix | Delete
* @since 1.3.7
[2263] Fix | Delete
*
[2264] Fix | Delete
* @param array $field Field.
[2265] Fix | Delete
* @param array $form_data Form data.
[2266] Fix | Delete
*/
[2267] Fix | Delete
do_action( 'wpforms_display_field_after', $field, $form_data ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
[2268] Fix | Delete
}
[2269] Fix | Delete
[2270] Fix | Delete
/**
[2271] Fix | Delete
* Whether to print the script in the footer.
[2272] Fix | Delete
*
[2273] Fix | Delete
* @since 1.9.0
[2274] Fix | Delete
*
[2275] Fix | Delete
* @return bool
[2276] Fix | Delete
*/
[2277] Fix | Delete
protected function load_script_in_footer(): bool {
[2278] Fix | Delete
[2279] Fix | Delete
return ! wpforms_is_frontend_js_header_force_load();
[2280] Fix | Delete
}
[2281] Fix | Delete
}
[2282] Fix | Delete
[2283] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function