| @@ -28,15 +28,15 @@ | ||
| 28 | 28 | * or the existing `ck_subscriber_id` cookie. |
| 29 | 29 | * |
| 30 | 30 | * @since 2.0.0 |
| 31 | 31 | * |
| 32 | - * @return WP_Error|bool|int|string Error | false | Subscriber ID | Signed Subscriber ID | |
| 32 | + * @return WP_Error|bool|int Error | false | Subscriber ID | |
| 33 | 33 | */ |
| 34 | 34 | public function get_subscriber_id() { |
| 35 | 35 | |
| 36 | 36 | // If the subscriber ID is in the request URI, use it. |
| 37 | 37 | if ( isset( $_REQUEST[ $this->key ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 38 | - return $this->validate_and_store_subscriber_id( sanitize_text_field( $_REQUEST[ $this->key ] ) ); // phpcs:ignore WordPress.Security.NonceVerification | |
| 38 | + return $this->validate_and_store_subscriber_id( absint( $_REQUEST[ $this->key ] ) ); // phpcs:ignore WordPress.Security.NonceVerification | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // If the subscriber ID is in a cookie, return it. |
| 42 | 42 | // For performance, we don't check that the subscriber ID exists every time, otherwise this would |
| @@ -55,10 +55,10 @@ | ||
| 55 | 55 | * the subscriber exists before storing their ID in a cookie. |
| 56 | 56 | * |
| 57 | 57 | * @since 2.0.0 |
| 58 | 58 | * |
| 59 | - * @param int|string $subscriber_id Possible Subscriber ID or Signed Subscriber ID. | |
| 60 | - * @return WP_Error|int|string Error | Confirmed Subscriber ID or Signed Subscriber ID | |
| 59 | + * @param int $subscriber_id Possible Subscriber ID. | |
| 60 | + * @return WP_Error|int Error | Confirmed Subscriber ID | |
| 61 | 61 | */ |
| 62 | 62 | public function validate_and_store_subscriber_id( $subscriber_id ) { |
| 63 | 63 | |
| 64 | 64 | // Bail if the API hasn't been configured. |
| @@ -88,9 +88,9 @@ | ||
| 88 | 88 | // Store the subscriber ID as a cookie. |
| 89 | 89 | $this->set( $subscriber['id'] ); |
| 90 | 90 | |
| 91 | 91 | // Return subscriber ID. |
| 92 | - return $subscriber['id']; | |
| 92 | + return absint( $subscriber['id'] ); | |
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
| @@ -99,9 +99,9 @@ | ||
| 99 | 99 | * |
| 100 | 100 | * @since 2.0.0 |
| 101 | 101 | * |
| 102 | 102 | * @param string $subscriber_email Possible Subscriber Email. |
| 103 | - * @return WP_Error|int|string Error | Confirmed Subscriber ID or Signed Subscriber ID | |
| 103 | + * @return WP_Error|int Error | Confirmed Subscriber ID | |
| 104 | 104 | */ |
| 105 | 105 | public function validate_and_store_subscriber_email( $subscriber_email ) { |
| 106 | 106 | |
| 107 | 107 | // Bail if the API hasn't been configured. |
| @@ -131,9 +131,9 @@ | ||
| 131 | 131 | // Store the subscriber ID as a cookie. |
| 132 | 132 | $this->set( $subscriber['id'] ); |
| 133 | 133 | |
| 134 | 134 | // Return subscriber ID. |
| 135 | - return $subscriber['id']; | |
| 135 | + return absint( $subscriber['id'] ); | |
| 136 | 136 | |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
| @@ -142,9 +142,9 @@ | ||
| 142 | 142 | * @since 2.0.0 |
| 143 | 143 | */ |
| 144 | 144 | private function get_subscriber_id_from_cookie() { |
| 145 | 145 | |
| 146 | - return $_COOKIE[ $this->key ]; | |
| 146 | + return absint( $_COOKIE[ $this->key ] ); | |
| 147 | 147 | |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| @@ -151,9 +151,9 @@ | ||
| 151 | 151 | * Stores the given subscriber ID in the `ck_subscriber_id` cookie. |
| 152 | 152 | * |
| 153 | 153 | * @since 2.0.0 |
| 154 | 154 | * |
| 155 | - * @param int|string $subscriber_id Subscriber ID. | |
| 155 | + * @param int $subscriber_id Subscriber ID. | |
| 156 | 156 | */ |
| 157 | 157 | public function set( $subscriber_id ) { |
| 158 | 158 | |
| 159 | 159 | setcookie( $this->key, (string) $subscriber_id, time() + ( 365 * DAY_IN_SECONDS ), '/' ); |