diff --git a/src/Common/Event_Automator/Integrations/Assets.php b/src/Common/Event_Automator/Integrations/Assets.php index 7681229fee..56a70c3c40 100644 --- a/src/Common/Event_Automator/Integrations/Assets.php +++ b/src/Common/Event_Automator/Integrations/Assets.php @@ -9,8 +9,6 @@ namespace TEC\Event_Automator\Integrations; -use TEC\Event_Automator\Plugin; - /** * Class Settings * @@ -26,31 +24,15 @@ class Assets { * @since TBD Migrated to Common from Event Automator */ public function register_admin_assets() { - $admin_helpers = \Tribe__Admin__Helpers::instance(); - $plugin = tribe( Plugin::class ); - - tribe_asset( - $plugin, - 'tec-event-automator-css', - 'tec-event-automator.css', - [ 'tribe-tooltip' ], - 'admin_enqueue_scripts', - [ - 'conditionals' => [ - [ $admin_helpers, 'is_screen' ], - ], - ] - ); - tribe_asset( - $plugin, + \Tribe__Main::instance(), 'tec-event-automator-js', 'tec-event-automator.js', - [ 'jquery', 'tribe-dropdowns', 'tribe-clipboard', 'tribe-tooltip-js' ], + [ 'jquery' ], 'admin_enqueue_scripts', [ 'conditionals' => [ - [ $admin_helpers, 'is_screen' ], + [ \Tribe__Admin__Helpers::instance(), 'is_screen' ], ], 'localize' => [ 'name' => 'tec_automator', diff --git a/src/Common/Event_Automator/Integrations/REST/V1/Endpoints/Queue/Integration_REST_Endpoint.php b/src/Common/Event_Automator/Integrations/REST/V1/Endpoints/Queue/Integration_REST_Endpoint.php index e3f6715441..14ff8ab4b0 100644 --- a/src/Common/Event_Automator/Integrations/REST/V1/Endpoints/Queue/Integration_REST_Endpoint.php +++ b/src/Common/Event_Automator/Integrations/REST/V1/Endpoints/Queue/Integration_REST_Endpoint.php @@ -234,37 +234,39 @@ public function swaggerize_args( array $args = [], array $defaults = [] ) { } $no_description = _x( 'No description provided', 'Default description for integration endpoint.', 'tribe-common' ); - $defaults = array_merge( [ - 'in' => 'body', - 'schema' => [ - 'type' => 'string', - ], - 'description' => $no_description, - 'required' => false, - 'items' => [ - 'type' => 'integer', + $defaults = array_merge( + [ + 'in' => 'body', + 'schema' => [ + 'type' => 'string', + ], + 'description' => $no_description, + 'required' => false, + 'items' => [ + 'type' => 'integer', + ], ], - ], $defaults ); - + $defaults + ); $swaggerized = []; foreach ( $args as $name => $info ) { if ( isset( $info['swagger_type'] ) ) { $type = $info['swagger_type']; } else { - $type = isset( $info['type'] ) ? $info['type'] : false; + $type = $info['type'] ?? false; } $type = $this->convert_type( $type ); $read = [ - 'name' => $name, - 'in' => isset( $info['in'] ) ? $info['in'] : false, - 'description' => isset( $info['description'] ) ? $info['description'] : false, - 'schema' => [ - 'type' => $type, + 'name' => $name, + 'in' => $info['in'] ?? false, + 'description' => $info['description'] ?? false, + 'schema' => [ + 'type' => $type, ], - 'required' => isset( $info['required'] ) ? $info['required'] : false, + 'required' => $info['required'] ?? false, ]; if ( isset( $info['items'] ) ) { @@ -281,12 +283,12 @@ public function swaggerize_args( array $args = [], array $defaults = [] ) { } // Copy in case we need to mutate default values for this field in args - $defaultsCopy = $defaults; - unset( $defaultsCopy['default'] ); - unset( $defaultsCopy['items'] ); - unset( $defaultsCopy['type'] ); + $defaults_copy = $defaults; + unset( $defaults_copy['default'] ); + unset( $defaults_copy['items'] ); + unset( $defaults_copy['type'] ); - $swaggerized[] = array_merge( $defaultsCopy, array_filter( $read ) ); + $swaggerized[] = array_merge( $defaults_copy, array_filter( $read ) ); } return $swaggerized; @@ -344,7 +346,7 @@ protected function load_api_key_pair( $consumer_id, $consumer_secret, $token = ' } $app_name = empty( $token['app_name'] ) ? '' : $token['app_name']; - $app_name = $app_header_id ? : $app_name; + $app_name = $app_header_id ?: $app_name; $this->api->set_api_key_last_access( $consumer_id, $app_name ); $this->set_endpoint_last_access( $app_name ); @@ -369,9 +371,7 @@ protected function verify_token( $request ) { return new WP_Error( 'missing_access_token', __( 'Missing access token.', 'tribe-common' ), [ 'status' => 401 ] ); } - $key_pair = $this->api->decode_jwt( $access_token ); - - return $key_pair; + return $this->api->decode_jwt( $access_token ); } /** @@ -440,7 +440,7 @@ abstract protected function get_display_name(): string; * @since TBD Migrated to Common from Event Automator */ public function add_to_dashboard() { - $api_id = $this->api::get_api_id(); + $api_id = $this->api::get_api_id(); add_filter( "tec_event_automator_{$api_id}_endpoints", [ $this, 'add_endpoint_details' ], 10, 2 ); } @@ -483,33 +483,20 @@ public function get_endpoint_details() { ]; // Setup queue counts only on that endpoint type. - if ( - static::$type !== 'queue' - || ! isset( $this->trigger ) - ) { - /** - * Filters the integration endpoint details. - * - * @since TBD Migrated to Common from Event Automator - * - * @param array $endpoint An array of the integration endpoint details. - * @param Abstract_REST_Endpoint $this An instance of the endpoint. - */ - return apply_filters( "tec_event_automator_{$api_id}_endpoint_details", $endpoint, $this ); + if ( static::$type === 'queue' && isset( $this->trigger ) ) { + $endpoint_queue = (array) $this->trigger->get_queue(); + $endpoint['count'] = empty( $endpoint_queue ) ? 0 : count( $endpoint_queue ); } - $endpoint_queue = (array) $this->trigger->get_queue(); - $endpoint['count'] = empty( $endpoint_queue ) ? 0 : count( $endpoint_queue ); - /** - * Filters the integation queue type endpoint details. + * Filters the integration endpoint details. * * @since TBD Migrated to Common from Event Automator * * @param array $endpoint An array of the integration endpoint details. * @param Abstract_REST_Endpoint $this An instance of the endpoint. */ - return apply_filters( "tec_event_automator_{$api_id}_queue_endpoint_details", $endpoint, $this ); + return apply_filters( "tec_event_automator_{$api_id}_endpoint_details", $endpoint, $this ); } /** @@ -520,7 +507,13 @@ public function get_endpoint_details() { * @return array An array of saved details for an endpoint. */ public function get_saved_details() { - return get_option( $this->get_option_id(), [ 'last_access' => '', 'enabled' => true ] ); + return get_option( + $this->get_option_id(), + [ + 'last_access' => '', + 'enabled' => true, + ] + ); } /** @@ -590,7 +583,7 @@ public function add_to_queue( $post_id, $data ) { return; } - $api_id = $this->api::get_api_id(); + $api_id = $this->api::get_api_id(); /** * Filters data passed to the trigger queue for an endpoint. @@ -703,8 +696,8 @@ public function pre_dispatch_verification( $result, $server, $request ) { * @param WP_REST_Response|WP_Error $response Response to replace the requested version with. Can be anything * a normal endpoint can return, or a WP_Error if replacing the * response with an error. - * @param WP_REST_Server $handler ResponseHandler instance (usually WP_REST_Server). - * @param WP_REST_Request $request Request used to generate the response. + * @param WP_REST_Server $handler ResponseHandler instance (usually WP_REST_Server). + * @param WP_REST_Request $request Request used to generate the response. * * @return WP_REST_Response|WP_Error The response. */ @@ -713,7 +706,7 @@ public function modify_rest_api_params_before_validation( $response, $handler, $ return $response; } - if ( $request->get_route() !== '/' . $this->get_events_route_namespace() . $this->get_endpoint_path() ) { + if ( $request->get_route() !== '/' . $this->get_events_route_namespace() . $this->get_endpoint_path() ) { return $response; } @@ -724,6 +717,6 @@ public function modify_rest_api_params_before_validation( $response, $handler, $ $request->set_param( 'organizer', $organizer_array ); } - return $response; + return $response; } } diff --git a/src/Common/Event_Automator/Integrations/REST/V1/Utilities/Action_Endpoints.php b/src/Common/Event_Automator/Integrations/REST/V1/Utilities/Action_Endpoints.php index f7a3b902e9..e4b5c7508c 100644 --- a/src/Common/Event_Automator/Integrations/REST/V1/Utilities/Action_Endpoints.php +++ b/src/Common/Event_Automator/Integrations/REST/V1/Utilities/Action_Endpoints.php @@ -23,22 +23,24 @@ class Action_Endpoints { * * @since TBD Migrated to Common from Event Automator * - * @param array $endpoint An array of the Zapier endpoint details. - * @param Abstract_REST_Endpoint $this An instance of the endpoint. + * @param array $endpoint An array of the Zapier endpoint details. + * @param Abstract_REST_Endpoint $endpoint_obj An instance of the endpoint. */ public function filter_details( $endpoint, $endpoint_obj ) { - if ( $endpoint_obj->get_id() !== 'create_events' ) { - return $endpoint; + if ( in_array( $endpoint_obj->get_id(), [ 'new_events', 'updated_events', 'canceled_events', 'create_events' ], true ) ) { + if ( ! class_exists( 'Tribe__Events__REST__V1__Validator__Base', false ) ) { + // Disable if Tribe__Events__REST__V1__Validator__Base class does not exist. + $endpoint['missing_dependency'] = true; + $endpoint['dependents'] = [ 'tec' ]; + } + } elseif ( in_array( $endpoint_obj->get_id(), [ 'attendees', 'updated_attendees', 'checkin', 'orders', 'refunded_orders' ], true ) ) { + if ( ! class_exists( 'Tribe__Tickets__REST__V1__Validator__Base', false ) ) { + // Disable if Tribe__Tickets__REST__V1__Validator__Base class does not exist. + $endpoint['missing_dependency'] = true; + $endpoint['dependents'] = [ 'et' ]; + } } - if ( class_exists( 'Tribe__Events__REST__V1__Validator__Base', false ) ) { - return $endpoint; - } - - // Disable if Tribe__Events__REST__V1__Validator__Base class does not exist. - $endpoint['missing_dependency'] = true; - $endpoint['dependents'] = $endpoint_obj->get_dependents(); - return $endpoint; } } diff --git a/src/Common/Event_Automator/Power_Automate/Power_Automate_Provider.php b/src/Common/Event_Automator/Power_Automate/Power_Automate_Provider.php index 34791b881a..1fa915dcfd 100644 --- a/src/Common/Event_Automator/Power_Automate/Power_Automate_Provider.php +++ b/src/Common/Event_Automator/Power_Automate/Power_Automate_Provider.php @@ -144,7 +144,7 @@ public function admin_routes() { * @since TBD Migrated to Common from Event Automator */ protected function add_actions() { - add_action( 'tribe_plugins_loaded', [ $this, 'register_admin_assets' ] ); + add_action( 'admin_init', [ $this, 'register_admin_assets' ] ); add_action( 'rest_api_init', [ $this, 'register_endpoints' ] ); // Add endpoints to settings dashboard. diff --git a/src/Common/Event_Automator/Zapier/Assets.php b/src/Common/Event_Automator/Zapier/Assets.php index a3d306925b..4546e6ef18 100644 --- a/src/Common/Event_Automator/Zapier/Assets.php +++ b/src/Common/Event_Automator/Zapier/Assets.php @@ -9,8 +9,6 @@ namespace TEC\Event_Automator\Zapier; -use TEC\Event_Automator\Plugin; - /** * Class Settings * @@ -26,31 +24,15 @@ class Assets { * @since TBD Migrated to Common from Event Automator */ public function register_admin_assets() { - $admin_helpers = \Tribe__Admin__Helpers::instance(); - $plugin = tribe( Plugin::class ); - - tribe_asset( - $plugin, - 'tec-event-automator-css', - 'tec-event-automator.css', - [ 'tribe-tooltip' ], - 'admin_enqueue_scripts', - [ - 'conditionals' => [ - [ $admin_helpers, 'is_screen' ], - ], - ] - ); - tribe_asset( - $plugin, + \Tribe__Main::instance(), 'tec-event-automator-js', 'tec-event-automator.js', - [ 'jquery', 'tribe-dropdowns', 'tribe-clipboard', 'tribe-tooltip-js' ], + [ 'jquery' ], 'admin_enqueue_scripts', [ 'conditionals' => [ - [ $admin_helpers, 'is_screen' ], + [ \Tribe__Admin__Helpers::instance(), 'is_screen' ], ], 'localize' => [ 'name' => 'tec_automator', diff --git a/src/Common/Event_Automator/Zapier/REST/V1/Utilities/Action_Endpoints.php b/src/Common/Event_Automator/Zapier/REST/V1/Utilities/Action_Endpoints.php index 6ade9243b6..32d3b67aa7 100644 --- a/src/Common/Event_Automator/Zapier/REST/V1/Utilities/Action_Endpoints.php +++ b/src/Common/Event_Automator/Zapier/REST/V1/Utilities/Action_Endpoints.php @@ -9,8 +9,6 @@ namespace TEC\Event_Automator\Zapier\REST\V1\Utilities; -use Tribe__Events__REST__V1__Validator__Base; - /** * Class Actions * @@ -25,22 +23,24 @@ class Action_Endpoints { * * @since TBD Migrated to Common from Event Automator * - * @param array $endpoint An array of the Zapier endpoint details. - * @param Abstract_REST_Endpoint $this An instance of the endpoint. + * @param array $endpoint An array of the Zapier endpoint details. + * @param Abstract_REST_Endpoint $endpoint_obj An instance of the endpoint. */ public function filter_details( $endpoint, $endpoint_obj ) { - if ( $endpoint_obj->get_id() !== 'create_events' ) { - return $endpoint; - } - - if ( class_exists( 'Tribe__Events__REST__V1__Validator__Base', false ) ) { - return $endpoint; + if ( in_array( $endpoint_obj->get_id(), [ 'new_events', 'updated_events', 'canceled_events', 'create_events' ], true ) ) { + if ( ! class_exists( 'Tribe__Events__REST__V1__Validator__Base', false ) ) { + // Disable if Tribe__Events__REST__V1__Validator__Base class does not exist. + $endpoint['missing_dependency'] = true; + $endpoint['dependents'] = [ 'tec' ]; + } + } elseif ( in_array( $endpoint_obj->get_id(), [ 'attendees', 'updated_attendees', 'checkin', 'orders', 'refunded_orders' ], true ) ) { + if ( ! class_exists( 'Tribe__Tickets__REST__V1__Validator__Base', false ) ) { + // Disable if Tribe__Tickets__REST__V1__Validator__Base class does not exist. + $endpoint['missing_dependency'] = true; + $endpoint['dependents'] = [ 'et' ]; + } } - // Disable if Tribe__Events__REST__V1__Validator__Base class does not exist. - $endpoint['missing_dependency'] = true; - $endpoint['dependents'] = $endpoint_obj->get_dependents(); - return $endpoint; } } diff --git a/src/Tribe/Service_Providers/Tooltip.php b/src/Tribe/Service_Providers/Tooltip.php index dd5ef6d193..b3c8d89509 100644 --- a/src/Tribe/Service_Providers/Tooltip.php +++ b/src/Tribe/Service_Providers/Tooltip.php @@ -40,16 +40,20 @@ private function hook() { * @since 4.9.8 */ public function add_tooltip_assets() { - $main = \Tribe__Main::instance(); + $main = \Tribe__Main::instance(); + $helpers = \Tribe__Admin__Helpers::instance(); tribe_asset( $main, 'tribe-tooltip', 'tooltip.css', [ 'tribe-common-skeleton-style' ], - null, + 'admin_enqueue_scripts', [ - 'groups' => 'tribe-tooltip', + 'groups' => 'tribe-tooltip', + 'conditionals' => [ + [ $helpers, 'is_screen' ], + ], ] ); @@ -58,9 +62,12 @@ public function add_tooltip_assets() { 'tribe-tooltip-js', 'tooltip.js', [ 'jquery', 'tribe-common' ], - null, + 'admin_enqueue_scripts', [ - 'groups' => 'tribe-tooltip' + 'groups' => 'tribe-tooltip', + 'conditionals' => [ + [ $helpers, 'is_screen' ], + ], ] ); } diff --git a/src/admin-views/dashboard/components/clear-button.php b/src/admin-views/dashboard/components/clear-button.php index 5ea1bbdbff..deff54374c 100644 --- a/src/admin-views/dashboard/components/clear-button.php +++ b/src/admin-views/dashboard/components/clear-button.php @@ -18,7 +18,7 @@ * @var Url $url The URLs handler for the integration. */ // Only show for queue endpoints. -if ( $endpoint['type'] !== 'queue' || ! $endpoint['enabled'] ) { +if ( $endpoint['type'] !== 'queue' || ! $endpoint['enabled'] || $endpoint['missing_dependency'] ) { return; } @@ -34,4 +34,4 @@ class="tec-settings-connection-endpoint-dashboard-details-action__button tec-set > - \ No newline at end of file + diff --git a/src/admin-views/dashboard/endpoints/endpoint.php b/src/admin-views/dashboard/endpoints/endpoint.php index e53aac9e69..3bddea74e2 100644 --- a/src/admin-views/dashboard/endpoints/endpoint.php +++ b/src/admin-views/dashboard/endpoints/endpoint.php @@ -19,88 +19,109 @@ */ ?> -
+
template( 'components/read-only', [ - 'classes_wrap' => [ 'tec-automator-grid-item', 'tec-settings-connection-endpoint-dashboard-details__name-wrap', ! $endpoint['enabled'] || $endpoint['missing_dependency'] ? 'disabled' : '', ], + $this->template( + 'components/read-only', + [ + 'classes_wrap' => [ 'tec-automator-grid-item', 'tec-settings-connection-endpoint-dashboard-details__name-wrap', ! $endpoint['enabled'] || $endpoint['missing_dependency'] ? 'disabled' : '' ], 'label' => _x( 'Name', 'Label for the integration endpoint dashboard endpoint name.', 'event-automator' ), 'screen_reader' => _x( 'The name for the integration endpoint.', 'The screen reader text of the label for the integration endpoint Dashboard endpoint name.', 'event-automator' ), - 'id' => "tec_automator_integration_endpoint_name_" . $endpoint['id'], + 'id' => 'tec_automator_integration_endpoint_name_' . $endpoint['id'], 'name' => "tec_automator_integration[]['endpoint_name']", 'value' => $endpoint['display_name'], - ] ); + ] + ); ?> template( 'components/read-only', [ + $last_access_classes = [ 'tec-automator-grid-item', 'tec-settings-connection-endpoint-dashboard-details__last-access-wrap' ]; + $last_access_label = _x( 'Last Access', 'Label for the integration endpoint Dashboards endpoint last access.', 'event-automator' ); + if ( $endpoint['enabled'] && ! $endpoint['missing_dependency'] ) { + $this->template( + 'components/read-only', + [ 'classes_wrap' => $last_access_classes, 'label' => $last_access_label, 'screen_reader' => _x( 'The last access for the integration endpoint.', 'The screen reader text of the label for the integration endpoint Dashboard endpoint last access.', 'event-automator' ), - 'id' => "tec_automator_integration_endpoint_last_access_" . $endpoint['id'], + 'id' => 'tec_automator_integration_endpoint_last_access_' . $endpoint['id'], 'name' => "tec_automator_integration[]['endpoint_last_access']", 'value' => str_replace( '|', ' - ', $endpoint['last_access'] ), - ] ); - } else { - $this->template( 'dashboard/components/disabled', [ + ] + ); + } else { + $this->template( + 'dashboard/components/disabled', + [ 'classes_wrap' => $last_access_classes, 'label' => $last_access_label, 'screen_reader' => _x( 'The last access is disabled as this endpoint is disabled.', 'The screen reader text of the label for the integration endpoint Dashboard endpoint last access when disabled.', 'event-automator' ), - ] ); - } + ] + ); + } ?> 0 ) { - $queue_status = _x( 'ready', 'Label for the integration endpoint Dashboards endpoint queue status.', 'event-automator' ); - } - if ( $manager::$api_id === "power-automate" ) { - $queue_status = $endpoint['count']; - } + $queue_classes = [ 'tec-automator-grid-item', 'tec-settings-connection-endpoint-dashboard-details__queue-wrap' ]; + $queue_label = _x( 'Queue', 'Label for the integration endpoint Dashboards endpoint queue.', 'event-automator' ); + $queue_status = _x( 'none', 'Label for the integration endpoint Dashboards endpoint queue status.', 'event-automator' ); + if ( $endpoint['count'] > 0 ) { + $queue_status = _x( 'ready', 'Label for the integration endpoint Dashboards endpoint queue status.', 'event-automator' ); + } + if ( $manager::$api_id === 'power-automate' ) { + $queue_status = $endpoint['count']; + } - if ( $endpoint['type'] === 'queue' && $endpoint['enabled'] ) { - $this->template( 'components/read-only', [ + if ( $endpoint['type'] === 'queue' && $endpoint['enabled'] ) { + $this->template( + 'components/read-only', + [ 'classes_wrap' => $queue_classes, 'label' => $queue_label, 'screen_reader' => _x( 'The Queue for the integration endpoint.', 'The screen reader text of the label for the integration endpoint Dashboard endpoint queue.', 'event-automator' ), - 'id' => "tec_automator_integration_endpoint_queue_" . $endpoint['id'], + 'id' => 'tec_automator_integration_endpoint_queue_' . $endpoint['id'], 'name' => "tec_automator_integration[]['endpoint_queue']", 'value' => $queue_status, - ] ); - } else { - $this->template( 'dashboard/components/disabled', [ + ] + ); + } else { + $this->template( + 'dashboard/components/disabled', + [ 'classes_wrap' => $queue_classes, 'label' => $queue_label, 'screen_reader' => _x( 'The Queue is disabled for this endpoint.', 'The screen reader text of the label for the integration endpoint Dashboard endpoint queue when disabled.', 'event-automator' ), - ] ); - } + ] + ); + } ?>
template( 'dashboard/components/clear-button', [ - 'endpoint' => $endpoint, - 'manager' => $manager, - 'url' => $url, - ] ); - $this->template( 'dashboard/components/status-button', [ - 'endpoint' => $endpoint, - 'manager' => $manager, - 'url' => $url, - ] ); - - if ( $endpoint['missing_dependency'] ) { - $this->template( 'dashboard/components/missing-dependency', [ + if ( $endpoint['missing_dependency'] ) { + $this->template( + 'dashboard/components/missing-dependency', + [ 'endpoint' => $endpoint, 'manager' => $manager, 'url' => $url, - ] ); - } + ] + ); + } else { + $this->template( + 'dashboard/components/clear-button', + [ + 'endpoint' => $endpoint, + 'manager' => $manager, + 'url' => $url, + ] + ); + $this->template( + 'dashboard/components/status-button', + [ + 'endpoint' => $endpoint, + 'manager' => $manager, + 'url' => $url, + ] + ); + } ?>
-
\ No newline at end of file +
diff --git a/src/admin-views/zapier/dashboard/components/clear-button.php b/src/admin-views/zapier/dashboard/components/clear-button.php index cf3573714e..02c538f8b8 100644 --- a/src/admin-views/zapier/dashboard/components/clear-button.php +++ b/src/admin-views/zapier/dashboard/components/clear-button.php @@ -18,7 +18,7 @@ * @var Url $url The URLs handler for the integration. */ // Only show for queue endpoints. -if ( $endpoint['type'] !== 'queue' || ! $endpoint['enabled'] ) { +if ( $endpoint['type'] !== 'queue' || ! $endpoint['enabled'] || $endpoint['missing_dependency'] ) { return; } @@ -34,4 +34,4 @@ class="tec-settings-connection-endpoint-dashboard-details-action__button tec-set > - \ No newline at end of file + diff --git a/src/admin-views/zapier/dashboard/endpoints/endpoint.php b/src/admin-views/zapier/dashboard/endpoints/endpoint.php index 81eec77c49..e0f842276e 100644 --- a/src/admin-views/zapier/dashboard/endpoints/endpoint.php +++ b/src/admin-views/zapier/dashboard/endpoints/endpoint.php @@ -19,80 +19,101 @@ */ ?> -
+
template( 'zapier/api/components/read-only', [ - 'classes_wrap' => [ 'tec-automator-grid-item', 'tec-settings-connection-endpoint-dashboard-details__name-wrap', ! $endpoint['enabled'] || $endpoint['missing_dependency'] ? 'disabled' : '', ], + $this->template( + 'zapier/api/components/read-only', + [ + 'classes_wrap' => [ 'tec-automator-grid-item', 'tec-settings-connection-endpoint-dashboard-details__name-wrap', ! $endpoint['enabled'] || $endpoint['missing_dependency'] ? 'disabled' : '' ], 'label' => _x( 'Name', 'Label for the Zapier Endpoint Dashboard endpoint name.', 'event-automator' ), 'screen_reader' => _x( 'The name for the Zapier endpoint.', 'The screen reader text of the label for the Zapier Endpoint Dashboard endpoint name.', 'event-automator' ), - 'id' => "tec_automator_zapier_endpoint_name_" . $endpoint['id'], + 'id' => 'tec_automator_zapier_endpoint_name_' . $endpoint['id'], 'name' => "tec_automator_zapier[]['endpoint_name']", 'value' => $endpoint['display_name'], - ] ); + ] + ); ?> template( 'zapier/api/components/read-only', [ + $last_access_classes = [ 'tec-automator-grid-item', 'tec-settings-connection-endpoint-dashboard-details__last-access-wrap' ]; + $last_access_label = _x( 'Last Access', 'Label for the Zapier Endpoint Dashboards endpoint last access.', 'event-automator' ); + if ( $endpoint['enabled'] && ! $endpoint['missing_dependency'] ) { + $this->template( + 'zapier/api/components/read-only', + [ 'classes_wrap' => $last_access_classes, 'label' => $last_access_label, 'screen_reader' => _x( 'The last access for the Zapier endpoint.', 'The screen reader text of the label for the Zapier Endpoint Dashboard endpoint last access.', 'event-automator' ), - 'id' => "tec_automator_zapier_endpoint_last_access_" . $endpoint['id'], + 'id' => 'tec_automator_zapier_endpoint_last_access_' . $endpoint['id'], 'name' => "tec_automator_zapier[]['endpoint_last_access']", 'value' => str_replace( '|', ' - ', $endpoint['last_access'] ), - ] ); - } else { - $this->template( 'zapier/dashboard/components/disabled', [ + ] + ); + } else { + $this->template( + 'zapier/dashboard/components/disabled', + [ 'classes_wrap' => $last_access_classes, 'label' => $last_access_label, 'screen_reader' => _x( 'The last access is disabled as this endpoint is disabled.', 'The screen reader text of the label for the Zapier Endpoint Dashboard endpoint last access when disabled.', 'event-automator' ), - ] ); - } + ] + ); + } ?> template( 'zapier/api/components/read-only', [ + $queue_classes = [ 'tec-automator-grid-item', 'tec-settings-connection-endpoint-dashboard-details__queue-wrap' ]; + $queue_label = _x( 'Queue', 'Label for the Zapier Endpoint Dashboards endpoint queue.', 'event-automator' ); + if ( $endpoint['type'] === 'queue' && $endpoint['enabled'] ) { + $this->template( + 'zapier/api/components/read-only', + [ 'classes_wrap' => $queue_classes, 'label' => $queue_label, 'screen_reader' => _x( 'The Queue for the Zapier endpoint.', 'The screen reader text of the label for the Zapier Endpoint Dashboard endpoint queue.', 'event-automator' ), - 'id' => "tec_automator_zapier_endpoint_queue_" . $endpoint['id'], + 'id' => 'tec_automator_zapier_endpoint_queue_' . $endpoint['id'], 'name' => "tec_automator_zapier[]['endpoint_queue']", 'value' => $endpoint['count'], - ] ); - } else { - $this->template( 'zapier/dashboard/components/disabled', [ + ] + ); + } else { + $this->template( + 'zapier/dashboard/components/disabled', + [ 'classes_wrap' => $queue_classes, 'label' => $queue_label, 'screen_reader' => _x( 'The Queue is disabled for this Zapier endpoint.', 'The screen reader text of the label for the Zapier Endpoint Dashboard endpoint queue when disabled.', 'event-automator' ), - ] ); - } + ] + ); + } ?>
template( 'zapier/dashboard/components/clear-button', [ - 'endpoint' => $endpoint, - 'manager' => $manager, - 'url' => $url, - ] ); - $this->template( 'zapier/dashboard/components/status-button', [ - 'endpoint' => $endpoint, - 'manager' => $manager, - 'url' => $url, - ] ); - - if ( $endpoint['missing_dependency'] ) { - $this->template( 'zapier/dashboard/components/missing-dependency', [ + if ( $endpoint['missing_dependency'] ) { + $this->template( + 'zapier/dashboard/components/missing-dependency', + [ 'endpoint' => $endpoint, 'manager' => $manager, 'url' => $url, - ] ); - } + ] + ); + } else { + $this->template( + 'zapier/dashboard/components/clear-button', + [ + 'endpoint' => $endpoint, + 'manager' => $manager, + 'url' => $url, + ] + ); + $this->template( + 'zapier/dashboard/components/status-button', + [ + 'endpoint' => $endpoint, + 'manager' => $manager, + 'url' => $url, + ] + ); + } ?>
-
\ No newline at end of file +