API
1 month ago
Blocks
10 months ago
License
1 month ago
AdminNotice.php
3 weeks ago
AdminNotices.php
3 weeks ago
AjaxActions.php
3 weeks ago
Blocks.php
1 year ago
Compatibility.php
10 months ago
Learn.php
1 month ago
Menu.php
1 month ago
Migrations.php
1 year ago
NpsSurvey.php
5 months ago
Onboarding.php
3 weeks ago
Player.php
4 days ago
PluginInstaller.php
1 month ago
PreloadService.php
1 year ago
ProCompatibility.php
1 month ago
ReusableVideos.php
2 weeks ago
RewriteRulesManager.php
1 year ago
Scripts.php
2 weeks ago
Settings.php
1 month ago
Shortcodes.php
1 month ago
Streamer.php
3 weeks ago
Translation.php
3 weeks ago
Usage.php
3 weeks ago
VideoPostType.php
2 weeks ago
ProCompatibility.php
102 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Pro plugin version compatibility notice. |
| 4 | * |
| 5 | * @package PrestoPlayer |
| 6 | * @subpackage Services |
| 7 | */ |
| 8 | |
| 9 | namespace PrestoPlayer\Services; |
| 10 | |
| 11 | use PrestoPlayer\Plugin; |
| 12 | use PrestoPlayer\Pro\Plugin as ProPlugin; |
| 13 | |
| 14 | /** |
| 15 | * Surfaces an admin notice prompting users to update Presto Player Pro when out of date. |
| 16 | */ |
| 17 | class ProCompatibility { |
| 18 | |
| 19 | /** |
| 20 | * The minimum Pro version recommended for compatibility with this core release. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | protected $recommended_pro_version = '3.2.0'; |
| 25 | |
| 26 | /** |
| 27 | * The minimum Pro version required to function at all. |
| 28 | * |
| 29 | * @var string |
| 30 | */ |
| 31 | protected $required_pro_version = '0.0.1'; |
| 32 | |
| 33 | /** |
| 34 | * Register hooks. |
| 35 | * |
| 36 | * @return void |
| 37 | */ |
| 38 | public function register() { |
| 39 | add_action( 'admin_notices', array( $this, 'showRecommendedVersionNotice' ) ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Check whether the active Pro plugin meets the requested version floor. |
| 44 | * |
| 45 | * @param string $type Either 'required' or 'recommended'. |
| 46 | * @return bool |
| 47 | */ |
| 48 | public function hasVersion( $type = 'recommended' ) { |
| 49 | if ( ! Plugin::isPro() ) { |
| 50 | return true; |
| 51 | } |
| 52 | $version = 'required' === $type ? $this->required_pro_version : $this->recommended_pro_version; |
| 53 | return ! version_compare( $version, ProPlugin::version(), '>' ); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Render the "update Pro" admin notice. |
| 58 | * |
| 59 | * @return void |
| 60 | */ |
| 61 | public function showRecommendedVersionNotice() { |
| 62 | // Has recommended version. |
| 63 | if ( $this->hasVersion( 'recommended' ) ) { |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | $notice_name = 'player_recommended_version_' . $this->recommended_pro_version; |
| 68 | |
| 69 | ob_start() |
| 70 | ?> |
| 71 | <div class="notice notice-info"> |
| 72 | <p><strong>Presto Player</strong></p> |
| 73 | <p><?php esc_html_e( 'Please update your Presto Player Pro plugin for compatibility with the Presto Player core plugin. This ensures you have access to new features and updates.', 'presto-player' ); ?></p> |
| 74 | <p> |
| 75 | <?php |
| 76 | printf( |
| 77 | /* translators: %s: recommended Pro plugin version number */ |
| 78 | esc_html__( 'The recommended minimum pro version is %s.', 'presto-player' ), |
| 79 | '<b>' . esc_html( $this->recommended_pro_version ) . '</b>' |
| 80 | ); |
| 81 | ?> |
| 82 | </p> |
| 83 | <p><a href=" |
| 84 | <?php |
| 85 | echo esc_url( |
| 86 | add_query_arg( |
| 87 | array( |
| 88 | 'presto_action' => 'dismiss_notices', |
| 89 | 'presto_notice' => $notice_name, |
| 90 | '_wpnonce' => wp_create_nonce( \PrestoPlayer\Services\AdminNotices::DISMISS_NONCE_ACTION ), |
| 91 | ) |
| 92 | ) |
| 93 | ); |
| 94 | ?> |
| 95 | "><?php esc_html_e( 'Dismiss Notice', 'presto-player' ); ?></a></p> |
| 96 | </div> |
| 97 | |
| 98 | <?php |
| 99 | echo ob_get_clean(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is pre-escaped HTML from the buffer above. |
| 100 | } |
| 101 | } |
| 102 |