-
Notifications
You must be signed in to change notification settings - Fork 125
Add course completion meta field #2877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
078d13d
0ba7170
776c692
30ac3f5
16df720
9235cc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,56 @@ | ||||||
| /** | ||||||
| * WordPress dependencies | ||||||
| */ | ||||||
| import { PanelRow, TextControl } from '@wordpress/components'; | ||||||
| import { useDispatch, useSelect } from '@wordpress/data'; | ||||||
| import { PluginDocumentSettingPanel } from '@wordpress/edit-post'; | ||||||
| import { __ } from '@wordpress/i18n'; | ||||||
| import { registerPlugin } from '@wordpress/plugins'; | ||||||
|
|
||||||
| const CourseCompletionMeta = () => { | ||||||
| const postMetaData = useSelect( ( select ) => select( 'core/editor' ).getEditedPostAttribute( 'meta' ) || {} ); | ||||||
| const { editPost } = useDispatch( 'core/editor' ); | ||||||
|
|
||||||
| const message = postMetaData?._course_completion_success_message || ''; | ||||||
| const link = postMetaData?._course_completion_survey_link || ''; | ||||||
|
|
||||||
| return ( | ||||||
| <PluginDocumentSettingPanel title={ __( 'Course Completion Settings', 'wporg-learn' ) }> | ||||||
|
||||||
| <PluginDocumentSettingPanel title={ __( 'Course Completion Settings', 'wporg-learn' ) }> | |
| <PluginDocumentSettingPanel title={ __( 'Completed screen', 'wporg-learn' ) }> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <p>{ __( 'If the fields are left blank, the default values will be applied.', 'wporg-learn' ) }</p> | |
| <p>{ __( 'These fields customize what is displayed on the Course Completed screen. If left blank, the default values will be applied.', 'wporg-learn' ) }</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we show a placeholder value here 'Congratulations on completing this course!'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I don't have a problem with it being cut off; I think it still provides an example of what is expected. If we did want to shorten it I'd just use Congratulations!, as it's still close to the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it still provides an example of what is expected.
This makes sense to me. 16df720
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,10 @@ | |
| * Inserter: no | ||
| */ | ||
|
|
||
| $course_id = isset( $_GET['course_id'] ) ? intval( $_GET['course_id'] ) : get_the_ID(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious about this, did you find a case where
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven’t encountered this, but I remember being reminded before that in certain places like before/after the loop or in header, footer, or admin pages, |
||
| $success_message = get_post_meta( $course_id, '_course_completion_success_message', true ) ?: __( 'Congratulations on completing this course!', 'wporg-learn' ); | ||
| $survey_link = get_post_meta( $course_id, '_course_completion_survey_link', true ) ?: 'https://docs.google.com/forms/d/e/1FAIpQLSf0QMflUedxjta0u5qS4_pl-9aY06BDBXgRn2PoZA1gRvD9jw/viewform'; | ||
|
|
||
| ?> | ||
|
|
||
| <!-- wp:heading {"level":1} --> | ||
|
|
@@ -15,7 +19,7 @@ | |
|
|
||
| <!-- wp:heading {"style":{"spacing":{"margin":{"top":"40px","bottom":"10px"}}},"fontSize":"large","fontFamily":"inter"} --> | ||
| <h2 class="wp-block-heading has-inter-font-family has-large-font-size" style="margin-top:40px;margin-bottom:10px"> | ||
| <?php esc_html_e( 'Congratulations on completing this course!', 'wporg-learn' ); ?> | ||
| <?php echo esc_html( $success_message ); ?> | ||
| </h2> | ||
| <!-- /wp:heading --> | ||
|
|
||
|
|
@@ -29,7 +33,7 @@ | |
| <div class="wp-block-buttons"> | ||
| <!-- wp:button {"style":{"spacing":{"padding":{"left":"32px","right":"32px","top":"17px","bottom":"17px"}}}} --> | ||
| <div class="wp-block-button"> | ||
| <a class="wp-block-button__link wp-element-button" href="https://docs.google.com/forms/d/e/1FAIpQLSf0QMflUedxjta0u5qS4_pl-9aY06BDBXgRn2PoZA1gRvD9jw/viewform" style="padding-top:17px;padding-right:32px;padding-bottom:17px;padding-left:32px"> | ||
| <a class="wp-block-button__link wp-element-button" href="<?php echo esc_url( $survey_link ); ?>" style="padding-top:17px;padding-right:32px;padding-bottom:17px;padding-left:32px"> | ||
| <?php esc_html_e( 'Complete the survey', 'wporg-learn' ); ?> | ||
| </a> | ||
| </div> | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9235cc4