PluginProbe ʕ •ᴥ•ʔ
WooCommerce Square / 5.4.2
WooCommerce Square v5.4.2
5.4.2 5.4.1 5.4.0 trunk 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.7.0 2.8.0 2.9.0 2.9.1 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.2.0 3.3.0 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.7.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 4.0.0 4.1.0 4.2.0 4.2.1 4.2.2 4.2.3 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 4.9.8 4.9.9 5.0.0 5.0.1 5.1.0 5.1.1 5.1.2 5.2.0 5.3.0 5.3.1 5.3.2 5.3.3
woocommerce-square / includes / Internal / Abilities / Domain / GetConnectionStatus.php
woocommerce-square / includes / Internal / Abilities / Domain Last commit date
AbstractSquareAbility.php 1 month ago GetConnectionStatus.php 1 month ago GetLocations.php 1 month ago GetOrderPaymentStatus.php 1 month ago GetPendingJobs.php 1 month ago GetProductSyncState.php 1 month ago GetSyncRecords.php 1 month ago GetSyncStatus.php 1 month ago
GetConnectionStatus.php
87 lines
1 <?php
2 /**
3 * Get connection status ability definition.
4 *
5 * @package WooCommerce\Square
6 */
7
8 // @phan-file-suppress PhanUndeclaredClassMethod, PhanUndeclaredFunction @phan-suppress-current-line UnusedSuppression -- Abilities API + AbilityDefinition added in WC 10.9; suppression covers older-WC compat runs where this class never loads.
9
10 namespace WooCommerce\Square\Internal\Abilities\Domain;
11
12 defined( 'ABSPATH' ) || exit;
13
14 use Automattic\WooCommerce\Abilities\AbilityDefinition;
15 use WooCommerce\Square\Internal\Abilities\Abilities_Registrar;
16
17 /**
18 * Registers the woocommerce-square/get-connection-status ability.
19 *
20 * Lean alternative to the kitchen-sink general settings read. Answers
21 * "is this store connected to Square, against which environment, and
22 * which location ID is configured?" with five focused fields — and
23 * deliberately excludes access_tokens, connection/disconnection URLs,
24 * and the locations list. The locations list is available as a
25 * separate ability (woocommerce-square/get-locations).
26 *
27 * @internal Only loaded when WooCommerce 10.9+ is active.
28 */
29 class GetConnectionStatus extends AbstractSquareAbility implements AbilityDefinition {
30
31 public static function get_name(): string {
32 return 'woocommerce-square/get-connection-status';
33 }
34
35 public static function get_registration_args(): array {
36 return array(
37 'label' => __( 'Get Square connection status', 'woocommerce-square' ),
38 'description' => __( 'Return the Square OAuth connection state: connected (bool), configured (bool), environment (sandbox or production), the configured location id, and whether the sandbox toggle is on. Deliberately excludes tokens, connection URLs, and the locations list.', 'woocommerce-square' ),
39 'category' => self::CATEGORY_SLUG,
40 'input_schema' => array(
41 'type' => 'object',
42 'default' => (object) array(),
43 'properties' => array(),
44 'additionalProperties' => false,
45 ),
46 'execute_callback' => array( self::class, 'execute' ),
47 'permission_callback' => array( Abilities_Registrar::class, 'can_manage_woocommerce_square' ),
48 'meta' => array(
49 'annotations' => array(
50 'readonly' => true,
51 'destructive' => false,
52 'idempotent' => true,
53 ),
54 'show_in_rest' => true,
55 'mcp' => array(
56 'public' => true,
57 ),
58 ),
59 );
60 }
61
62 /**
63 * Execute callback.
64 *
65 * @param mixed $input Ignored.
66 * @return array|\WP_Error
67 */
68 public static function execute( $input = null ) {
69 unset( $input );
70
71 $settings = self::get_settings_handler_or_error();
72 if ( is_wp_error( $settings ) ) {
73 return $settings;
74 }
75
76 $location_id = $settings->get_location_id();
77
78 return array(
79 'is_connected' => (bool) $settings->is_connected(),
80 'is_configured' => (bool) $settings->is_configured(),
81 'is_sandbox' => (bool) $settings->is_sandbox(),
82 'environment' => (string) $settings->get_environment(),
83 'location_id' => ! empty( $location_id ) ? (string) $location_id : null,
84 );
85 }
86 }
87