‘https://www.youtube.com/embed/’ . $video_id . ‘?autoplay=1&mute=1&loop=1&playlist=’ . $video_id . ‘&playsinline=1&enablejsapi=1’ . $extra_params, ‘is_yt’ => true ); } return array(’embed’ => $url, ‘is_yt’ => false); } // 3. डैशबोर्ड मेनू का लेआउट function dkzon_mp4_linker_page() { if (isset($_POST[‘save_dkzon_mp4’])) { $videos = array(); if (isset($_POST[‘mp4_url’]) && is_array($_POST[‘mp4_url’])) { foreach ($_POST[‘mp4_url’] as $key => $url) { $prod_id = sanitize_text_field($_POST[‘product_id’][$key]); $user_name = sanitize_text_field($_POST[‘user_name’][$key]); $likes_cnt = sanitize_text_field($_POST[‘likes_count’][$key]); $url = esc_url_raw($url); if (!empty($url) && !empty($prod_id)) { $saved_videos_old = get_option(‘dkzon_mp4_video_data’, array()); $user_clicks = isset($saved_videos_old[$key][‘user_clicks_count’]) ? $saved_videos_old[$key][‘user_clicks_count’] : 0; $videos[] = array( ‘url’ => $url, ‘product_id’ => $prod_id, ‘user_name’ => !empty($user_name) ? $user_name : ‘Happy Buyer’, ‘likes_count’ => !empty($likes_cnt) ? $likes_cnt : ‘450’, ‘user_clicks_count’=> $user_clicks ); } } } update_option(‘dkzon_mp4_video_data’, $videos); echo ‘
DKZON Engine Updated Successfully!’; } $saved_videos = get_option(‘dkzon_mp4_video_data’, array()); ?>
DKZON – Reels Pro v28.0
$video) { $count++; $live_user_likes = isset($video[‘user_clicks_count’]) ? $video[‘user_clicks_count’] : 0; ?>
| S.No. | Direct .mp4 or YouTube URL | WooCommerce ID | User Name (Overlay) | Base Likes | Live Likes | Shortcode | Action |
|---|---|---|---|---|---|---|---|
| + | Delete | ||||||
| 0 | Auto | Delete |
+ Add New Reel ”), $atts); $saved_videos = get_option(‘dkzon_mp4_video_data’, array()); if (empty($saved_videos) || !is_array($saved_videos)) return ”; global $dkzon_reels_should_load_js; $dkzon_reels_should_load_js = true; $requested_key = ($pairs[‘key’] !== ”) ? intval($pairs[‘key’]) : null; if ($requested_key === null || !isset($saved_videos[$requested_key])) { return ”; } $preview_slide_data = $saved_videos[$requested_key]; $preview_video_url = isset($preview_slide_data[‘url’]) ? $preview_slide_data[‘url’] : ”; $preview_prod_id = isset($preview_slide_data[‘product_id’]) ? intval($preview_slide_data[‘product_id’]) : 0; $preview_prod_img = ”; $preview_rating = ‘4.5’; $preview_price = ”; if (function_exists(‘wc_get_product’) && $preview_prod_id > 0) { $preview_product = wc_get_product($preview_prod_id); if ($preview_product) { $img_id = $preview_product->get_image_id(); if ($img_id) { $img_src = wp_get_attachment_image_src($img_id, ‘thumbnail’); if ($img_src) { $preview_prod_img = $img_src[0]; } } if (empty($preview_prod_img)) { $preview_prod_img = wc_placeholder_img_src(‘thumbnail’); } $avg_rating = $preview_product->get_average_rating(); if ($avg_rating > 0) { $preview_rating = number_format($avg_rating, 1); } $raw_price = $preview_product->is_type(‘variable’) ? $preview_product->get_variation_price(‘min’) : $preview_product->get_price(); $preview_price = (!empty($raw_price) || $raw_price == 0) ? wc_price($raw_price) : $preview_product->get_price_html(); } } $output = ”; $preview_yt_data = dkzon_get_youtube_data($preview_video_url, true); $output .= ‘
‘; if ($preview_yt_data[‘is_yt’]) { $output .= ”.esc_url($preview_yt_data[’embed’]).”; $output .= ‘
‘; } else { $output .= ‘‘; } $output .= ‘
‘; if (!empty($preview_prod_img)) { $output .= ‘‘; } $output .= ‘
‘; $output .= ‘
‘; $output .= ”.$preview_rating.’ ★’; $output .= ‘
‘; if (!empty($preview_price)) { $output .= ‘
‘.$preview_price.’
‘; } $output .= ‘
‘; $output .= ‘
‘; $output .= ”; return $output; } // 5. AJAX Hooks add_action(‘wp_ajax_dkzon_save_live_like’, ‘dkzon_save_live_like_callback’); add_action(‘wp_ajax_nopriv_dkzon_save_live_like’, ‘dkzon_save_live_like_callback’); function dkzon_save_live_like_callback() { if (isset($_POST[‘reel_key’]) && isset($_POST[‘action_type’])) { $reel_key = intval($_POST[‘reel_key’]); $action_type = sanitize_text_field($_POST[‘action_type’]); $saved_videos = get_option(‘dkzon_mp4_video_data’, array()); if (isset($saved_videos[$reel_key])) { $current_clicks = isset($saved_videos[$reel_key][‘user_clicks_count’]) ? intval($saved_videos[$reel_key][‘user_clicks_count’]) : 0; $saved_videos[$reel_key][‘user_clicks_count’] = ($action_type === ‘increase’) ? $current_clicks + 1 : max(0, $current_clicks – 1); update_option(‘dkzon_mp4_video_data’, $saved_videos); } } wp_die(); } // 6. मास्टर पॉपअप और स्क्रिप्ट्स इंजन (Full Render Fix) add_action(‘wp_footer’, ‘dkzon_render_master_pool_popup_html’); function dkzon_render_master_pool_popup_html() { global $dkzon_reels_should_load_js; if (empty($dkzon_reels_should_load_js)) return; $saved_videos = get_option(‘dkzon_mp4_video_data’, array()); if (empty($saved_videos) || !is_array($saved_videos)) return; $all_admin_keys = array_keys($saved_videos); ?> ×
0) { $product = wc_get_product($prod_id); if ($product) { $prod_title = $product->get_name(); $average_rating = $product->get_average_rating(); if ($average_rating > 0) { $rating = number_format($average_rating, 1); } } } global $wp; $wp_request = (isset($wp) && is_object($wp) && isset($wp->request)) ? $wp->request : ”; $current_page_url = add_query_arg( array( ‘reel_id’ => $current_key ), home_url($wp_request) ); $slide_uniq = ‘master_reel_’ . $current_key; $yt_data = dkzon_get_youtube_data($mp4_url, false); ?>
<div class="swiper-slide" data-reel-key="<?php echo $current_key; ?>">
<?php if ($yt_data['is_yt']) : ?>
<!-- Master Touch Protection Overlay Layer -->
<div class="dkzon-yt-touch-overlay" onclick="toggleYtPlayPauseState('<?php echo $slide_uniq; ?>_video')"></div>
<iframe id="<?php echo $slide_uniq; ?>_video" src="<?php echo esc_url($yt_data['embed']); ?>" style="width:100%; height:100%; border:none; display:block; aspect-ratio:9/16; border-radius:24px;" allow="autoplay; encrypted-media; picture-in-picture" data-yt="true"></iframe>
<?php else : ?>
<video id="<?php echo $slide_uniq; ?>_video" src="<?php echo esc_url($mp4_url); ?>" loop playsinline muted style="width:100%; height:100%; display:block; object-fit: cover; aspect-ratio: 9/16; border-radius:24px;" data-yt="false" onclick="toggleMp4PlayPauseState(this)"></video>
<?php endif; ?>
<!-- Side Control Panel Inside Slide Context -->
<div style="position: absolute; right: 14px; bottom: 115px; display: flex; flex-direction: column; align-items: center; gap: 16px; z-index: 101; pointer-events: auto;">
<button onclick="toggleReelMute('<?php echo $slide_uniq; ?>_video', this)" class="reel-sound-btn muted" style="background: rgba(0,0,0,0.5); border: none; border-radius: 50%; width: 42px; height: 42px; cursor: pointer; color: #fff; display: flex; align-items: center; justify-content: center; padding:0; backdrop-filter: blur(4px); margin-bottom: 2px;">
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18H5a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h4l5-5v18l-5-5z" fill="currentColor" stroke="none"></path><line class="mute-line" x1="1" y1="1" x2="23" y2="23" stroke="#fff" stroke-width="2.5"></line></svg>
</button>
<div style="text-align: center; cursor: pointer;" onclick="handleReelLike(this, '<?php echo $current_key; ?>')" data-liked="false">
<div class="like-icon" style="background: rgba(0,0,0,0.5); border-radius: 50%; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; color: #fff;">
<svg viewBox="0 0 24 24" width="22" height="22" fill="currentColor"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>
</div>
<span class="like-counter" style="color: #fff; font-size: 12px; font-weight: bold; text-shadow: 1px 1px 4px rgba(0,0,0,0.8); display:block; margin-top:4px;"><?php echo $total_likes; ?></span>
</div>
<div style="text-align: center; cursor: pointer;" onclick="triggerDkzonUniversalLiveShare('<?php echo esc_js($prod_title); ?>', '<?php echo esc_url($current_page_url); ?>')">
<div class="share-btn-box" style="background: rgba(0,0,0,0.5); border-radius: 50%; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; color: #fff;">
<svg viewBox="0 0 24 24" width="22" height="22" fill="currentColor"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92 1.61 0 2.92-1.31 2.92-2.92s-1.31-2.92-2.92-2.92z"/></svg>
</div>
<span style="color: #fff; font-size: 12px; font-weight: bold; text-shadow: 1px 1px 4px rgba(0,0,0,0.8); display:block; margin-top:4px;">Share</span>
</div>
</div>
<!-- Gradient Layer & User Info Card -->
<div style="position: absolute; bottom: 0; left: 0; width: 100%; height: 160px; background: linear-gradient(to top, rgba(0,0,0,0.9) 30%, rgba(0,0,0,0.4) 70%, transparent); z-index: 100; pointer-events: none;"></div>
<div style="position: absolute; left: 16px; bottom: 85px; z-index: 101; display: flex; flex-direction: column; gap: 6px; pointer-events: none;">
<div style="display: flex; align-items: center; gap: 8px;">
<?php
$avatar_letter = function_exists('mb_substr') ? mb_substr($user_name, 0, 1, 'UTF-8') : substr($user_name, 0, 1);
?>
<div style="width: 32px; height: 32px; background: #9f2265; border-radius: 50%; color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 13px; border: 1.5px solid #fff;"><?php echo esc_html($avatar_letter); ?></div>
<div><p style="color: #fff; margin: 0; font-size: 14px; font-weight: 700;">@<?php echo str_replace(' ', '', strtolower($user_name)); ?></p></div>
</div>
<div style="display: flex; align-items: center; margin-top: 2px;">
<div style="background: #23bb75; color: #fff; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 12px;"><?php echo $rating; ?> ★</div>
</div>
</div>
<!-- CTA Button Layer -->
<div style="position: absolute; bottom: 0; left: 0; width: 100%; padding: 18px; box-sizing: border-box; z-index:101; pointer-events: auto;">
<a href="<?php echo esc_url(get_permalink($prod_id)); ?>" class="button expand" style="background-color:#830b0b !important; border-color:#9f2265 !important; color:#ffffff !important; border-radius:12px; font-weight:700; font-size:14px; padding: 1px 20px; display: block; text-align: center; margin: 0; text-decoration:none;"><i class="icon-shopping-cart" style="margin-right:8px;"></i> Buy Now (Select Size)</a>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
<!-- मास्टर जावास्क्रिप्ट थ्रेड कंट्रोलर -->
<script>
var dkzon_ajax_url = "<?php echo admin_url('admin-ajax.php'); ?>";
var dkzon_master_swiper = null;
var dkzon_global_muted = true;
var dkzon_ordered_keys_pool = <?php echo json_encode($all_admin_keys); ?>;
var dkzon_yt_play_states = {};
function openDkzonMasterPoolReels(targetKey) {
var modal = document.getElementById('dkzon-master-modal');
if (!modal) return;
modal.style.display = 'flex';
document.body.style.overflow = 'hidden';
var containerEl = document.getElementById('dkzon-master-swiper-container');
if (dkzon_master_swiper) {
dkzon_master_swiper.destroy(true, true);
dkzon_master_swiper = null;
}
if (containerEl && !dkzon_master_swiper) {
dkzon_master_swiper = new Swiper(containerEl, {
direction: 'vertical',
slidesPerView: 1,
spaceBetween: 0,
watchSlidesProgress: true,
autoHeight: false,
roundLengths: true,
resistanceRatio: 0,
nested: true,
touchReleaseOnEdges: true,
passiveListeners: false,
threshold: 8,
observer: true,
observeParents: true,
on: {
init: function () { dkzon_master_play_active(this); },
slideChange: function () { dkzon_master_play_active(this); }
}
});
}
var slideIndex = dkzon_ordered_keys_pool.indexOf(parseInt(targetKey));
if (slideIndex > -1 && dkzon_master_swiper) {
dkzon_master_swiper.update();
dkzon_master_swiper.slideTo(slideIndex, 0, false);
setTimeout(function() {
dkzon_master_play_active(dkzon_master_swiper);
}, 100);
}
}
function dkzon_master_play_active(swiperInstance) {
swiperInstance.slides.forEach(function(slide) {
var video = slide.querySelector('video');
if (video) { video.pause(); }
var iframe = slide.querySelector('iframe');
if (iframe) { iframe.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); }
});
var activeSlide = swiperInstance.slides[swiperInstance.activeIndex];
if (!activeSlide) return;
// अगले और पिछले स्लाइड को डोम थ्रेड में रिफ्लेक्सिवली शो करने के लिए
swiperInstance.update();
var activeVideo = activeSlide.querySelector('video');
var activeIframe = activeSlide.querySelector('iframe');
var soundBtn = activeSlide.querySelector('.reel-sound-btn');
var muteLine = soundBtn ? soundBtn.querySelector('.mute-line') : null;
if (soundBtn && muteLine) {
muteLine.style.display = dkzon_global_muted ? 'block' : 'none';
}
if (activeVideo) {
activeVideo.muted = dkzon_global_muted;
activeVideo.play().catch(function(e){});
}
if (activeIframe) {
var iframeId = activeIframe.id;
dkzon_yt_play_states[iframeId] = true;
var action = dkzon_global_muted ? 'mute' : 'unMute';
setTimeout(function() {
activeIframe.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
activeIframe.contentWindow.postMessage('{"event":"command","func":"' + action + '","args":""}', '*');
}, 250);
}
}
function toggleYtPlayPauseState(iframeId) {
var iframe = document.getElementById(iframeId);
if (!iframe) return;
if (dkzon_yt_play_states[iframeId] === false) {
iframe.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
dkzon_yt_play_states[iframeId] = true;
} else {
iframe.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
dkzon_yt_play_states[iframeId] = false;
}
}
function toggleMp4PlayPauseState(videoEl) {
if (videoEl.paused) {
videoEl.play().catch(function(e){});
} else {
videoEl.pause();
}
}
function closeDkzonMasterPoolReels() {
var modal = document.getElementById('dkzon-master-modal');
if (modal) {
modal.style.display = 'none';
document.body.style.overflow = '';
}
if (dkzon_master_swiper) {
dkzon_master_swiper.slides.forEach(function(slide) {
var video = slide.querySelector('video');
if (video) { video.pause(); }
var iframe = slide.querySelector('iframe');
if (iframe) { iframe.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); }
});
dkzon_master_swiper.destroy(true, true);
dkzon_master_swiper = null;
}
}
function toggleReelMute(elementId, btn) {
var element = document.getElementById(elementId);
var isYt = element ? (element.getAttribute('data-yt') === 'true') : true;
dkzon_global_muted = !dkzon_global_muted;
document.querySelectorAll('.mute-line').forEach(function(line) {
line.style.display = dkzon_global_muted ? 'block' : 'none';
});
if (!isYt && element) {
element.muted = dkzon_global_muted;
} else if (isYt && element) {
var action = dkzon_global_muted ? 'mute' : 'unMute';
element.contentWindow.postMessage('{"event":"command","func":"' + action + '","args":""}', '*');
}
}
function handleReelLike(element, reelKey) {
var iconContainer = element.querySelector('.like-icon');
var countSpan = element.querySelector('.like-counter');
var currentCount = parseInt(countSpan.innerText);
var isLiked = element.getAttribute('data-liked') === 'true';
var action_type = isLiked ? 'decrease' : 'increase';
if(isLiked) {
iconContainer.style.color = '#fff';
countSpan.innerText = currentCount - 1;
element.setAttribute('data-liked', 'false');
} else {
iconContainer.style.color = '#ef4444';
countSpan.innerText = currentCount + 1;
element.setAttribute('data-liked', 'true');
}
var formData = new FormData();
formData.append('action', 'dkzon_save_live_like');
formData.append('reel_key', reelKey);
formData.append('action_type', action_type);
fetch(dkzon_ajax_url, { method: 'POST', body: formData });
}
function triggerDkzonUniversalLiveShare(title, url) {
var shareText = "😍 Watch this amazing trending item video on DKZON! 👇\n" + url;
if (navigator.share && !navigator.userAgent.includes('wv')) {
navigator.share({ title: title, text: "😍 Watch this amazing trending item video on DKZON! 👇\n", url: url }).catch((e) => console.log(e));
} else {
var intentUrl = "intent:#Intent;action=android.intent.action.SEND;type=text/plain;S.android.intent.extra.TEXT=" + encodeURIComponent(shareText) + ";end";
var fallbackLink = document.createElement('a');
fallbackLink.href = intentUrl;
fallbackLink.rel = 'external';
document.body.appendChild(fallbackLink);
try { fallbackLink.click(); } catch(e) {
navigator.clipboard.writeText(url);
alert("Link copied! Share it with your friends.");
}
document.body.removeChild(fallbackLink);
}
}
<?php if (isset($_GET['reel_id'])) : ?>
setTimeout(function() { openDkzonMasterPoolReels(<?php echo intval($_GET['reel_id']); ?>); }, 1000);
<?php endif; ?>
</script>
<?php}
