Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| Jetpack_Data | n/a |
0 / 0 |
n/a |
0 / 0 |
2 | n/a |
0 / 0 |
|||
| get_access_token | n/a |
0 / 0 |
n/a |
0 / 0 |
2 | |||||
| 1 | <?php |
| 2 | /** |
| 3 | * Jetpack_Data was deprecated in Jetpack 9.5. |
| 4 | * Some plugins (like WooCommerce Shipping & Tax) still rely on one method from that class. |
| 5 | * See https://github.com/Automattic/jetpack/issues/18977 |
| 6 | * |
| 7 | * Until the problem is solved, this file brings back Jetpack_Data to Atomic sites. |
| 8 | * |
| 9 | * @package automattic/wpcomsh |
| 10 | */ |
| 11 | |
| 12 | use Automattic\Jetpack\Connection\Tokens; |
| 13 | |
| 14 | /** |
| 15 | * Jetpack_Data class. |
| 16 | */ |
| 17 | class Jetpack_Data { |
| 18 | /** |
| 19 | * Get a token based on query args. |
| 20 | * |
| 21 | * @deprecated Jetpack 7.5 Use Connection_Manager instead. |
| 22 | * |
| 23 | * @param int|false $user_id false: Return the Blog Token. int: Return that user's User Token. |
| 24 | * @param string|false $token_key If provided, check that the token matches the provided input. |
| 25 | * @param bool|true $suppress_errors If true, return a falsy value when the token isn't found; |
| 26 | * When false, return a descriptive WP_Error when the token isn't found. |
| 27 | */ |
| 28 | public static function get_access_token( $user_id = false, $token_key = false, $suppress_errors = true ) { |
| 29 | if ( class_exists( '\Automattic\Jetpack\Connection\Tokens' ) ) { |
| 30 | return ( new Tokens() )->get_access_token( $user_id, $token_key, $suppress_errors ); |
| 31 | } |
| 32 | |
| 33 | return false; |
| 34 | } |
| 35 | } |