Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Commit

Permalink
targeting #33 (enclosures) and setting version number to 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gerritvanaaken committed Nov 1, 2012
1 parent e8d4b86 commit 50dcb22
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 69 deletions.
86 changes: 51 additions & 35 deletions podlove-web-player/podlove-web-player.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
/**
* @package PodloveWebPlayer
* @version 1.1.2
* @version 1.2
*/

/*
Plugin Name: Podlove Web Player
Plugin URI: http://podlove.org/podlove-web-player/
Description: Video and audio plugin for WordPress built on the MediaElement.js HTML5 media player library.
Author: Gerrit van Aaken and others
Version: 1.1.2
Version: 1.2
Author URI: http://praegnanz.de
License: GPLv3, MIT
*/
Expand Down Expand Up @@ -124,7 +124,7 @@ function podlove_pwp_add_scripts() {
// the scripts
wp_enqueue_script('mediaelementjs-scripts', PODLOVEWEBPLAYER_MEJS_DIR . 'mediaelement-and-player.min.js', array('jquery'), '2.9.1', false);
wp_enqueue_script('ba-hashchange', PODLOVEWEBPLAYER_DIR . 'libs/jquery.ba-hashchange.min.js', array('jquery'), '1.3.0', false);
wp_enqueue_script('podlove-web-player', PODLOVEWEBPLAYER_DIR . 'podlove-web-player.js', array('jquery', 'mediaelementjs-scripts'), '1.1.2', false);
wp_enqueue_script('podlove-web-player', PODLOVEWEBPLAYER_DIR . 'podlove-web-player.js', array('jquery', 'mediaelementjs-scripts'), '1.2', false);
}
}
add_action('wp_print_scripts', 'podlove_pwp_add_scripts');
Expand Down Expand Up @@ -496,9 +496,41 @@ function podlove_pwp_chapters_from_string($chapstring) {
return count($chapters) > 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 '<p style="border-top:2px solid red;padding-top:6px;color:#c00">Using the shortcode <code>[audio]</code> and <code>[video]</code> for the Podlove Web Player is <strong>deprecated</strong> and will be dropped.<br /> Use <code>[podloveaudio]</code> and <code>[podlovevideo]</code> instead!</p>';
}
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 ) )
Expand All @@ -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;
Expand All @@ -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 '<p style="border-top:2px solid red;padding-top:6px;color:#c00">Using the shortcode <code>[audio]</code> and <code>[video]</code> for the Podlove Web Player is <strong>deprecated</strong> and will be dropped.<br /> Use <code>[podloveaudio]</code> and <code>[podlovevideo]</code> instead!</p>';
}
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 */

Expand Down
12 changes: 10 additions & 2 deletions podlove-web-player/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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 =
Expand Down
104 changes: 72 additions & 32 deletions podlove-web-player/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,92 +8,132 @@
<form method="post" action="options.php">
<?php wp_nonce_field('update-options'); ?>

<h3 class="title"><span>General Settings</span></h3>
<table class="widefat fixed">
<thead>
<tr class="title">
<th scope="col" class="manage-column">General Settings</th>
<th scope="col" class="manage-column"></th>
</tr>
</thead>
<tbody>
<tr class="mainrow">
<th scope="titledesc">
<label for="pwp_script_on_demand">Load script on demand:</label>
</th>
<td class="forminp">
<input name="pwp_script_on_demand" type="checkbox" id="pwp_script_on_demand" <?php echo (get_option('pwp_script_on_demand') == true ? "checked" : "") ?>>
</td>
</tr>
</tbody>
</table>

<table class="form-table">
<tr valign="top">
<table class="widefat fixed" style="margin-top: 20px">
<thead>
<tr class="title">
<th scope="col" class="manage-column">Enclosures</th>
<th scope="col" class="manage-column"></th>
</tr>
</thead>
<tbody>
<tr class="mainrow">
<th scope="row">
<label for="pwp_script_on_demand">Load Script on Demand</label>
<label for="pwp_enclosure_detect">Auto-detect enclosures in posts:</label><br>
<small>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.</small>
</th>
<td>
<input name="pwp_script_on_demand" type="checkbox" id="pwp_script_on_demand" <?php echo (get_option('pwp_script_on_demand') == true ? "checked" : "") ?>>
<input name="pwp_enclosure_detect" type="checkbox" id="pwp_enclosure_detect" <?php echo (get_option('pwp_enclosure_detect') == true ? "checked" : "") ?>>
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="pwp_enclosure_detect">Auto-detect enclosures in posts</label>
<br>
<label for="pwp_enclosure_force">Force enclosure players</label>

