Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wpforms-.../includes
File: class-process.php
*
[1500] Fix | Delete
* @param array $fields List of form fields.
[1501] Fix | Delete
*
[1502] Fix | Delete
* @return array
[1503] Fix | Delete
*/
[1504] Fix | Delete
private function remove_raw_data_before_save( array $fields ): array {
[1505] Fix | Delete
[1506] Fix | Delete
foreach ( $fields as $key => $field ) {
[1507] Fix | Delete
if ( ! empty( $field['type'] ) && $field['type'] === 'password' ) {
[1508] Fix | Delete
unset( $fields[ $key ]['value_raw'] );
[1509] Fix | Delete
}
[1510] Fix | Delete
}
[1511] Fix | Delete
[1512] Fix | Delete
return $fields;
[1513] Fix | Delete
}
[1514] Fix | Delete
[1515] Fix | Delete
/**
[1516] Fix | Delete
* Save payment to the database.
[1517] Fix | Delete
*
[1518] Fix | Delete
* @since 1.8.2
[1519] Fix | Delete
*
[1520] Fix | Delete
* @param array $entry User submitted data.
[1521] Fix | Delete
*
[1522] Fix | Delete
* @return int Payment ID.
[1523] Fix | Delete
*/
[1524] Fix | Delete
private function payment_save( $entry ) {
[1525] Fix | Delete
[1526] Fix | Delete
if ( ! wpforms_has_payment( 'entry', $this->fields ) ) {
[1527] Fix | Delete
return 0;
[1528] Fix | Delete
}
[1529] Fix | Delete
[1530] Fix | Delete
$entry['entry_id'] = $this->entry_id;
[1531] Fix | Delete
[1532] Fix | Delete
$form_submission = wpforms()->get( 'submission' )->register( $this->fields, $entry, $this->form_data['id'], $this->form_data );
[1533] Fix | Delete
[1534] Fix | Delete
// Prepare the payment data.
[1535] Fix | Delete
$payment_data = $form_submission->prepare_payment_data();
[1536] Fix | Delete
[1537] Fix | Delete
// Bail early in case payment field exists,
[1538] Fix | Delete
// but no payment data was provided (e.g. old payment addon is used).
[1539] Fix | Delete
if ( empty( $payment_data['gateway'] ) ) {
[1540] Fix | Delete
return 0;
[1541] Fix | Delete
}
[1542] Fix | Delete
[1543] Fix | Delete
// Create payment.
[1544] Fix | Delete
$payment_id = wpforms()->get( 'payment' )->add( $payment_data );
[1545] Fix | Delete
[1546] Fix | Delete
if ( ! $payment_id ) {
[1547] Fix | Delete
return 0;
[1548] Fix | Delete
}
[1549] Fix | Delete
[1550] Fix | Delete
// Insert payment meta.
[1551] Fix | Delete
wpforms()->get( 'payment_meta' )->bulk_add( $payment_id, $form_submission->prepare_payment_meta() );
[1552] Fix | Delete
[1553] Fix | Delete
/**
[1554] Fix | Delete
* Fire after payment was saved to database.
[1555] Fix | Delete
*
[1556] Fix | Delete
* @since 1.8.2
[1557] Fix | Delete
*
[1558] Fix | Delete
* @param int $payment_id Payment id.
[1559] Fix | Delete
* @param array $fields Form fields.
[1560] Fix | Delete
* @param array $form_data Form data.
[1561] Fix | Delete
*/
[1562] Fix | Delete
do_action( 'wpforms_process_payment_saved', $payment_id, $this->fields, $this->form_data );
[1563] Fix | Delete
[1564] Fix | Delete
return $payment_id;
[1565] Fix | Delete
}
[1566] Fix | Delete
[1567] Fix | Delete
/**
[1568] Fix | Delete
* Process AJAX form submit.
[1569] Fix | Delete
*
[1570] Fix | Delete
* @since 1.5.3
[1571] Fix | Delete
*/
[1572] Fix | Delete
public function ajax_submit() {
[1573] Fix | Delete
[1574] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.Missing
[1575] Fix | Delete
$form_id = isset( $_POST['wpforms']['id'] ) ? absint( $_POST['wpforms']['id'] ) : 0;
[1576] Fix | Delete
[1577] Fix | Delete
if ( empty( $form_id ) ) {
[1578] Fix | Delete
wp_send_json_error();
[1579] Fix | Delete
}
[1580] Fix | Delete
[1581] Fix | Delete
if ( isset( $_POST['wpforms']['post_id'] ) ) {
[1582] Fix | Delete
// We don't have a global $post when processing ajax requests.
[1583] Fix | Delete
// Therefore, it's needed to set a global $post manually for compatibility with functions used in smart tag processing.
[1584] Fix | Delete
global $post;
[1585] Fix | Delete
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
[1586] Fix | Delete
$post = WP_Post::get_instance( absint( $_POST['wpforms']['post_id'] ) );
[1587] Fix | Delete
}
[1588] Fix | Delete
// phpcs:enable WordPress.Security.NonceVerification.Missing
[1589] Fix | Delete
[1590] Fix | Delete
add_filter( 'wp_redirect', [ $this, 'ajax_process_redirect' ], 999 );
[1591] Fix | Delete
[1592] Fix | Delete
do_action( 'wpforms_ajax_submit_before_processing', $form_id );
[1593] Fix | Delete
[1594] Fix | Delete
// If redirect happens in listen(), ajax_process_redirect() gets executed because of the filter on `wp_redirect`.
[1595] Fix | Delete
// The code, that is below listen(), runs only if no redirect happened.
[1596] Fix | Delete
$this->listen();
[1597] Fix | Delete
[1598] Fix | Delete
$form_data = $this->form_data;
[1599] Fix | Delete
[1600] Fix | Delete
if ( empty( $form_data ) ) {
[1601] Fix | Delete
$form_data = wpforms()->get( 'form' )->get( $form_id, [ 'content_only' => true ] );
[1602] Fix | Delete
$form_data = apply_filters( 'wpforms_frontend_form_data', $form_data );
[1603] Fix | Delete
}
[1604] Fix | Delete
[1605] Fix | Delete
if ( ! empty( $this->errors[ $form_id ] ) ) {
[1606] Fix | Delete
$this->ajax_process_errors( $form_id, $form_data );
[1607] Fix | Delete
wp_send_json_error();
[1608] Fix | Delete
}
[1609] Fix | Delete
[1610] Fix | Delete
ob_start();
[1611] Fix | Delete
[1612] Fix | Delete
wpforms()->get( 'frontend' )->confirmation( $form_data );
[1613] Fix | Delete
[1614] Fix | Delete
$response = apply_filters( 'wpforms_ajax_submit_success_response', [ 'confirmation' => ob_get_clean() ], $form_id, $form_data );
[1615] Fix | Delete
[1616] Fix | Delete
do_action( 'wpforms_ajax_submit_completed', $form_id, $response );
[1617] Fix | Delete
[1618] Fix | Delete
wp_send_json_success( $response );
[1619] Fix | Delete
}
[1620] Fix | Delete
[1621] Fix | Delete
/**
[1622] Fix | Delete
* Process AJAX errors.
[1623] Fix | Delete
*
[1624] Fix | Delete
* @since 1.5.3
[1625] Fix | Delete
* @todo This should be re-used/combined for AMP verify-xhr requests.
[1626] Fix | Delete
*
[1627] Fix | Delete
* @param int $form_id Form ID.
[1628] Fix | Delete
* @param array $form_data Form data and settings.
[1629] Fix | Delete
*/
[1630] Fix | Delete
protected function ajax_process_errors( $form_id, $form_data ) {
[1631] Fix | Delete
[1632] Fix | Delete
$errors = isset( $this->errors[ $form_id ] ) ? $this->errors[ $form_id ] : [];
[1633] Fix | Delete
[1634] Fix | Delete
$errors = apply_filters( 'wpforms_ajax_submit_errors', $errors, $form_id, $form_data );
[1635] Fix | Delete
[1636] Fix | Delete
if ( empty( $errors ) ) {
[1637] Fix | Delete
wp_send_json_error();
[1638] Fix | Delete
}
[1639] Fix | Delete
[1640] Fix | Delete
// General errors are errors that cannot be populated with jQuery Validate plugin.
[1641] Fix | Delete
$general_errors = array_intersect_key( $errors, array_flip( [ 'header', 'footer', 'recaptcha' ] ) );
[1642] Fix | Delete
[1643] Fix | Delete
foreach ( $general_errors as $key => $error ) {
[1644] Fix | Delete
ob_start();
[1645] Fix | Delete
wpforms()->get( 'frontend' )->form_error( $key, $error, $form_data );
[1646] Fix | Delete
$general_errors[ $key ] = ob_get_clean();
[1647] Fix | Delete
}
[1648] Fix | Delete
[1649] Fix | Delete
$fields = isset( $form_data['fields'] ) ? $form_data['fields'] : [];
[1650] Fix | Delete
[1651] Fix | Delete
// Get registered fields errors only.
[1652] Fix | Delete
$field_errors = array_intersect_key( $errors, $fields );
[1653] Fix | Delete
[1654] Fix | Delete
// Transform field ids to field names for jQuery Validate plugin.
[1655] Fix | Delete
foreach ( $field_errors as $key => $error ) {
[1656] Fix | Delete
[1657] Fix | Delete
$name = $this->ajax_error_field_name( $fields[ $key ], $form_data, $error );
[1658] Fix | Delete
[1659] Fix | Delete
if ( $name ) {
[1660] Fix | Delete
$field_errors[ $name ] = $error;
[1661] Fix | Delete
}
[1662] Fix | Delete
[1663] Fix | Delete
unset( $field_errors[ $key ] );
[1664] Fix | Delete
}
[1665] Fix | Delete
[1666] Fix | Delete
$response = [];
[1667] Fix | Delete
[1668] Fix | Delete
if ( $general_errors ) {
[1669] Fix | Delete
$response['errors']['general'] = $general_errors;
[1670] Fix | Delete
}
[1671] Fix | Delete
[1672] Fix | Delete
if ( $field_errors ) {
[1673] Fix | Delete
$response['errors']['field'] = $field_errors;
[1674] Fix | Delete
}
[1675] Fix | Delete
[1676] Fix | Delete
$response = apply_filters( 'wpforms_ajax_submit_errors_response', $response, $form_id, $form_data );
[1677] Fix | Delete
[1678] Fix | Delete
do_action( 'wpforms_ajax_submit_completed', $form_id, $response );
[1679] Fix | Delete
[1680] Fix | Delete
wp_send_json_error( $response );
[1681] Fix | Delete
}
[1682] Fix | Delete
[1683] Fix | Delete
/**
[1684] Fix | Delete
* Get field name for an ajax error message.
[1685] Fix | Delete
*
[1686] Fix | Delete
* @since 1.6.3
[1687] Fix | Delete
*
[1688] Fix | Delete
* @param array $field Field settings.
[1689] Fix | Delete
* @param array $form_data Form data and settings.
[1690] Fix | Delete
* @param string|string[] $error Error message.
[1691] Fix | Delete
*
[1692] Fix | Delete
* @return string
[1693] Fix | Delete
*/
[1694] Fix | Delete
private function ajax_error_field_name( array $field, array $form_data, $error ): string {
[1695] Fix | Delete
[1696] Fix | Delete
$props = wpforms()->get( 'frontend' )->get_field_properties( $field, $form_data );
[1697] Fix | Delete
[1698] Fix | Delete
/**
[1699] Fix | Delete
* Filter the field name for an ajax error message.
[1700] Fix | Delete
*
[1701] Fix | Delete
* @since 1.6.3
[1702] Fix | Delete
*
[1703] Fix | Delete
* @param string $name Error field name.
[1704] Fix | Delete
* @param array $field Field.
[1705] Fix | Delete
* @param array $props Field properties.
[1706] Fix | Delete
* @param string|string[] $error Error message.
[1707] Fix | Delete
*/
[1708] Fix | Delete
return (string) apply_filters( 'wpforms_process_ajax_error_field_name', '', $field, $props, $error );
[1709] Fix | Delete
}
[1710] Fix | Delete
[1711] Fix | Delete
/**
[1712] Fix | Delete
* Process AJAX redirect.
[1713] Fix | Delete
*
[1714] Fix | Delete
* @since 1.5.3
[1715] Fix | Delete
*
[1716] Fix | Delete
* @param string $url Redirect URL.
[1717] Fix | Delete
*/
[1718] Fix | Delete
public function ajax_process_redirect( $url ) {
[1719] Fix | Delete
[1720] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Missing
[1721] Fix | Delete
$form_id = isset( $_POST['wpforms']['id'] ) ? absint( $_POST['wpforms']['id'] ) : 0;
[1722] Fix | Delete
[1723] Fix | Delete
if ( empty( $form_id ) ) {
[1724] Fix | Delete
wp_send_json_error();
[1725] Fix | Delete
}
[1726] Fix | Delete
[1727] Fix | Delete
$response = [
[1728] Fix | Delete
'form_id' => $form_id,
[1729] Fix | Delete
'redirect_url' => $url,
[1730] Fix | Delete
];
[1731] Fix | Delete
[1732] Fix | Delete
$response = apply_filters( 'wpforms_ajax_submit_redirect', $response, $form_id, $url );
[1733] Fix | Delete
[1734] Fix | Delete
do_action( 'wpforms_ajax_submit_completed', $form_id, $response );
[1735] Fix | Delete
[1736] Fix | Delete
wp_send_json_success( $response );
[1737] Fix | Delete
}
[1738] Fix | Delete
}
[1739] Fix | Delete
[1740] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function