Wistia Player API plugin for wordpress


Hello Guys,

I would like to tell about the Wistia Player API with wordpress Shortcode.

Here is the code for the wistia player API plugin for wordpress.

Following steps you must be follow.

Step 1:

Just copy and paste this php code with new file. File namis yours.

Step 2:

Upload that file to your wordpress wp-content folder.

Step 3:

Go to the back-end of your wordpress site and enable this plugin.

Step 4:

Now this plugin is ready to configure. see the left menu with settings tab. Here you can see the wistia player tab. Just go to this page.  You can see the settings for the API key for wistia player .

Step 5:

if you don’t have API key means,  go to this site <a href=”http://wistia.com&#8221; target=”_blank”>http://wistia.com<a/&gt; and register as user in wistia site.

Step 6:

You can use this short-code in post, page and widget.

[wistia clip_id=”32090122″ width=”600″ height=”375″]

You can get the clip id from wistia.com site. You can upload your videos there.

That’s All. Now you can see the video in your wordpress site.

<!———————————————————————

<?php
/*
Plugin Name: Wistia Player
Plugin URI: http://wistia.com
Description: Wistia Video player for wordpress .
Version: The Plugin’s Version Number, e.g.: 1.0
Author: Manimaran
Author URI: https://manisanjai.wordpress.com
License: Free
*/
add_action(‘admin_menu’, ‘wistia_player_menu’);

function wistia_player_menu() {
add_options_page(‘Wistia Player Options’, ‘Wistia Player’, ‘manage_options’, ‘my-unique-identifier’, ‘wistia_player_options’);
add_action( ‘admin_init’, ‘register_mysettings’ );

}
function register_mysettings() {
//register our settings
if($_POST[‘api_user_id’])
update_option(“api_user_id”, $_POST[‘api_user_id’]);
if($_POST[‘api_user_password’])
update_option(“api_user_password”, $_POST[‘api_user_password’]);
if($_POST[‘api_width’])
update_option(“api_width”, $_POST[‘api_width’]);
if($_POST[‘api_height’])
update_option(“api_height”, $_POST[‘api_height’]);
}

function wistia_player_options() {
if (!current_user_can(‘manage_options’))  {
wp_die( __(‘You do not have sufficient permissions to access this page.’) );
}?>
<div>
<h2>Wistia Player Settings</h2>

<form method=”post” action=””>

<table>
<tr valign=”top”>
<th scope=”row”>API USER ID :</th>
<td><input type=”text” name=”api_user_id” value=”<?php echo get_option(‘api_user_id’); ?>” /></td>
</tr>
<tr valign=”top”>
<th scope=”row”>API PASSWORD :</th>
<td><input type=”text” name=”api_user_password” value=”<?php echo get_option(‘api_user_password’); ?>” /></td>
</tr>
<tr valign=”top”>
<th scope=”row”>Default Width :</th>
<td><input type=”text” name=”api_width” value=”<?php echo get_option(‘api_width’); ?>” /></td>
</tr>
<tr valign=”top”>
<th scope=”row”>Default Height :</th>
<td><input type=”text” name=”api_height” value=”<?php echo get_option(‘api_height’); ?>” /></td>
</tr>
<tr valign=”top”>
<th scope=”row”>You can use short-code :</th>
<td><strong>[wistia clip_id=”32090212″ width=”600″ height=”375″]</strong></p></td>
</tr>

</table>

<p>
<input type=”submit” value=”<?php _e(‘Save Changes’) ?>” />
</p>
</form>
</div>
<?php
}
class lux_wistia {

function shortcode($atts, $content=null) {
extract(shortcode_atts(array(
‘clip_id’     => ”,
‘width’     => ”,
‘height’     => ”,
), $atts));

if(!$width)
$width = get_option(‘api_width’);
if(!$height)
$height = get_option(‘api_height’);

if(!$width)
$width = ‘600’;
if(!$height)
$height = ‘375’;

$api_user_id = get_option(‘api_user_id’);

$api_user_password = get_option(‘api_user_password’);

if (empty($clip_id)) return ‘<!– Lux Vimeo: Invalid clip_id –>’;

$url = “https://api.wistia.com/v1/medias/$clip_id.json&#8221;;

$context = stream_context_create(array(
‘http’ => array(
‘method’=>”GET”,
‘header’  => “Authorization: Basic ” . base64_encode(“$api_user_id:$api_user_password”),
))
);
$return = file_get_contents($url, false, $context);
if($return){
$result = json_decode(“$return”);
}
global $current_user;
if(!$current_user->ID){
$ss = $width.’x’.$height;
if($result)
echo ‘<div ><a href=”‘.get_permalink().'”><img src=”‘.str_replace(“100×60″,$ss,$result->thumbnail->url).'” border=”0″ /></a></div>’;
}else{
if($result)
echo ‘<div >’.$result->embedCode.'</div>’;
}
?>
<style type=”text/css”>
.wistia_class object, .wistia_class embed{
width:<?php echo $width;?>px;
height:<?php echo $height;?>px;
float:left;
}
</style>
<?php

}
}
add_shortcode(‘wistia’, array(‘lux_wistia’, ‘shortcode’));
?>

——————————————————————–>

Here is screenshot for the plugin settings:

If you have any clarification about this one, you can contact me via email:

manisanjai@gmail.com

2 thoughts on “Wistia Player API plugin for wordpress

  1. Tried this but got error everytime I tried to activate.

    Parse error: syntax error, unexpected T_STRING in /data10/var/www/vhosts/2355productions.com/httpdocs/wp-content/plugins/Wistia.php on line 14

    Any help?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s