Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WordPress Playground plugin #154

Merged
merged 57 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
301f3d4
Moving plugin to playground-tools
seanmorris Nov 16, 2023
4e0ad0e
Removing submodule, adding actual files.
seanmorris Nov 16, 2023
c98995c
Removing extra files.
seanmorris Nov 16, 2023
1804c37
PR comments.
seanmorris Nov 22, 2023
76165e4
README.
seanmorris Nov 22, 2023
c824a6a
Merge branch 'trunk' into sm-collector-plugin
seanmorris Nov 22, 2023
72537ca
PR comments.
seanmorris Nov 22, 2023
2f309c2
PR Comments.
seanmorris Nov 27, 2023
5783245
Using WPDB.
seanmorris Nov 29, 2023
e449927
Tweak.
seanmorris Dec 6, 2023
a6574d0
Tweaks.
seanmorris Dec 6, 2023
77a9338
previews.
seanmorris Dec 11, 2023
13f3f38
Fixing plugin activation bug
seanmorris Dec 11, 2023
a0377ca
Comment
seanmorris Dec 11, 2023
c8e6a99
Tweaks.
seanmorris Dec 11, 2023
097ee8e
Escaping backticks.
seanmorris Dec 17, 2023
6133433
Translations and admin urls
bgrgicak Jan 26, 2024
b0fda05
Translations and capabilities
bgrgicak Jan 26, 2024
4b5d6f1
Add development instructions to readme
bgrgicak Feb 1, 2024
c3ac35e
Fix login
bgrgicak Feb 1, 2024
1ee4c4e
Use WP escaping
bgrgicak Feb 1, 2024
ec5b367
Skip collecting all hidden files
bgrgicak Feb 1, 2024
8786c66
Build sqldump in memory
bgrgicak Feb 1, 2024
d5aeac0
Add missing r
bgrgicak Feb 1, 2024
c73e652
Replace php://memory with a variable
bgrgicak Feb 2, 2024
964f80d
Add Composer and ZipStream-PHP
bgrgicak Feb 2, 2024
22b6cd4
Replace ZipArchive with ZipStream
bgrgicak Feb 2, 2024
6be086a
Fix font size
bgrgicak Feb 2, 2024
a4a0800
Update packages/collector/Collector.php
bgrgicak Feb 2, 2024
daa8733
Address feedback
bgrgicak Feb 2, 2024
7168a87
Clean up
bgrgicak Feb 2, 2024
6958de3
Apply WordPress standards and restructure
bgrgicak Feb 5, 2024
d4cb48d
Add playground url filters
bgrgicak Feb 5, 2024
a1464c9
Use RecursiveDirectoryIterator
bgrgicak Feb 5, 2024
9680963
Remove unused changes
bgrgicak Feb 5, 2024
8adf171
Refactor download link
bgrgicak Feb 5, 2024
db8c89d
Cleanup db exporter
bgrgicak Feb 5, 2024
d62a634
Correctly escape and prepare INSERT data
bgrgicak Feb 6, 2024
43a1f25
Fix plugin activation
bgrgicak Feb 6, 2024
ae902c2
Update composer dependencies
bgrgicak Feb 6, 2024
d4ba3d2
Rename plugin to Playground
bgrgicak Feb 6, 2024
024d37d
Add Start Playground feature
bgrgicak Feb 6, 2024
fc596e4
DB table order
bgrgicak Feb 6, 2024
20d9fb1
Prevent playground from loading on download page
bgrgicak Feb 6, 2024
d7c2a0c
Rename menu button
bgrgicak Feb 6, 2024
2942c73
Add braces to if
bgrgicak Feb 6, 2024
e0cb7c5
More feedback
bgrgicak Feb 6, 2024
ee10c8f
Update schema regex to strip new lines
bgrgicak Feb 6, 2024
1a6d999
Remove collector folder
bgrgicak Feb 6, 2024
c02934d
Replace esc_sql and add hidden file todo
bgrgicak Feb 6, 2024
71bf839
Add namespace and comments
bgrgicak Feb 6, 2024
1eb00ee
Use quote_identifier for column names
bgrgicak Feb 7, 2024
dd36deb
Remove columns from insert
bgrgicak Feb 7, 2024
95c1126
Use playgroundRemoteUrl variable
bgrgicak Feb 7, 2024
1faf0c5
Fetch blueprints in backend to avoid cors issues
bgrgicak Feb 7, 2024
3bdd04a
Remove blueprint fetching
bgrgicak Feb 7, 2024
3219dea
Escape new lines in insert values
bgrgicak Feb 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/playground/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*]
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
339 changes: 339 additions & 0 deletions packages/playground/LICENSE

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions packages/playground/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
WordPress Playground
Copyright 2023 "The Contributors"

