ap_delete_notifications( array $args = array() )
Description #
Delete notifications.
Parameters #
- $argsarray (Optional) Arguments. Default value: array()
Source #
File: addons/notifications/functions.php
function ap_delete_notifications( $args = array() ) { global $wpdb; $where = array(); if ( isset( $args['user_id'] ) ) { $where['noti_user_id'] = 'AND noti_user_id = ' . (int) $args['user_id']; } if ( isset( $args['actor'] ) ) { $where['noti_actor'] = 'AND noti_actor = ' . (int) $args['actor']; } if ( isset( $args['parent'] ) ) { $where['noti_noti_parent'] = 'AND noti_parent = ' . (int) $args['parent']; } if ( isset( $args['ref_id'] ) ) { $where['noti_ref_id'] = 'AND noti_ref_id = ' . (int) $args['ref_id']; } if ( isset( $args['ref_type'] ) ) { $where['noti_ref_type'] = 'AND noti_ref_type'; if ( is_array( $args['ref_type'] ) ) { $args['ref_type'] = array_map( 'sanitize_text_field', $args['ref_type'] ); $args['ref_type'] = esc_sql( $args['ref_type'] ); if ( ! empty( $where['noti_ref_type'] ) ) { $where['noti_ref_type'] .= ' IN(' . sanitize_comma_delimited( $args['ref_type'], 'str' ) . ')'; } } else { $where['noti_ref_type'] .= '= "' . esc_sql( sanitize_text_field( $args['ref_type'] ) ) . '"'; } } if ( isset( $args['verb'] ) ) { $where['noti_verb'] = 'AND noti_verb = "' . esc_sql( sanitize_text_field( $args['verb'] ) ) . '"'; } if ( isset( $args['seen'] ) ) { $where['noti_seen'] = 'AND noti_seen = "' . esc_sql( sanitize_text_field( $args['seen'] ) ) . '"'; } if ( empty( $where ) ) { return; } $where_claue = implode( ' ', $where ); $delete = $wpdb->query( "DELETE FROM {$wpdb->prefix}ap_notifications WHERE 1=1 {$where_claue}" ); // phpcs:ignore WordPress.DB if ( false === $delete ) { return $delete; } do_action( 'ap_deleted_notifications', $args ); return $delete; }
Expand full source code Collapse full source code View on GitHub: addons/notifications/functions.php:163
Add your comment