Skip to content

Commit a1aa94c

Browse files
Merge pull request #1148 from WPChill/2.11.4
2.11.4
2 parents f404781 + 3d21dec commit a1aa94c

File tree

13 files changed

+54
-20
lines changed

13 files changed

+54
-20
lines changed

Modula.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin URI: https://wp-modula.com/
55
* Description: Modula is the most powerful, user-friendly WordPress gallery plugin. Add galleries, masonry grids and more in a few clicks.
66
* Author: WPChill
7-
* Version: 2.11.3
7+
* Version: 2.11.4
88
* Author URI: https://www.wpchill.com/
99
* License: GPLv3 or later
1010
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -47,7 +47,7 @@
4747
* @since 2.0.2
4848
*/
4949

50-
define( 'MODULA_LITE_VERSION', '2.11.3' );
50+
define( 'MODULA_LITE_VERSION', '2.11.4' );
5151
define( 'MODULA_PATH', plugin_dir_path( __FILE__ ) );
5252
define( 'MODULA_URL', plugin_dir_url( __FILE__ ) );
5353
defined( 'MODULA_PRO_STORE_URL' ) || define( 'MODULA_PRO_STORE_URL', 'https://wp-modula.com' );

apps/notification-system/notification/notification-actions.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Button } from '@wordpress/components';
33
import he from 'he';
44

55
export function NotificationActions( { actions, id, onDismiss } ) {
6-
76
const handleClick = (action, id) => {
87
if (action.callback && typeof window[action.callback] === 'function') {
98
window[action.callback](action, id);
@@ -20,7 +19,7 @@ export function NotificationActions( { actions, id, onDismiss } ) {
2019
<Button
2120
key={index}
2221
className={action.class || 'notification-action'}
23-
{...(action.url ? { href: action.url } : {})}
22+
{...(action.url ? { href: he.decode(action.url) } : {})}
2423
{...(action.id ? { id: action.id } : {})}
2524
target={action.target || ''}
2625
text={he.decode(action.label || __('Action', 'modula-best-grid-gallery'))}

apps/notification-system/notification/notifications-list.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export function NotificationsList() {
2626
};
2727

2828
useEffect(() => {
29-
3029
visibleNotifications.forEach( (notification) => {
3130
if (notification.timed && openPanels.includes( notification.id ) ) {
3231
setTimeout(() => {

apps/notification-system/query/useNotificationDismiss.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { useMutation } from '@tanstack/react-query';
22
import apiFetch from '@wordpress/api-fetch';
33

4-
const dismissNotice = async ( data ) => {
5-
console.error(data);
4+
const dismissNotice = async ( {id, permanent} ) => {
65
const response = await apiFetch( {
7-
path: '/modula-api/v1/notifications/',
6+
path: `/modula/v1/notifications/${id || ''}`,
87
method: 'DELETE',
9-
data: data,
8+
data: { permanent },
109
} );
1110
return response;
1211
};

apps/notification-system/query/useNotificationQuery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const useNotificationQuery = () => {
55
queryKey: ['notifications'],
66
queryFn: async () => {
77
const data = await apiFetch({
8-
path: `/modula-api/v1/notifications`,
8+
path: `/modula/v1/notifications`,
99
method: 'GET',
1010
});
1111
return data;

apps/notification-system/query/useNotificationsDismiss.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import apiFetch from '@wordpress/api-fetch';
33

44
const dismissNotices = () => {
55
const response = apiFetch( {
6-
path: '/modula-api/v1/notifications',
6+
path: '/modula/v1/notifications',
77
method: 'DELETE',
88
} );
99
return response;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '2b99bd8c07dd045879b3');
1+
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => 'e9b0768b4f909a8b9e65');

assets/js/admin/notification-system/notification-system.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
= 2.11.3 - 27.11.2024 =
33
Fixed: PHP Warning
44
Fixed: Gallery item has data-width and data-height on non-required gallery types
5+
Fixed: Notification action URL encoding
56

67
= 2.11.2 - 20.11.2024 =
78
Added: Increased functionality for sanitization of gallery settings.

includes/admin/class-modula-rest-api.php

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
}
66

77
class Modula_Rest_Api {
8-
protected $namespace = 'modula-api/v1';
8+
protected $namespace = 'modula/v1';
99

1010
public function __construct() {
1111
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
@@ -17,7 +17,7 @@ public function register_routes() {
1717
'/notifications',
1818
array(
1919
'methods' => 'GET',
20-
'callback' => array( $this, 'process_request' ),
20+
'callback' => array( $this, 'get_notifications' ),
2121
'permission_callback' => array( $this, '_permissions_check' ),
2222
)
2323
);
@@ -27,7 +27,7 @@ public function register_routes() {
2727
'/notifications',
2828
array(
2929
'methods' => 'DELETE',
30-
'callback' => array( $this, 'process_request' ),
30+
'callback' => array( $this, 'delete_notifications' ),
3131
'permission_callback' => array( $this, '_permissions_check' ),
3232
)
3333
);
@@ -37,7 +37,7 @@ public function register_routes() {
3737
'/notifications/(?P<id>[\w-]+)',
3838
array(
3939
'methods' => 'DELETE',
40-
'callback' => array( $this, 'process_request' ),
40+
'callback' => array( $this, 'delete_notification' ),
4141
'permission_callback' => array( $this, '_permissions_check' ),
4242
)
4343
);
@@ -74,6 +74,41 @@ function ( $carry, $item ) {
7474
return rest_ensure_response( array() );
7575
}
7676

77+
public function delete_notifications() {
78+
$manager = Modula_Notifications::get_instance();
79+
$manager->clear_notifications();
80+
return rest_ensure_response( true );
81+
}
82+
83+
public function delete_notification( $request ) {
84+
$manager = Modula_Notifications::get_instance();
85+
$body = $request->get_json_params();
86+
$notification_id = $request->get_param( 'id' );
87+
88+
if ( ! $notification_id ) {
89+
return rest_ensure_response( false );
90+
}
91+
92+
$permanent = isset( $body['permanent'] ) ? $body['permanent'] : false;
93+
$manager->clear_notification( $notification_id, $permanent );
94+
return rest_ensure_response( true );
95+
}
96+
97+
public function get_notifications() {
98+
$manager = Modula_Notifications::get_instance();
99+
$notifications = $manager->get_notifications();
100+
101+
$is_empty = array_reduce(
102+
$notifications,
103+
function ( $carry, $item ) {
104+
return $carry && empty( $item );
105+
},
106+
true
107+
);
108+
109+
return rest_ensure_response( $is_empty ? array() : $notifications );
110+
}
111+
77112
public function _permissions_check() {
78113
return current_user_can( 'manage_options' );
79114
}

0 commit comments

Comments
 (0)