' . esc_html__( 'Settings', 'astute-speed' ) . '' ); return $links; } add_filter( 'plugin_action_links_' . plugin_basename( ASTSP_FILE ), 'astsp_action_links' ); /** * Connect or disconnect, when the Account form was posted. * * @return array{0: string, 1: string} Notice type and message, or two empty strings. */ function astsp_account_maybe_act() { if ( ! isset( $_POST['astsp_account_nonce'] ) || ! current_user_can( 'manage_options' ) ) { return array( '', '' ); } check_admin_referer( 'astsp_account', 'astsp_account_nonce' ); if ( isset( $_POST['astsp_disconnect'] ) ) { astsp_service_disconnect(); return array( 'success', __( 'Disconnected. Nothing more is sent to the speed service. Critical CSS already on the site keeps working.', 'astute-speed' ) ); } if ( isset( $_POST['astsp_connect'] ) ) { if ( empty( $_POST['astsp_consent'] ) ) { return array( 'error', __( 'Tick the box to agree before connecting.', 'astute-speed' ) ); } $result = astsp_service_connect(); return $result['ok'] ? array( 'success', __( 'Connected. You can now make critical CSS and preview images with the better compression.', 'astute-speed' ) ) : array( 'error', $result['message'] ); } if ( isset( $_POST['astsp_refresh'] ) ) { astsp_service_status( true ); return array( 'success', __( 'Refreshed.', 'astute-speed' ) ); } return array( '', '' ); } /** * Render the Account screen. * * @return void */ function astsp_account_render_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } list( $type, $message ) = astsp_account_maybe_act(); $connected = astsp_service_connected(); $status = $connected ? astsp_service_status() : array(); echo '
'; echo '

' . esc_html__( 'Astute Speed account', 'astute-speed' ) . '

'; if ( '' !== $message ) { echo '

' . esc_html( $message ) . '

'; } echo '

' . esc_html__( 'Everything on the Page Speed and Images screens works on your own server, free and without limits. Two extras run on the Write & Grow speed service, because they need tools most hosts don\'t have: critical CSS, made by rendering your pages in a real browser, and better image compression.', 'astute-speed' ) . '

'; echo '
'; wp_nonce_field( 'astsp_account', 'astsp_account_nonce' ); if ( ! $connected ) { echo '

' . esc_html__( 'Connect this site', 'astute-speed' ) . '

'; echo '

' . esc_html__( 'Free sites get critical CSS for single posts once a month, and better compression for 100 images a month. A licence adds the homepage, pages and archives, and more of both.', 'astute-speed' ) . '

'; echo '

' . esc_html__( 'What is sent, and only when you use these features:', 'astute-speed' ) . '

' . esc_html__( 'Nothing about your visitors or users is sent.', 'astute-speed' ) . ' '; echo '' . esc_html__( 'Terms of use', 'astute-speed' ) . ' ยท '; echo '' . esc_html__( 'Privacy policy', 'astute-speed' ) . '

'; echo '

'; echo '

'; } else { echo '

' . esc_html__( 'Connected', 'astute-speed' ) . '

'; if ( ! empty( $status['error'] ) ) { echo '

' . esc_html( $status['error'] ) . '

'; } else { $limits = (array) ( $status['limits'] ?? array() ); $used = (array) ( $status['used'] ?? array() ); echo ''; echo ''; echo ''; echo ''; if ( 'free' === ( $status['plan'] ?? 'free' ) ) { echo '

' . esc_html__( 'See licences', 'astute-speed' ) . '

'; } } echo '

'; echo '

'; } echo '
'; }