Skip to content

Commit

Permalink
Improved documentation about including WP when running PHP (#649)
Browse files Browse the repository at this point in the history
Add `require_once "/wordpress/wp-load.php";` to Blueprint examples in the documentation to clarify how to call WordPress functions.
  • Loading branch information
janw-me authored Oct 6, 2023
1 parent 1af59f2 commit 32f17e1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ You can connect to the Playground using the JavaScript client. Here's an example
});
const response = await client.run({
code: '<?php echo "Hi!"; ',
// wp-load.php is only required if you want to interact with WordPresss.
code: '<?php require_once "/wordpress/wp-load.php"; $posts = get_posts(); echo "Post Title: " . $posts[0]->post_title;',
});
console.log(response.text);
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ You can also use Blueprints with the JavaScript API using the `startPlaygroundWe
});
const response = await client.run({
code: '<?php echo "Hi!"; ',
// wp-load.php is only required if you want to interact with WordPresss.
code: '<?php require_once "/wordpress/wp-load.php"; $posts = get_posts(); echo "Post Title: " . $posts[0]->post_title;',
});
console.log(response.text);
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { fileToUint8Array } from './common';
* <code>
* {
* "step": "runPHP",
* "code": "<?php echo 'Hello World'; ?>"
* "code": "<?php require_once 'wordpress/wp-load.php'; wp_insert_post(array('post_title' => 'wp-load.php required for WP functionality', 'post_status' => 'publish')); ?>"
* }
* </code>
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/playground/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const client = await startPlaygroundWeb({
});

const response = await client.run({
code: '<?php echo "Hi!"; ',
// wp-load.php is only required if you want to interact with WordPresss.
code: '<?php require_once "/wordpress/wp-load.php"; $posts = get_posts(); echo "Post Title: " . $posts[0]->post_title;',
});
console.log(response.text);
```
Expand Down

0 comments on commit 32f17e1

Please sign in to comment.