From 83b7bda1e37c83766de236d150583fd7d4e6a121 Mon Sep 17 00:00:00 2001 From: Paulo Pinto Date: Mon, 12 Sep 2022 15:22:17 +0100 Subject: [PATCH 1/3] Run phpcs on PRs --- .github/workflows/pull-request.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..e567581 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,18 @@ +name: PR checks + +on: + pull_request: + types: [ opened, synchronize ] + +jobs: + lint-plugin: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install composer dependencies + run: composer install + + - name: Run phpcs + run: ./vendor/bin/phpcs From 92cccf4c8ca2d9bb99bc1beb4a048fbd5a4f3b77 Mon Sep 17 00:00:00 2001 From: Paulo Pinto Date: Mon, 12 Sep 2022 16:28:32 +0100 Subject: [PATCH 2/3] Disable nonce checks --- src/Http/Handlers/AuthorizeHandler.php | 2 ++ src/Storage/UserClaimsStorage.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Http/Handlers/AuthorizeHandler.php b/src/Http/Handlers/AuthorizeHandler.php index fd23b5b..473db07 100644 --- a/src/Http/Handlers/AuthorizeHandler.php +++ b/src/Http/Handlers/AuthorizeHandler.php @@ -1,5 +1,7 @@ Date: Mon, 12 Sep 2022 16:28:38 +0100 Subject: [PATCH 3/3] Make phpcs happy --- src/Http/Router.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Http/Router.php b/src/Http/Router.php index 6c5eccd..1667ec3 100644 --- a/src/Http/Router.php +++ b/src/Http/Router.php @@ -56,14 +56,14 @@ function () use ( $route, $methods ) { ); } - private function get_current_route() { + private function get_current_route(): string { $wp_url = get_site_url(); - $installed_dir = parse_url( $wp_url, PHP_URL_PATH ); + $installed_dir = wp_parse_url( $wp_url, PHP_URL_PATH ); - // requested uri relative to WP install - $request_uri = str_replace( $installed_dir, '', $_SERVER['REQUEST_URI'] ); + // Requested URI relative to WP install. + $uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; + $uri = str_replace( $installed_dir, '', $uri ); - $uri = sanitize_text_field( wp_unslash( $request_uri ) ); $route = strtok( $uri, '?' ); return trim( $route, '/' );