array( 'label' => __( 'I no longer need the plugin', 'cookie-rocket' ) ), 'found_better' => array( 'label' => __( 'I found a better plugin', 'cookie-rocket' ), 'placeholder' => __( 'Which one? (optional)', 'cookie-rocket' ), ), 'not_working' => array( 'label' => __( 'I couldn’t get the plugin to work', 'cookie-rocket' ), 'placeholder' => __( 'What went wrong? (optional)', 'cookie-rocket' ), ), 'broke_site' => array( 'label' => __( 'It broke my site or my layout', 'cookie-rocket' ), 'placeholder' => __( 'What broke? (optional)', 'cookie-rocket' ), ), 'missing_feature' => array( 'label' => __( 'It’s missing a feature I need', 'cookie-rocket' ), 'placeholder' => __( 'Which feature? (optional)', 'cookie-rocket' ), ), 'temporary' => array( 'label' => __( 'It’s a temporary deactivation', 'cookie-rocket' ) ), 'other' => array( 'label' => __( 'Other', 'cookie-rocket' ), 'placeholder' => __( 'Please tell us more (optional)', 'cookie-rocket' ), ), ); } public function enqueue( string $hook ): void { if ( 'plugins.php' !== $hook ) { return; } wp_enqueue_style( 'cookroco-deactivate', COOKROCO_PLUGIN_URL . 'admin/assets/deactivate.css', array(), COOKROCO_VERSION ); wp_enqueue_script( 'cookroco-deactivate', COOKROCO_PLUGIN_URL . 'admin/assets/deactivate.js', array(), COOKROCO_VERSION, true ); wp_localize_script( 'cookroco-deactivate', 'CookieRocketDeact', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'cookroco_deactivate' ), 'plugin' => plugin_basename( COOKROCO_PLUGIN_FILE ), 'pluginEnc' => rawurlencode( plugin_basename( COOKROCO_PLUGIN_FILE ) ), 'msgDefault' => __( 'Anything else we should know? (optional)', 'cookie-rocket' ), 'sending' => __( 'Sending…', 'cookie-rocket' ), ) ); } public function render_modal(): void { $reasons = $this->reasons(); ?>
reasons() ) ) { wp_send_json_error(); } $message = isset( $_POST['message'] ) ? sanitize_textarea_field( wp_unslash( $_POST['message'] ) ) : ''; // Opt-in relay. Non-blocking so the UI is never delayed; delivery does not gate deactivation. wp_remote_post( self::ENDPOINT, array( 'timeout' => 4, 'blocking' => false, 'headers' => array( 'Accept' => 'application/json' ), // WordPress's default user agent carries the site's address; the readme promises it is not sent. 'user-agent' => 'Cookie Rocket/' . COOKROCO_VERSION, 'body' => array( 'plugin' => 'cookie-rocket', 'reason' => $reason, 'message' => mb_substr( $message, 0, 2000 ), 'version' => COOKROCO_VERSION, 'wp' => get_bloginfo( 'version' ), 'php' => PHP_VERSION, 'locale' => get_locale(), ), ) ); wp_send_json_success(); } }