API
2 years ago
Blocks
5 years ago
License
5 years ago
AdminNotice.php
5 years ago
AdminNotices.php
4 years ago
AjaxActions.php
2 years ago
Blocks.php
5 years ago
Compatibility.php
4 years ago
Menu.php
3 years ago
Migrations.php
5 years ago
Player.php
2 years ago
ProCompatibility.php
2 years ago
ReusableVideos.php
4 years ago
Scripts.php
2 years ago
Settings.php
4 years ago
Shortcodes.php
2 years ago
Streamer.php
4 years ago
Translation.php
2 years ago
VideoPostType.php
4 years ago
Compatibility.php
109 lines
| 1 | <?php |
| 2 | |
| 3 | namespace PrestoPlayer\Services; |
| 4 | |
| 5 | class Compatibility |
| 6 | { |
| 7 | public function register() |
| 8 | { |
| 9 | // wp rocket compat |
| 10 | add_action('rocket_exclude_js', [$this, 'excludeComponentsFile']); |
| 11 | |
| 12 | // siteground optimize |
| 13 | add_action('sgo_js_minify_exclude', [$this, 'excludeHandle']); |
| 14 | |
| 15 | // godaddy's shitty feedback modal |
| 16 | add_action('admin_enqueue_scripts', [$this, 'goDaddyModal'], 99); |
| 17 | |
| 18 | // allow our player html |
| 19 | add_filter('wp_kses_allowed_html', [$this, 'allowHtml'], 11); |
| 20 | |
| 21 | // allow our css variables in safe css. |
| 22 | add_filter('safe_style_css', [$this, 'safeCSS']); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Allows our css variables to be outputted wp_kses_allowed_html |
| 27 | * |
| 28 | * @param array $styles Array of allowed styles. |
| 29 | * @return array |
| 30 | */ |
| 31 | public function safeCSS($styles) |
| 32 | { |
| 33 | $player_styles = [ |
| 34 | '--plyr-color-main', |
| 35 | '--plyr-captions-background', |
| 36 | '--presto-player-border-radius', |
| 37 | '--presto-player-logo-width', |
| 38 | '--presto-player-email-border-radius', |
| 39 | '--presto-player-button-border-radius', |
| 40 | '--presto-player-button-color', |
| 41 | '--presto-player-button-text', |
| 42 | '--presto-player-cta-background-opacity', |
| 43 | '--plyr-audio-controls-background', |
| 44 | '--plyr-audio-control-color', |
| 45 | '--plyr-range-thumb-background', |
| 46 | '--plyr-range-fill-background' |
| 47 | ]; |
| 48 | return array_merge($player_styles, $styles); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Lets us use our player tag in content. |
| 53 | * |
| 54 | * @param array $tags Allowed tags. |
| 55 | * @return array |
| 56 | */ |
| 57 | public function allowHtml($tags) |
| 58 | { |
| 59 | $tags['presto-player'] = [ |
| 60 | 'direction' => true, |
| 61 | 'css' => true, |
| 62 | 'skin' => true, |
| 63 | 'icon-url' => true, |
| 64 | 'id' => true, |
| 65 | 'src' => true, |
| 66 | 'css' => true, |
| 67 | 'class' => true, |
| 68 | 'preload' => true, |
| 69 | 'poster' => true, |
| 70 | 'playsinline' => true, |
| 71 | 'autoplay' => true, |
| 72 | ]; |
| 73 | return $tags; |
| 74 | } |
| 75 | |
| 76 | public function goDaddyModal() |
| 77 | { |
| 78 | global $post_type; |
| 79 | if ('pp_video_block' == $post_type) { |
| 80 | wp_dequeue_script('nextgen-feedback-modal'); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Exclude module by file |
| 86 | * |
| 87 | * @param array $excluded_js |
| 88 | * @return array |
| 89 | */ |
| 90 | public function excludeComponentsFile($excluded_js) |
| 91 | { |
| 92 | $excluded_js[] = str_replace(home_url(), '', PRESTO_PLAYER_PLUGIN_URL . "dist/components/web-components/web-components.esm.js"); |
| 93 | |
| 94 | return $excluded_js; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Exclude module by handle |
| 99 | * |
| 100 | * @param array $handles |
| 101 | * @return array |
| 102 | */ |
| 103 | public function excludeHandle($handles) |
| 104 | { |
| 105 | $handles[] = 'presto-components'; |
| 106 | return $handles; |
| 107 | } |
| 108 | } |
| 109 |