Licensed under the GNU GENERAL PUBLIC LICENSE, Version 2.0, June 1991
(the "License"); you may not use this file except in compliance with
the License.

You may obtain a copy of the License at:

https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
13 changes: 13 additions & 0 deletions packages/playground/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# WordPress Playground

_v0.0.0_

A WordPress plugin for collecting the content of a site and spinning up WordPress Playground with a copy of the site content.

The current version of the plugin allows you to preview a plugin installation from the WordPress.org repository in a WordPress Playground instance.

## Testing

- Install and activate the plugin in your WordPress install
- On your site open the _Add Plugins_ page and click the _Preview Now_ button
- Click on _Sandbox Site_ in the _Tools_ menu to load the WordPress Playground with the plugin installed
68 changes: 68 additions & 0 deletions packages/playground/assets/css/playground.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.tools_page_playground #wpbody-content,
.tools_page_playground #wpcontent {
padding-left: 0px !important;
}

.tools_page_playground #wpwrap,
.tools_page_playground #wpbody,
.tools_page_playground #wpbody-content {
padding-bottom: 0px;
height: 100%;
}

.tools_page_playground #wpwrap,
.tools_page_playground #wpbody {
position: initial;
}

#wp-playground-toolbar {
background-color: #eaaa00;
font-weight: bold;
text-align: center;
font-size: 1rem;
padding: 0.75em;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
position: relative;
z-index: 1999999;
animation: playground-fade-in 0.25s 0.65s
cubic-bezier(0.175, 0.885, 0.5, 1.85) 1 forwards;
transform: translateY(-100%);
}

#wp-playground-toolbar > a {
text-transform: capitalize;
padding: 0 0.5rem;
}

#wp-playground-main-area {
position: relative;
display: flex;
flex: 1;
}

#wp-playground,
#wp-playground-wrapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 999999;
background-color: #fff;
display: flex;
flex-direction: column;
}

@keyframes playground-fade-in {
from {
transform: translateY(-100%);
}

to {
transform: translateY(0);
}
}
61 changes: 61 additions & 0 deletions packages/playground/assets/js/playground.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
(async () => {
const { startPlaygroundWeb } = await import(
playground.playgroundPackageUrl
);
const blueprint = {
features: {
networking: true,
},
preferredVersions: {
wp: playground.wpVersion,
php: playground.phpVersion,
},
steps: [
{
step: 'unzip',
zipFile: {
resource: 'url',
url: playground.zipUrl,
},
extractToPath: '/wordpress',
},
{
step: 'runSql',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely! I'd like Playground to do that automatically eventually, but today of course let's stick to an explicit step.

sql: {
resource: 'vfs',
path: '/wordpress/schema/_Schema.sql',
},
},
{
step: 'login',
},
],
};

if (playground.pluginSlug) {
blueprint.steps.push({
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org/plugins",
"slug": playground.pluginSlug
},
"options": {
"activate": true
}
});
}

const client = await startPlaygroundWeb({
iframe: document.getElementById('wp-playground'),
remoteUrl: playground.playgroundRemoteUrl,
blueprint,
});

await client.isReady();

if ( playground.pluginSlug ) {
client.goTo('/wp-admin/plugins.php');
} else {
client.goTo('/wp-admin');
}
})();
7 changes: 7 additions & 0 deletions packages/playground/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "wordpress/playground",
"description": "A WordPress plugin for collecting the content of a site and spinning up WordPress Playground with a copy of the site content.",
"require": {
"maennchen/zipstream-php": "^2.2"
}
}
Loading
Loading