PluginProbe ʕ •ᴥ•ʔ
Presto Player / 4.2.1
Presto Player v4.2.1
4.3.0 4.2.4 4.2.3 4.2.2 4.2.0 4.2.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.12.0 1.13.0 1.14.0 1.14.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3-beta1 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.0-beta1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
presto-player / inc / Plugin.php
presto-player / inc Last commit date
Blocks 3 months ago Contracts 1 year ago Database 1 month ago Integrations 3 months ago Libraries 3 months ago Models 1 month ago Seeds 1 year ago Services 1 month ago Support 1 month ago config 1 month ago lib 1 month ago Activator.php 1 month ago Attachment.php 4 months ago Controller.php 1 year ago Core.php 1 year ago Deactivator.php 2 months ago Factory.php 3 months ago Files.php 1 year ago Playlist.php 1 year ago Plugin.php 1 month ago Requirements.php 1 year ago support.php 1 year ago
Plugin.php
151 lines
1 <?php
2 /**
3 * Plugin main class file.
4 *
5 * @package PrestoPlayer
6 */
7
8 namespace PrestoPlayer;
9
10 /**
11 * Main Plugin class.
12 */
13 class Plugin {
14 /**
15 * Required versions for features.
16 *
17 * @var array
18 */
19 protected const REQUIRED_VERSIONS = array(
20 'popups' => '3.0.0',
21 );
22
23 /**
24 * Check if pro version is enabled AND licensed.
25 *
26 * In wp-env tests, defining `PRESTO_TESTSUITE` short-circuits the license
27 * check so unrelated Pro feature tests don't have to seed license state.
28 * To exercise the actual license-validity path inside a test, opt in via:
29 *
30 * add_filter( 'presto_player_force_license_check', '__return_true' );
31 *
32 * @return bool
33 */
34 protected function isPro() {
35 if ( ! defined( 'PRESTO_PLAYER_PRO_ENABLED' ) ) {
36 return false;
37 }
38
39 // Test-suite bypass; opt back in via `presto_player_force_license_check`.
40 if (
41 defined( 'PRESTO_TESTSUITE' ) && PRESTO_TESTSUITE
42 && ! apply_filters( 'presto_player_force_license_check', false )
43 ) {
44 return true;
45 }
46
47 return Services\License\License::isActive();
48 }
49
50 /**
51 * Get the required pro version.
52 *
53 * @return string
54 */
55 protected function requiredProVersion() {
56 return '0.0.3';
57 }
58
59 /**
60 * Get the required pro version for a feature.
61 *
62 * @param string $feature Feature name to check.
63 * @return string
64 */
65 protected function requiredProVersionForFeature( $feature ) {
66 return self::REQUIRED_VERSIONS[ $feature ];
67 }
68
69 /**
70 * Get the version from plugin data
71 *
72 * @return string
73 */
74 protected function version() {
75 // Load version from plugin data.
76 if ( ! \function_exists( 'get_plugin_data' ) ) {
77 require_once \ABSPATH . 'wp-admin/includes/plugin.php';
78 }
79
80 return \get_plugin_data( PRESTO_PLAYER_PLUGIN_FILE, false, false )['Version'];
81 }
82
83 /**
84 * Get the current pro version.
85 *
86 * @return string|false
87 */
88 protected function proVersion() {
89 if ( ! $this->isPro() ) {
90 return false;
91 }
92 if ( class_exists( '\PrestoPlayer\Pro\Plugin' ) ) {
93 return \PrestoPlayer\Pro\Plugin::version();
94 }
95 return false;
96 }
97
98 /**
99 * Check if pro version meets minimum required version for a feature.
100 *
101 * @param string $feature Feature name to check.
102 * @return bool
103 */
104 protected function hasRequiredProVersion( $feature ) {
105 // get the required version for the feature.
106 $required_versions = $this->requiredProVersionForFeature( $feature );
107
108 // The feature does not exist.
109 if ( empty( $required_versions ) ) {
110 return false;
111 }
112
113 // get the pro version.
114 $pro_version = $this->proVersion();
115
116 // Pro version is not set (not installed).
117 if ( ! $pro_version ) {
118 return false;
119 }
120
121 // Compare the pro version with the required version.
122 return version_compare( $pro_version, $required_versions, '>=' );
123 }
124
125 /**
126 * Get the license status.
127 *
128 * @return string 'licensed' or 'unlicensed'
129 */
130 protected function licenseStatus() {
131 if ( ! $this->isPro() || ! class_exists( '\PrestoPlayer\Pro\Plugin' ) ) {
132 return 'unlicensed';
133 }
134
135 $pro_plugin = new \PrestoPlayer\Pro\Plugin();
136 return $pro_plugin->hasLicense() ? 'licensed' : 'unlicensed';
137 }
138
139 /**
140 * Static Facade Accessor
141 *
142 * @param string $method Method to call.
143 * @param mixed $params Method params.
144 *
145 * @return mixed
146 */
147 public static function __callStatic( $method, $params ) {
148 return call_user_func_array( array( new static(), $method ), $params );
149 }
150 }
151