Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified wp-content/mu-plugins/pub/wporg-learn-cli.php
100755 → 100644
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Sensei_Reports_Overview_Service_Courses;
use function WPOrg_Learn\Post_Meta\{get_workshop_duration};
use function WordPressdotorg\Locales\get_locale_name_from_code;
use function WPOrg_Learn\Utils\ensure_float;

add_action( 'init', __NAMESPACE__ . '\init' );

Expand Down Expand Up @@ -72,6 +73,30 @@ function render( $attributes, $content, $block ) {
// Get the last updated time.
$last_updated = get_last_updated_time( $course_id );

// Settins for the Duration of the course, set in Course sidebar duration meta field
$duration = ensure_float( get_post_meta( $block->context['postId'], '_duration', true ) );

if ( empty( $duration ) ) {
return '';
}

if ( 1 === $duration ) {
$completion = __( '1 hour', 'wporg-learn' );
} elseif ( $duration > 1 ) {
$completion = sprintf(
/* translators: %s: duration in hours */
__( '%s hours', 'wporg-learn' ),
$duration
);
} else {
// Display it in minutes.
$minutes = round( $duration * 60 );
$completion = sprintf(
/* translators: %s: duration in minutes */
__( '%s minutes', 'wporg-learn' ),
$minutes
);
}
// Set up array of data to be used.
$meta_fields = array(
array(
Expand All @@ -89,6 +114,11 @@ function render( $attributes, $content, $block ) {
'value' => $last_updated,
'key' => 'last-updated',
),
array(
'label' => __( 'Estimated duration', 'wporg-learn' ),
'value' => $completion,
'key' => 'duration',
),
);
} elseif ( 'wporg_workshop' === $block->context['postType'] ) {
$workshop = get_post( $block->context['postId'] );
Expand Down