Skip to content

Commit 94952d7

Browse files
author
Woo
committed
Updates to 4.24.2.1.24.1
1 parent 5adea8b commit 94952d7

File tree

218 files changed

+4154
-1924
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+4154
-1924
lines changed

changelog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
*** Sensei Pro (WC Paid Courses) ***
22

3+
2024-08-08 - version 4.24.2.1.24.1
4+
* Sensei LMS: Version bump to 4.24.2 https://raw.githubusercontent.com/Automattic/sensei/version/4.24.2/changelog.txt
5+
* Sensei Pro: Version bump to 1.24.1
6+
* Ensure lesson preview setting takes precedence over course expiration
7+
* Deprecation notices on PHP 8.2
8+
* Missing translations for interactive blocks
9+
310
2024-06-13 - version 4.24.1.1.24.0
411
* Sensei LMS: Version bump to 4.24.1 https://raw.githubusercontent.com/Automattic/sensei/version/4.24.1/changelog.txt
512

plugins/sensei-lms/assets/admin/course-pre-publish-panel/course-pre-publish-panel.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
*/
44
import { __ } from '@wordpress/i18n';
55
import { useEntityProp } from '@wordpress/core-data';
6-
import { PluginPrePublishPanel } from '@wordpress/edit-post';
6+
import { PluginPrePublishPanel as DeprecatedPluginPrePublishPanel } from '@wordpress/edit-post';
7+
import { PluginPrePublishPanel as NewPluginPrePublishPanel } from '@wordpress/editor';
78
import { ToggleControl } from '@wordpress/components';
89

910
/**
1011
* Internal dependencies
1112
*/
1213
import SenseiIcon from '../../icons/logo-tree.svg';
1314

15+
const PluginPrePublishPanel =
16+
NewPluginPrePublishPanel || DeprecatedPluginPrePublishPanel;
17+
1418
/**
1519
* Course pre-publish panel.
1620
*/

