partials
2 years ago
ads.php
2 years ago
calendly.php
2 years ago
custom-logo.php
2 years ago
dailymotion.php
2 years ago
elements.php
2 years ago
general.php
2 years ago
go-premium.php
2 years ago
google-calendar.php
2 years ago
instagram.php
2 years ago
license.php
5 years ago
main-template.php
5 years ago
opensea.php
2 years ago
premium.php
2 years ago
shortcode.php
2 years ago
soundcloud.php
2 years ago
sources.php
2 years ago
spotify.php
2 years ago
twitch.php
2 years ago
vimeo.php
2 years ago
wistia.php
2 years ago
youtube.php
3 years ago
ads.php
1172 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Custom Logo Settings page |
| 4 | * All undefined vars comes from 'render_settings_page' method |
| 5 | * |
| 6 | * */ |
| 7 | |
| 8 | use EmbedPress\Includes\Classes\Helper; |
| 9 | |
| 10 | $video_demo_adUrl = 'https://embedpress.com/wp-content/uploads/2023/12/notificationX-demo-ad.mp4'; |
| 11 | $image_demo_adUrl = 'https://embedpress.com/wp-content/uploads/2023/12/demo-ad.gif'; |
| 12 | $youtube_embed_url = 'https://www.youtube.com/embed/coLxfjnrm3I?enablejsapi=1&origin=' . site_url(); |
| 13 | |
| 14 | |
| 15 | global $pro_active; |
| 16 | $updgrade_pro_text = ' You'; |
| 17 | if(!$pro_active){ |
| 18 | $updgrade_pro_text = ' This is a pro feature but you'; |
| 19 | } |
| 20 | |
| 21 | ?> |
| 22 | |
| 23 | <div class="embedpress_calendly_settings background__white radius-25 p40"> |
| 24 | <div class="ad-settings-top"> |
| 25 | <div <?php if(!$pro_active): echo 'class="ad-settings-content"'; endif; ?>> |
| 26 | <h3 class="ads-settings-title"> |
| 27 | <?php |
| 28 | echo wp_kses_post( |
| 29 | sprintf( |
| 30 | esc_html__( |
| 31 | 'Advertise Across %s with EmbedPress – Your Gateway to Unlimited Exposure!', |
| 32 | 'embedpress' |
| 33 | ), |
| 34 | '<a target="_blank" href="' . esc_url('https://embedpress.com/sources/') . '"><span style="color:#FF7369">' . esc_html__('150+ Platforms', 'embedpress') . '</span></a>' |
| 35 | ) |
| 36 | ); |
| 37 | ?> |
| 38 | |
| 39 | </h3> |
| 40 | <p class="ads-settings-description"> |
| 41 | <?php |
| 42 | echo wp_kses_post( |
| 43 | sprintf( |
| 44 | esc_html__( |
| 45 | "Now, you can showcase your ads across %s, guaranteeing unlimited exposure for your business through your embedded contents.%s can check the settings below for a demo example. | %s", |
| 46 | 'embedpress' |
| 47 | ), |
| 48 | '<strong>' . esc_html__('150+ diverse platforms', 'embedpress') . '</strong>', |
| 49 | $updgrade_pro_text, |
| 50 | '<a href="' . esc_url('https://embedpress.com/docs/how-to-configure-ep-ads-settings/ ') . '" target="_blank" style="color:#FF7369"><strong>' . esc_html__('Docs', 'embedpress') . '</strong></a>' |
| 51 | ) |
| 52 | ); |
| 53 | |
| 54 | ?> |
| 55 | </p> |
| 56 | </div> |
| 57 | <?php |
| 58 | |
| 59 | if (!$pro_active) : |
| 60 | ?> |
| 61 | <a href="<?php echo esc_url('https://wpdeveloper.com/in/upgrade-embedpress'); ?>" target="_blank" class="button button-pro-upgrade"><?php echo esc_html__('Upgrade To Pro', 'embedpress'); ?><i class="ep-icon ep-link-icon"></i></a> |
| 62 | <?php endif; ?> |
| 63 | </div> |
| 64 | |
| 65 | <div class="entry-content clear" ast-blocks-layout="true" itemprop="text"> |
| 66 | <div class="ad-preview-sectiion"> |
| 67 | <div class="video-ad-prewiew-options"> |
| 68 | <div class="ad__adjust__wrap " style="display: block;"> |
| 69 | |
| 70 | <div class="ad__adjust"> |
| 71 | <form class="ad__adjust__controller" id="ad-preview-0"> |
| 72 | <div class="form-input-wrapper"> |
| 73 | <div class="ad__adjust__controller__item"> |
| 74 | <span class="controller__label"><?php echo esc_html__('Upload Ad', 'embedpress'); ?></span> |
| 75 | <div class="ad__adjust__controller__inputs ad-upload-options"> |
| 76 | |
| 77 | <button class="uploadBtn" type="button" data-upload-index="0"> |
| 78 | <span class="dashicons dashicons-upload"></span> <?php echo esc_html__('Upload', 'embedpress'); ?> |
| 79 | </button> |
| 80 | |
| 81 | <input type="hidden" id="fileInput-0" name="adFileUrl" value="<?php echo esc_url('https://embedpress.com/wp-content/uploads/2023/12/notificationX-demo-ad.mp4'); ?>" /> |
| 82 | |
| 83 | <p class="uploaded-file-url-0 uploaded"><?php echo esc_html('File Name: notificationX-demo-ad.mp4'); ?></p> |
| 84 | </div> |
| 85 | </div> |
| 86 | |
| 87 | <div class="ad__adjust__controller__item"> |
| 88 | <span class="controller__label"><?php echo esc_html__('Ad Redirection URL', 'embedpress'); ?></span> |
| 89 | <div class="ad__adjust__controller__inputs"> |
| 90 | <input type="url" name="adUrl" id="ad_cta_url" class="form__control" data-default="<?php echo esc_url('https://notificationx.com/'); ?>" value="<?php echo esc_url('https://notificationx.com/'); ?>"> |
| 91 | </div> |
| 92 | </div> |
| 93 | |
| 94 | <div class="ad__adjust__controller__item"> |
| 95 | <span class="controller__label"><?php echo esc_html__('Ad Start After (Sec)', 'embedpress'); ?></span> |
| 96 | <div class="ad__adjust__controller__inputs"> |
| 97 | <input type="range" min="1" max="100" data-default="10" value="10" class="opacity__range" name="adStart"> |
| 98 | <input readonly="" type="number" class="form__control range__value" data-default="10" value="10"> |
| 99 | </div> |
| 100 | </div> |
| 101 | |
| 102 | <div class="ad__adjust__controller__item skip-controller"> |
| 103 | <span class="controller__label"><?php echo esc_html__('Skip Button', 'embedpress'); ?></span> |
| 104 | <div class="ad__adjust__controller__inputs"> |
| 105 | <label class="input__switch switch__text "> |
| 106 | <input type="checkbox" name="adSkipButton" data-default="no" data-value="no" value="yes" checked> |
| 107 | <span></span> |
| 108 | |
| 109 | </label> |
| 110 | </div> |
| 111 | </div> |
| 112 | |
| 113 | <div class="ad__adjust__controller__item skip-controller"> |
| 114 | <span class="controller__label"><?php echo esc_html__('Skip Button After (Sec)', 'embedpress'); ?></span> |
| 115 | <div class="ad__adjust__controller__inputs"> |
| 116 | <input type="range" min="1" max="100" data-default="5" value="5" class="x__range" name="adSkipButtonAfter"> |
| 117 | <input readonly="" type="number" class="form__control range__value" data-default="5" value="5"> |
| 118 | </div> |
| 119 | </div> |
| 120 | </div> |
| 121 | |
| 122 | <button type="submit" class="button preview-btn-0"> <?php echo esc_html__('Start Preview', 'embedpress'); ?> </button> |
| 123 | </form> |
| 124 | |
| 125 | </div> |
| 126 | </div> |
| 127 | </div> |
| 128 | <div class="embedpress-gutenberg-wrapper aligncenter ep-content-protection-disabled inline" id="1c3da3de-7606-4e9f-9693-d4b570cd2ca30"> |
| 129 | <h2 class="wp-block-heading has-text-align-center"><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-ast-global-color-2-color"><?php echo esc_html__('Live Preview for Video', 'embedpress'); ?></h2> |
| 130 | <p class="preview-description"><?php echo esc_html__('Experience EmbedPress Ad feature with YouTube video, but it will work with all embedded contents such as videos, audios, documents, etc..', 'embedpress'); ?></p> |
| 131 | <div class="wp-block-embed__wrapper"> |
| 132 | <div id="ep-gutenberg-content-ep-ad-preview-0" class="ep-gutenberg-content"> |
| 133 | <div data-sponsored-id="ep-ad-preview-0" id="ep-ad-preview-0" class="ad-mask" data-ad-index="0"> |
| 134 | <div class="ep-embed-content-wraper "> |
| 135 | <div class="ose-youtube ose-embedpress-responsive"> |
| 136 | <iframe width="560" height="315" src="<?php echo esc_url($youtube_embed_url); ?>" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> |
| 137 | </div> |
| 138 | </div> |
| 139 | <div class="main-ad-template" id="ad-template-0" data-adType="video" style="display:none"> |
| 140 | <div class="ep-ad-container"> |
| 141 | <div class="ep-ad-content ad-video hidden" style="position: relative;"> |
| 142 | <a target="_blank" class="ad-url" href="#"> |
| 143 | |
| 144 | <video class="ep-ad" muted=""> |
| 145 | <source src="<?php echo esc_url($video_demo_adUrl); ?>"> |
| 146 | </video> |
| 147 | |
| 148 | <div class="ad-timer"> |
| 149 | <span class="ad-running-time"></span> |
| 150 | <span class="ad-duration"> • Ad</span> |
| 151 | </div> |
| 152 | <div class="progress-bar-container"> |
| 153 | <div class="progress-bar"></div> |
| 154 | </div> |
| 155 | </a> |
| 156 | |
| 157 | |
| 158 | <button title="Skip Ad" class="skip-ad-button" style="display: none;"> |
| 159 | <?php echo esc_html__('Skip Ad', 'embedpress'); ?> </button> |
| 160 | |
| 161 | </div> |
| 162 | |
| 163 | <div class="ep-ad-content ad-image hidden" style="position: relative;"> |
| 164 | <a target="_blank" class="ad-url" href="#"> |
| 165 | <img decoding="async" class="ep-ad" src="<?php echo esc_url($image_demo_adUrl); ?>"> |
| 166 | </a> |
| 167 | <button title="Skip Ad" class="skip-ad-button" style="display: inline-block;"> |
| 168 | <?php echo esc_html__('Skip Ad', 'embedpress'); ?> </button> |
| 169 | |
| 170 | </div> |
| 171 | </div> |
| 172 | </div> |
| 173 | </div> |
| 174 | </div> |
| 175 | </div> |
| 176 | </div> |
| 177 | |
| 178 | </div> |
| 179 | <div class="ad-preview-sectiion"> |
| 180 | <div class="video-ad-prewiew-options"> |
| 181 | <div class="ad__adjust__wrap " style="display: block;"> |
| 182 | <div class="ad__adjust"> |
| 183 | <form class="ad__adjust__controller" id="ad-preview-1"> |
| 184 | <div class="form-input-wrapper"> |
| 185 | |
| 186 | <div class="ad__adjust__controller__item"> |
| 187 | <span class="controller__label"><?php echo esc_html__('Upload Ad', 'embedpress'); ?></span> |
| 188 | <div class="ad__adjust__controller__inputs ad-upload-options"> |
| 189 | <button class="uploadBtn" type="button" data-upload-index="1"> |
| 190 | <span class="dashicons dashicons-upload"></span> <?php echo esc_html__('Upload', 'embedpress'); ?> |
| 191 | </button> |
| 192 | |
| 193 | <input type="hidden" id="fileInput-1" name="adFileUrl" value="<?php echo esc_url($image_demo_adUrl); ?>" /> |
| 194 | <p class="uploaded-file-url-1 uploaded"><?php echo esc_html('File Name: demo-ad.gif'); ?></p> |
| 195 | </div> |
| 196 | </div> |
| 197 | |
| 198 | |
| 199 | <div class="ad__adjust__controller__item"> |
| 200 | <span class="controller__label"><?php echo esc_html__('Ad Redirection URL', 'embedpress'); ?></span> |
| 201 | <div class="ad__adjust__controller__inputs"> |
| 202 | <input type="url" name="adUrl" id="ad_cta_url" class="form__control" data-default="<?php echo esc_url('https://notificationx.com/'); ?>" value="<?php echo esc_url('https://notificationx.com/'); ?>"> |
| 203 | </div> |
| 204 | </div> |
| 205 | |
| 206 | <div class="ad__adjust__controller__item"> |
| 207 | <span class="controller__label"><?php echo esc_html__('Ad Start After (Sec)', 'embedpress'); ?></span> |
| 208 | <div class="ad__adjust__controller__inputs"> |
| 209 | <input type="range" max="100" data-default="10" value="10" class="opacity__range" name="adStart"> |
| 210 | <input readonly="" type="number" class="form__control range__value" data-default="10" value="10"> |
| 211 | </div> |
| 212 | </div> |
| 213 | |
| 214 | <div class="ad__adjust__controller__item skip-controller hidden"> |
| 215 | <span class="controller__label"><?php echo esc_html__('Skip Button', 'embedpress'); ?></span> |
| 216 | <div class="ad__adjust__controller__inputs"> |
| 217 | <label class="input__switch switch__text "> |
| 218 | <input type="checkbox" name="adSkipButton" data-default="no" data-value="no" value="yes" checked> |
| 219 | <span></span> |
| 220 | |
| 221 | </label> |
| 222 | </div> |
| 223 | </div> |
| 224 | |
| 225 | <div class="ad__adjust__controller__item skip-controller hidden"> |
| 226 | <span class="controller__label"><?php echo esc_html__('Skip Button After (Sec)', 'embedpress'); ?></span> |
| 227 | <div class="ad__adjust__controller__inputs"> |
| 228 | <input type="range" max="100" data-default="5" value="5" class="x__range" name="adSkipButtonAfter"> |
| 229 | <input readonly="" type="number" class="form__control range__value" data-default="5" value="5"> |
| 230 | </div> |
| 231 | </div> |
| 232 | |
| 233 | </div> |
| 234 | <button type="submit" class="button preview-btn-1"> <?php echo esc_html__('Start Preview', 'embedpress'); ?> </button> |
| 235 | |
| 236 | </form> |
| 237 | |
| 238 | </div> |
| 239 | </div> |
| 240 | </div> |
| 241 | <div class="embedpress-gutenberg-wrapper aligncenter ep-content-protection-disabled inline" id="1c3da3de-7606-4e9f-9693-d4b570cd2ca31"> |
| 242 | <h2 class="wp-block-heading has-text-align-center"><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-ast-global-color-2-color"><?php echo esc_html__('Live Preview for Documents', 'embedpress'); ?></h2> |
| 243 | |
| 244 | <p class="preview-description"><?php echo esc_html__('Experience EmbedPress Ad feature with with a PDF, but it will work with all embedded contents such as videos, audios, documents, etc..', 'embedpress'); ?></p> |
| 245 | |
| 246 | <div class="wp-block-embed__wrapper "> |
| 247 | <div id="ep-gutenberg-content-ep-ad-preview-1" class="ep-gutenberg-content"> |
| 248 | <div data-sponsored-id="ep-ad-preview-1" id="ep-ad-preview-1" class="ad-mask" data-ad-index="0"> |
| 249 | <div class="ep-embed-content-wraper"> |
| 250 | <div class="position-right-wraper gutenberg-pdf-wraper"> |
| 251 | <?php |
| 252 | $pdf_url = EMBEDPRESS_SETTINGS_ASSETS_URL . 'embedpress.pdf'; |
| 253 | $renderer = Helper::get_pdf_renderer(); |
| 254 | $src = $renderer . ((strpos($renderer, '?') == false) ? '?' : '&') . 'file=' . urlencode($pdf_url); |
| 255 | ?> |
| 256 | <iframe title="sample" class="embedpress-embed-document-pdf embedpress-pdf-1701320841615" style="width:550px;height:320px; max-width:100%; display: inline-block" src="<?php echo esc_url($src); ?>" frameborder="0" oncontextmenu="return false;"></iframe> |
| 257 | <p class="embedpress-el-powered"><?php echo esc_html__('Powered By EmbedPress', 'embedpress'); ?></p> |
| 258 | </div> |
| 259 | </div> |
| 260 | |
| 261 | <div class="main-ad-template" id="ad-template-1" data-adType="image" style="display:none"> |
| 262 | <div class="ep-ad-container"> |
| 263 | <div class="ep-ad-content ad-video hidden" style="position: relative;"> |
| 264 | <a target="_blank" class="ad-url" href="#"> |
| 265 | |
| 266 | <video class="ep-ad" muted=""> |
| 267 | <source src="<?php echo esc_url($video_demo_adUrl); ?>"> |
| 268 | </video> |
| 269 | |
| 270 | <div class="ad-timer"> |
| 271 | <span class="ad-running-time"></span> |
| 272 | <span class="ad-duration"> • Ad</span> |
| 273 | </div> |
| 274 | <div class="progress-bar-container"> |
| 275 | <div class="progress-bar"></div> |
| 276 | </div> |
| 277 | </a> |
| 278 | |
| 279 | |
| 280 | <button title="Skip Ad" class="skip-ad-button" style="display: none;"> |
| 281 | <?php echo esc_html__('Skip Ad', 'embedpress'); ?> </button> |
| 282 | |
| 283 | </div> |
| 284 | |
| 285 | <div class="ep-ad-content ad-image hidden" style="position: relative;"> |
| 286 | <a target="_blank" class="ad-url" href="#"> |
| 287 | <img decoding="async" class="ep-ad" src="<?php echo esc_url($image_demo_adUrl); ?>"> |
| 288 | </a> |
| 289 | <button title="Skip Ad" class="skip-ad-button" style="display: inline-block;"> |
| 290 | <?php echo esc_html__('Skip Ad', 'embedpress'); ?> </button> |
| 291 | |
| 292 | </div> |
| 293 | </div> |
| 294 | </div> |
| 295 | </div> |
| 296 | </div> |
| 297 | </div> |
| 298 | </div> |
| 299 | |
| 300 | </div> |
| 301 | </div> |
| 302 | |
| 303 | </div> |
| 304 | |
| 305 | <style> |
| 306 | /* page css */ |
| 307 | .entry-content.clear { |
| 308 | padding: 0 10px; |
| 309 | } |
| 310 | |
| 311 | .ad-settings-top { |
| 312 | padding: 20px 25px; |
| 313 | /* background: #EEEDF4; */ |
| 314 | color: #444; |
| 315 | border-radius: 15px; |
| 316 | display: flex; |
| 317 | align-items: center; |
| 318 | justify-content: space-between; |
| 319 | margin-bottom: 60px; |
| 320 | border: 1px solid #f9f3f3; |
| 321 | } |
| 322 | |
| 323 | .ad-settings-content { |
| 324 | width: calc(100% - 240px); |
| 325 | } |
| 326 | |
| 327 | h3.ads-settings-title { |
| 328 | color: #131F4D; |
| 329 | margin-bottom: 10px; |
| 330 | font-size: 18px; |
| 331 | } |
| 332 | |
| 333 | p.ads-settings-description { |
| 334 | font-size: 16px; |
| 335 | line-height: 1.6; |
| 336 | color: #25396F; |
| 337 | text-align: justify; |
| 338 | } |
| 339 | |
| 340 | .ad__adjust__controller__item .controller__label { |
| 341 | font-size: 16px; |
| 342 | font-weight: 400; |
| 343 | color: #7C8DB5; |
| 344 | width: 180px; |
| 345 | } |
| 346 | |
| 347 | .ad-preview-sectiion { |
| 348 | display: flex; |
| 349 | gap: 30px; |
| 350 | justify-content: space-around; |
| 351 | margin-bottom: 60px; |
| 352 | border-bottom: 1px solid #ddd; |
| 353 | padding-bottom: 60px; |
| 354 | } |
| 355 | |
| 356 | |
| 357 | .ad-upload-options { |
| 358 | width: 320px; |
| 359 | } |
| 360 | |
| 361 | p.uploaded { |
| 362 | background: #efeef5; |
| 363 | padding: 5px 10px; |
| 364 | word-wrap: break-word; |
| 365 | border-radius: 5px; |
| 366 | } |
| 367 | |
| 368 | button.uploadBtn { |
| 369 | font-size: 14px; |
| 370 | padding: 10px 15px; |
| 371 | border-radius: 5px; |
| 372 | display: flex; |
| 373 | align-items: center; |
| 374 | gap: 5px; |
| 375 | border: 1px solid #ddd; |
| 376 | cursor: pointer; |
| 377 | color: #394b7b; |
| 378 | margin-bottom: 10px; |
| 379 | |
| 380 | } |
| 381 | |
| 382 | button.uploadBtn span.dashicons.dashicons-upload { |
| 383 | font-size: 18px; |
| 384 | } |
| 385 | |
| 386 | .video-ad-prewiew-options { |
| 387 | width: 45% |
| 388 | } |
| 389 | |
| 390 | .ad__adjust__controller__item { |
| 391 | display: flex; |
| 392 | align-items: center; |
| 393 | justify-content: space-between; |
| 394 | margin-bottom: 30px; |
| 395 | gap: 20px; |
| 396 | } |
| 397 | |
| 398 | .ad__adjust__controller__inputs { |
| 399 | max-width: 100%; |
| 400 | width: calc(100% - 15px); |
| 401 | } |
| 402 | |
| 403 | .ad__adjust__controller__inputs p { |
| 404 | margin-top: 5px; |
| 405 | color: #131F4D; |
| 406 | } |
| 407 | |
| 408 | /* Common Styles */ |
| 409 | /* .ad-mask .ose-embedpress-responsive { |
| 410 | position: relative; |
| 411 | } */ |
| 412 | |
| 413 | .ad-running { |
| 414 | display: inline-block !important; |
| 415 | } |
| 416 | |
| 417 | .ep-ad-content.ad-image img { |
| 418 | object-fit: cover; |
| 419 | } |
| 420 | |
| 421 | .ep-ad-content.ad-image { |
| 422 | height: 100%; |
| 423 | width: 100%; |
| 424 | } |
| 425 | |
| 426 | /* .ad-mask .ep-embed-content-wraper::after { |
| 427 | content: ''; |
| 428 | position: absolute; |
| 429 | top: 0; |
| 430 | left: 0; |
| 431 | right: 0; |
| 432 | bottom: 0; |
| 433 | } */ |
| 434 | |
| 435 | .ep-embed-content-wraper { |
| 436 | position: relative; |
| 437 | } |
| 438 | |
| 439 | .embedpress-gutenberg-wrapper { |
| 440 | width: 55%; |
| 441 | } |
| 442 | |
| 443 | h2.wp-block-heading { |
| 444 | font-size: 22px; |
| 445 | margin-bottom: 12px; |
| 446 | color: #131F4D |
| 447 | } |
| 448 | |
| 449 | p.preview-description { |
| 450 | font-size: 16px; |
| 451 | line-height: 1.6; |
| 452 | color: #25396F; |
| 453 | margin-bottom: 15px; |
| 454 | width: 580px; |
| 455 | max-width: 100%; |
| 456 | text-align: justify; |
| 457 | } |
| 458 | |
| 459 | .ose-youtube { |
| 460 | /* display: none !important; */ |
| 461 | opacity: 0 |
| 462 | } |
| 463 | |
| 464 | div[data-sponsored-id] { |
| 465 | position: relative; |
| 466 | display: inline-block; |
| 467 | max-width: 100%; |
| 468 | } |
| 469 | .embedpress-document-embed div[data-sponsored-id] { |
| 470 | width: 100%; |
| 471 | } |
| 472 | |
| 473 | .main-ad-template.image.ad-running { |
| 474 | position: absolute; |
| 475 | z-index: 1; |
| 476 | bottom: 75px; |
| 477 | left: 50%; |
| 478 | height: auto; |
| 479 | } |
| 480 | |
| 481 | [data-sponsored-id] .main-ad-template.image.ad-running { |
| 482 | border-radius: 5px; |
| 483 | } |
| 484 | |
| 485 | .ep-ad-container { |
| 486 | position: relative; |
| 487 | height: 100%; |
| 488 | display: flex; |
| 489 | align-items: center; |
| 490 | background-color: #000; |
| 491 | justify-content: center; |
| 492 | |
| 493 | } |
| 494 | |
| 495 | .ep-ad-content.ad-video { |
| 496 | height: 100%; |
| 497 | } |
| 498 | |
| 499 | a.ad-url { |
| 500 | display: inline; |
| 501 | } |
| 502 | |
| 503 | .main-ad-template video, |
| 504 | .main-ad-template img { |
| 505 | width: 100%; |
| 506 | height: 100%; |
| 507 | background-color: #000; |
| 508 | } |
| 509 | |
| 510 | .progress-bar-container { |
| 511 | margin-top: -10px; |
| 512 | background: #ff000021; |
| 513 | } |
| 514 | |
| 515 | .progress-bar { |
| 516 | background: #5be82a; |
| 517 | height: 5px; |
| 518 | margin-top: -4px; |
| 519 | max-width: 100%; |
| 520 | } |
| 521 | |
| 522 | button.skip-ad-button { |
| 523 | position: absolute; |
| 524 | bottom: 15px; |
| 525 | right: 10px; |
| 526 | border: none; |
| 527 | background: #d41556b5 !important; |
| 528 | color: white !important; |
| 529 | z-index: 999999999; |
| 530 | font-size: 14px; |
| 531 | border-radius: 4px; |
| 532 | height: 30px; |
| 533 | width: 80px; |
| 534 | font-weight: normal; |
| 535 | display: flex; |
| 536 | align-items: center; |
| 537 | justify-content: center; |
| 538 | cursor: pointer; |
| 539 | text-transform: capitalize; |
| 540 | font-weight: 600; |
| 541 | font-size: 12px; |
| 542 | padding: 0; |
| 543 | } |
| 544 | |
| 545 | .ad-timer { |
| 546 | position: absolute; |
| 547 | background: #d41556b5; |
| 548 | font-size: 14px; |
| 549 | width: 110px; |
| 550 | color: white; |
| 551 | bottom: 15px; |
| 552 | left: 10px; |
| 553 | text-align: center; |
| 554 | border-radius: 4px; |
| 555 | height: 30px; |
| 556 | width: 80px; |
| 557 | font-weight: normal; |
| 558 | display: flex; |
| 559 | align-items: center; |
| 560 | justify-content: center; |
| 561 | } |
| 562 | |
| 563 | [data-sponsored-id] .hidden, |
| 564 | .hidden { |
| 565 | display: none !important; |
| 566 | } |
| 567 | |
| 568 | /* Specific Styles for Ad Type 1 */ |
| 569 | [data-sponsored-id="ep-ad-preview-0"] .main-ad-template { |
| 570 | width: 550px; |
| 571 | height: 310px; |
| 572 | max-width: 100%; |
| 573 | display: inline-block; |
| 574 | } |
| 575 | |
| 576 | [data-sponsored-id="ep-ad-preview-0"] .main-ad-template.image.ad-running { |
| 577 | width: 300px; |
| 578 | height: 200px; |
| 579 | bottom: 10%; |
| 580 | left: 25%; |
| 581 | } |
| 582 | |
| 583 | /* Specific Styles for Ad Type 2 */ |
| 584 | [data-sponsored-id="ep-ad-preview-1"] .main-ad-template { |
| 585 | width: 550px; |
| 586 | height: 310px; |
| 587 | max-width: 100%; |
| 588 | display: inline-block; |
| 589 | } |
| 590 | |
| 591 | [data-sponsored-id="ep-ad-preview-1"] .main-ad-template.image.ad-running { |
| 592 | width: 300px !important; |
| 593 | height: 200px !important; |
| 594 | bottom: 10%; |
| 595 | left: 25%; |
| 596 | } |
| 597 | |
| 598 | iframe.ose-youtube { |
| 599 | /* display: none !important; */ |
| 600 | max-width: 100%; |
| 601 | max-height: 310px; |
| 602 | height: 310px; |
| 603 | width: 550px; |
| 604 | } |
| 605 | |
| 606 | .position-right-wraper.gutenberg-pdf-wraper iframe { |
| 607 | border: 1px solid #ddd; |
| 608 | } |
| 609 | |
| 610 | p.embedpress-el-powered { |
| 611 | text-align: center; |
| 612 | } |
| 613 | |
| 614 | .info-message-section { |
| 615 | max-width: 800px; |
| 616 | margin: auto; |
| 617 | margin-bottom: 60px; |
| 618 | width: 100%; |
| 619 | } |
| 620 | |
| 621 | .info-message { |
| 622 | display: flex; |
| 623 | align-items: center; |
| 624 | gap: 10px; |
| 625 | /* background: #fbebed; */ |
| 626 | padding: 12px; |
| 627 | border-radius: 5px; |
| 628 | font-size: 14px; |
| 629 | line-height: 1.4em; |
| 630 | border-left: 4px solid #fe8c59; |
| 631 | border: 1px solid #faf4f4; |
| 632 | color: #25396F; |
| 633 | } |
| 634 | |
| 635 | .info-message svg { |
| 636 | width: 18px; |
| 637 | } |
| 638 | |
| 639 | span.dashicons.dashicons-warning { |
| 640 | color: #fe8c59; |
| 641 | } |
| 642 | |
| 643 | @media only screen and (max-width: 1540px) { |
| 644 | |
| 645 | |
| 646 | .ad__adjust__controller__item { |
| 647 | flex-direction: column; |
| 648 | align-items: start; |
| 649 | padding-right: 15px; |
| 650 | gap: 10px; |
| 651 | } |
| 652 | |
| 653 | .video-ad-prewiew-options .form-input-wrapper { |
| 654 | max-height: 440px; |
| 655 | overflow: auto; |
| 656 | max-width: 100%; |
| 657 | } |
| 658 | |
| 659 | |
| 660 | .video-ad-prewiew-options .form-input-wrapper::-webkit-scrollbar { |
| 661 | width: 5px; |
| 662 | } |
| 663 | |
| 664 | .video-ad-prewiew-options .form-input-wrapper::-webkit-scrollbar-track { |
| 665 | background: #f5f7fd; |
| 666 | border-radius: 5px; |
| 667 | } |
| 668 | |
| 669 | .video-ad-prewiew-options .form-input-wrapper::-webkit-scrollbar-thumb { |
| 670 | background: #988FBD; |
| 671 | border-radius: 5px; |
| 672 | } |
| 673 | |
| 674 | .template__wrapper input[type=range] { |
| 675 | margin: 0; |
| 676 | } |
| 677 | |
| 678 | form#ad-preview-0 .form-input-wrapper { |
| 679 | max-height: 400px !important; |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | |
| 684 | @media only screen and (max-width: 1440px) { |
| 685 | .embedpress-gutenberg-wrapper { |
| 686 | width: 60%; |
| 687 | } |
| 688 | |
| 689 | .video-ad-prewiew-options { |
| 690 | width: 40% |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | @media screen and (max-width: 1250px) { |
| 695 | .ad-preview-sectiion { |
| 696 | flex-direction: column-reverse; |
| 697 | } |
| 698 | |
| 699 | .video-ad-prewiew-options { |
| 700 | width: 100%; |
| 701 | } |
| 702 | |
| 703 | .embedpress-gutenberg-wrapper { |
| 704 | width: 100%; |
| 705 | } |
| 706 | |
| 707 | .ad-settings-top { |
| 708 | display: block; |
| 709 | } |
| 710 | |
| 711 | .ad-settings-content { |
| 712 | width: 100%; |
| 713 | margin-bottom: 15px; |
| 714 | } |
| 715 | |
| 716 | h3.ads-settings-title { |
| 717 | line-height: 1.5; |
| 718 | } |
| 719 | |
| 720 | p.ads-settings-description { |
| 721 | line-height: 1.3; |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | @media screen and (max-width: 991px) { |
| 726 | div[data-sponsored-id] { |
| 727 | max-width: 100%; |
| 728 | display: block; |
| 729 | } |
| 730 | |
| 731 | iframe.ose-youtube { |
| 732 | width: 100%; |
| 733 | height: 400px; |
| 734 | max-height: 100%; |
| 735 | } |
| 736 | } |
| 737 | </style> |
| 738 | |
| 739 | |
| 740 | <script> |
| 741 | // Check if data-playerid attribute exists and get its value |
| 742 | const isPyr = document.querySelector('[data-playerid]')?.getAttribute('data-playerid'); |
| 743 | |
| 744 | if (!isPyr) { |
| 745 | var scriptUrl = 'https://www.youtube.com/s/player/9d15588c/www-widgetapi.vflset/www-widgetapi.js'; |
| 746 | try { |
| 747 | var ttPolicy = window.trustedTypes.createPolicy("youtube-widget-api", { |
| 748 | createScriptURL: function(x) { |
| 749 | return x; |
| 750 | } |
| 751 | }); |
| 752 | scriptUrl = ttPolicy.createScriptURL(scriptUrl); |
| 753 | } catch (e) {} |
| 754 | |
| 755 | var YT; |
| 756 | if (!window["YT"]) YT = { loading: 0, loaded: 0 }; |
| 757 | var YTConfig; |
| 758 | if (!window["YTConfig"]) YTConfig = { "host": "https://www.youtube.com" }; |
| 759 | if (!YT.loading) { |
| 760 | YT.loading = 1; |
| 761 | (function() { |
| 762 | var l = []; |
| 763 | YT.ready = function(f) { |
| 764 | if (YT.loaded) f(); |
| 765 | else l.push(f); |
| 766 | }; |
| 767 | window.onYTReady = function() { |
| 768 | YT.loaded = 1; |
| 769 | var i = 0; |
| 770 | for (; i < l.length; i++) try { |
| 771 | l[i](); |
| 772 | } catch (e) {} |
| 773 | }; |
| 774 | YT.setConfig = function(c) { |
| 775 | var k; |
| 776 | for (k in c) |
| 777 | if (c.hasOwnProperty(k)) YTConfig[k] = c[k]; |
| 778 | }; |
| 779 | var a = document.createElement("script"); |
| 780 | a.type = "text/javascript"; |
| 781 | a.id = "www-widgetapi-script"; |
| 782 | a.src = scriptUrl; |
| 783 | a.async = true; |
| 784 | var c = document.currentScript; |
| 785 | if (c) { |
| 786 | var n = c.nonce || c.getAttribute("nonce"); |
| 787 | if (n) a.setAttribute("nonce", n); |
| 788 | } |
| 789 | var b = document.getElementsByTagName("script")[0]; |
| 790 | b.parentNode.insertBefore(a, b); |
| 791 | })(); |
| 792 | } |
| 793 | } |
| 794 | |
| 795 | let adsContainers = document.querySelectorAll('[data-sponsored-id]'); |
| 796 | let container = document.querySelector('[data-sponsored-id]'); |
| 797 | var player = []; |
| 798 | var playerInit = []; |
| 799 | var playerIndex = 0; |
| 800 | let adTimeout; |
| 801 | |
| 802 | adsContainers = Array.from(adsContainers); |
| 803 | |
| 804 | const getYTVideoId = (url) => { |
| 805 | // Check if the input is a string |
| 806 | if (typeof url !== 'string') { |
| 807 | return false; |
| 808 | } |
| 809 | |
| 810 | const regex = /(?:youtube\.com\/(?:[^\/]+\/[^\/]+\/|(?:v|e(?:mbed)?)\/|[^#]*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/; |
| 811 | const match = url.match(regex); |
| 812 | |
| 813 | if (match && match[1]) { |
| 814 | return match[1]; |
| 815 | } |
| 816 | return false; |
| 817 | } |
| 818 | |
| 819 | const hasParentClass = (element, className) => { |
| 820 | var parent = element.parentNode; |
| 821 | |
| 822 | while (parent && !(parent.classList && parent.classList.contains(className))) { |
| 823 | parent = parent.parentNode; |
| 824 | } |
| 825 | |
| 826 | return !!(parent && parent.classList && parent.classList.contains(className)); |
| 827 | } |
| 828 | |
| 829 | |
| 830 | const adInitialization = (adContainer, index, adAtts, adType) => { |
| 831 | const blockId = adAtts.clientId; |
| 832 | const blockIdMD5 = adContainer.getAttribute('data-sponsored-id'); |
| 833 | const adStartAfter = adAtts.adStart * 1000; |
| 834 | const adContent = adAtts.adContent; |
| 835 | const adVideo = adContainer.querySelector('.ep-ad'); |
| 836 | const adSource = adAtts.adSource; |
| 837 | const adVideos = []; |
| 838 | const srcUrl = adAtts.url || adAtts.embedpress_embeded_link; |
| 839 | const adSkipButtonAfter = parseInt(adAtts.adSkipButtonAfter); |
| 840 | const adSkipButton = adAtts.adSkipButton; |
| 841 | const adUrl = adAtts.adUrl; |
| 842 | |
| 843 | adVideos.push(adVideo); |
| 844 | |
| 845 | const adTemplate = adContainer.querySelector('.main-ad-template'); |
| 846 | const imageAdTemplate = adContainer.querySelector('.main-ad-template.image'); |
| 847 | const progressBar = adContainer.querySelector('.progress-bar'); |
| 848 | const skipButton = adTemplate.querySelector('.skip-ad-button'); |
| 849 | const adRunningTime = adContainer.querySelector('.ad-running-time'); |
| 850 | var playerId; |
| 851 | const adMask = adContainer; |
| 852 | |
| 853 | let playbackInitiated = false; |
| 854 | |
| 855 | if (skipButton && adSource !== 'video') { |
| 856 | skipButton.style.display = 'inline-block'; |
| 857 | } |
| 858 | |
| 859 | const hashClass = hasParentClass(adContainer, 'ep-content-protection-enabled'); |
| 860 | |
| 861 | if (hashClass) { |
| 862 | adContainer.classList.remove('ad-mask'); |
| 863 | } |
| 864 | |
| 865 | playerId = adContainer.querySelector('[data-playerid]')?.getAttribute('data-playerid'); |
| 866 | |
| 867 | if (getYTVideoId(srcUrl)) { |
| 868 | player[index]?.playVideo(); |
| 869 | player[index]?.seekTo(0); |
| 870 | } |
| 871 | clearTimeout(adTimeout); |
| 872 | |
| 873 | adTemplate.classList.remove('image', 'video'); |
| 874 | adTemplate.classList.add(adType); |
| 875 | |
| 876 | if (adType === 'image' && adUrl) { |
| 877 | adTemplate.querySelector('.ad-image .ad-url')?.setAttribute('href', adUrl); |
| 878 | } else { |
| 879 | adTemplate.querySelector('.ad-video .ad-url')?.setAttribute('href', adUrl); |
| 880 | } |
| 881 | |
| 882 | if (!playbackInitiated) { |
| 883 | adTimeout = setTimeout(() => { |
| 884 | if (adSource !== 'image') { |
| 885 | adContainer.querySelector('.ep-embed-content-wraper').classList.add('hidden'); |
| 886 | } |
| 887 | adTemplate?.classList.add('ad-running'); |
| 888 | adTemplate?.classList.remove('hidden'); |
| 889 | if (adVideo && adSource === 'video') { |
| 890 | adVideo.muted = false; |
| 891 | adTemplate.querySelector('.ad-video').classList.remove('hidden'); |
| 892 | adTemplate.querySelector('.ad-image').classList.add('hidden'); |
| 893 | adVideo.play(); |
| 894 | } |
| 895 | |
| 896 | if (adType === 'image') { |
| 897 | adTemplate.querySelector('.ad-image').classList.remove('hidden'); |
| 898 | adTemplate.querySelector('.ad-video').classList.add('hidden'); |
| 899 | } |
| 900 | }, adStartAfter); |
| 901 | |
| 902 | playbackInitiated = true; |
| 903 | } |
| 904 | |
| 905 | adContainer.classList.remove('ad-mask'); |
| 906 | |
| 907 | if (adType == 'video') { |
| 908 | adVideo?.addEventListener('timeupdate', () => { |
| 909 | const currentTime = adVideo?.currentTime; |
| 910 | const videoDuration = adVideo?.duration; |
| 911 | |
| 912 | if (currentTime <= videoDuration) { |
| 913 | const remainingTime = Math.max(0, videoDuration - currentTime); // Ensure it's not negative |
| 914 | adRunningTime.innerText = Math.floor(remainingTime / 60) + ':' + (Math.floor(remainingTime) % 60).toString().padStart(2, '0'); |
| 915 | } |
| 916 | |
| 917 | if (!isNaN(currentTime) && !isNaN(videoDuration)) { |
| 918 | const progress = (currentTime / videoDuration) * 100; |
| 919 | progressBar.style.width = progress + '%'; |
| 920 | |
| 921 | if (adSkipButton && currentTime >= adSkipButtonAfter) { |
| 922 | skipButton.style.display = 'inline-block'; |
| 923 | } else { |
| 924 | skipButton.style.display = 'none'; |
| 925 | } |
| 926 | } |
| 927 | }); |
| 928 | } |
| 929 | |
| 930 | document?.addEventListener('click', (event) => { |
| 931 | if (event.target.classList.contains('skip-ad-button')) { |
| 932 | adTemplate?.classList.remove('ad-running'); |
| 933 | document.querySelector('.preview-btn-' + index).innerText = 'Play Preview'; |
| 934 | document.querySelector('.preview-btn-' + index).removeAttribute('disabled'); |
| 935 | |
| 936 | if (adType == 'video') { |
| 937 | adVideo.pause(); |
| 938 | adVideo.currentTime = 0; |
| 939 | |
| 940 | if (getYTVideoId(srcUrl)) { |
| 941 | player[index]?.playVideo(); |
| 942 | } |
| 943 | adTemplate.querySelector('.ad-video').classList.add('hidden'); |
| 944 | |
| 945 | } else { |
| 946 | adTemplate.querySelector('.ad-image').classList.add('hidden'); |
| 947 | } |
| 948 | adContainer.querySelector('.ep-embed-content-wraper').classList.remove('hidden'); |
| 949 | } |
| 950 | }); |
| 951 | |
| 952 | if (adType == 'video') { |
| 953 | adVideo?.addEventListener('play', () => { |
| 954 | if (typeof playerInit !== 'undefined' && playerInit.length > 0) { |
| 955 | playerInit[playerId]?.stop(); |
| 956 | } |
| 957 | }); |
| 958 | |
| 959 | adVideo?.addEventListener('ended', () => { |
| 960 | adTemplate.classList.add('hidden'); |
| 961 | adContainer.querySelector('.ep-embed-content-wraper').classList.remove('hidden'); |
| 962 | document.querySelector('.preview-btn-' + index).innerText = 'Play Preview'; |
| 963 | document.querySelector('.preview-btn-' + index).removeAttribute('disabled'); |
| 964 | }); |
| 965 | } |
| 966 | playerIndex++; |
| 967 | } |
| 968 | |
| 969 | function onYouTubeIframeAPIReady(iframe, srcUrl, adVideo, index) { |
| 970 | if (iframe && getYTVideoId(srcUrl) !== null) { |
| 971 | player[index] = new YT.Player(iframe, { |
| 972 | videoId: getYTVideoId(srcUrl), |
| 973 | events: { |
| 974 | 'onReady': (event) => onPlayerReady(event, adVideo), |
| 975 | } |
| 976 | }); |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | function onPlayerReady(event, adVideo) { |
| 981 | adVideo?.addEventListener('ended', function() { |
| 982 | event.target.playVideo(); |
| 983 | }); |
| 984 | |
| 985 | adVideo?.addEventListener('play', function() { |
| 986 | event.target.pauseVideo(); |
| 987 | }); |
| 988 | event.target.g.style = 'opacity: 1'; |
| 989 | } |
| 990 | |
| 991 | window.onload = function() { |
| 992 | let yVideos = setInterval(() => { |
| 993 | var youtubeVideos = document.querySelectorAll('.ose-youtube'); |
| 994 | if (youtubeVideos.length > 0) { |
| 995 | clearInterval(yVideos); |
| 996 | |
| 997 | youtubeVideos.forEach((yVideo, index) => { |
| 998 | const srcUrl = yVideo.querySelector('iframe')?.getAttribute('src'); |
| 999 | const adVideo = yVideo.closest('.ad-mask')?.querySelector('.ep-ad'); |
| 1000 | const isYTChannel = yVideo.closest('.ad-mask')?.querySelector('.ep-youtube-channel'); |
| 1001 | if (adVideo && !isYTChannel) { |
| 1002 | onYouTubeIframeAPIReady(yVideo, srcUrl, adVideo, index); |
| 1003 | } |
| 1004 | }); |
| 1005 | } |
| 1006 | }, 100); |
| 1007 | }; |
| 1008 | |
| 1009 | function getFormData(index) { |
| 1010 | var form = document.getElementById("ad-preview-" + index); |
| 1011 | var formData = new FormData(form); |
| 1012 | |
| 1013 | var formDataObject = {}; |
| 1014 | formData.forEach(function(value, key) { |
| 1015 | formDataObject[key] = value; |
| 1016 | }); |
| 1017 | |
| 1018 | return formDataObject; |
| 1019 | } |
| 1020 | |
| 1021 | const rangeUpdate = () => { |
| 1022 | var rangeInputs = document.querySelectorAll('input[type="range"]'); |
| 1023 | var numberInputs = document.querySelectorAll('input[type="number"]'); |
| 1024 | |
| 1025 | rangeInputs.forEach(function(rangeInput, index) { |
| 1026 | var numberInput = numberInputs[index]; |
| 1027 | |
| 1028 | rangeInput.addEventListener('input', function() { |
| 1029 | numberInput.value = rangeInput.value; |
| 1030 | }); |
| 1031 | }); |
| 1032 | } |
| 1033 | |
| 1034 | rangeUpdate(); |
| 1035 | |
| 1036 | jQuery(document).on('click', '.preview-btn-0', function(e) { |
| 1037 | e.preventDefault(); |
| 1038 | const index = 0; |
| 1039 | const adContainer = document.querySelector('#ep-ad-preview-' + index); |
| 1040 | const adType = document.querySelector('#ad-template-' + index).getAttribute('data-adType'); |
| 1041 | const currentAdAtts = getFormData(index); |
| 1042 | |
| 1043 | const adAtts = { |
| 1044 | "clientId": "1c3da3de-7606-4e9f-9693-d4b570cd2ca30", |
| 1045 | "url": "https://www.youtube.com/watch?v=AMU66nbFnGg&pp=ygUMd3BkZXZlbG9lcGVy", |
| 1046 | "height": "310", |
| 1047 | "adManager": true, |
| 1048 | "adFileUrl": currentAdAtts?.adFileUrl, |
| 1049 | "adUrl": currentAdAtts?.adUrl, |
| 1050 | "width": "600", |
| 1051 | "adSource": adType ?? 'video', |
| 1052 | "adXPosition": 25, |
| 1053 | "adYPosition": 10, |
| 1054 | "adStart": currentAdAtts?.adStart, |
| 1055 | "adSkipButton": currentAdAtts?.adSkipButton === 'yes' ? true : false, |
| 1056 | "adSkipButtonAfter": currentAdAtts?.adSkipButtonAfter |
| 1057 | } |
| 1058 | |
| 1059 | if (currentAdAtts?.adFileUrl) { |
| 1060 | adInitialization(adContainer, index, adAtts, adType); |
| 1061 | jQuery('.preview-btn-' + index).attr('disabled', true); |
| 1062 | |
| 1063 | let startIn = parseInt(currentAdAtts?.adStart) - 1; |
| 1064 | const setIntervalId = setInterval(() => { |
| 1065 | jQuery('.preview-btn-' + index).text('Ad starting in ' + startIn-- + ' sec'); |
| 1066 | if (startIn === -1) { |
| 1067 | clearInterval(setIntervalId); |
| 1068 | jQuery('.preview-btn-' + index).text('Ad Running'); |
| 1069 | } |
| 1070 | }, 1000); |
| 1071 | } else { |
| 1072 | jQuery('.uploaded-file-url-' + index).text('Please upload a video/image Ad.'); |
| 1073 | } |
| 1074 | }); |
| 1075 | |
| 1076 | jQuery(document).on('click', '.preview-btn-1', function(e) { |
| 1077 | e.preventDefault(); |
| 1078 | const index = 1; |
| 1079 | const adContainer = document.querySelector('#ep-ad-preview-' + index); |
| 1080 | const adType = document.querySelector('#ad-template-' + index).getAttribute('data-adType'); |
| 1081 | const currentAdAtts = getFormData(index); |
| 1082 | |
| 1083 | const adAtts = { |
| 1084 | "clientId": "1c3da3de-7606-4e9f-9693-d4b570cd2ca31", |
| 1085 | "url": "https://www.africau.edu/images/default/sample.pdf", |
| 1086 | "height": "310", |
| 1087 | "adManager": true, |
| 1088 | "adFileUrl": currentAdAtts?.adFileUrl, |
| 1089 | "adUrl": currentAdAtts?.adUrl, |
| 1090 | "width": "600", |
| 1091 | "adSource": adType ?? 'video', |
| 1092 | "adXPosition": 25, |
| 1093 | "adYPosition": 10, |
| 1094 | "adStart": currentAdAtts?.adStart, |
| 1095 | "adSkipButton": currentAdAtts?.adSkipButton === 'yes' ? true : false, |
| 1096 | "adSkipButtonAfter": currentAdAtts?.adSkipButtonAfter |
| 1097 | } |
| 1098 | |
| 1099 | if (currentAdAtts?.adFileUrl) { |
| 1100 | adInitialization(adContainer, index, adAtts, adType); |
| 1101 | jQuery('.preview-btn-' + index).attr('disabled', true); |
| 1102 | |
| 1103 | let startIn = parseInt(currentAdAtts?.adStart) - 1; |
| 1104 | const setIntervalId = setInterval(() => { |
| 1105 | jQuery('.preview-btn-' + index).text('Ad starting in ' + startIn-- + ' sec'); |
| 1106 | if (startIn === -1) { |
| 1107 | clearInterval(setIntervalId); |
| 1108 | jQuery('.preview-btn-' + index).text('Ad Running'); |
| 1109 | } |
| 1110 | }, 1000); |
| 1111 | } else { |
| 1112 | jQuery('.uploaded-file-url-' + index).text('Please upload a video/image Ad.'); |
| 1113 | } |
| 1114 | }); |
| 1115 | </script> |
| 1116 | |
| 1117 | <script> |
| 1118 | jQuery(document).ready(function($) { |
| 1119 | var mediaUploader; |
| 1120 | |
| 1121 | // Trigger when the "Upload" button is clicked |
| 1122 | $('.uploadBtn').click(function(e) { |
| 1123 | e.preventDefault(); |
| 1124 | |
| 1125 | const index = $(this).data('upload-index'); |
| 1126 | |
| 1127 | // Reset mediaUploader variable |
| 1128 | mediaUploader = undefined; |
| 1129 | |
| 1130 | if (mediaUploader) { |
| 1131 | mediaUploader.open(); |
| 1132 | return; |
| 1133 | } |
| 1134 | |
| 1135 | // Extend the wp.media object |
| 1136 | mediaUploader = wp.media.frames.file_frame = wp.media({ |
| 1137 | title: 'Choose File', |
| 1138 | button: { |
| 1139 | text: 'Choose File' |
| 1140 | }, |
| 1141 | multiple: false, |
| 1142 | library: { |
| 1143 | type: ['image', 'video'] |
| 1144 | }, |
| 1145 | }); |
| 1146 | |
| 1147 | // Handle the file selection |
| 1148 | mediaUploader.on('select', function() { |
| 1149 | var attachment = mediaUploader.state().get('selection').first().toJSON(); |
| 1150 | |
| 1151 | if (attachment.type === 'image') { |
| 1152 | $('#ad-preview-' + index + ' .skip-controller').addClass('hidden'); |
| 1153 | $('#ad-preview-' + index + ' .image-ad-control').removeClass('hidden'); |
| 1154 | $('#ad-template-' + index + ' img').attr('src', attachment.url); |
| 1155 | |
| 1156 | } else { |
| 1157 | $('#ad-preview-' + index + ' .skip-controller').removeClass('hidden'); |
| 1158 | $('#ad-preview-' + index + ' .image-ad-control').addClass('hidden'); |
| 1159 | $('#ad-template-' + index + ' video').attr('src', attachment.url); |
| 1160 | } |
| 1161 | |
| 1162 | $('#fileInput-' + index).val(attachment.url); |
| 1163 | $('.uploaded-file-url-' + index).text('File Name: ' + attachment.name + '.' + attachment.subtype); |
| 1164 | $('#ad-template-' + index).attr('data-adType', attachment.type); |
| 1165 | $('.uploaded-file-url-' + index).addClass('uploaded'); |
| 1166 | }); |
| 1167 | |
| 1168 | // Open the media uploader |
| 1169 | mediaUploader.open(); |
| 1170 | }); |
| 1171 | }); |
| 1172 | </script> |