Skip to content

Commit c750276

Browse files
authored
Merge pull request #7662 from Automattic/release/4.24.2
Release 4.24.2
2 parents 6e29d1f + 56ee2b8 commit c750276

22 files changed

+983
-917
lines changed

changelog.txt

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
*** Changelog ***
22

3+
## 4.24.2 - 2024-08-08
4+
### Security
5+
- Improve email templates security
6+
7+
### Changed
8+
- Pass `checks` argument to `sensei_can_user_view_lesson` filter [#7657](https://github.com/Automattic/sensei/pull/7657)
9+
- "Course Started" email is now "Course Enrolled" [#7661](https://github.com/Automattic/sensei/pull/7661)
10+
11+
### Fixed
12+
- Deprecation notices on PHP 8.2 [#7650](https://github.com/Automattic/sensei/pull/7650)
13+
- Custom styles for emails in preview and in sent messages [#7595](https://github.com/Automattic/sensei/pull/7595)
14+
- Keep current status for a question when it is updated [#7603](https://github.com/Automattic/sensei/pull/7603)
15+
- Prevent lesson loading error in Learning Mode for themes that are using referenced styles [#7658](https://github.com/Automattic/sensei/pull/7658)
16+
- Remove limit from report export [#7647](https://github.com/Automattic/sensei/pull/7647)
17+
- Set default names for modules without titles when saving course in the course tour [#7652](https://github.com/Automattic/sensei/pull/7652)
18+
- Replace "Continue to next lesson" with "Back to lesson" CTA in quiz when lesson is last in course [#7642](https://github.com/Automattic/sensei/pull/7642)
19+
- Register blocks to make their translations available in the editor [#7643](https://github.com/Automattic/sensei/pull/7643)
20+
- Tour modal tooltip visibility [#7653](https://github.com/Automattic/sensei/pull/7653)
21+
322
## 4.24.1 - 2024-06-13
423
### Security
524
- Improve security for lessons and modules ordering

changelog/fix-blocks-translation

-4
This file was deleted.

changelog/fix-continue-to-next-lesson-not-react

-4
This file was deleted.

changelog/fix-deprecation-notices

-4
This file was deleted.

changelog/fix-email-styles

-4
This file was deleted.

changelog/fix-handle-empty-module-on-save-frontend

-4
This file was deleted.

changelog/fix-passing-array-to-strncmp

-4
This file was deleted.

changelog/fix-question-status-reset

-4
This file was deleted.

changelog/fix-report-export-limit

-4
This file was deleted.

changelog/fix-student-started-course-email-subject

-4
This file was deleted.

changelog/fix-tour-button-tooltips

-4
This file was deleted.

changelog/update-sensei-can-user-view-lesson-args

-4
This file was deleted.

config/psalm/psalm-baseline.xml

+15-6
Original file line numberDiff line numberDiff line change
@@ -4364,9 +4364,6 @@
43644364
<DocblockTypeContradiction occurrences="1">
43654365
<code>is_wp_error( $result )</code>
43664366
</DocblockTypeContradiction>
4367-
<InvalidAttribute occurrences="1">
4368-
<code>\ReturnTypeWillChange</code>
4369-
</InvalidAttribute>
43704367
<InvalidScalarArgument occurrences="1">
43714368
<code>$timestamp</code>
43724369
</InvalidScalarArgument>
@@ -4380,9 +4377,6 @@
43804377
<code>false</code>
43814378
<code>false</code>
43824379
</FalsableReturnStatement>
4383-
<InvalidAttribute occurrences="1">
4384-
<code>\ReturnTypeWillChange</code>
4385-
</InvalidAttribute>
43864380
<InvalidFalsableReturnType occurrences="1">
43874381
<code>array</code>
43884382
</InvalidFalsableReturnType>
@@ -5380,6 +5374,21 @@
53805374
<code>Sensei_REST_API_Send_Message_Controller</code>
53815375
</PropertyNotSetInConstructor>
53825376
</file>
5377+
<file src="includes/rest-api/class-sensei-rest-api-sensei-emails-controller.php">
5378+
<InvalidReturnStatement occurrences="1">
5379+
<code>$parent_check</code>
5380+
</InvalidReturnStatement>
5381+
<InvalidReturnType occurrences="1">
5382+
<code>true|WP_Error</code>
5383+
</InvalidReturnType>
5384+
<PropertyNotSetInConstructor occurrences="5">
5385+
<code>Sensei_REST_API_Sensei_Emails_Controller</code>
5386+
<code>Sensei_REST_API_Sensei_Emails_Controller</code>
5387+
<code>Sensei_REST_API_Sensei_Emails_Controller</code>
5388+
<code>Sensei_REST_API_Sensei_Emails_Controller</code>
5389+
<code>Sensei_REST_API_Sensei_Emails_Controller</code>
5390+
</PropertyNotSetInConstructor>
5391+
</file>
53835392
<file src="includes/rest-api/class-sensei-rest-api-setup-wizard-controller.php">
53845393
<DeprecatedMethod occurrences="1">
53855394
<code>install_extensions</code>

includes/blocks/class-sensei-block-quiz-question.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ public function __construct() {
4545
/**
4646
* Renders the block as an empty string.
4747
*
48-
* @deprecated $$next-version$$
48+
* @deprecated 4.24.2
4949
*
5050
* @param array $attributes The block attributes.
5151
* @param string $content The block content.
5252
*
5353
* @return string The block HTML.
5454
*/
5555
public function render_quiz_question( array $attributes, string $content ): string { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
56-
_deprecated_function( __METHOD__, '$$next-version$$', '__return_empty_string' );
56+
_deprecated_function( __METHOD__, '4.24.2', '__return_empty_string' );
5757

5858
return '';
5959
}

includes/internal/emails/class-email-post-type.php

+13-12
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function init(): void {
6969
*
7070
* @internal
7171
*
72-
* @since $$next-version$$
72+
* @since 4.24.2
7373
*
7474
* @param array $editor_settings The editor settings.
7575
* @param object $editor_context The editor context.
@@ -150,7 +150,7 @@ public function register_post_type(): void {
150150
register_post_type(
151151
self::POST_TYPE,
152152
[
153-
'labels' => [
153+
'labels' => [
154154
'name' => __( 'Emails', 'sensei-lms' ),
155155
'singular_name' => __( 'Email', 'sensei-lms' ),
156156
'add_new' => __( 'Add New', 'sensei-lms' ),
@@ -165,16 +165,17 @@ public function register_post_type(): void {
165165
'menu_name' => __( 'Emails', 'sensei-lms' ),
166166
'name_admin_bar' => __( 'Email', 'sensei-lms' ),
167167
],
168-
'public' => true,
169-
'exclude_from_search' => true,
170-
'publicly_queryable' => false,
171-
'show_in_nav_menus' => false,
172-
'show_ui' => true,
173-
'show_in_menu' => false,
174-
'show_in_rest' => true, // Enables the Gutenberg editor.
175-
'hierarchical' => false,
176-
'rewrite' => false,
177-
'supports' => [ 'title', 'editor', 'author', 'revisions' ],
168+
'public' => true,
169+
'exclude_from_search' => true,
170+
'publicly_queryable' => false,
171+
'show_in_nav_menus' => false,
172+
'show_ui' => true,
173+
'show_in_menu' => false,
174+
'show_in_rest' => true, // Enables the Gutenberg editor.
175+
'hierarchical' => false,
176+
'rewrite' => false,
177+
'supports' => [ 'title', 'editor', 'author', 'revisions' ],
178+
'rest_controller_class' => 'Sensei_REST_API_Sensei_Emails_Controller',
178179
]
179180
);
180181
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* Sensei REST API: Sensei_REST_API_Sensei_Emails_Controller class.
4+
*
5+
* @package sensei-lms
6+
* @since 4.24.2
7+
*/
8+
9+
if ( ! defined( 'ABSPATH' ) ) {
10+
exit;
11+
}
12+
13+
/**
14+
* A REST controller for Sensei Emails CPT.
15+
*
16+
* @since 4.24.2
17+
*
18+
* @see WP_REST_Posts_Controller
19+
*/
20+
class Sensei_REST_API_Sensei_Emails_Controller extends WP_REST_Posts_Controller {
21+
/**
22+
* Checks if a given request has access to read posts.
23+
*
24+
* @param WP_REST_Request $request Full details about the request.
25+
*
26+
* @return true|WP_Error True if the request has read access, WP_Error object otherwise.
27+
*/
28+
public function get_items_permissions_check( $request ) {
29+
$parent_check = parent::get_items_permissions_check( $request );
30+
31+
if ( is_wp_error( $parent_check ) ) {
32+
return $parent_check;
33+
}
34+
35+
if ( ! current_user_can( 'manage_sensei' ) ) {
36+
return new WP_Error(
37+
'rest_forbidden_context',
38+
__( 'Sorry, you are not allowed to view posts in this post type.', 'sensei-lms' ),
39+
array( 'status' => rest_authorization_required_code() )
40+
);
41+
}
42+
43+
return true;
44+
}
45+
46+
/**
47+
* Checks if the logged-in user should have access to a specific sensei email.
48+
*
49+
* @param WP_REST_Request $request Full details about the request.
50+
*
51+
* @return true|WP_Error True if the request has read access, WP_Error object otherwise.
52+
*/
53+
public function get_item_permissions_check( $request ) {
54+
$parent_check = parent::get_item_permissions_check( $request );
55+
56+
if ( is_wp_error( $parent_check ) ) {
57+
return $parent_check;
58+
}
59+
60+
if ( ! current_user_can( 'edit_post', $request['id'] ) ) {
61+
return new WP_Error(
62+
'rest_forbidden_context',
63+
__( 'Sorry, you are not allowed to view this item.', 'sensei-lms' ),
64+
array( 'status' => rest_authorization_required_code() )
65+
);
66+
}
67+
68+
return true;
69+
}
70+
}

includes/sensei-functions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function sensei_can_user_view_lesson( $lesson_id = null, $user_id = null ) {
176176
* Filter if the user can view lesson and quiz content.
177177
*
178178
* @since 1.9.0
179-
* @since $$next-version$$ Added $checks parameter.
179+
* @since 4.24.2 Added $checks parameter.
180180
*
181181
* @hook sensei_can_user_view_lesson
182182
*

0 commit comments

Comments
 (0)