get_path( 'directory', false ) . 'assets/'; $min = charitable_get_min_suffix(); $version = charitable()->get_version(); $dependencies = array(); wp_register_script( 'charitable-admin-square-settings', $assets_dir . 'js/integrations/square/square-settings.js', $dependencies, $version, false ); wp_enqueue_script( 'charitable-admin-square-settings' ); wp_enqueue_style( 'charitable-admin-square', $assets_dir . 'css/admin/charitable-admin-square' . $min . '.css', array(), $version ); } /** * Create and return the class object. * * @since 1.1.0 * * @return Charitable_Square_Admin */ public static function get_instance() { if ( is_null( self::$instance ) ) { self::$instance = new Charitable_Square_Admin(); } return self::$instance; } /** * When Square settings are saved, maybe run background processes to set hidden settings. * * @since 1.8.7 * * @param array $values The submitted values. * @param array $new_values The new settings. * @param array $old_values The previous settings. * @return array */ public function save_square_settings( $values, $new_values, $old_values ) { if ( charitable_is_debug( 'webhook' ) ) { error_log( 'save_square_settings'); // phpcs:ignore error_log( print_r( $values, true ) ); // phpcs:ignore error_log( print_r( $new_values, true ) ); // phpcs:ignore error_log( print_r( $old_values, true ) ); // phpcs:ignore } /* Bail early if this is not the Square settings page. */ if ( ! array_key_exists( 'gateways_square', $values ) ) { return $values; } /* Bail early if Square is not an active gateway */ if ( isset( $values['active_gateways'] ) && ! array_key_exists( 'gateways_square', $values['active_gateways'] ) ) { return $values; } return $values; } /** * Localize needed strings. * * @since 1.8.7 * * @param array $strings JS strings. * * @return array */ public function javascript_strings( $strings ): array { $strings = (array) $strings; $strings['square'] = array( 'mode_update' => wp_kses( __( '
Switching sandbox/production modes requires Square account reconnection.
Press the "Connect with Square" button after saving the settings to reconnect.
', 'charitable' ), array( 'p' => array(), 'em' => array(), ) ), 'refresh_error' => esc_html__( 'Something went wrong while performing a refresh tokens request.', 'charitable' ), 'webhook_create_title' => esc_html__( 'Personal Access Token', 'charitable' ), '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.
', 'charitable' ), array( 'a' => array( 'href' => array(), 'target' => array(), ), 'p' => array(), ) ), esc_url( self::SQUARE_APPS_URL ), esc_url( charitable_utm_link( 'https://wpcharitable.com/docs/setting-up-square-webhooks/', 'Settings - Payments', 'Square Webhooks Documentation Modal' ) ) ), 'webhook_token_placeholder' => esc_html__( 'Personal Access Token', 'charitable' ), 'token_is_required' => esc_html__( 'Personal Access Token is required to proceed.', 'charitable' ), 'webhook_urls' => array( 'rest' => '', // Helpers::get_webhook_url_for_rest(), 'curl' => '', // Helpers::get_webhook_url_for_curl(), ), ); return $strings; } } endif;