Implemented popup shortcode for includepage

parent fd4dd83d
......@@ -156,6 +156,7 @@ ul.products li.sexhack_thumbli {
font-size: 0.9em;
color: #e0e0e0;
font-weight: 400;
margin: 0 0 0.11em;
}
......
......@@ -93,6 +93,20 @@ div.etn-single-event-media img.wp-post-image {
}
.shmpopup {
position:fixed;
background-color:black;
z-index:999;
border: 1px solid white;
padding: 15px;
box-shadow: 5px 10px #888888;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 15px;
min-width:400px;
}
.site-header-shmlogin:hover > li.shmlogin > a {
color:#d8d8d8;
}
......@@ -186,6 +200,14 @@ li.current_page_item {
text-align:center;
}
.shm_video_login #pms_login p {
margin-bottom: 3px;
}
.shm_video_login #pms_login p input, .shm_video_login #pms_login div button {
padding: .118047em;
}
.sh_adv_hide {
line-height: 0.8;
margin: 0 0 0 0 ;
......
......@@ -49,7 +49,6 @@ if(!class_exists('SH_Query')) {
{
global $wpdb;
if($source) sexhack_log("save_Video called from $source");
if(is_object($video))
{
......
......@@ -252,27 +252,110 @@ if(!class_exists('SH_Shortcodes')) {
{
extract( shortcode_atts(array(
"page" => '',
'level' => 'public',
'level' => 'public',
'random' => 'false',
'popup' => 'false',
'class' => 'shmpopup',
'campaign' => '',
'expire' => false,
'expiredays' => false,
'delay' => '0',
'before' => '',
'after' => ''
), $attr));
if(!array_key_exists('page', $attr)) return;
if($attr['page']=='') return;
$before='';
$after='';
$content='';
$random=false;
$popup=false;
$shmclass='shmpopup';
$delay='0';
$campaign='';
$expiredays=false;
$expire=false;
if(array_key_exists('expire', $attr) && is_numeric($attr['expire'])) $expire=$attr['expire'];
if(array_key_exists('expiredays', $attr) && is_numeric($attr['expiredays'])) $expiredays=$attr['expiredays'];
if(array_key_exists('campaign', $attr) && $attr['campaign'] != '') $campaign=$attr['campaign'];
if(array_key_exists('delay', $attr) && is_numeric($attr['delay']) && intval($attr['delay']) > 0) $delay=$attr['delay'];
if(array_key_exists('class', $attr) && $attr['class'] != '' ) $shmclass=$attr['class'];
if(array_key_exists('popup', $attr) && $attr['popup']=='true') $popup=true;
if(array_key_exists('before', $attr) && $attr['before'] != '') $before=$attr['before'];
if(array_key_exists('after', $attr) && $attr['after'] != '') $after=$attr['after'];
if(!array_key_exists('level', $attr)) $attr['level'] = 'public';
if(!$expire && !$expiredays) $expiredays="1";
if(($attr['level'] == 'guestonly' && !is_user_logged_in()) || ($attr['level'] == 'public' or !$attr['level']) || (is_user_logged_in() && ($attr['level']=='members' || ($attr['level']=='premium' && user_is_premium()))))
{
if(is_numeric($attr['page'])) {
$ipost = get_post($attr['page']);
if($ipost)
return apply_filters('the_content', $ipost->post_content);
if($pos = strpos($attr['page'], ',')) {
$pages=explode(',', $attr['page']);
} else {
$args = array(
'name' => $attr['page'],
'post_type' => 'page',
'post_status' => 'publish',
'posts_per_page' => 1
);
$res = get_posts($args);
if($res) {
return apply_filters('the_content', $res[0]->post_content);
$pages=array($attr['page']);
}
if($campaign!='') $cookie=$campaign;
else $cookie=md5($attr['page']);
if(count($pages) > 1 && array_key_exists('random', $attr) && $attr['random']=='true') $random=true;
if($random || $popup) {
$class=str_replace('.', '_', uniqid('shinclude_', true));
$script="<script language='javascript'>\n";
if($expiredays || $expire) $script.="var strcookie = readCookie('shmpopup_".$cookie."'); if (strcookie === null) {";
$script.="$(window).on('load', function() {\n";
}
if($random) {
$script.=" shinc=$($('.".$class."')[Math.floor(Math.random()*$('.".$class."').length)]);\n";
} else if($popup) {
$script.=" shinc=$('.".$class."');";
}
if($popup) {
$script.=" shinc.addClass('".$shmclass."');";
if($campaign!='') $script.=" shinc.find('form').submit(function(){\$.post('/content/plugins/matomo/app/matomo.php', {'idsite':1, 'rec': '1','mtm_campaign': '".$campaign."','mtm_kwd': shinc.attr('data-shmname') })});";
}
if($random || $popup) {
$script.=" setTimeout(function() { shinc.show();";
if($expiredays) $script.=" createCookie('shmpopup_".$cookie."','opened',$expiredays);";
elseif($expire) $script.=" createCookieSeconds('shmpopup_".$cookie."','opened',$expire);";
$script.=" }, $delay);\n";
$script.="});\n";
if($expiredays || $expire) $script.="}\n";
$script.="</script>";
$before=$script.$before;
}
foreach($pages as $page) {
$popheader="<div style='float:right;width:10%;margin-left:90%;border:1px solid white;border-radius:10px;padding:5px;cursor:pointer;min-width:60px;' onClick='$(\".".$class."\").hide();'>Close X</div>";
$randheader="<div data-shmname='".$page."' class='".$class."' style='display:none;'>";
if(is_numeric($page)) {
$ipost = get_post($page);
if($ipost) {
if($random || $popup) $content.=$randheader;
if($popup) $content.=$popheader;
$content=$content.$ipost->post_content;
if($random || $popup) $content.="</div>";
}
} else {
$args = array(
'name' => $page,
'post_type' => 'page',
'post_status' => 'publish',
'posts_per_page' => 1
);
$res = get_posts($args);
if($res) {
if($random || $popup) $content.=$randheader;
if($popup) $content.=$popheader;
$content=$content.$res[0]->post_content;
if($random || $popup) $content.="</div>";
}
}
}
}
if($content && $content!='')
return apply_filters('the_content', $before.$content.$after);
}
return;
}
......
......@@ -119,7 +119,7 @@ if(!class_exists('SH_Video')) {
if(!is_array($attr)) return false;
foreach($attr as $k => $v)
{
if(array_key_exists($k, $this->attributes)) $this->attributes[$k] = $v;
if(array_key_exists($k, $this->attributes)) $this->attributes[$k] = stripslashes($v);
}
if($post && is_object($post)) $this->__set('post', $post);
......
......@@ -142,7 +142,7 @@ if(!class_exists('SH_VideoGallery')) {
elseif($video_preview) $vtags[] = '<label class="sexhack_vtag sexhack_preview" style="*LEFT*">preview</label>';
if($hls_member)$vtags[] = '<label class="sexhack_vtag sexhack_members" style="*LEFT*">members</label>';
if($hls_premium) {
if($video->ppv_is_ppv) $vtags[] = '<label class="sexhack_vtag sexhack_premium" style="*LEFT*">PPV</label>';
if($premium_is_ppv=='Y') $vtags[] = '<label class="sexhack_vtag sexhack_premium" style="*LEFT*">PPV</label>';
else $vtags[] = '<label class="sexhack_vtag sexhack_premium" style="*LEFT*">premium</label>';
}
......
......@@ -114,7 +114,8 @@ function save_sexhack_video_forms( $post_id)
}
// Video description
$video->description = sanitize_text_field( $_POST['video_description'] );
//$video->description = sanitize_text_field( $_POST['video_description'] );
$video->description = $_POST['video_description'];
......
......@@ -5,7 +5,40 @@ function shmChangeGif(o){
console.log("loading "+o.src);
}
function createCookieSeconds(name,value,seconds) {
if(seconds) {
var date = new Date();
date.setTime(date.getTime()+(seconds*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
//window.onload = function(){
//var thumbhovers = document.getElementsByClassName("sexhack_thumb_hover");
//for (var i = 0; i < thumbhovers.length; i++) {
......
......@@ -84,7 +84,8 @@ get_header(); ?>
$video_preview = $video->preview;
$gif_preview = $video->gif_small;
$gif = $video->gif;
$premium_is_ppv = $video->premium_is_ppv;
$premium_is_ppv = false;
if($video->premium_is_ppv=='Y') $premium_is_ppv=true;
$categories = $video->get_categories(true);
......@@ -104,10 +105,12 @@ get_header(); ?>
$tabtext = array('subscribers' => 'Subscribers',
'members' => 'Members',
'public' => 'Public');
if($premium_is_ppv) $tabtext['subscribers'] = 'PPV';
if($hls_public || $video_preview ) $avail[] = 'public';
if($hls_members) $avail[] = 'members';
if($hls_premium) $avail[] = 'subscribers';
$videoaccess = get_query_var('videoaccess', false);
if($videoaccess && in_array($videoaccess, $avail))
......@@ -240,29 +243,42 @@ get_header(); ?>
<?php echo $video->get_title(); echo " (".$tabtext[$tab]." version)"; ?>
</h2>
</header><!-- .entry-header -->
<br><hr>
<p><?php echo do_shortcode($video->description); ?></p>
<?php
$pcontent = do_shortcode(get_post()->post_content);
if($pcontent!='') { ?>
<p><?php echo $pcontent; ?></p>
<?php } ?>
<hr>
<?php
echo $htmltags;
?>
<?php if(!$video->user_bought_video() && $hls_premium && ($premium_is_ppv && user_is_premium() || !user_is_premium())) { ?>
<h3><a href="<?php echo \wc_get_checkout_url()."?add-to-cart=".strval($video->product_id)."&shm_direct_checkout=".strval($video->product_id); ?>"><button>Buy unlimited access to this video</button></a></h3>
<?php } ?>
<?php if(!$video->user_bought_video() && $hls_premium && !$premium_is_ppv && !user_is_premium() && user_is_member()) { ?>
<h3><a href="/product-category/subscriptions/"><button>Upgrade to access premium versions</button></a></h3>
<?php } ?>
<?php if($video->has_downloads()) { // XXX IS already bought this should redirect to the video ?>
<?php if(!$video->user_bought_video()) { ?>
<h3><a href="<?php echo \wc_get_checkout_url()."?add-to-cart=".strval($video->product_id)."&shm_direct_checkout=".strval($video->product_id); ?>"><button>Download full version</button></a></h3>
<?php } else { ?>
<h3><a href="<?php echo get_permalink($video->product_id);?>"><button>Download</button></a></h3>
<?php } ?>
<?php } ?>
<?php if(!user_has_member_access()) { ?>
<div class='sexhack-videonotify' style="padding:1px; margin: 0 auto;">
<div class='sexhack-videonotify' style="padding:1px; margin: 0 auto; margin-left: 10%;">
<a href="/register/">
<img src="<?php echo plugin_dir_url(__FILE__)."/img/cropped-sexhack_members-300x99.jpg";?>" alt="Register for free and watch members version!" />
</a>
</div>
<?php } ?>
<?php if(!$video->user_bought_video() && $hls_premium && $premium_is_ppv) { ?>
<h3><a href="<?php echo get_permalink($video->product_id); ?>">Buy unlimited full access to this video</a></h3>
<?php } ?>
<?php if($video->has_downloads()) { ?>
<h3><a href="<?php echo get_permalink($video->product_id); ?>">Download the full lenght hi-res version of this video</a></h3>
<?php } ?>
<?php
if(!is_user_logged_in())
echo "<div style='width: 80%; margin-left: 10%;' >".do_shortcode('[pms-login redirect_url="/account" ]')."</div>";
echo "<div class='shm_video_login' style='max-width: 300px; width: 80%; margin-left: 10%;' ><h4>Already a member? Login:</h4></div>";
echo "<div class='shm_video_login' style='max-width: 300px; width: 80%; margin-left: 10%;' >".do_shortcode('[pms-login redirect_url="/account" ]')."</div>";
?>
<hr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment