| @@ -212,5 +212,146 @@ | ||
| 212 | 212 | */ |
| 213 | 213 | public function get_plugins_with_dependencies() { |
| 214 | 214 | return array_filter( $this->plugins, [ $this, 'has_dependencies' ] ); |
| 215 | 215 | } |
| 216 | + | |
| 217 | + /** | |
| 218 | + * Determines whether or not a plugin is active. | |
| 219 | + * | |
| 220 | + * @deprecated 23.4 | |
| 221 | + * @codeCoverageIgnore | |
| 222 | + * | |
| 223 | + * @param string $plugin The plugin slug to check. | |
| 224 | + * | |
| 225 | + * @return bool Whether or not the plugin is active. | |
| 226 | + */ | |
| 227 | + public function is_active( $plugin ) { | |
| 228 | + _deprecated_function( __METHOD__, 'Yoast SEO 23.4', 'is_plugin_active' ); | |
| 229 | + | |
| 230 | + return is_plugin_active( $plugin ); | |
| 231 | + } | |
| 232 | + | |
| 233 | + /** | |
| 234 | + * Gets all the possibly available plugins. | |
| 235 | + * | |
| 236 | + * @deprecated 23.4 | |
| 237 | + * @codeCoverageIgnore | |
| 238 | + * | |
| 239 | + * @return array Array containing the information about the plugins. | |
| 240 | + */ | |
| 241 | + public function get_plugins() { | |
| 242 | + _deprecated_function( __METHOD__, 'Yoast SEO 23.4', 'WPSEO_Addon_Manager::get_addon_filenames' ); | |
| 243 | + | |
| 244 | + return $this->plugins; | |
| 245 | + } | |
| 246 | + | |
| 247 | + /** | |
| 248 | + * Gets a specific plugin. Returns an empty array if it cannot be found. | |
| 249 | + * | |
| 250 | + * @deprecated 23.4 | |
| 251 | + * @codeCoverageIgnore | |
| 252 | + * | |
| 253 | + * @param string $plugin The plugin to search for. | |
| 254 | + * | |
| 255 | + * @return array The plugin properties. | |
| 256 | + */ | |
| 257 | + public function get_plugin( $plugin ) { // @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- needed for BC reasons | |
| 258 | + _deprecated_function( __METHOD__, 'Yoast SEO 23.4', 'WPSEO_Addon_Manager::get_plugin_file' ); | |
| 259 | + if ( ! isset( $this->plugins[ $plugin ] ) ) { | |
| 260 | + return []; | |
| 261 | + } | |
| 262 | + | |
| 263 | + return $this->plugins[ $plugin ]; | |
| 264 | + } | |
| 265 | + | |
| 266 | + /** | |
| 267 | + * Gets the version of the plugin. | |
| 268 | + * | |
| 269 | + * @deprecated 23.4 | |
| 270 | + * @codeCoverageIgnore | |
| 271 | + * | |
| 272 | + * @param array $plugin The information available about the plugin. | |
| 273 | + * | |
| 274 | + * @return string The version associated with the plugin. | |
| 275 | + */ | |
| 276 | + public function get_version( $plugin ) { // @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- needed for BC reasons | |
| 277 | + _deprecated_function( __METHOD__, 'Yoast SEO 23.4', 'WPSEO_Addon_Manager::get_installed_addons_versions' ); | |
| 278 | + if ( ! isset( $plugin['version'] ) ) { | |
| 279 | + return ''; | |
| 280 | + } | |
| 281 | + | |
| 282 | + return $plugin['version']; | |
| 283 | + } | |
| 284 | + | |
| 285 | + /** | |
| 286 | + * Checks whether a dependency is available. | |
| 287 | + * | |
| 288 | + * @deprecated 22.4 | |
| 289 | + * @codeCoverageIgnore | |
| 290 | + * | |
| 291 | + * @param array $dependency The information about the dependency to look for. | |
| 292 | + * | |
| 293 | + * @return bool Whether or not the dependency is available. | |
| 294 | + */ | |
| 295 | + public function is_dependency_available( $dependency ) { | |
| 296 | + _deprecated_function( __METHOD__, 'Yoast SEO 22.4' ); | |
| 297 | + | |
| 298 | + return isset( get_plugins()[ $dependency['slug'] ] ); | |
| 299 | + } | |
| 300 | + | |
| 301 | + /** | |
| 302 | + * Gets the names of the dependencies. | |
| 303 | + * | |
| 304 | + * @deprecated 23.4 | |
| 305 | + * @codeCoverageIgnore | |
| 306 | + * | |
| 307 | + * @param array $plugin The plugin to get the dependency names from. | |
| 308 | + * | |
| 309 | + * @return array Array containing the names of the associated dependencies. | |
| 310 | + */ | |
| 311 | + public function get_dependency_names( $plugin ) { // @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- needed for BC reasons | |
| 312 | + _deprecated_function( __METHOD__, 'Yoast SEO 23.4' ); | |
| 313 | + if ( ! $this->has_dependencies( $plugin ) ) { | |
| 314 | + return []; | |
| 315 | + } | |
| 316 | + | |
| 317 | + return array_keys( $plugin['_dependencies'] ); | |
| 318 | + } | |
| 319 | + | |
| 320 | + /** | |
| 321 | + * Determines whether or not a plugin is a Premium product. | |
| 322 | + * | |
| 323 | + * @deprecated 23.4 | |
| 324 | + * @codeCoverageIgnore | |
| 325 | + * | |
| 326 | + * @param array $plugin The plugin to check. | |
| 327 | + * | |
| 328 | + * @return bool Whether or not the plugin is a Premium product. | |
| 329 | + */ | |
| 330 | + public function is_premium( $plugin ) { | |
| 331 | + _deprecated_function( __METHOD__, 'Yoast SEO 23.4' ); | |
| 332 | + | |
| 333 | + return isset( $plugin['premium'] ) && $plugin['premium'] === true; | |
| 334 | + } | |
| 335 | + | |
| 336 | + /** | |
| 337 | + * Gets all installed plugins. | |
| 338 | + * | |
| 339 | + * @deprecated 23.4 | |
| 340 | + * @codeCoverageIgnore | |
| 341 | + * | |
| 342 | + * @return array The installed plugins. | |
| 343 | + */ | |
| 344 | + public function get_installed_plugins() { | |
| 345 | + | |
| 346 | + _deprecated_function( __METHOD__, 'Yoast SEO 23.4', 'WPSEO_Addon_Manager::get_installed_addons_versions' ); | |
| 347 | + $installed = []; | |
| 348 | + | |
| 349 | + foreach ( $this->plugins as $plugin_key => $plugin ) { | |
| 350 | + if ( $this->is_installed( $plugin ) ) { | |
| 351 | + $installed[ $plugin_key ] = $plugin; | |
| 352 | + } | |
| 353 | + } | |
| 354 | + | |
| 355 | + return $installed; | |
| 356 | + } | |
| 216 | 357 | } |