'25%','50'=>'50%','75'=>'75%');
//public $prepare_switch = true;
// Construct
public function __construct()
{
$plugin_b = plugin_basename(__FILE__);
$plugin_b = "playpops.php";
// exit();
add_filter('plugin_action_links_' . $plugin_b, 'mmPlayPopsFb_ActionLinks');
add_action('add_meta_boxes', array( $this, 'mmPlayPopsFb_AddMetaBox'));
add_action('save_post', array( $this, 'mmPlayPopsFb_Save'));
add_filter('the_content', array($this, 'mmPlayPopsFb_ConvertPlayer'), 20);
// add_filter('the_content', array($this, 'mmAddtoBodyTop'), 20);
}
// -------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------
// Functions
// -------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------
public function mmGetShareButtons($urlshare, $playpops_skip_message)
{
/*
-->
*/
// Create image directory
$dirImages = PLAYPOPS_PLUGIN_URL . "images";
// Create share buttons
$sharebuttons = '
';
$popskipmsg = '
';
$sharebuttons = $sharebuttons . $popskipmsg;
return $sharebuttons;
}
/*
public function mmAddtoBodyTop($content)
{
if(is_single())
{
$iframe_js = "";
$content = $iframe_js . $content;
}
return $content;
}
*/
public function mmGetVideoLength($video_id, $playpops_key)
{
// If playpops key is not defined then exit
if (empty($playpops_key))
return;
// Define url for google api calls
$url = 'https://www.googleapis.com/youtube/v3/videos?id=' . $video_id . '&part=contentDetails&key=' . $playpops_key;
// AIzaSyDUUjO-exXUFhEIlDXfbm4N6ocMGA-ZFnk
//Using cURL php extension to make the request to youtube API
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//$feed holds a rss feed xml returned by youtube API
$json_response = curl_exec($ch);
//print_r($json_response);
//exit();
curl_close($ch);
//$entry = $xml->entry[0];
$responseObj = json_decode($json_response, true);
// duration
$duration = $responseObj['items'][0]['contentDetails']['duration'];
// Convert to seconds
preg_match_all('/(\d+)/', $duration, $parts);
$hours = floor($parts[0][0] / 60);
$minutes = $parts[0][0] % 60;
$seconds = $parts[0][1];
$totalseconds = ($hours * 3600) + ($minutes * 60) + $seconds;
return $totalseconds;
}
// Get current url
public function mmCurPageURL()
{
$pageURL = 'http';
if (isset($_SERVER["HTTPS"]))
if ($_SERVER["HTTPS"] == "on")
{
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80")
$pageURL .= $_SERVER["SERVER_NAME"].":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
else
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
return $pageURL;
}
// -------------------------------------------
// functions : Social Functions
// -------------------------------------------
public function mmFacebookLike($fb_pageurl, $playpops_skip_message)
{
// Define the popup skip message
$popskipmsg = '';
// define the small box
$iframe_box320 = '';
// define the bigger size frame
$iframe_box600 = '';
$iframe_box = $iframe_box320 . $iframe_box600 . $popskipmsg;
return $iframe_box;
}
// -------------------------------------------
// functions : Admin Functions
// -------------------------------------------
// Add Settings Link
public function mmPlayPops_ActionLinks($links)
{
$links[] = 'Settings';
return $links;
}
//
function mmRearrangeVideos($videos_iframes)
{
// Open an array empty
$new_videos = array();
// reorder the videos dims
for ($j = 0; $j < count($videos_iframes[0]); $j++)
{
// define the index re-order
if ($j == 1)
$row = 3;
elseif ($j == 2)
$row = 1;
elseif ($j == 3)
$row = 2;
else
$row = $j;
// Re-organize the array
$new_videos[0][$row] = $videos_iframes[0][$j];
}
return $new_videos;
}
//
function mmPlayPopsFb_ArrayConcatenate($videos_frm, $videos_obj)
{
// Open an array empty
$new_videos = array();
// Determine which array is bigger and save count as max value
if (count($videos_frm[0]) > count($videos_obj[0]))
{
$videos_max = count($videos_frm[0]);
}
else
{
$videos_max = count($videos_obj[0]);
// Determine how many videos need to be added
$videos_total = count($videos_frm[0]) + count($videos_obj[0]);
$video_counter = 0;
$video_counter_j = 0;
}
for ($i = 0; $i < count($videos_frm); $i++)
{
// reorder the videos dims
for ($j = 0; $j < count($videos_frm[0]); $j++)
{
//echo $i . " " . $video_counter_j . " | " . $i . " " . $j . "
";
//echo $videos_frm[$i][$j] . "
";
$new_videos[$i][$video_counter_j] = $videos_frm[$i][$j];
//$video_counter = $video_counter + 1;
$video_counter_j = $video_counter_j + 1;
}
for ($j = 0; $j < count($videos_obj[0]); $j++)
{
//echo $i . " " . $video_counter_j . " | " . $i . " " . $j . "
";
//echo $videos_obj[$i][$j] . "
";
$new_videos[$i][$video_counter_j] = $videos_obj[$i][$j];
//$video_counter = $video_counter + 1;
$video_counter_j = $video_counter_j + 1;
}
// reset the counter
//$video_counter = 0;
$video_counter_j = 0;
}
return $new_videos;
}
// http://stackoverflow.com/a/5831191/430112
function mmGetiFrames($text)
{
// Start with an empty array
$matches = array();
// Find all iframe embedded youtube players with the link first
// width height source
$pattern[0] = '~