Skip to content

Commit

Permalink
Only use the external controller if we embed an iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
Mataniko committed Apr 24, 2015
1 parent 382e747 commit ef75963
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 35 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ Copy the folder "thePlatform-video-manager" with all included files into the "wp

# == Screenshots ==

1. thePlatform's Setting screen
2. View your media library, search for videos, and sort the returned media set
3. Modify video metadata
1. Manage and Edit Media in mpx
2. Upload Media to mpx directly from WordPress
3. Choosing different metadata fields
4. Easily embed videos from mpx into your posts
5. Upload media to your mpx account

# == Changelog ==

## = 2.1.0 =
* Added Advanced Settings
* Added new shortcode parameters
* Simplified account settings
* Added a new option to embed the PDK external controller in posts with our video player

## = 2.0.0 =
* Removed 3rd party libraries in favor of native Wordpress look and feel
Expand Down Expand Up @@ -161,6 +161,7 @@ This plugin requires an account with thePlatform's mpx. Please contact your Acco
## = Embedding Preferences =
* Default Player - The default player used for embedding and in the Media Browser
* Embed Tag Type - IFrame or Script embed
* Use PDK External Controller - Load the external controller in posts that have our player as an IFrame
* Media Embed Type - Embed Media by the Media PID, Release PID or Media GUID.
* Player Embed Type - Video Only (/embed/) or Full Player
* RSS Embed Type - In an RSS feed, provide a link back to the Article, or an iframe/script tag
Expand Down
9 changes: 5 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ View your content hosted by thePlatform and easily embed videos from your librar
Copy the folder "thePlatform-video-manager" with all included files into the "wp-content/plugins" folder of WordPress. Activate the plugin and set your mpx credentials in the plugin settings interface.

== Screenshots ==
thePlatform's Setting screen
View your media library, search for videos, and sort the returned media set
Modify video metadata
Manage and Edit Media in mpx
Upload Media to mpx directly from WordPress
Choosing different metadata fields
Easily embed videos from mpx into your posts
Upload media to your mpx account

== Changelog ==

= 2.1.0 =
Added Advanced Settings
Added new shortcode parameters
Simplified account settings
Added a new option to embed the PDK external controller in posts with our video player

= 2.0.0 =
Removed 3rd party libraries in favor of native Wordpress look and feel
Expand Down Expand Up @@ -159,6 +159,7 @@ mpx Account - The mpx account to upload and retrieve media from
= Embedding Preferences =
Default Player - The default player used for embedding and in the Media Browser
Embed Tag Type - IFrame or Script embed
Use PDK External Controller - Load the external controller in posts that have our as an IFrame
Media Embed Type - Embed Media by the Media PID, Release PID or Media GUID.
Player Embed Type - Video Only (/embed/) or Full Player
RSS Embed Type - In an RSS feed, provide a link back to the Article, or an iframe/script tag
Expand Down
2 changes: 1 addition & 1 deletion thePlatform-constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function TP_PREFERENCES_OPTIONS_FIELDS() {
),
array(
'id' => 'enqueue_external_controller',
'title' => 'Enqueue PDK External Controller',
'title' => 'Use PDK External Controller',
'type' => 'boolean'
),
array(
Expand Down
43 changes: 17 additions & 26 deletions thePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ function __construct() {
add_action( 'admin_init', array( $this, 'register_scripts' ) );
add_action( 'admin_init', array( $this, 'theplatform_register_plugin_settings' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_external_controller' ) );

if ( current_user_can( $this->tp_editor_cap ) ) {
add_filter( 'media_upload_tabs', array( $this, 'tp_upload_tab' ) );
Expand Down Expand Up @@ -134,18 +133,6 @@ function admin_enqueue_scripts( $hook ) {
}
}

function enqueue_external_controller( $hook ) {
$preferences = get_option( TP_PREFERENCES_OPTIONS_KEY );

if ( $preferences === false ) {
return;
}

if ( $preferences['enqueue_external_controller'] == 'true' ) {
wp_enqueue_script( 'tp_pdk_external_controller_js', '//pdk.theplatform.com/pdk/tpPdkController.js' );
}
}

/**
* Registers javascripts and css used throughout the plugin
*/
Expand Down Expand Up @@ -660,19 +647,19 @@ function shortcode( $atts ) {
}

list( $account, $width, $height, $media, $player, $mute, $autoplay, $tag, $embedded, $params, $playall, $instance ) = array_values( shortcode_atts( array(
'account' => '',
'width' => '',
'height' => '',
'media' => '',
'player' => '',
'mute' => '',
'autoplay' => '',
'tag' => '',
'embedded' => '',
'params' => '',
'playall' => '',
'instance' => '',
), $atts ) );
'account' => '',
'width' => '',
'height' => '',
'media' => '',
'player' => '',
'mute' => '',
'autoplay' => '',
'tag' => '',
'embedded' => '',
'params' => '',
'playall' => '',
'instance' => '',
), $atts ) );

if ( empty( $width ) ) {
$width = (int) $this->preferences['default_width'];
Expand Down Expand Up @@ -719,6 +706,10 @@ function shortcode( $atts ) {
$instance = mt_rand();
}

if ( $this->preferences['enqueue_external_controller'] == 'true' && $tag == 'iframe' ) {
wp_enqueue_script( 'tp_pdk_external_controller_js', '//pdk.theplatform.com/pdk/tpPdkController.js' );
}


if ( ! is_feed() ) {
$output = $this->get_embed_shortcode( $account, $media, $player, $width, $height, $autoplay, $tag, $embedded, $mute, $params, $playall, $instance );
Expand Down

0 comments on commit ef75963

Please sign in to comment.