Changeset 10169 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/post-meta.php
- Timestamp:
- 08/13/2020 11:43:14 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/post-meta.php
r10147 r10169 81 81 function get_workshop_duration( WP_Post $workshop, $format = 'raw' ) { 82 82 $raw_duration = $workshop->duration ? absint( $workshop->duration ) : 0; 83 $interval = date_diff( new DateTime( '@0' ), new DateTime( "@$raw_duration" ) ); // The '@' ignores timezone.84 $return = null;83 $interval = date_diff( new DateTime( '@0' ), new DateTime( "@$raw_duration" ) ); // The '@' ignores timezone. 84 $return = null; 85 85 86 86 switch ( $format ) { … … 92 92 $return = human_time_diff( 0, $interval->d * DAY_IN_SECONDS ); 93 93 } elseif ( $interval->h > 0 ) { 94 $return = $hours = human_time_diff( 0, $interval->h * HOUR_IN_SECONDS ); 94 $hours = human_time_diff( 0, $interval->h * HOUR_IN_SECONDS ); 95 $return = $hours; 95 96 96 97 if ( $interval->i > 0 ) { 97 98 $minutes = human_time_diff( 0, $interval->i * MINUTE_IN_SECONDS ); 98 $return = sprintf(99 $return = sprintf( 99 100 // translators: 1 is a string like "2 hours". 2 is a string like "20 mins". 100 _x( '%1$s, %2$s', 'hours and minutes', 'wporg-learn' ),101 _x( '%1$s, %2$s', 'hours and minutes', 'wporg-learn' ), 101 102 $hours, 102 103 $minutes … … 148 149 function render_metabox_workshop_details( WP_Post $post ) { 149 150 $duration_interval = get_workshop_duration( $post, 'interval' ); 150 $captions = get_post_meta( $post->ID, 'video_caption_language' ) ?: array();151 $captions = get_post_meta( $post->ID, 'video_caption_language' ) ?: array(); 151 152 152 153 require dirname( dirname( __FILE__ ) ) . '/views/metabox-workshop-details.php'; … … 167 168 * Update the post meta values from the meta box fields when the post is saved. 168 169 * 169 * @param int $post_id170 * @param int $post_id 170 171 * @param WP_Post $post 171 172 */ … … 182 183 183 184 $presenter_wporg_username = filter_input( INPUT_POST, 'presenter-wporg-username' ); 184 $usernames = array_map( 'trim', explode( ',', $presenter_wporg_username ) );185 $usernames = array_map( 'trim', explode( ',', $presenter_wporg_username ) ); 185 186 delete_post_meta( $post_id, 'presenter_wporg_username' ); 186 foreach ( $usernames as $username ) {187 foreach ( $usernames as $username ) { 187 188 add_post_meta( $post_id, 'presenter_wporg_username', $username ); 188 189 } … … 192 193 193 194 $video_caption_language = filter_input( INPUT_POST, 'video-caption-language' ); 194 $captions = array_map( 'trim', explode( ',', $video_caption_language ) );195 $captions = array_map( 'trim', explode( ',', $video_caption_language ) ); 195 196 delete_post_meta( $post_id, 'video_caption_language' ); 196 foreach ( $captions as $caption ) {197 foreach ( $captions as $caption ) { 197 198 add_post_meta( $post_id, 'video_caption_language', $caption ); 198 199 }
Note: See TracChangeset
for help on using the changeset viewer.