id ) { remove_all_actions( 'admin_notices' ); remove_all_actions( 'all_admin_notices' ); } } /** "Settings" link on the Plugins list row. */ public static function action_links( $links ) { array_unshift( $links, '' . esc_html__( 'Settings', 'ableguard-accessibility-toolkit' ) . '' ); return $links; } /** * Only the switch is a registered setting. `options.php` writes every option in the posted * group and sets any field the form left out to empty, so a group holding the credentials * would let any form that shares it rewrite or blank them — and would write them through * 0.3.1's storage. The credentials are saved by the connection store instead. A settings * screen opened before an update still posts them, and `options.php` now ignores them. */ public static function register_settings() { register_setting( 'ableguard', 'ableguard_enabled', array( 'sanitize_callback' => 'rest_sanitize_boolean' ) ); } public static function handle_sync() { // The nonce keeps the name it always had: it is never shown, and a form opened // before an update was minted under it. if ( ! current_user_can( 'manage_options' ) || ! check_admin_referer( 'equalsites_sync' ) ) { wp_die( esc_html__( 'Not allowed.', 'ableguard-accessibility-toolkit' ) ); } $result = EqualSites_Api_Client::sync_rules(); set_transient( self::sync_notice_key(), is_wp_error( $result ) ? $result->get_error_message() : 'ok', MINUTE_IN_SECONDS ); wp_safe_redirect( admin_url( 'admin.php?page=ableguard' ) ); exit; } /** * The result of the last "Sync now" press is handed to the next page load in * a short-lived, per-user transient rather than in the address, so the screen * never prints text that arrived in a URL. */ private static function sync_notice_key() { return 'ableguard_sync_notice_' . get_current_user_id(); } public static function render_page() { // Read directly, not from the request's snapshot: this is a control path, and it shows // what pages apply (the delivery counts only while it belongs to the connection). $view = EqualSites_Connect_Store::view_direct(); $rules = $view['rules']; $last_sync = $view['last_sync']; $statement = $view['statement_html']; $enabled = (bool) ableguard_option( 'ableguard_enabled', 'equalsites_enabled', true ); $api_url = ableguard_api_origin( $view['api_url'] ); $refused = '' !== $view['api_url'] && '' === $api_url; $configured = '' !== $api_url && $view['has_connection']; $connected = $configured && $last_sync > 0; // The label is a masked address that any plugin could have written into the options table, // so it is checked again here, and printed escaped like everything else. $account = $view['has_connection'] && EqualSites_Connect::valid_account_label( $view['account'] ) ? $view['account'] : ''; $flow = EqualSites_Connect::take_notice(); $flow = null === $flow ? null : EqualSites_Connect::notice_view( $flow ); $synced = get_transient( self::sync_notice_key() ); if ( false !== $synced ) { delete_transient( self::sync_notice_key() ); } $synced = false === $synced ? '' : (string) $synced; ?>
' . esc_html( $account ) . '' ); ?>