id : ''; $allowed = (strpos($id, 'allaccessible') !== false) || in_array($id, array('plugins', 'dashboard'), true); if (!$allowed) return false; return true; } public static function maybe_render() { if (!self::should_show()) return; $nonce = wp_create_nonce(self::AJAX_ACTION); $ajax = admin_url('admin-ajax.php'); ?>

'forbidden'), 403); } check_ajax_referer(self::AJAX_ACTION); $act = isset($_POST['nudge_act']) ? sanitize_key($_POST['nudge_act']) : ''; $state = (array) get_option(self::OPTION, array()); switch ($act) { case 'sentiment': // Record sentiment for analytics; don't mark done yet — // the user still has a step-2 action to take. $state['sentiment'] = sanitize_key($_POST['sentiment'] ?? ''); $state['sentiment_at'] = time(); break; case 'review': // clicked the wp.org review link case 'done': // "I already did" $state['done'] = true; break; case 'feedback': $state['done'] = true; $comment = isset($_POST['comment']) ? sanitize_textarea_field($_POST['comment']) : ''; self::relay_feedback($comment); break; case 'snooze': $state['snooze_until'] = time() + self::SNOOZE_DAYS * DAY_IN_SECONDS; break; default: wp_send_json_error(array('message' => 'unknown action'), 400); } update_option(self::OPTION, $state, false); wp_send_json_success(array('act' => $act)); } /** * Relay review-nudge feedback to the existing AllAccessible feedback * endpoint — same one DeactivationSurvey uses, same form shape */ private static function relay_feedback(string $comment) { if ($comment === '') return; if (!function_exists('wp_remote_post')) return; $plugin_data = wp_json_encode(array( 'version' => defined('AACB_VERSION') ? AACB_VERSION : 'unknown', 'url' => get_bloginfo('url'), )); wp_remote_post('https://app.allaccessible.org/api/wp-feedback', array( 'body' => array( 'type' => 'review_nudge', 'reason' => 'could_be_better', 'plugin' => $plugin_data, 'comment-could_be_better' => $comment, ), 'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'), 'timeout' => 5, 'blocking' => false, )); } }