' . 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 '
' . esc_html( $message ) . '
' . 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 '