| 1 |
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 |
/** |
| 3 |
* Deprecated classes for backwards compatibility. |
| 4 |
* |
| 5 |
* Version 4.0.0 moved all classes into the `Webfinger` namespace. The |
| 6 |
* pre-4.0.0 global class names are kept working here, so third-party |
| 7 |
* checks like `class_exists( 'Webfinger' )` (e.g. in the ActivityPub |
| 8 |
* plugin) and calls to the old static methods keep working. |
| 9 |
* |
| 10 |
* @package Webfinger |
| 11 |
*/ |
| 12 |
|
| 13 |
// phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound |
| 14 |
|
| 15 |
/* |
| 16 |
* The aliases are registered lazily, so a deprecation notice is triggered |
| 17 |
* the moment a legacy class name is actually referenced. |
| 18 |
*/ |
| 19 |
\spl_autoload_register( |
| 20 |
function ( $class_name ) { |
| 21 |
$deprecated = array( |
| 22 |
'Webfinger_Admin' => \Webfinger\Admin::class, |
| 23 |
'Webfinger_Legacy' => \Webfinger\Legacy::class, |
| 24 |
); |
| 25 |
|
| 26 |
if ( ! isset( $deprecated[ $class_name ] ) ) { |
| 27 |
return; |
| 28 |
} |
| 29 |
|
| 30 |
\_deprecated_class( $class_name, '4.0.0', $deprecated[ $class_name ] ); |
| 31 |
|
| 32 |
\class_alias( $deprecated[ $class_name ], $class_name ); |
| 33 |
} |
| 34 |
); |
| 35 |
|
| 36 |
/** |
| 37 |
* Legacy Webfinger class (deprecated). |
| 38 |
* |
| 39 |
* A subclass instead of a plain alias, because two static methods moved |
| 40 |
* to `Webfinger\User` and would otherwise be lost. |
| 41 |
*/ |
| 42 |
class Webfinger extends \Webfinger\Webfinger { |
| 43 |
|
| 44 |
/** |
| 45 |
* Returns a users default WebFinger resource. |
| 46 |
* |
| 47 |
* @deprecated 4.0.0 Use `Webfinger\User::get_resource()` instead. |
| 48 |
* |
| 49 |
* @param mixed $id_or_name_or_object User ID, login name or object. |
| 50 |
* @param boolean $with_protocol Whether to prepend the `acct:` scheme. |
| 51 |
* |
| 52 |
* @return string|null The users default WebFinger resource. |
| 53 |
*/ |
| 54 |
public static function get_user_resource( $id_or_name_or_object, $with_protocol = true ) { |
| 55 |
\_deprecated_function( __METHOD__, '4.0.0', '\Webfinger\User::get_resource()' ); |
| 56 |
|
| 57 |
return \Webfinger\User::get_resource( $id_or_name_or_object, $with_protocol ); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Returns all WebFinger resources of a user. |
| 62 |
* |
| 63 |
* @deprecated 4.0.0 Use `Webfinger\User::get_resources()` instead. |
| 64 |
* |
| 65 |
* @param mixed $id_or_name_or_object User ID, login name or object. |
| 66 |
* |
| 67 |
* @return string[] The users WebFinger resources. |
| 68 |
*/ |
| 69 |
public static function get_user_resources( $id_or_name_or_object ) { |
| 70 |
\_deprecated_function( __METHOD__, '4.0.0', '\Webfinger\User::get_resources()' ); |
| 71 |
|
| 72 |
return \Webfinger\User::get_resources( $id_or_name_or_object ); |
| 73 |
} |
| 74 |
} |
| 75 |
|