Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/elemento.../modules/notifica...
File: options.php
<?php
[0] Fix | Delete
namespace Elementor\Modules\Notifications;
[1] Fix | Delete
[2] Fix | Delete
class Options {
[3] Fix | Delete
[4] Fix | Delete
public static function has_unread_notifications(): bool {
[5] Fix | Delete
$current_user = wp_get_current_user();
[6] Fix | Delete
[7] Fix | Delete
if ( ! $current_user ) {
[8] Fix | Delete
return false;
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
$unread_notifications = get_transient( "elementor_unread_notifications_{$current_user->ID}" );
[12] Fix | Delete
[13] Fix | Delete
if ( false === $unread_notifications ) {
[14] Fix | Delete
$notifications = API::get_notifications_by_conditions();
[15] Fix | Delete
$notifications_ids = wp_list_pluck( $notifications, 'id' );
[16] Fix | Delete
[17] Fix | Delete
$unread_notifications = array_diff( $notifications_ids, static::get_notifications_dismissed() );
[18] Fix | Delete
[19] Fix | Delete
set_transient( "elementor_unread_notifications_{$current_user->ID}", $unread_notifications, HOUR_IN_SECONDS );
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
return ! empty( $unread_notifications );
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
public static function get_notifications_dismissed() {
[26] Fix | Delete
$current_user = wp_get_current_user();
[27] Fix | Delete
[28] Fix | Delete
if ( ! $current_user ) {
[29] Fix | Delete
return [];
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
$notifications_dismissed = get_user_meta( $current_user->ID, '_e_notifications_dismissed', true );
[33] Fix | Delete
[34] Fix | Delete
if ( ! is_array( $notifications_dismissed ) ) {
[35] Fix | Delete
$notifications_dismissed = [];
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
return $notifications_dismissed;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
public static function mark_notification_read( $notifications ): bool {
[42] Fix | Delete
$current_user = wp_get_current_user();
[43] Fix | Delete
[44] Fix | Delete
if ( ! $current_user ) {
[45] Fix | Delete
return false;
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
$notifications_dismissed = static::get_notifications_dismissed();
[49] Fix | Delete
[50] Fix | Delete
foreach ( $notifications as $notification ) {
[51] Fix | Delete
if ( ! in_array( $notification['id'], $notifications_dismissed, true ) ) {
[52] Fix | Delete
$notifications_dismissed[] = $notification['id'];
[53] Fix | Delete
}
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
$notifications_dismissed = array_unique( $notifications_dismissed );
[57] Fix | Delete
[58] Fix | Delete
update_user_meta( $current_user->ID, '_e_notifications_dismissed', $notifications_dismissed );
[59] Fix | Delete
[60] Fix | Delete
delete_transient( "elementor_unread_notifications_{$current_user->ID}" );
[61] Fix | Delete
[62] Fix | Delete
return true;
[63] Fix | Delete
}
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function