<label for="pwp_enclosure_force">Force enclosure players:</label><br>
<small>… additionally to regular Podlove Web Players, if both are present</small>
</th>
<td>
<input name="pwp_enclosure_detect" type="checkbox" id="pwp_enclosure_detect" <?php echo (get_option('pwp_enclosure_detect') == true ? "checked" : "") ?>>
<br>
<input name="pwp_enclosure_force" type="checkbox" id="pwp_enclosure_force" <?php echo (get_option('pwp_enclosure_force') == true ? "checked" : "") ?>> <label for="pwp_enclosure_force">… additionally to shortcode instances</label>

<input name="pwp_enclosure_force" type="checkbox" id="pwp_enclosure_force" <?php echo (get_option('pwp_enclosure_force') == true ? "checked" : "") ?>>
</td>
</tr>

</tbody>
</table>


<h3 class="title"><span>Video Settings</span></h3>

<table class="form-table">
<script>
jQuery('#pwp_enclosure_detect').change(function(){
if (this.checked == false) {
jQuery('#pwp_enclosure_force')[0].checked = false;
}
});
</script>


<table class="widefat fixed" style="margin-top: 20px">
<thead>
<tr class="title">
<th scope="col" class="manage-column">Video settings</th>
<th scope="col" class="manage-column"></th>
</tr>
</thead>
<tbody>
<tr valign="top">
<th scope="row">
<label for="pwp_default_video_width">Default Width</label>
<label for="pwp_default_video_width">Default width:</label>
</th>
<td>
<input name="pwp_default_video_width" id="pwp_default_video_width" value="<?php echo get_option('pwp_default_video_width'); ?>">
<input name="pwp_default_video_width" id="pwp_default_video_width" value="<?php echo get_option('pwp_default_video_width'); ?>"> <span class="description">such as "640"</span>
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="pwp_default_video_height">Default Height</label>
<label for="pwp_default_video_height">Default height:</label>
</th>
<td>
<input name="pwp_default_video_height" id="pwp_default_video_height" value="<?php echo get_option('pwp_default_video_height'); ?>">
<input name="pwp_default_video_height" id="pwp_default_video_height" value="<?php echo get_option('pwp_default_video_height'); ?>"> <span class="description">such as "360"</span>
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="pwp_default_video_type">Default Type</label>
<label for="pwp_default_video_type">Default type:</label>
</th>
<td>
<input name="pwp_default_video_type" id="pwp_default_video_type" value="<?php echo get_option('pwp_default_video_type'); ?>"> <span class="description">such as "video/mp4"</span>
</td>
</tr>
</tbody>
</table>


<h3 class="title"><span>Audio Settings</span></h3>

<table class="form-table">
<tr valign="top">
<table class="widefat fixed" style="margin-top: 20px">
<thead>
<tr class="title">
<th scope="col" class="manage-column">Audio settings</th>
<th scope="col" class="manage-column"></th>
</tr>
</thead>
<tbody>
<tr valign="top">
<th scope="row">
<label for="pwp_default_audio_width">Default Width</label>
<label for="pwp_default_audio_width">Default width:</label>
</th>
<td>
<input name="pwp_default_audio_width" id="pwp_default_audio_width" value="<?php echo get_option('pwp_default_audio_width'); ?>" />
<input name="pwp_default_audio_width" id="pwp_default_audio_width" value="<?php echo get_option('pwp_default_audio_width'); ?>" /> <span class="description">such as "400" (keep blank for auto)</span>
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="pwp_default_audio_height">Default Height</label>
<label for="pwp_default_audio_height">Default height:</label>
</th>
<td>
<input name="pwp_default_audio_height" id="pwp_default_audio_height" value="<?php echo get_option('pwp_default_audio_height'); ?>" />
<input name="pwp_default_audio_height" id="pwp_default_audio_height" value="<?php echo get_option('pwp_default_audio_height'); ?>" /> <span class="description">stick to "30" if unsure</span>
</td>
</tr>
<th scope="row">
<label for="pwp_default_audio_type">Default Type</label>
<label for="pwp_default_audio_type">Default type:</label>
</th>
<td>
<input name="pwp_default_audio_type" id="pwp_default_audio_type" value="<?php echo get_option('pwp_default_audio_type'); ?>" /> <span class="description">such as "audio/mp3"</span>
</td>
</tr>
</tbody>
</table>

<input type="hidden" name="action" value="update">
Expand Down

0 comments on commit 50dcb22

Please sign in to comment.