: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace WPForms\Admin\Payments\Views\Overview;
use WPForms\Admin\Notice;
* Bulk actions on the Payments Overview page.
const ALLOWED_ACTIONS = [
* Get the current action selected from the bulk actions dropdown.
* @return string|false The action name or False if no action was selected
private function current_action() {
// phpcs:disable WordPress.Security.NonceVerification.Recommended
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] !== '-1' ) {
return sanitize_key( $_REQUEST['action'] );
if ( isset( $_REQUEST['action2'] ) && $_REQUEST['action2'] !== '-1' ) {
return sanitize_key( $_REQUEST['action2'] );
// phpcs:enable WordPress.Security.NonceVerification.Recommended
private function process() {
if ( empty( $_GET['_wpnonce'] ) || empty( $_GET['payment_id'] ) ) {
if ( ! wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'bulk-wpforms_page_wpforms-payments' ) ) {
wp_die( esc_html__( 'Your session expired. Please reload the page.', 'wpforms-lite' ) );
$this->ids = array_map( 'absint', (array) $_GET['payment_id'] );
$this->action = $this->current_action();
if ( empty( $this->ids ) || ! $this->action || ! $this->is_allowed_action( $this->action ) ) {
private function process_action() {
$method = "process_action_{$this->action}";
// Check that we have a method for this action.
if ( ! method_exists( $this, $method ) ) {
foreach ( $this->ids as $id ) {
$processed = $this->$method( $id ) ? $processed + 1 : $processed;
$this->display_bulk_action_message( $processed );
* @param int $id Payment ID to trash.
private function process_action_trash( $id ) {
return wpforms()->get( 'payment' )->update( $id, [ 'is_published' => 0 ] );
* @param int $id Payment ID to restore from trash.
private function process_action_restore( $id ) {
return wpforms()->get( 'payment' )->update( $id, [ 'is_published' => 1 ] );
* @param int $id Payment ID to delete.
private function process_action_delete( $id ) {
return wpforms()->get( 'payment' )->delete( $id );
* Display a bulk action message.
* @param int $count Count of processed payment IDs.
private function display_bulk_action_message( $count ) {
switch ( $this->action ) {
/* translators: %d - number of deleted payments. */
$message = sprintf( _n( '%d payment was successfully permanently deleted.', '%d payments were successfully permanently deleted.', $count, 'wpforms-lite' ), number_format_i18n( $count ) );
/* translators: %d - number of restored payments. */
$message = sprintf( _n( '%d payment was successfully restored.', '%d payments were successfully restored.', $count, 'wpforms-lite' ), number_format_i18n( $count ) );
/* translators: %d - number of trashed payments. */
$message = sprintf( _n( '%d payment was successfully moved to the Trash.', '%d payments were successfully moved to the Trash.', $count, 'wpforms-lite' ), number_format_i18n( $count ) );
if ( empty( $message ) ) {
Notice::success( $message );
* Determine whether the action is allowed.
* @param string $action Action name.
private function is_allowed_action( $action ) {
return in_array( $action, self::ALLOWED_ACTIONS, true );