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
/home/sportsfe.../httpdocs/wp-conte.../plugins/wpforms-.../src/Admin/Payments/Views/Overview/Traits
File: ResetNotices.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace WPForms\Admin\Payments\Views\Overview\Traits;
[2] Fix | Delete
[3] Fix | Delete
use WPForms\Admin\Payments\Views\Overview\Coupon;
[4] Fix | Delete
use WPForms\Admin\Payments\Views\Overview\Search;
[5] Fix | Delete
use WPForms\Db\Payments\ValueValidator;
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* This file is part of the Table class and contains methods responsible for
[9] Fix | Delete
* displaying notices on the Payments Overview page.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 1.8.4
[12] Fix | Delete
*/
[13] Fix | Delete
trait ResetNotices {
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* Show reset filter box.
[17] Fix | Delete
*
[18] Fix | Delete
* @since 1.8.4
[19] Fix | Delete
*/
[20] Fix | Delete
private function show_reset_filter() {
[21] Fix | Delete
[22] Fix | Delete
$applied_filters = [
[23] Fix | Delete
$this->get_search_reset_filter(),
[24] Fix | Delete
$this->get_status_reset_filter(),
[25] Fix | Delete
$this->get_coupon_reset_filter(),
[26] Fix | Delete
$this->get_form_reset_filter(),
[27] Fix | Delete
$this->get_type_reset_filter(),
[28] Fix | Delete
$this->get_gateway_reset_filter(),
[29] Fix | Delete
$this->get_subscription_status_reset_filter(),
[30] Fix | Delete
];
[31] Fix | Delete
[32] Fix | Delete
$applied_filters = array_filter( $applied_filters );
[33] Fix | Delete
[34] Fix | Delete
// Let's not show the reset filter notice if there are no applied filters.
[35] Fix | Delete
if ( empty( $applied_filters ) ) {
[36] Fix | Delete
return;
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
// Output the reset filter notice.
[40] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[41] Fix | Delete
echo wpforms_render(
[42] Fix | Delete
'admin/payments/reset-filter-notice',
[43] Fix | Delete
[
[44] Fix | Delete
'total' => $this->get_valid_status_count_from_request(),
[45] Fix | Delete
'applied_filters' => $applied_filters,
[46] Fix | Delete
],
[47] Fix | Delete
true
[48] Fix | Delete
);
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* Show search reset filter.
[53] Fix | Delete
*
[54] Fix | Delete
* @since 1.8.4
[55] Fix | Delete
*
[56] Fix | Delete
* @return array
[57] Fix | Delete
*/
[58] Fix | Delete
private function get_search_reset_filter() {
[59] Fix | Delete
[60] Fix | Delete
// Do not show the reset filter notice on the search results page.
[61] Fix | Delete
if ( ! Search::is_search() ) {
[62] Fix | Delete
return [];
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
$search_where = $this->get_search_where( $this->get_search_where_key() );
[66] Fix | Delete
$search_mode = $this->get_search_mode( $this->get_search_mode_key() );
[67] Fix | Delete
[68] Fix | Delete
return [
[69] Fix | Delete
'reset_url' => remove_query_arg( [ 's', 'search_where', 'search_mode', 'paged' ] ),
[70] Fix | Delete
'results' => sprintf(
[71] Fix | Delete
' %s <em>%s</em> %s "<em>%s</em>"',
[72] Fix | Delete
__( 'where', 'wpforms-lite' ),
[73] Fix | Delete
esc_html( $search_where ),
[74] Fix | Delete
esc_html( $search_mode ),
[75] Fix | Delete
// It's important to escape the search term here for security.
[76] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[77] Fix | Delete
esc_html( isset( $_GET['s'] ) ? wp_unslash( $_GET['s'] ) : '' )
[78] Fix | Delete
),
[79] Fix | Delete
];
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
/**
[83] Fix | Delete
* Show status reset filter.
[84] Fix | Delete
*
[85] Fix | Delete
* @since 1.8.4
[86] Fix | Delete
*
[87] Fix | Delete
* @return array
[88] Fix | Delete
*/
[89] Fix | Delete
private function get_status_reset_filter() {
[90] Fix | Delete
[91] Fix | Delete
// Do not show the reset filter notice on the status results page.
[92] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[93] Fix | Delete
if ( empty( $this->get_valid_status_from_request() ) || $this->is_trash_view() ) {
[94] Fix | Delete
return [];
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
$statuses = ValueValidator::get_allowed_one_time_statuses();
[98] Fix | Delete
[99] Fix | Delete
// Leave early if the status is not found.
[100] Fix | Delete
if ( ! isset( $statuses[ $this->get_valid_status_from_request() ] ) ) {
[101] Fix | Delete
return [];
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
return [
[105] Fix | Delete
'reset_url' => remove_query_arg( [ 'status' ] ),
[106] Fix | Delete
'results' => sprintf(
[107] Fix | Delete
' %s "<em>%s</em>"',
[108] Fix | Delete
__( 'with the status', 'wpforms-lite' ),
[109] Fix | Delete
$statuses[ $this->get_valid_status_from_request() ]
[110] Fix | Delete
),
[111] Fix | Delete
];
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* Show coupon reset filter.
[116] Fix | Delete
*
[117] Fix | Delete
* @since 1.8.4
[118] Fix | Delete
*
[119] Fix | Delete
* @return array
[120] Fix | Delete
*/
[121] Fix | Delete
private function get_coupon_reset_filter() {
[122] Fix | Delete
[123] Fix | Delete
// Do not show the reset filter notice on the coupon results page.
[124] Fix | Delete
if ( ! Coupon::is_coupon() ) {
[125] Fix | Delete
return [];
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
// Get the payment meta with the specified coupon ID.
[129] Fix | Delete
$payment_meta = wpforms()->get( 'payment_meta' )->get_all_by_meta(
[130] Fix | Delete
'coupon_id',
[131] Fix | Delete
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Recommended
[132] Fix | Delete
absint( $_GET['coupon_id'] )
[133] Fix | Delete
);
[134] Fix | Delete
[135] Fix | Delete
// If the coupon info is empty, exit the function.
[136] Fix | Delete
if ( empty( $payment_meta['coupon_info'] ) ) {
[137] Fix | Delete
return [];
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
return [
[141] Fix | Delete
'reset_url' => remove_query_arg( [ 'coupon_id', 'paged' ] ),
[142] Fix | Delete
'results' => sprintf(
[143] Fix | Delete
' %s "<em>%s</em>"',
[144] Fix | Delete
__( 'with the coupon', 'wpforms-lite' ),
[145] Fix | Delete
$this->get_coupon_name_by_info( $payment_meta['coupon_info']->value )
[146] Fix | Delete
),
[147] Fix | Delete
];
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
/**
[151] Fix | Delete
* Show form reset filter.
[152] Fix | Delete
*
[153] Fix | Delete
* @since 1.8.4
[154] Fix | Delete
*
[155] Fix | Delete
* @return array
[156] Fix | Delete
*/
[157] Fix | Delete
private function get_form_reset_filter() {
[158] Fix | Delete
[159] Fix | Delete
// Do not show the reset filter notice on the form results page.
[160] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[161] Fix | Delete
if ( empty( $_GET['form_id'] ) ) {
[162] Fix | Delete
return [];
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
// Retrieve the form with the specified ID.
[166] Fix | Delete
$form = wpforms()->get( 'form' )->get( absint( $_GET['form_id'] ) );
[167] Fix | Delete
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[168] Fix | Delete
[169] Fix | Delete
// If the form is not found or not published, exit the function.
[170] Fix | Delete
if ( ! $form || $form->post_status !== 'publish' ) {
[171] Fix | Delete
return [];
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
return [
[175] Fix | Delete
'reset_url' => remove_query_arg( [ 'form_id', 'paged' ] ),
[176] Fix | Delete
'results' => sprintf(
[177] Fix | Delete
' %s "<em>%s</em>"',
[178] Fix | Delete
__( 'with the form titled', 'wpforms-lite' ),
[179] Fix | Delete
! empty( $form->post_title ) ? $form->post_title : $form->post_name
[180] Fix | Delete
),
[181] Fix | Delete
];
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
/**
[185] Fix | Delete
* Show type reset filter.
[186] Fix | Delete
*
[187] Fix | Delete
* @since 1.8.4
[188] Fix | Delete
*
[189] Fix | Delete
* @return array
[190] Fix | Delete
*/
[191] Fix | Delete
private function get_type_reset_filter() {
[192] Fix | Delete
[193] Fix | Delete
// Do not show the reset filter notice on the type results page.
[194] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[195] Fix | Delete
if ( empty( $_GET['type'] ) ) {
[196] Fix | Delete
return [];
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
$allowed_types = ValueValidator::get_allowed_types();
[200] Fix | Delete
$type = explode( '|', sanitize_text_field( wp_unslash( $_GET['type'] ) ) );
[201] Fix | Delete
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[202] Fix | Delete
[203] Fix | Delete
return [
[204] Fix | Delete
'reset_url' => remove_query_arg( [ 'type', 'paged' ] ),
[205] Fix | Delete
'results' => sprintf(
[206] Fix | Delete
' %s "<em>%s</em>"',
[207] Fix | Delete
_n( 'with the type', 'with the types', count( $type ), 'wpforms-lite' ),
[208] Fix | Delete
implode( ', ', array_intersect_key( $allowed_types, array_flip( $type ) ) )
[209] Fix | Delete
),
[210] Fix | Delete
];
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
/**
[214] Fix | Delete
* Show gateway reset filter.
[215] Fix | Delete
*
[216] Fix | Delete
* @since 1.8.4
[217] Fix | Delete
*
[218] Fix | Delete
* @return array
[219] Fix | Delete
*/
[220] Fix | Delete
private function get_gateway_reset_filter() {
[221] Fix | Delete
[222] Fix | Delete
// Do not show the reset filter notice on the gateway results page.
[223] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[224] Fix | Delete
if ( empty( $_GET['gateway'] ) ) {
[225] Fix | Delete
return [];
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
$allowed_gateways = ValueValidator::get_allowed_gateways();
[229] Fix | Delete
$gateway = explode( '|', sanitize_text_field( wp_unslash( $_GET['gateway'] ) ) );
[230] Fix | Delete
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[231] Fix | Delete
[232] Fix | Delete
return [
[233] Fix | Delete
'reset_url' => remove_query_arg( [ 'gateway', 'paged' ] ),
[234] Fix | Delete
'results' => sprintf(
[235] Fix | Delete
' %s "<em>%s</em>"',
[236] Fix | Delete
_n( 'with the gateway', 'with the gateways', count( $gateway ), 'wpforms-lite' ),
[237] Fix | Delete
implode( ', ', array_intersect_key( $allowed_gateways, array_flip( $gateway ) ) )
[238] Fix | Delete
),
[239] Fix | Delete
];
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
/**
[243] Fix | Delete
* Show subscription status reset filter.
[244] Fix | Delete
*
[245] Fix | Delete
* @since 1.8.4
[246] Fix | Delete
*
[247] Fix | Delete
* @return array
[248] Fix | Delete
*/
[249] Fix | Delete
private function get_subscription_status_reset_filter() {
[250] Fix | Delete
[251] Fix | Delete
// Do not show the reset filter notice on the subscription status results page.
[252] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[253] Fix | Delete
if ( empty( $_GET['subscription_status'] ) ) {
[254] Fix | Delete
return [];
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
$allowed_subscription_statuses = ValueValidator::get_allowed_subscription_statuses();
[258] Fix | Delete
$subscription_status = explode( '|', sanitize_text_field( wp_unslash( $_GET['subscription_status'] ) ) );
[259] Fix | Delete
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[260] Fix | Delete
[261] Fix | Delete
return [
[262] Fix | Delete
'reset_url' => remove_query_arg( [ 'subscription_status', 'paged' ] ),
[263] Fix | Delete
'results' => sprintf(
[264] Fix | Delete
' %s "<em>%s</em>"',
[265] Fix | Delete
_n( 'with the subscription status', 'with the subscription statuses', count( $subscription_status ), 'wpforms-lite' ),
[266] Fix | Delete
implode( ', ', array_intersect_key( $allowed_subscription_statuses, array_flip( $subscription_status ) ) )
[267] Fix | Delete
),
[268] Fix | Delete
];
[269] Fix | Delete
}
[270] Fix | Delete
}
[271] Fix | Delete
[272] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function