Skip to content

Commit

Permalink
Release 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikola Miljkovic committed Jun 3, 2017
1 parent 95ae30d commit 3d0fb45
Show file tree
Hide file tree
Showing 24 changed files with 468 additions and 13,573 deletions.
36 changes: 33 additions & 3 deletions includes/admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function wpfc_sermon_audio_validate( $new, $post_id, $field ) {
if ( $field['id'] != 'sermon_audio' ) {
return $new;
}
$audio = get_post_meta( $post_id, 'sermon_audio', 'true' );
$audio = get_post_meta( $post_id, 'sermon_audio', true );
// Stop if PowerPress plugin is active
// Solves conflict regarding enclosure field: http://wordpress.org/support/topic/breaks-blubrry-powerpress-plugin?replies=6
if ( defined( 'POWERPRESS_VERSION' ) ) {
Expand All @@ -84,8 +84,8 @@ function wpfc_sermon_audio_validate( $new, $post_id, $field ) {
// This will set the length of the enclosure automatically
do_enclose( $audio, $post_id );
// Set duration as post meta
$current = get_post_meta( $post_id, 'sermon_audio', 'true' );
$currentduration = get_post_meta( $post_id, '_wpfc_sermon_duration', 'true' );
$current = get_post_meta( $post_id, 'sermon_audio', true );
$currentduration = get_post_meta( $post_id, '_wpfc_sermon_duration', true );
// only grab if different (getting data from dropbox can be a bit slow)
if ( $new != '' && ( $new != $current || empty( $currentduration ) ) ) {
// get file data
Expand Down Expand Up @@ -439,3 +439,33 @@ function wpfc_taxonomy_short_description_shorten( $string, $max_length = 23, $ap

return $string;
}

/**
* Returns duration of an MP3 file
*
* @param string $mp3_url URL to the MP3 file
*
* @return string duration
*/
function wpfc_mp3_duration( $mp3_url ) {
if ( empty( $mp3_url ) ) {
return '';
}

if ( ! class_exists( 'getID3' ) ) {
require_once ABSPATH . 'wp-includes/ID3/getid3.php';
}

// create a temporary file for the MP3 file
$filename = tempnam( '/tmp', 'getid3' );

if ( file_put_contents( $filename, file_get_contents( $mp3_url ) ) ) {
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze( $filename );
unlink( $filename );
}

$duration = isset( $ThisFileInfo['playtime_string'] ) ? $ThisFileInfo['playtime_string'] : '';

return $duration;
}
2 changes: 1 addition & 1 deletion includes/fix-dates.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function render_warning() {
?>
<div class="notice notice-error is-dismissible">
<p><strong>Important!</strong> Sermon Manager needs to check dates of old sermons.
<a href="<?php echo admin_url( 'edit.php?post_type=wpfc_sermon&page=' . basename( SERMON_MANAGER_PATH ) . '/includes/options.php#sermon-options-dates-fix' ); ?>">Click
<a href="<?php echo admin_url( 'edit.php?post_type=wpfc_sermon&page=' . basename( SERMON_MANAGER_PATH ) . 'includes/options.php#sermon-options-dates-fix' ); ?>">Click
here</a> if you want to do it now.</p>
</div>
<?php
Expand Down
Loading

0 comments on commit 3d0fb45

Please sign in to comment.