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