From 50dcb22bd30bf52e6bb609cf42b43c7820641c83 Mon Sep 17 00:00:00 2001 From: gerritvanaaken Date: Thu, 1 Nov 2012 20:05:09 +0100 Subject: [PATCH] targeting #33 (enclosures) and setting version number to 1.2 --- podlove-web-player/podlove-web-player.php | 86 ++++++++++-------- podlove-web-player/readme.txt | 12 ++- podlove-web-player/settings.php | 104 +++++++++++++++------- 3 files changed, 133 insertions(+), 69 deletions(-) diff --git a/podlove-web-player/podlove-web-player.php b/podlove-web-player/podlove-web-player.php index 6d00ec136..1d9499a00 100644 --- a/podlove-web-player/podlove-web-player.php +++ b/podlove-web-player/podlove-web-player.php @@ -1,7 +1,7 @@ 0 ? $chapters : false; } + +/* Shortcodes */ + +function podlove_pwp_audio_shortcode($attributes) { + return is_feed() ? '' : podlove_pwp_media_shortcode('audio', $attributes); +} + +// [audio] is deprecated +add_shortcode('audio', 'podlove_pwp_audio_shortcode'); +add_shortcode('podloveaudio', 'podlove_pwp_audio_shortcode'); + +function podlove_pwp_video_shortcode($attributes) { + return is_feed() ? '' : podlove_pwp_media_shortcode('video', $attributes); +} + +// [video] is deprecated +add_shortcode('video', 'podlove_pwp_video_shortcode'); +add_shortcode('podlovevideo', 'podlove_pwp_video_shortcode'); + +/* Announce deprecation of [audio] and [video] shortcode */ + +function podlove_pwp_deprecated_widget_function() { + echo '

Using the shortcode [audio] and [video] for the Podlove Web Player is deprecated and will be dropped.
Use [podloveaudio] and [podlovevideo] instead!

'; +} +function podlove_pwp_add_dashboard_widgets() { + wp_add_dashboard_widget('podlove_pwp_deprecated_widget', 'Podlove Web Player', 'podlove_pwp_deprecated_widget_function'); +} +add_action('wp_dashboard_setup', 'podlove_pwp_add_dashboard_widgets' ); // Hint: For Multisite Network Admin Dashboard use wp_network_dashboard_setup instead of wp_dashboard_setup. + + /* Auto-detect enclosures */ -function pwp_get_enclosed($post_id) { + +// modified version of get_enclosed. Returns arrays with meta info instead of plain strings. +function podlove_pwp_get_enclosed($post_id) { $custom_fields = get_post_custom( $post_id ); $pung = array(); if ( !is_array( $custom_fields ) ) @@ -515,9 +547,19 @@ function pwp_get_enclosed($post_id) { return $pung; } -;function podlove_pwp_enclosure($content) { +function podlove_pwp_enclosure($content) { global $post; - if ($enclosures = pwp_get_enclosed($post->ID)) { + + if ($enclosures = podlove_pwp_get_enclosed($post->ID) // do we have enclosures in this post? + AND ( + get_option('pwp_enclosure_force') == true) // forced to render enclosures by option + OR + (!strpos($content, "[podloveaudio") AND + !strpos($content, "[podlovevideo") AND + !strpos($content, "[audio") AND + !strpos($content, "[video")) // there is no manual shortcode + ) + { foreach($enclosures as $enclosure) { $type = substr($enclosure[2], 0, strpos($enclosure[2], "/")); $content = do_shortcode('[podlove'.$type.' type="'.$enclosure[2].'" src="'.$enclosure[0].'"]').$content; @@ -526,37 +568,11 @@ function pwp_get_enclosed($post_id) { return $content; } -if( !is_feed() ) { - add_filter('the_content', 'podlove_pwp_enclosure'); -} - -/* Shortcodes */ - -function podlove_pwp_audio_shortcode($attributes) { - return is_feed() ? '' : podlove_pwp_media_shortcode('audio', $attributes); +if( !is_feed() && get_option('pwp_enclosure_detect') == true) { + // fire auto-detect script before regular shortcode, which has prio 11 + add_filter('the_content', 'podlove_pwp_enclosure', 10); } -// [audio] is deprecated -add_shortcode('audio', 'podlove_pwp_audio_shortcode'); -add_shortcode('podloveaudio', 'podlove_pwp_audio_shortcode'); - -function podlove_pwp_video_shortcode($attributes) { - return is_feed() ? '' : podlove_pwp_media_shortcode('video', $attributes); -} - -// [video] is deprecated -add_shortcode('video', 'podlove_pwp_video_shortcode'); -add_shortcode('podlovevideo', 'podlove_pwp_video_shortcode'); - -/* Announce deprecation of [audio] and [video] shortcode */ - -function podlove_pwp_deprecated_widget_function() { - echo '

Using the shortcode [audio] and [video] for the Podlove Web Player is deprecated and will be dropped.
Use [podloveaudio] and [podlovevideo] instead!

'; -} -function podlove_pwp_add_dashboard_widgets() { - wp_add_dashboard_widget('podlove_pwp_deprecated_widget', 'Podlove Web Player', 'podlove_pwp_deprecated_widget_function'); -} -add_action('wp_dashboard_setup', 'podlove_pwp_add_dashboard_widgets' ); // Hint: For Multisite Network Admin Dashboard use wp_network_dashboard_setup instead of wp_dashboard_setup. /* Initialisation */ diff --git a/podlove-web-player/readme.txt b/podlove-web-player/readme.txt index 4970dbdd0..a6f873266 100644 --- a/podlove-web-player/readme.txt +++ b/podlove-web-player/readme.txt @@ -4,7 +4,7 @@ Donate link: http://podlove.org/ Tags: podcasting, podlove, html5audio, audio, video, podcast, player Requires at least: 3.4.0 Tested up to: 3.4.1 -Stable tag: 1.1.2 +Stable tag: 1.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -180,6 +180,14 @@ Takes chapter string from the defined custom field (the standard WordPress ones) [podloveaudio chapters="http://mychapters.com/chapters.txt"] += chapterlinks = + +Option for the jumplink behaviour in chapter table + + [podloveaudio chapterlinks="all"] (default, all chapter links are clickable) + [podloveaudio chapterlinks="buffered"] (only buffered chapters are clickable) + [podloveaudio chapterlinks="false"] (chapters are not linked) + = All attributes video example = All options enabled: @@ -202,7 +210,7 @@ Earlier versions of this plugin could handle alternative shortcodes, too: [audio == Changelog == -= 1.1.2 = += 1.2 = * prevents activation conflicts with other instances of the plugin = 1.1.1 = diff --git a/podlove-web-player/settings.php b/podlove-web-player/settings.php index 7aa89953c..cfd1be494 100644 --- a/podlove-web-player/settings.php +++ b/podlove-web-player/settings.php @@ -8,92 +8,132 @@
-

General Settings

+ + + + + + + + + + + + + +
General Settings
+ + + > +
- - +
+ + + + + + + + - +
Enclosures
- +
+ WordPress automatically creates an "enclosure" custom field whenever it detects an URL to a media file in the post text. + Use this option to turn these enclosures into a Podlove Web Player instances.
- > + >
- -
- - +
+ … additionally to regular Podlove Web Players, if both are present
- > -
- > - + >
- -

Video Settings

- - + + + +
+ + + + + + + +
Video settings
- + - + such as "640"
- + - + such as "360"
- + such as "video/mp4"
-

Audio Settings

- - - +
+ + + + + + + +
Audio settings
- + - + such as "400" (keep blank for auto)
- + - + stick to "30" if unsure
- + such as "audio/mp3"