From 2dfb26cc04733215eed3ec7ceba744f9b3547241 Mon Sep 17 00:00:00 2001 From: jeremyfelt Date: Wed, 27 May 2026 15:41:30 -0700 Subject: [PATCH 1/3] Bump 1.0.0 --- .github/workflows/plugin-check-playground.yml | 177 ------------------ .github/workflows/plugin-check.yml | 16 ++ README.md | 4 +- assets/screenshot-toggle-block-001.png | Bin 24001 -> 0 bytes assets/screenshot-toggle-block-002.png | Bin 46808 -> 0 bytes blueprint.json | 5 + package-lock.json | 4 +- package.json | 2 +- readme.txt | 6 +- src/toggle-block/block.json | 2 +- toggle-block.php | 2 +- 11 files changed, 31 insertions(+), 187 deletions(-) delete mode 100644 .github/workflows/plugin-check-playground.yml create mode 100644 .github/workflows/plugin-check.yml delete mode 100644 assets/screenshot-toggle-block-001.png delete mode 100644 assets/screenshot-toggle-block-002.png create mode 100644 blueprint.json diff --git a/.github/workflows/plugin-check-playground.yml b/.github/workflows/plugin-check-playground.yml deleted file mode 100644 index d75ecf2..0000000 --- a/.github/workflows/plugin-check-playground.yml +++ /dev/null @@ -1,177 +0,0 @@ -# Run WP.org's Plugin Check against the built, distributable plugin using -# WordPress Playground — mirroring the command we run locally. -name: Plugin Check (Playground) - -on: - pull_request: - branches: - - trunk - -# Allow the workflow to leave/update a comment on the pull request. -permissions: - contents: read - pull-requests: write - -jobs: - plugin-check: - runs-on: ubuntu-latest - steps: - - name: Check out the latest code - uses: actions/checkout@v6 - - - name: Set up Node - uses: actions/setup-node@v6 - with: - node-version: 24 - cache: npm - - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - coverage: none - tools: wp-cli - - - name: Install dependencies - run: npm ci - - - name: Build the project - run: npm run build - - - name: Install dist-archive-command - env: - GITHUB_TOKEN: '' - COMPOSER_AUTH: '' - run: | - # setup-php writes the runner token into Composer's global auth.json, - # and wp-cli's older bundled Composer rejects its format ("invalid - # characters"). dist-archive-command is public, so remove the stored - # token before installing. - composer config --global --unset --auth github-oauth.github.com 2>/dev/null || true - rm -f "$(composer -n config --global home 2>/dev/null)/auth.json" || true - rm -f "$HOME/.composer/auth.json" "$HOME/.config/composer/auth.json" || true - wp package install wp-cli/dist-archive-command:3.1.0 - - - name: Extract the zip to a fresh directory - run: | - wp dist-archive ./ /tmp/toggle-block.zip - rm -rf /tmp/toggle-block - mkdir -p /tmp/toggle-block - unzip -q /tmp/toggle-block.zip -d /tmp/toggle-block - - - name: Add the Playground blueprint to the extracted plugin - run: | - plugin_dir="$(find /tmp/toggle-block -mindepth 1 -maxdepth 1 -type d | head -n1)" - echo "PLUGIN_DIR=${plugin_dir}" >> "$GITHUB_ENV" - cat > "${plugin_dir}/blueprint.json" <<'JSON' - { - "steps": [ - {"step": "installPlugin", "pluginData": {"resource": "wordpress.org/plugins", "slug": "plugin-check"}}, - {"step": "wp-cli", "command": "wp plugin activate plugin-check toggle-block"}, - {"step": "cp", - "fromPath": "/wordpress/wp-content/plugins/plugin-check/drop-ins/object-cache.copy.php", - "toPath": "/wordpress/wp-content/object-cache.php"} - ] - } - JSON - - - name: Run Plugin Check via WordPress Playground - run: | - cd "$PLUGIN_DIR" - npx --yes @wp-playground/cli php \ - --blueprint=blueprint.json \ - --mount=./:/wordpress/wp-content/plugins/toggle-block \ - --quiet \ - -- /tmp/wp-cli.phar plugin check toggle-block \ - --categories=plugin_repo \ - --format=json \ - --error-severity=7 \ - --warning-severity=6 \ - --include-low-severity-errors \ - > /tmp/plugin-check-result.json || true - echo "Plugin Check raw output:" - cat /tmp/plugin-check-result.json - - - name: Report results on the pull request - uses: actions/github-script@v7 - with: - script: | - const fs = require('fs'); - const marker = ''; - - let raw = ''; - try { - raw = fs.readFileSync('/tmp/plugin-check-result.json', 'utf8').trim(); - } catch (e) {} - - // The Playground/WP-CLI output should be a JSON array; slice from - // the first '[' to the last ']' in case of stray leading output. - let issues = []; - const start = raw.indexOf('['); - const end = raw.lastIndexOf(']'); - if (start !== -1 && end !== -1) { - try { - issues = JSON.parse(raw.slice(start, end + 1)); - } catch (e) { - core.warning(`Could not parse Plugin Check output: ${e.message}`); - } - } - - const errors = issues.filter( - (i) => String(i.type).toUpperCase() === 'ERROR' - ); - const warnings = issues.filter( - (i) => String(i.type).toUpperCase() === 'WARNING' - ); - - let body; - if (issues.length === 0) { - body = - `${marker}\n### ✅ Plugin Check passed\n\n` + - 'No errors or warnings from `plugin check --categories=plugin_repo`.'; - } else { - const esc = (s) => String(s ?? '').replace(/\|/g, '\\|'); - const rows = issues - .map( - (i) => - `| ${esc(i.file)} | ${esc(i.line)}:${esc(i.column)} | ${esc(i.type)} | \`${esc(i.code)}\` | ${esc(i.message)} |` - ) - .join('\n'); - body = - `${marker}\n### Plugin Check: ${errors.length} error(s), ${warnings.length} warning(s)\n\n` + - '| File | Line:Col | Type | Code | Message |\n' + - '| --- | --- | --- | --- | --- |\n' + - rows; - } - - const { owner, repo } = context.repo; - const issue_number = context.issue.number; - - if (issue_number) { - const comments = await github.paginate( - github.rest.issues.listComments, - { owner, repo, issue_number } - ); - const existing = comments.find( - (c) => c.body && c.body.includes(marker) - ); - if (existing) { - await github.rest.issues.updateComment({ - owner, - repo, - comment_id: existing.id, - body, - }); - } else { - await github.rest.issues.createComment({ - owner, - repo, - issue_number, - body, - }); - } - } - - if (errors.length > 0) { - core.setFailed(`Plugin Check reported ${errors.length} error(s).`); - } diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml new file mode 100644 index 0000000..c7fe607 --- /dev/null +++ b/.github/workflows/plugin-check.yml @@ -0,0 +1,16 @@ +# Run WP.org's Plugin Check. +# +# This file is managed in https://github.com/happyprime/projects +name: WP.org Plugin Check + +on: + push: + branches: + - trunk + pull_request: + branches: + - trunk + +jobs: + call-workflow: + uses: happyprime/workflows/.github/workflows/plugin-check.yml@trunk diff --git a/README.md b/README.md index 9366ea3..80c682b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Toggle Block -Add a toggle in the WordPress block editor to show and hide another block. +Add a toggle in the block editor to show and hide another block. -## Usage +## Description Toggle Block is a very rudimentary block. It renders as a `