get_error_message() ) ); exit; } wp_safe_redirect( self::page_url( 'connected' ) ); exit; } /** * Fallback: the admin pastes the connection code shown on flatratechat.com. */ public static function handle_paste_code() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have permission to do that.', 'flatratechat' ) ); } check_admin_referer( 'flatratechat_paste_code' ); $code = isset( $_POST['frc_code'] ) ? sanitize_text_field( wp_unslash( $_POST['frc_code'] ) ) : ''; $r = FlatRateChat_Service::exchange_code( $code ); if ( is_wp_error( $r ) ) { wp_safe_redirect( self::page_url( 'error', $r->get_error_message() ) ); exit; } wp_safe_redirect( self::page_url( 'connected' ) ); exit; } /** * Disconnect: remove the script and our options from this site. */ public static function handle_disconnect() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have permission to do that.', 'flatratechat' ) ); } check_admin_referer( 'flatratechat_disconnect' ); FlatRateChat_Service::disconnect(); wp_safe_redirect( self::page_url( 'disconnected' ) ); exit; } /** * Refresh the cached plan + usage. */ public static function handle_refresh() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have permission to do that.', 'flatratechat' ) ); } check_admin_referer( 'flatratechat_refresh' ); delete_transient( FlatRateChat_Service::TR_STATUS ); wp_safe_redirect( self::page_url() ); exit; } /** * Notices after a redirect. */ private static function notices() { if ( ! isset( $_GET['frc_notice'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- display only. return; } $notice = sanitize_key( wp_unslash( $_GET['frc_notice'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $detail = isset( $_GET['frc_detail'] ) ? sanitize_text_field( wp_unslash( $_GET['frc_detail'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $map = array( 'connected' => array( 'success', __( 'Connected. The chat bubble is now on your site. It can take a few minutes until all your pages are read.', 'flatratechat' ) ), 'disconnected' => array( 'info', __( 'Disconnected. The chat bubble was removed from your site. Your FlatRateChat account still exists at flatratechat.com.', 'flatratechat' ) ), 'state' => array( 'error', __( 'That connection attempt was not started from this site or has expired (15 minutes). Click Connect again.', 'flatratechat' ) ), 'error' => array( 'error', $detail ? $detail : __( 'Something went wrong. Click Connect again.', 'flatratechat' ) ), ); if ( ! isset( $map[ $notice ] ) ) { return; } printf( '
%2$s
' . esc_html__( 'Privacy Policy', 'flatratechat' ) . '', '' . esc_html__( 'Terms', 'flatratechat' ) . '' ); ?>
| |
| get_error_message() ); ?> | |
|
0 ) {
$pct = min( 100, (int) round( $used * 100 / $included ) );
echo '';
}
if ( ! empty( $status['resets_on'] ) ) {
echo ' ' . esc_html( sprintf( /* translators: %s: date */ __( 'Counter resets on %s.', 'flatratechat' ), date_i18n( get_option( 'date_format' ), strtotime( (string) $status['resets_on'] ) ) ) ) . ' '; } ?> | |
| ' . esc_html__( '(reading your site now)', 'flatratechat' ) . ''; } ?> |