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