plugins/sensei-lms/assets/admin/editor-wizard/patterns-list.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ const PatternsList = ( { onChoose } ) => {
137137
>
138138
<div className="sensei-patterns-list__item-preview">
139139
<BlockPreview
140-
__experimentalPadding={ 30 }
140+
additionalStyles={ [
141+
{ css: 'body { padding: 30px; }' },
142+
] }
141143
blocks={ blocks
142144
.filter( withoutLessonActions )
143145
.map( withBlockExample ) }

plugins/sensei-lms/assets/admin/tour/course-tour/steps.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { store as editorStore } from '@wordpress/editor';
1313
* Internal dependencies
1414
*/
1515
import { TourStep } from '../types';
16+
import { setBlockMeta } from '../../../shared/blocks/block-metadata';
1617
import { getFirstBlockByName } from '../../../blocks/course-outline/data';
1718
import {
1819
highlightElementsWithBorders,
@@ -48,7 +49,7 @@ function focusOnCourseOutlineBlock() {
4849
if ( ! courseOutlineBlock ) {
4950
return;
5051
}
51-
dispatch( editorStore ).selectBlock( courseOutlineBlock.clientId );
52+
dispatch( blockEditorStore ).selectBlock( courseOutlineBlock.clientId );
5253
}
5354

5455
async function ensureLessonBlocksIsInEditor() {
@@ -86,6 +87,40 @@ async function ensureLessonBlocksIsInEditor() {
8687
insertLessonBlock( 'Lesson 1' );
8788
}
8889

90+
/**
91+
* Check all modules have titles, if not, assign a default title.
92+
*/
93+
function ensureModulesHaveTitles() {
94+
const blocks = getCourseOutlineBlock().innerBlocks;
95+
const modules = blocks.filter(
96+
( block ) => block.name === 'sensei-lms/course-outline-module'
97+
);
98+
const moduleTitles = modules
99+
.map( ( block ) => {
100+
if ( block.name !== 'sensei-lms/course-outline-module' ) {
101+
return null;
102+
}
103+
const title = block.attributes?.title?.trim();
104+
return title || null;
105+
} )
106+
.filter( ( value ) => !! value );
107+
108+
if ( modules.length > 0 ) {
109+
let i = 0;
110+
modules.forEach( ( module ) => {
111+
let title = module.attributes?.title?.trim();
112+
if ( title !== '' ) {
113+
return;
114+
}
115+
do {
116+
title = __( 'Module', 'sensei-lms' ) + ' ' + ++i;
117+
} while ( moduleTitles.includes( title ) );
118+
module.attributes.title = title;
119+
setBlockMeta( module.clientId, module.attributes );
120+
} );
121+
}
122+
}
123+
89124
/**
90125
* Returns the tour steps for the Course Outline block.
91126
*
@@ -209,7 +244,7 @@ function getTourSteps() {
209244
heading: __( 'Adding a module', 'sensei-lms' ),
210245
descriptions: {
211246
desktop: __(
212-
'A module is a container for a group of related lessons in a course. Click + to open the inserter. Then click the Module option.',
247+
'A module is a container for a group of related lessons in a course. Click + to open the inserter. Then click the Module option and give it a name.',
213248
'sensei-lms'
214249
),
215250
mobile: null,
@@ -512,6 +547,7 @@ function getTourSteps() {
512547
);
513548

514549
if ( ! savedLesson ) {
550+
ensureModulesHaveTitles();
515551
const { savePost } = dispatch( editorStore );
516552
savePost();
517553
await waitForElement( savedlessonSelector, 15 );

plugins/sensei-lms/assets/admin/tour/data/store.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
/**
22
* WordPress dependencies
33
*/
4-
import { createReduxStore, register } from '@wordpress/data';
5-
/**
6-
* Internal dependencies
7-
*/
8-
import { createReducerFromActionMap } from '../../../shared/data/store-helpers';
94
import { controls } from '@wordpress/data-controls';
105
import apiFetch from '@wordpress/api-fetch';
116

12-
export const SENSEI_TOUR_STORE = 'sensei/tour';
7+
/**
8+
* Internal dependencies
9+
*/
10+
import {
11+
createReducerFromActionMap,
12+
createStore,
13+
} from '../../../shared/data/store-helpers';
1314

1415
export const DEFAULT_STATE = {
1516
showTour: true,
@@ -80,11 +81,9 @@ export const reducers = {
8081
DEFAULT: ( action, state ) => state,
8182
};
8283

83-
export const store = createReduxStore( SENSEI_TOUR_STORE, {
84+
export const SENSEI_TOUR_STORE = createStore( 'sensei/tour', {
8485
reducer: createReducerFromActionMap( reducers, DEFAULT_STATE ),
8586
actions,
8687
selectors,
8788
controls,
8889
} );
89-
90-
register( store );

plugins/sensei-lms/assets/admin/tour/lesson-tour/steps.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { ExternalLink } from '@wordpress/components';
88
import { select, dispatch } from '@wordpress/data';
99
import { store as blockEditorStore } from '@wordpress/block-editor';
1010
import { store as editPostStore } from '@wordpress/edit-post';
11-
import { store as editorStore } from '@wordpress/editor';
1211

1312
/**
1413
* Internal dependencies
@@ -59,23 +58,23 @@ export const focusOnQuizBlock = () => {
5958
if ( ! quizBlock ) {
6059
return;
6160
}
62-
dispatch( editorStore ).selectBlock( quizBlock.clientId );
61+
dispatch( blockEditorStore ).selectBlock( quizBlock.clientId );
6362
};
6463

6564
export const focusOnQuestionBlock = () => {
6665
const questionBlock = getFirstQuestionBlock();
6766
if ( ! questionBlock ) {
6867
return;
6968
}
70-
dispatch( editorStore ).selectBlock( questionBlock.clientId );
69+
dispatch( blockEditorStore ).selectBlock( questionBlock.clientId );
7170
};
7271

7372
export const focusOnBooleanQuestionBlock = () => {
7473
const questionBlock = getFirstBooleanQuestionBlock();
7574
if ( ! questionBlock ) {
7675
return;
7776
}
78-
dispatch( editorStore ).selectBlock( questionBlock.clientId );
77+
dispatch( blockEditorStore ).selectBlock( questionBlock.clientId );
7978
};
8079

8180
export const ensureBooleanQuestionIsInEditor = () => {

plugins/sensei-lms/assets/blocks/course-actions-block/course-status-toolbar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* WordPress dependencies
33
*/
4-
import { Toolbar } from '@wordpress/components';
4+
import { ToolbarGroup } from '@wordpress/components';
55
import { useContext } from '@wordpress/element';
66

77
/**
@@ -41,14 +41,14 @@ const CourseStatusToolbar = ( {
4141
: setCourseStatus;
4242

4343
return (
44-
<Toolbar>
44+
<ToolbarGroup>
4545
<ToolbarDropdown
4646
options={ CourseStatusOptions }
4747
optionsLabel="Course Status"
4848
value={ courseStatusValue }
4949
onChange={ setCourseStatusCallback }
5050
/>
51-
</Toolbar>
51+
</ToolbarGroup>
5252
);
5353
};
5454

plugins/sensei-lms/assets/blocks/course-outline/lesson-block/lesson-edit-toolbar.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
/**
22
* WordPress dependencies
33
*/
4-
import { Button, Spinner, Toolbar, ToolbarItem } from '@wordpress/components';
4+
import {
5+
Button,
6+
Spinner,
7+
ToolbarGroup,
8+
ToolbarItem,
9+
} from '@wordpress/components';
10+
import { forwardRef } from '@wordpress/element';
511
import { useDispatch, useSelect } from '@wordpress/data';
612
import { store as editPostStore } from '@wordpress/edit-post';
713
import { store as editorStore } from '@wordpress/editor';
@@ -19,14 +25,19 @@ const getLessonURL = ( lessonId ) => `post.php?post=${ lessonId }&action=edit`;
1925
*
2026
* @param {Object} props Component props.
2127
* @param {number} props.lessonId The lesson ID.
28+
* @param {Object} forwardedRef The forwarded ref.
2229
*/
23-
export const EditLessonLink = ( { lessonId } ) => (
24-
<a
25-
href={ getLessonURL( lessonId ) }
26-
className="wp-block-sensei-lms-course-outline-lesson__edit"
27-
>
28-
{ __( 'Edit lesson', 'sensei-lms' ) }
29-
</a>
30+
export const EditLessonLink = forwardRef(
31+
( { lessonId, ...props }, forwardedRef ) => (
32+
<a
33+
ref={ forwardedRef }
34+
href={ getLessonURL( lessonId ) }
35+
className="wp-block-sensei-lms-course-outline-lesson__edit"
36+
{ ...props }
37+
>
38+
{ __( 'Edit lesson', 'sensei-lms' ) }
39+
</a>
40+
)
3041
);
3142

3243
/**
@@ -70,12 +81,18 @@ const LessonEditToolbar = ( { lessonId, lessonTitle } ) => {
7081

7182
let toolbarItem = savePostLink;
7283
if ( lessonId ) {
73-
toolbarItem = <EditLessonLink lessonId={ lessonId } />;
84+
toolbarItem = (
85+
<ToolbarItem as={ EditLessonLink } lessonId={ lessonId } />
86+
);
7487
} else if ( isSavingPost || isSavingStructure || isSavingMetaBoxes ) {
7588
toolbarItem = savingPostIndicator;
7689
}
7790

78-
return <Toolbar className="components-button">{ toolbarItem }</Toolbar>;
91+
return (
92+
<ToolbarGroup className="components-button">
93+
{ toolbarItem }
94+
</ToolbarGroup>
95+
);
7996
};
8097

8198
export default LessonEditToolbar;

plugins/sensei-lms/assets/blocks/course-outline/lesson-block/lesson-settings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const LessonSettings = ( {
5151
) }
5252
<PanelBody title={ __( 'Typography', 'sensei-lms' ) }>
5353
<FontSizePicker
54+
__nextHasNoMarginBottom // Can be removed when we support WP 6.5+
5455
fontSizes={ fontSizes }
5556
value={ fontSize }
5657
onChange={ ( value ) => {

plugins/sensei-lms/assets/blocks/course-outline/status-preview/status-store.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
/**
22
* WordPress dependencies
33
*/
4-
import { select as selectData, registerStore } from '@wordpress/data';
4+
import { select as selectData } from '@wordpress/data';
55

66
/**
77
* Internal dependencies
88
*/
99
import { Status } from './index';
1010
import { select, controls } from '@wordpress/data-controls';
11-
import { createReducerFromActionMap } from '../../../shared/data/store-helpers';
11+
import {
12+
createStore,
13+
createReducerFromActionMap,
14+
} from '../../../shared/data/store-helpers';
1215

1316
const DEFAULT_STATE = {
1417
completedLessons: [],
@@ -311,9 +314,7 @@ const reducers = {
311314
DEFAULT: ( action, state ) => state,
312315
};
313316

314-
export const COURSE_STATUS_STORE = 'sensei/course-status';
315-
316-
registerStore( COURSE_STATUS_STORE, {
317+
export const COURSE_STATUS_STORE = createStore( 'sensei/course-status', {
317318
reducer: createReducerFromActionMap( reducers, DEFAULT_STATE ),
318319
actions,
319320
selectors,

0 commit comments

Comments
 (0)