| Name | Size | Mode | Actions |
|---|---|---|---|
| Builder/ | - | 0755 | rm |
| Payments/ | - | 0755 | rm |
| Connect.php | 22417 | 0644 | editdlrm |
| Entries.php | 847 | 0644 | editdlrm |
| Notices.php | 7218 | 0644 | editdlrm |
| Settings.php | 16525 | 0644 | editdlrm |
| WebhookSettings.php | 12921 | 0644 | editdlrm |
/home/vianto5/heredit.mx/wp-content/plugins/wpforms/src/Integrations/Square/Admin/Settings.php (16525B)
Switching sandbox/production modes requires Square account reconnection.
Press the "Connect with Square" button after saving the settings to reconnect.
', 'wpforms-lite' ), [ 'p' => [], 'em' => [], ] ), 'refresh_error' => esc_html__( 'Something went wrong while performing a refresh tokens request.', 'wpforms-lite' ), 'webhook_create_title' => esc_html__( 'Personal Access Token', 'wpforms-lite' ), 'webhook_create_description' => sprintf( wp_kses( /* translators: %s - the Square developer dashboard URL. */ __( 'To receive events, create a webhook route by providing your Personal Access Token, which you can find after registering an app on the Square Developer Dashboard. You can also set it up manually in the Advanced section.
See our documentation for details.
', 'wpforms-lite' ), [ 'a' => [ 'href' => [], 'target' => [], ], 'p' => [], ] ), esc_url( WebhookSettings::SQUARE_APPS_URL ), esc_url( wpforms_utm_link( 'https://wpforms.com/docs/setting-up-square-webhooks/', 'Settings - Payments', 'Square Webhooks Documentation Modal' ) ) ), 'webhook_token_placeholder' => esc_html__( 'Personal Access Token', 'wpforms-lite' ), 'token_is_required' => esc_html__( 'Personal Access Token is required to proceed.', 'wpforms-lite' ), 'webhook_urls' => [ 'rest' => Helpers::get_webhook_url_for_rest(), 'curl' => Helpers::get_webhook_url_for_curl(), ], ]; return $strings; } /** * Register Settings fields. * * @since 1.9.5 * * @param array $settings Array of current form settings. * * @return array */ public function register( $settings ): array { $settings = (array) $settings; $settings['payments']['square-heading'] = [ 'id' => 'square-heading', 'content' => $this->get_heading_content(), 'type' => 'content', 'no_label' => true, 'class' => [ 'section-heading' ], ]; foreach ( Helpers::get_available_modes() as $mode ) { $mode = sanitize_key( $mode ); $settings['payments'][ 'square-connection-status-' . $mode ] = [ 'id' => 'square-connection-status-' . $mode, 'name' => esc_html__( 'Connection Status', 'wpforms-lite' ), 'content' => $this->get_connection_status_content( $mode ), 'type' => 'content', 'is_hidden' => Helpers::get_mode() !== $mode, ]; if ( $this->is_connected ) { $is_location_set = ! empty( Helpers::get_location_id( $mode ) ); $settings['payments'][ 'square-location-id-' . $mode ] = [ 'id' => 'square-location-id-' . $mode, 'class' => $is_location_set ? '' : 'location-error', 'name' => esc_html__( 'Business Location', 'wpforms-lite' ), 'desc' => esc_html__( 'Only active locations that support credit card processing in Square can be chosen.', 'wpforms-lite' ), 'type' => 'select', 'choicesjs' => true, 'options' => $this->get_location_options( $mode ), 'is_hidden' => Helpers::get_mode() !== $mode, ]; $settings['payments'][ 'square-location-status-' . $mode ] = [ 'id' => 'square-location-status-' . $mode, 'content' => $is_location_set ? '' : $this->get_location_content_error(), 'type' => 'content', 'is_hidden' => Helpers::get_mode() !== $mode, ]; } } $settings['payments']['square-sandbox-mode'] = [ 'id' => 'square-sandbox-mode', 'name' => esc_html__( 'Test Mode', 'wpforms-lite' ), 'desc' => sprintf( wp_kses( /* translators: %s - WPForms.com URL for Square payment with more details. */ __( 'Prevent Square from processing live transactions. Learn More', 'wpforms-lite' ), [ 'a' => [ 'href' => [], 'target' => [], 'rel' => [], 'class' => [], ], ] ), esc_url( wpforms_utm_link( 'https://wpforms.com/docs/how-to-test-square-payments-on-your-site/', 'Settings - Payments', 'Square Test Documentation' ) ) ), 'type' => 'toggle', 'status' => true, ]; $webhooks_settings = $this->webhook_settings->settings( $settings ); return array_merge( $settings, $webhooks_settings ); } /** * Reset transients on settings save. * * @since 1.9.5 */ public function reset_transients() { array_map( 'WPForms\Integrations\Square\Helpers::detete_transients', Helpers::get_available_modes() ); } /** * Retrieve a section header content. * * @since 1.9.5 * * @return string */ private function get_heading_content(): string { return '' . sprintf( wp_kses( /* translators: %s - WPForms.com Square documentation article URL. */ __( 'Easily collect credit card payments with Square. For getting started and more information, see our Square documentation.', 'wpforms-lite' ), [ 'a' => [ 'href' => [], 'target' => [], 'rel' => [], ], ] ), esc_url( wpforms_utm_link( 'https://wpforms.com/docs/how-to-install-and-use-the-square-addon-with-wpforms/', 'Settings - Payments', 'Square Documentation' ) ) ) . '
' . Notices::get_fee_notice(); } /** * Retrieve a Connection Status setting content. * * @since 1.9.5 * * @param string $mode Square mode. * * @return string */ private function get_connection_status_content( string $mode ): string { $this->is_connected = false; $connection = Connection::get( $mode ); if ( ! $connection ) { return $this->get_disconnected_status_content( $mode ); } $content = $this->get_disabled_status_content( $connection ); if ( ! empty( $content ) ) { return $content; } $this->is_connected = true; return $this->get_enabled_status_content( $connection ); } /** * Retrieve a location content error. * * @since 1.9.5 * * @return string */ private function get_location_content_error(): string { return '' . $this->get_error_icon() . esc_html__( 'Business Location is required to process Square payments.', 'wpforms-lite' ) . '
' . sprintf( wp_kses( /* translators: %s - WPForms.com Square documentation article URL. */ __( 'Securely connect to Square with just a few clicks to begin accepting payments! Learn More', 'wpforms-lite' ), [ 'a' => [ 'href' => [], 'target' => [], 'rel' => [], 'class' => [], ], ] ), esc_url( wpforms_utm_link( 'https://wpforms.com/docs/how-to-install-and-use-the-square-addon-with-wpforms/#connect-square', 'Settings - Payments', 'Square Learn More' ) ) ) . '
'; } /** * Retrieve a connection is missing status content. * * @since 1.9.5 * * @param string $mode Square mode. * * @return string */ private function get_missing_status_content( string $mode ): string { return '' . esc_html__( 'It appears your connection may be invalid. You must refresh tokens or reconnect your account.', 'wpforms-lite' ) . '
' . '' . $this->get_refresh_button( $mode ) . $this->get_disconnect_button( $mode, false ) . '
' . esc_html__( 'Your connection is expired. You must refresh tokens or reconnect your account.', 'wpforms-lite' ) . '
' . '' . $this->get_refresh_button( $mode ) . $this->get_disconnect_button( $mode, false ) . '
' . esc_html__( 'WPForms currency and Business Location currency are not matched.', 'wpforms-lite' ) . '
' . $button . '
' : $button; } /** * Retrieve the Disconnect button. * * @since 1.9.5 * * @param string $mode Square mode. * @param bool $wrap Optional. Wrap a button HTML element or not. * * @return string */ private function get_disconnect_button( string $mode, bool $wrap = true ): string { $button = sprintf( '%3$s', esc_url( $this->connect->get_disconnect_url( $mode ) ), esc_attr__( 'Disconnect Square account', 'wpforms-lite' ), esc_html__( 'Disconnect', 'wpforms-lite' ) ); return $wrap ? '' . $button . '
' : $button; } /** * Retrieve the Refresh tokens button. * * @since 1.9.5 * * @param string $mode Square mode. * * @return string */ private function get_refresh_button( string $mode ): string { return sprintf( '', esc_attr( $mode ), esc_url( Helpers::get_settings_page_url() ), esc_attr__( 'Refresh connection tokens', 'wpforms-lite' ), esc_html__( 'Refresh tokens', 'wpforms-lite' ) ); } /** * Retrieve the Error icon emoji. * * @since 1.9.5 * * @return string */ private function get_error_icon(): string { return ''; } /** * Retrieve Business Location options. * * @since 1.9.5 * * @param string $mode Square mode. * * @return array */ private function get_location_options( string $mode ): array { $locations = $this->connect->get_connected_locations( $mode ); return ! empty( $locations ) ? array_column( $locations, 'name', 'id' ) : [ '' => esc_html__( 'No locations were found', 'wpforms-lite' ) ]; } }