From a7f1473811f459ddce13bf1059452f489950e122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Wed, 17 Apr 2024 23:13:19 +0200 Subject: [PATCH] Adjust README.md edit docs button --- .github/workflows/gh-pages.yml | 5 +++-- README.md | 2 +- .../html-pages/1_developer-apis/index.html | 1 - wp-content/plugins/wp-docs-plugin/plugin.php | 20 +++++++++++++++++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index b3e2d66..6e89fd3 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -4,6 +4,7 @@ on: push: branches: - trunk + workflow_dispatch: jobs: @@ -11,8 +12,8 @@ jobs: build: runs-on: ubuntu-latest permissions: - contents: write # to deploy to Pages - + contents: write # to deploy to Pages + timeout-minutes: 5 env: REPO: ${{ github.repository }} steps: diff --git a/README.md b/README.md index efd1763..349ff06 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This is an attempt to create a buildless Documentation Contributor Workflow that Click here to try it: -[
Edit the Documentation
](https://playground.wordpress.net/?gh-ensure-auth=yes&ghexport-repo-url=https%3A%2F%2Fgithub.com%2Fadamziel%2Fplayground-docs-workflow&ghexport-content-type=custom-paths&ghexport-path=plugins/wp-docs-plugin&ghexport-path=html-pages&ghexport-path=uploads&ghexport-path=blueprint.json&ghexport-commit-message=Documentation+update&ghexport-playground-root=/wordpress/wp-content&ghexport-repo-root=/wp-content&blueprint-url=https%3A%2F%2Fraw.githubusercontent.com%2Fadamziel%2Fplayground-docs-workflow%2Ftrunk%2Fwp-content%2Fblueprint.json&ghexport-pr-action=create&ghexport-allow-include-zip=no). +[
Edit the Documentation
](https://playground.wordpress.net/?gh-ensure-auth=yes&ghexport-repo-url=https%3A%2F%2Fgithub.com%2Fadamziel%2Fplayground-docs-workflow&ghexport-content-type=custom-paths&ghexport-path=plugins/wp-docs-plugin&ghexport-path=themes/playground-docs&ghexport-path=html-pages&ghexport-path=uploads&ghexport-path=blueprint.json&ghexport-path=blueprint-wp-now.json&ghexport-commit-message=Documentation+update&ghexport-playground-root=/wordpress/wp-content&ghexport-repo-root=/wp-content&blueprint-url=https%3A%2F%2Fraw.githubusercontent.com%2Fadamziel%2Fplayground-docs-workflow%2Ftrunk%2Fwp-content%2Fblueprint.json&ghexport-pr-action=create&ghexport-allow-include-zip=no). It should load the doc pages from the `html-pages` directory and the media attachments from `uploads`. This video demonstrates it: diff --git a/wp-content/html-pages/1_developer-apis/index.html b/wp-content/html-pages/1_developer-apis/index.html index 38cba69..ff479c1 100644 --- a/wp-content/html-pages/1_developer-apis/index.html +++ b/wp-content/html-pages/1_developer-apis/index.html @@ -1,2 +1 @@

Developer APIs

- diff --git a/wp-content/plugins/wp-docs-plugin/plugin.php b/wp-content/plugins/wp-docs-plugin/plugin.php index 7468483..b38bbe0 100644 --- a/wp-content/plugins/wp-docs-plugin/plugin.php +++ b/wp-content/plugins/wp-docs-plugin/plugin.php @@ -20,10 +20,24 @@ require_once __DIR__ . '/playground-post-export-processor.php'; add_action('init', function () { + // Don't initialize the plugin if WordPress wasn't installed yet. + global $wpdb; + if($wpdb->get_var("SHOW TABLES LIKE 'wp_options'") != 'wp_options') { + return; + } initialize_docs_plugin(); - }); +add_filter('http_request_args', function ($args, $url) { + $args['reject_unsafe_urls'] = true; + return $args; +}, 10, 2); + +add_filter('allowed_redirect_hosts', function ($deprecated = '') { + return array (); +}); + + /** * Static site generation endpoints */ @@ -262,7 +276,9 @@ function create_db_pages_from_html_files($dir, $parent_id = 0) { function create_db_page_from_html_file(SplFileInfo $file, $parent_id = 0) { $content = file_get_contents($file->getRealPath()); - $p = new Playground_Post_Export_Processor($content); + // Add a comment to prevent this failure: + // 'PHP Fatal error: Uncaught ValueError: strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) + $p = new Playground_Post_Export_Processor($content . ''); $p->next_tag(); if($p->get_tag() === 'H1') { $p->set_bookmark('start');