block-embedpress.php
563 lines
| 1 | <?php |
| 2 | |
| 3 | use EmbedPress\Includes\Classes\Helper; |
| 4 | |
| 5 | // Exit if accessed directly. |
| 6 | if (!defined('ABSPATH')) { |
| 7 | exit; |
| 8 | } |
| 9 | /** |
| 10 | * It renders gutenberg block of embedpress on the frontend |
| 11 | * @param array $attributes |
| 12 | */ |
| 13 | |
| 14 | if(!function_exists('lock_content_form_handler')){ |
| 15 | add_action('wp_ajax_lock_content_form_handler', 'lock_content_form_handler'); |
| 16 | add_action('wp_ajax_nopriv_lock_content_form_handler', 'lock_content_form_handler'); |
| 17 | |
| 18 | function lock_content_form_handler() { |
| 19 | // print_r($embedHTML); |
| 20 | |
| 21 | $client_id = isset($_POST['client_id']) ? sanitize_text_field($_POST['client_id']) : ''; |
| 22 | $password = isset($_POST['password']) ? sanitize_text_field($_POST['password']) : ''; |
| 23 | $post_id = isset($_POST['post_id']) ? absint($_POST['post_id']) : 0; |
| 24 | |
| 25 | $epbase64 = get_post_meta( $post_id, 'ep_base_' .$client_id, true ); |
| 26 | $hash_key = get_post_meta( $post_id, 'hash_key_' .$client_id, true ); |
| 27 | |
| 28 | // Set the decryption key and initialization vector (IV) |
| 29 | $key = Helper::get_hash(); |
| 30 | |
| 31 | // Decode the base64 encoded cipher |
| 32 | $cipher = base64_decode($epbase64); |
| 33 | // Decrypt the cipher using AES-128-CBC encryption |
| 34 | |
| 35 | $wp_pass_key = hash('sha256', wp_salt(32) . md5($password)); |
| 36 | $iv = substr($wp_pass_key, 0, 16); |
| 37 | |
| 38 | if ($wp_pass_key === $hash_key) { |
| 39 | setcookie("password_correct_", $password, time()+3600); |
| 40 | |
| 41 | $embed = openssl_decrypt($cipher, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv) . '<script> |
| 42 | var now = new Date(); |
| 43 | var time = now.getTime(); |
| 44 | var expireTime = time + 1000 * 60 * 60 * 24 * 30; |
| 45 | now.setTime(expireTime); |
| 46 | document.cookie = "password_correct_'.esc_js($client_id).'='.esc_js($hash_key).'; expires=" + now.toUTCString() + "; path=/"; |
| 47 | </script>'; |
| 48 | |
| 49 | } |
| 50 | else{ |
| 51 | $embed = 0; |
| 52 | } |
| 53 | |
| 54 | // Process the form data and return a response |
| 55 | $response = array( |
| 56 | 'success' => true, |
| 57 | 'password' => $password, |
| 58 | 'embedHtml' => $embed, |
| 59 | 'post_id' => $post_id |
| 60 | ); |
| 61 | |
| 62 | wp_send_json($response); |
| 63 | |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | if (!function_exists('has_content_allowed_roles')) { |
| 68 | function has_content_allowed_roles($allowed_roles = []) { |
| 69 | if ((count($allowed_roles) === 1 && empty($allowed_roles[0]))) { |
| 70 | return true; |
| 71 | } |
| 72 | |
| 73 | $current_user = wp_get_current_user(); |
| 74 | $user_roles = $current_user->roles; |
| 75 | |
| 76 | return !empty(array_intersect($user_roles, $allowed_roles)); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | function embedpress_block_scripts($attributes) { |
| 81 | |
| 82 | $script_handles = []; |
| 83 | |
| 84 | if(!empty($attributes['customPlayer'])){ |
| 85 | $script_handles[] = 'plyr.polyfilled'; |
| 86 | $script_handles[] = 'initplyr'; |
| 87 | $script_handles[] = 'vimeo-player'; |
| 88 | } |
| 89 | |
| 90 | $script_handles[] = 'embedpress-google-photos-album'; |
| 91 | $script_handles[] = 'embedpress-remove-round-button'; |
| 92 | $script_handles[] = 'embedpress-front'; |
| 93 | |
| 94 | if(!empty($attributes['adManager'])){ |
| 95 | $script_handles[] = 'embedpress-ads'; |
| 96 | } |
| 97 | |
| 98 | if((!empty($attributes['instaLayout']) && $attributes['instaLayout'] == 'insta-carousel') || (!empty($attributes['ytChannelLayout']) && $attributes['ytChannelLayout'] == 'carousel')){ |
| 99 | $script_handles[] = 'cg-carousel'; |
| 100 | } |
| 101 | |
| 102 | foreach ($script_handles as $handle) { |
| 103 | wp_enqueue_script($handle); |
| 104 | } |
| 105 | |
| 106 | $style_handles = []; |
| 107 | |
| 108 | if(!empty($attributes['customPlayer'])){ |
| 109 | $style_handles[] = 'plyr'; |
| 110 | } |
| 111 | |
| 112 | if((!empty($attributes['instaLayout']) && $attributes['instaLayout'] == 'insta-carousel') || (!empty($attributes['ytChannelLayout']) && $attributes['ytChannelLayout'] == 'carousel')){ |
| 113 | $style_handles[] = 'cg-carousel'; |
| 114 | } |
| 115 | |
| 116 | $style_handles[] = 'embedpress_blocks-cgb-style-css'; |
| 117 | $style_handles[] = 'embedpress-style'; |
| 118 | |
| 119 | foreach ($style_handles as $handle) { |
| 120 | wp_enqueue_style($handle, false, [], EMBEDPRESS_PLUGIN_VERSION); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | function embedpress_render_block($attributes) |
| 125 | { |
| 126 | |
| 127 | embedpress_block_scripts($attributes); |
| 128 | |
| 129 | |
| 130 | $client_id = !empty($attributes['clientId']) ? md5($attributes['clientId']) : ''; |
| 131 | $block_id = !empty($attributes['clientId']) ? $attributes['clientId'] : ''; |
| 132 | $custom_player = !empty($attributes['customPlayer']) ? $attributes['customPlayer'] : 0; |
| 133 | $instaLayout = !empty($attributes['instaLayout']) ? ' '.$attributes['instaLayout'] : ' insta-grid'; |
| 134 | $mode = !empty($attributes['mode']) ? ' ep-google-photos-'.$attributes['mode'] : ''; |
| 135 | |
| 136 | $_carousel_options = ''; |
| 137 | $_carousel_id = ''; |
| 138 | if(!empty($attributes['instaLayout']) && $attributes['instaLayout'] === 'insta-carousel'){ |
| 139 | $_carousel_id = 'data-carouselid=' . esc_attr($client_id) . ''; |
| 140 | |
| 141 | $layout = $attributes['instaLayout']; |
| 142 | $slidesShow = !empty($attributes['slidesShow']) ? $attributes['slidesShow'] : 5; |
| 143 | $carouselAutoplay = !empty($attributes['carouselAutoplay']) ? $attributes['carouselAutoplay'] : 0; |
| 144 | $autoplaySpeed = !empty($attributes['autoplaySpeed']) ? $attributes['autoplaySpeed'] : 3000; |
| 145 | $transitionSpeed = !empty($attributes['transitionSpeed']) ? $attributes['transitionSpeed'] : 1000; |
| 146 | $carouselLoop = !empty($attributes['carouselLoop']) ? $attributes['carouselLoop'] : 0; |
| 147 | $carouselArrows = !empty($attributes['carouselArrows']) ? $attributes['carouselArrows'] : 0; |
| 148 | $spacing = !empty($attributes['carouselSpacing']) ? $attributes['carouselSpacing'] : 0; |
| 149 | |
| 150 | // print_r($attributes); |
| 151 | |
| 152 | $carousel_options = [ |
| 153 | 'layout' => $layout, |
| 154 | 'slideshow' => $slidesShow, |
| 155 | 'autoplay' => $carouselAutoplay, |
| 156 | 'autoplayspeed' => $autoplaySpeed, |
| 157 | 'transitionspeed' => $transitionSpeed, |
| 158 | 'loop' => $carouselLoop, |
| 159 | 'arrows' => $carouselArrows, |
| 160 | 'spacing' => $spacing |
| 161 | ]; |
| 162 | |
| 163 | $carousel_options_string = json_encode($carousel_options); |
| 164 | $_carousel_options = 'data-carousel-options='. htmlentities($carousel_options_string, ENT_QUOTES) .''; |
| 165 | } |
| 166 | |
| 167 | $cEmbedType = !empty($attributes['cEmbedType']) ? ' '.$attributes['cEmbedType'] : ''; |
| 168 | |
| 169 | $_custom_player = ''; |
| 170 | $_player_options = ''; |
| 171 | |
| 172 | if (!empty($custom_player)) { |
| 173 | |
| 174 | $is_self_hosted = Helper::check_media_format($attributes['url']); |
| 175 | |
| 176 | $_custom_player = 'data-playerid=' . esc_attr($client_id); |
| 177 | $player_preset = !empty($attributes['playerPreset']) ? $attributes['playerPreset'] : 'preset-default'; |
| 178 | $player_color = !empty($attributes['playerColor']) ? $attributes['playerColor'] : ''; |
| 179 | $poster_thumbnail = !empty($attributes['posterThumbnail']) ? $attributes['posterThumbnail'] : ''; |
| 180 | $player_pip = !empty($attributes['playerPip']) ? true : false; |
| 181 | $player_restart = !empty($attributes['playerRestart']) ? true : false; |
| 182 | $player_rewind = !empty($attributes['playerRewind']) ? true : false; |
| 183 | $player_fastForward = !empty($attributes['playerFastForward']) ? true : false; |
| 184 | $player_tooltip = !empty($attributes['playerTooltip']) ? true : false; |
| 185 | $player_hide_controls = !empty($attributes['playerHideControls']) ? true : false; |
| 186 | $player_download = !empty($attributes['playerDownload']) ? true : false; |
| 187 | |
| 188 | $playerOptions = [ |
| 189 | 'rewind' => $player_rewind, |
| 190 | 'restart' => $player_restart, |
| 191 | 'pip' => $player_pip, |
| 192 | 'poster_thumbnail' => $poster_thumbnail, |
| 193 | 'player_color' => $player_color, |
| 194 | 'player_preset' => $player_preset, |
| 195 | 'fast_forward' => $player_fastForward, |
| 196 | 'player_tooltip' => $player_tooltip, |
| 197 | 'hide_controls' => $player_hide_controls, |
| 198 | 'download' => $player_download, |
| 199 | ]; |
| 200 | |
| 201 | if(!empty($attributes['fullscreen'])){ |
| 202 | $playerOptions['fullscreen'] = $attributes['fullscreen']; |
| 203 | } |
| 204 | |
| 205 | if(!empty($is_self_hosted['selhosted'])){ |
| 206 | $playerOptions['self_hosted'] = $is_self_hosted['selhosted']; |
| 207 | $playerOptions['hosted_format'] = $is_self_hosted['format']; |
| 208 | } |
| 209 | |
| 210 | //Youtube options |
| 211 | if(!empty($attributes['starttime'])){ |
| 212 | $playerOptions['start'] = $attributes['starttime']; |
| 213 | } |
| 214 | if(!empty($attributes['endtime'])){ |
| 215 | $playerOptions['end'] = $attributes['endtime']; |
| 216 | } |
| 217 | if(!empty($attributes['relatedvideos'])){ |
| 218 | $playerOptions['rel'] = $attributes['relatedvideos']; |
| 219 | } |
| 220 | if(!empty($attributes['muteVideo'])){ |
| 221 | $playerOptions['mute'] = $attributes['muteVideo']; |
| 222 | } |
| 223 | |
| 224 | //vimeo options |
| 225 | if(!empty($attributes['vstarttime'])){ |
| 226 | $playerOptions['t'] = $attributes['vstarttime']; |
| 227 | } |
| 228 | if(!empty($attributes['vautoplay'])){ |
| 229 | $playerOptions['vautoplay'] = $attributes['vautoplay']; |
| 230 | } |
| 231 | if(!empty($attributes['vautopause'])){ |
| 232 | $playerOptions['autopause'] = $attributes['vautopause']; |
| 233 | } |
| 234 | if(!empty($attributes['vdnt'])){ |
| 235 | $playerOptions['dnt'] = $attributes['vdnt']; |
| 236 | } |
| 237 | |
| 238 | $playerOptionsString = json_encode($playerOptions); |
| 239 | $_player_options = 'data-options='. htmlentities($playerOptionsString, ENT_QUOTES); |
| 240 | } |
| 241 | |
| 242 | $pass_hash_key = isset($attributes['contentPassword']) ? md5($attributes['contentPassword']): ''; |
| 243 | |
| 244 | |
| 245 | |
| 246 | if (!empty($attributes['embedHTML'])) { |
| 247 | $embed = apply_filters('embedpress_gutenberg_embed', $attributes['embedHTML'], $attributes); |
| 248 | |
| 249 | $content_share_class = ''; |
| 250 | $share_position_class = ''; |
| 251 | $share_position = isset($attributes['sharePosition']) ? $attributes['sharePosition'] : 'right'; |
| 252 | |
| 253 | if(!empty($attributes['contentShare'])) { |
| 254 | $content_share_class = 'ep-content-share-enabled'; |
| 255 | $share_position_class = 'ep-share-position-'.$share_position; |
| 256 | } |
| 257 | |
| 258 | $password_correct = isset($_COOKIE['password_correct_'.$client_id]) ? $_COOKIE['password_correct_'.$client_id] : ''; |
| 259 | $hash_pass = hash('sha256', wp_salt(32) . md5(isset($attributes['contentPassword']) ? $attributes['contentPassword'] : '')); |
| 260 | |
| 261 | $content_protection_class = 'ep-content-protection-enabled'; |
| 262 | if(empty($attributes['lockContent']) || empty($attributes['contentPassword']) || $hash_pass === $password_correct) { |
| 263 | $content_protection_class = 'ep-content-protection-disabled'; |
| 264 | } |
| 265 | |
| 266 | $aligns = [ |
| 267 | 'left' => 'alignleft', |
| 268 | 'right' => 'alignright', |
| 269 | 'wide' => 'alignwide', |
| 270 | 'full' => 'alignfull', |
| 271 | 'center' => 'aligncenter', |
| 272 | ]; |
| 273 | if (isset($attributes['align'])) { |
| 274 | $alignment = isset($aligns[$attributes['align']]) ? $aligns[$attributes['align']] . ' clear' : ''; |
| 275 | } else { |
| 276 | $alignment = 'aligncenter'; // default alignment is center in js, so keeping same here |
| 277 | } |
| 278 | $embed = Helper::customLogo($embed, $attributes); |
| 279 | $url = !empty($attributes['href']) ? $attributes['href'] : ''; |
| 280 | |
| 281 | $adsAtts = ''; |
| 282 | |
| 283 | if(!empty($attributes['adManager'])) { |
| 284 | $ad = base64_encode(json_encode($attributes)); |
| 285 | $adsAtts = "data-sponsored-id=$client_id data-sponsored-attrs=$ad class=sponsored-mask"; |
| 286 | } |
| 287 | |
| 288 | $hosted_format = ''; |
| 289 | if (!empty($custom_player)) { |
| 290 | $self_hosted = Helper::check_media_format($attributes['url']); |
| 291 | $hosted_format = isset($self_hosted['format']) ? $self_hosted['format'] : ''; |
| 292 | } |
| 293 | |
| 294 | $yt_channel_class = ''; |
| 295 | if(Helper::is_youtube_channel($attributes['url'])){ |
| 296 | $yt_channel_class = 'embedded-youtube-channel'; |
| 297 | } |
| 298 | |
| 299 | $autoPause = ''; |
| 300 | if(!empty($attributes['autoPause'])){ |
| 301 | $autoPause = ' enabled-auto-pause'; |
| 302 | } |
| 303 | |
| 304 | ob_start(); |
| 305 | ?> |
| 306 | <div class="embedpress-gutenberg-wrapper <?php echo esc_attr( $alignment.' '.$content_share_class.' '.$share_position_class.' '.$content_protection_class); echo esc_attr( $cEmbedType ); ?>" id="<?php echo esc_attr($block_id); ?>"> |
| 307 | <?php |
| 308 | $share_position = isset($attributes['sharePosition']) ? $attributes['sharePosition'] : 'right'; |
| 309 | $custom_thumbnail = isset($attributes['customThumbnail']) ? $attributes['customThumbnail'] : ''; |
| 310 | ?> |
| 311 | <div class="wp-block-embed__wrapper <?php if(!empty($attributes['contentShare'])) echo esc_attr( 'position-'.$share_position.'-wraper'); ?> <?php if($attributes['videosize'] == 'responsive') echo esc_attr( 'ep-video-responsive' ); ?>"> |
| 312 | <div id="ep-gutenberg-content-<?php echo esc_attr( $client_id )?>" class="ep-gutenberg-content<?php echo esc_attr($autoPause); ?>"> |
| 313 | <div |
| 314 | <?php echo esc_attr( $adsAtts ); ?> > |
| 315 | <div class="ep-embed-content-wraper <?php |
| 316 | if (!empty($custom_player)) { |
| 317 | echo esc_attr($player_preset); |
| 318 | } |
| 319 | echo esc_attr($instaLayout); |
| 320 | echo esc_attr($mode); |
| 321 | ?> <?php echo esc_attr($hosted_format); ?> <?php echo esc_attr($yt_channel_class); ?>" |
| 322 | <?php echo esc_attr($_custom_player); ?> |
| 323 | <?php echo esc_attr($_player_options); ?> |
| 324 | <?php echo esc_attr( $_carousel_id ); ?> |
| 325 | <?php echo esc_attr($_carousel_options); ?> |
| 326 | > |
| 327 | <?php |
| 328 | $hash_pass = hash('sha256', wp_salt(32) . md5($attributes['contentPassword'])); |
| 329 | $password_correct = isset($_COOKIE['password_correct_'.$client_id]) ? $_COOKIE['password_correct_'.$client_id] : ''; |
| 330 | if( |
| 331 | !apply_filters('embedpress/is_allow_rander', false) || |
| 332 | empty($attributes['lockContent']) || |
| 333 | ($attributes['protectionType'] == 'password' && empty($attributes['contentPassword'])) || |
| 334 | ($attributes['protectionType'] == 'password' && (!empty(Helper::is_password_correct($client_id))) && ($hash_pass === $password_correct)) || |
| 335 | ($attributes['protectionType'] == 'user-role' && has_content_allowed_roles($attributes['userRole'])) |
| 336 | ){ |
| 337 | |
| 338 | if(!empty($attributes['contentShare'])) { |
| 339 | $content_id = $attributes['clientId']; |
| 340 | $embed .= Helper::embed_content_share($content_id, $attributes); |
| 341 | } |
| 342 | echo $embed; |
| 343 | } else { |
| 344 | if(!empty($attributes['contentShare'])) { |
| 345 | $content_id = $attributes['clientId']; |
| 346 | $embed .= Helper::embed_content_share($content_id, $attributes); |
| 347 | } |
| 348 | |
| 349 | if ($attributes['protectionType'] == 'password') { |
| 350 | do_action('embedpress/display_password_form', $client_id, $embed, $pass_hash_key, $attributes); |
| 351 | } else { |
| 352 | do_action('embedpress/content_protection_content', $client_id, $attributes['protectionMessage'], $attributes['userRole']); |
| 353 | } |
| 354 | |
| 355 | } |
| 356 | ?> |
| 357 | </div> |
| 358 | <?php |
| 359 | if(!empty($attributes['adManager'])) { |
| 360 | $embed = apply_filters('embedpress/generate_ad_template', $embed, $client_id, $attributes, 'gutenberg'); |
| 361 | |
| 362 | } |
| 363 | ?> |
| 364 | </div> |
| 365 | </div> |
| 366 | </div> |
| 367 | </div> |
| 368 | <?php |
| 369 | |
| 370 | echo embedpress_render_block_style($attributes); |
| 371 | |
| 372 | |
| 373 | return ob_get_clean(); |
| 374 | |
| 375 | |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | /** |
| 380 | * Make style function for embedpress render block |
| 381 | */ |
| 382 | |
| 383 | function embedpress_render_block_style($attributes) |
| 384 | { |
| 385 | $uniqid = !empty($attributes['url']) ? '.ose-uid-' . md5($attributes['url']) : ''; |
| 386 | $client_id = !empty($attributes['clientId']) ? $attributes['clientId'] : ''; |
| 387 | |
| 388 | $custom_player = !empty($attributes['customPlayer']) ? $attributes['customPlayer'] : 0; |
| 389 | $player_color = !empty($attributes['playerColor']) ? $attributes['playerColor'] : ''; |
| 390 | $player_pip = !empty($attributes['playerPip']) ? 'block' : 'none'; |
| 391 | $logoX = !empty($attributes['logoX']) ? $attributes['logoX'] : 5; |
| 392 | $logoY = !empty($attributes['logoY']) ? $attributes['logoY'] : 10; |
| 393 | $logoOpacity = !empty($attributes['logoOpacity']) ? $attributes['logoOpacity'] : '1'; |
| 394 | $player_pip = !empty($attributes['playerPip']) ? 'block' : 'none'; |
| 395 | |
| 396 | $playerStyle = ''; |
| 397 | |
| 398 | if (!empty($custom_player)) { |
| 399 | $playerStyle = ' |
| 400 | [data-playerid="' . md5($client_id). '"] { |
| 401 | --plyr-color-main: ' . ($player_color && strlen($player_color) === 7 |
| 402 | ? 'rgba(' . hexdec(substr($player_color, 1, 2)) . ', ' . hexdec(substr($player_color, 3, 2)) . ', ' . hexdec(substr($player_color, 5, 2)) . ', .8)!important;' |
| 403 | : 'rgba(0, 0, 0, .8)!important;' |
| 404 | ) . '; |
| 405 | } |
| 406 | [data-playerid="' . md5($client_id). '"].custom-player-preset-3, [data-playerid="' . md5($client_id). '"].custom-player-preset-4 { |
| 407 | --plyr-color-main: ' . ($player_color && strlen($player_color) === 7 |
| 408 | ? 'rgb(' . hexdec(substr($player_color, 1, 2)) . ', ' . hexdec(substr($player_color, 3, 2)) . ', ' . hexdec(substr($player_color, 5, 2)) . ')!important;' |
| 409 | : 'rgba(0, 0, 0, .8)!important;' |
| 410 | ) . '; |
| 411 | } |
| 412 | [data-playerid="' . md5($client_id). '"] [data-plyr="pip"] { |
| 413 | display: '.$player_pip.'; |
| 414 | } |
| 415 | |
| 416 | [data-playerid="' . md5($client_id). '"] .plyr{ |
| 417 | width: ' . esc_attr($attributes['width']) . 'px !important; |
| 418 | height: ' . esc_attr($attributes['height']) . 'px!important; |
| 419 | max-height: ' . esc_attr($attributes['height']) . 'px!important; |
| 420 | } |
| 421 | |
| 422 | '; |
| 423 | } |
| 424 | |
| 425 | |
| 426 | $_iscustomlogo = ''; |
| 427 | |
| 428 | $youtubeStyles = ''; |
| 429 | |
| 430 | if(!empty($attributes['customlogo'])){ |
| 431 | $_iscustomlogo = $uniqid.' img.watermark.ep-custom-logo { |
| 432 | display: block !important; |
| 433 | } |
| 434 | |
| 435 | |
| 436 | #ep-gutenberg-content-'. md5($client_id).' img.watermark { |
| 437 | border: 0; |
| 438 | position: absolute; |
| 439 | bottom: '.esc_attr($logoY).'%; |
| 440 | right: '.esc_attr($logoX).'%; |
| 441 | max-width: 150px; |
| 442 | max-height: 75px; |
| 443 | -o-transition: opacity 0.5s ease-in-out; |
| 444 | -moz-transition: opacity 0.5s ease-in-out; |
| 445 | -webkit-transition: opacity 0.5s ease-in-out; |
| 446 | transition: opacity 0.5s ease-in-out; |
| 447 | z-index:1; |
| 448 | opacity: '.esc_attr($logoOpacity).'; |
| 449 | } |
| 450 | #ep-gutenberg-content-'. md5($client_id).' img.watermark:hover { |
| 451 | opacity: 1; |
| 452 | } |
| 453 | '; |
| 454 | } |
| 455 | $youtubeStyles = '<style> |
| 456 | .ose-youtube' . esc_attr($uniqid) . ' { |
| 457 | width: ' . esc_attr($attributes['width']) . 'px !important; |
| 458 | height: ' . esc_attr($attributes['height']) . 'px!important; |
| 459 | max-height: ' . esc_attr($attributes['height']) . 'px !important; |
| 460 | max-width: 100%; |
| 461 | } |
| 462 | |
| 463 | .ose-youtube' . esc_attr($uniqid) . '>iframe { |
| 464 | height: ' . esc_attr($attributes['height']) . 'px !important; |
| 465 | max-height: ' . esc_attr($attributes['height']) . 'px !important; |
| 466 | width: 100%; |
| 467 | position: relative !important; |
| 468 | } |
| 469 | |
| 470 | |
| 471 | ' . esc_attr($uniqid) . ' .wistia_embed { |
| 472 | max-width: 100%; |
| 473 | } |
| 474 | |
| 475 | .alignright .ose-wistia' . esc_attr($uniqid) .'{ |
| 476 | margin-left: auto; |
| 477 | } |
| 478 | .alignleft .ose-wistia' . esc_attr($uniqid) .'{ |
| 479 | margin-right: auto; |
| 480 | } |
| 481 | .aligncenter .ose-wistia' . esc_attr($uniqid) .'{ |
| 482 | margin: auto; |
| 483 | } |
| 484 | '.$uniqid.' img.watermark{ |
| 485 | display: none; |
| 486 | } |
| 487 | '.$_iscustomlogo.' |
| 488 | '.$playerStyle.' |
| 489 | |
| 490 | |
| 491 | |
| 492 | </style>'; |
| 493 | |
| 494 | if($attributes['videosize'] == 'responsive') { |
| 495 | |
| 496 | $width = !empty($attributes['width']) ? $attributes['width'] : 600; |
| 497 | $height = intval($width) * (9/16); |
| 498 | |
| 499 | $youtubeStyles = '<style> |
| 500 | .ose-youtube' . esc_attr($uniqid) . ' { |
| 501 | position: relative; |
| 502 | width: ' . esc_attr($attributes['width']) . 'px !important; |
| 503 | height: ' . esc_attr($height) . 'px !important; |
| 504 | max-width: 100%; |
| 505 | } |
| 506 | |
| 507 | .ose-wistia{ |
| 508 | height: auto !important; |
| 509 | padding-top: 0; |
| 510 | } |
| 511 | |
| 512 | .ose-youtube' . esc_attr($uniqid) . ' > iframe { |
| 513 | width: 100%; |
| 514 | max-height:100%!important; |
| 515 | } |
| 516 | |
| 517 | .ep-video-responsive{ |
| 518 | display: inline-block!important; |
| 519 | max-width: 100%; |
| 520 | } |
| 521 | '.$uniqid.' img.watermark{ |
| 522 | display: none; |
| 523 | } |
| 524 | '.$_iscustomlogo.' |
| 525 | '.$playerStyle.' |
| 526 | |
| 527 | </style>'; |
| 528 | } |
| 529 | |
| 530 | $youtubeStyles .= '<style> |
| 531 | .ose-matterport' . esc_attr($uniqid) . ' { |
| 532 | position: relative; |
| 533 | width: ' . esc_attr($attributes['width']) . 'px !important; |
| 534 | height: ' . esc_attr($attributes['height']) . 'px !important; |
| 535 | max-width: 100%; |
| 536 | } |
| 537 | .ose-giphy' . esc_attr($uniqid) . ' img{ |
| 538 | position: relative; |
| 539 | width: ' . esc_attr($attributes['width']) . 'px !important; |
| 540 | height: ' . esc_attr($attributes['height']) . 'px !important; |
| 541 | max-width: 100%; |
| 542 | } |
| 543 | |
| 544 | .ose-'. esc_attr($uniqid) . ', .ose-' . esc_attr($uniqid) . ' iframe, ' . esc_attr($uniqid) . ' .getty, .embera-embed-responsive.embera-embed-responsive-rich.embera-embed-responsive-provider-gettyimages { |
| 545 | height: ' . esc_attr($attributes['height']) . 'px !important; |
| 546 | max-height: ' . esc_attr($attributes['height']) . 'px !important; |
| 547 | } |
| 548 | .getty div:last-child{ |
| 549 | padding: 0!important; |
| 550 | height: ' . esc_attr($attributes['height']) . 'px !important; |
| 551 | max-height: ' . esc_attr($attributes['height']) . 'px !important; |
| 552 | } |
| 553 | |
| 554 | |
| 555 | |
| 556 | </style>'; |
| 557 | |
| 558 | |
| 559 | |
| 560 | return $youtubeStyles; |
| 561 | } |
| 562 | ?> |
| 563 |