Skip to content

Commit 78d47bf

Browse files
committed
feat: wordpress instance management
1 parent 50a87a7 commit 78d47bf

18 files changed

+397
-58
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
# https://github.com/actions/setup-python
2626
uses: actions/setup-python@v5
2727
with:
28-
python-version: 3.8
28+
python-version: 3.9
2929
cache: "pip"
3030
- name: Upgrade pip and setuptools
3131
# https://pypi.org/project/pip/

.github/workflows/test.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: ['3.8', '3.12']
12+
python-version: ['3.7', '3.12']
1313
steps:
1414
- uses: actions/checkout@v4
1515
- name: Set up Python ${{ matrix.python-version }}
@@ -20,6 +20,15 @@ jobs:
2020
run: python -m pip install --upgrade pip
2121
- name: Install dependencies
2222
run: |
23-
pip install .[dev]
23+
if [ "${{ matrix.python-version }}" = "3.7" ]; then
24+
pip install "tutor==15.0.0"
25+
else
26+
pip install -U tutor
27+
fi
28+
echo "Installing tutor-contrib-wordpress"
29+
pip install -e .[dev]
30+
echo "Enable wordpress plugin and save configuration"
31+
tutor plugins enable wordpress
32+
tutor config save
2433
- name: Test lint, types, and format
2534
run: make test

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11

2+
<a id='changelog-1.1.0'></a>
3+
## v1.1.0 (2024-11-27)
4+
5+
- [Feature] Added comprehensive WordPress integration for Open edX including:
6+
- Full WordPress installation and configuration management
7+
- Integration with Open edX Commerce WordPress Plugin and WooCommerce
8+
- Configurable WordPress settings including version, host, ports, and database options
9+
(by @CodeWithEmad)
10+
211
<a id='changelog-1.0.1'></a>
312
## v1.0.1 (2024-07-27)
413

README.rst

Lines changed: 65 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,23 @@ WordPress Plugin for `Tutor`_
1010
:target: https://www.gnu.org/licenses/agpl-3.0.en.html
1111

1212
Overview
13-
--------
13+
********
1414

15-
This is a `Tutor`_ plugin for integrating the `Open edX Commerce WordPress Plugin`_ with your Open edX instance.
16-
The plugin allows seamless synchronization and interaction between your WordPress site and Open edX platform,
17-
providing a cohesive e-commerce experience. If you don't know how to install the WordPress plugin, check out
18-
this `installation guide`_.
15+
This is a `Tutor`_ plugin that provides complete WordPress integration with your Open edX instance. It includes:
1916

20-
Before you start
21-
----------------
17+
- Full WordPress installation and management
18+
- Integration with the `Open edX Commerce WordPress Plugin`_
2219

23-
This plugin does **not** create or manage a WordPress instance at the moment. It is designed to assist with the
24-
configuration and integration of the Open edX platform with an existing WordPress site. If you need this feature,
25-
feel free to open an issue or better yet, a PR.
20+
If you need help installing the WordPress plugin, check out this `installation guide`_.
2621

2722
Prerequisites
28-
-------------
23+
*************
2924

30-
- A running WordPress site with the `Open edX Commerce WordPress Plugin`_ installed.
31-
- Installation of Tutor version >= 15.0.0.
25+
- Installation of Tutor version >= 15.0.0
26+
- MySQL database (can use the same one as Open edX)
3227

3328
Installation
34-
------------
29+
************
3530

3631
Ensure you are using Tutor v15+ (Olive onwards). First, install the plugin by running:
3732

@@ -51,59 +46,96 @@ Alternatively, if you already have a running Open edX instance, just run the nec
5146
.. code-block:: bash
5247
5348
tutor dev|local|k8s do init --limit=wordpress
49+
tutor dev|local|k8s start wordpress
5450
5551
Configuration
56-
-------------
52+
*************
5753

58-
Inside your WordPress admin panel, you will need to configure the following values:
54+
The plugin automatically installs WordPress with the Open edX Commerce and Woocommerce plugins. Inside your WordPress
55+
admin panel, go to Settings -> Open edX Sync plugin, and configure:
5956

6057
- **Open edX Domain**
6158
- **Client ID**
6259
- **Client Secret**
6360

61+
To verify the connection, click on "Generate JWT Token". If the process is successful, a new token will be generated.
62+
6463
.. image:: https://raw.githubusercontent.com/codewithemad/tutor-contrib-wordpress/master/images/openedx-sync-plugin-settings.png
6564
:alt: Open edX Sync Plugin Settings in your WordPress Settings
6665

67-
6866
You can retrieve these configuration values by running:
6967

7068
.. code-block:: bash
7169
72-
tutor wordpress config
70+
tutor dev|local|k8s do wordpress config
7371
72+
This command will output the current configurations, including the Client ID, Client Secret, Open edX Domain,
73+
and WordPress Domain. Here is an example of the output:
7474

7575
.. code-block:: text
7676
7777
===============================================
78-
WordPress Plugin Configurations
78+
WordPress Plugin Configurations
7979
===============================================
8080
81-
Open edX Domain: http://local.edly.io
82-
Client ID: qjCayDktffXrU09N17NrslKyWQ2EwzWn
83-
Client ID (dev): JDx6Uy0hN67VUfacxKcLyYQz7HK9liVx
84-
Client Secret: P4w82huaZQdyz4qolknsIHYneGEoIggc
81+
Client ID: vvpTamiepPwjZhr0uOQGr5PhYBzp2hQw
82+
Client ID (dev): MlbXk1V3wB7nWPAAyLF3McyfBBMqExa4
83+
Client Secret: MdrgbtU8Q94He3gejF6Zf5MDookoeozO
8584
85+
Open edX Domain: http://local.edly.io:8000
86+
Wordpress Domain: http://site.local.edly.io:8080
8687
87-
Or by using Tutor to print them individually:
88+
Variables
89+
*********
8890

89-
.. code-block:: bash
91+
The plugin supports the following configuration variables:
92+
93+
- ``WORDPRESS_VERSION``: Plugin version
94+
- ``WORDPRESS_HOST``: WordPress site hostname
95+
- ``WORDPRESS_PORT``: WordPress port (default: 8080)
96+
- ``WORDPRESS_DEBUG``: Enable WordPress debug mode (default: false)
97+
- ``WORDPRESS_DOCKER_IMAGE``: Docker image for WordPress
98+
- ``WORDPRESS_OPENEDX_PLUGIN``: URL to the Open edX Commerce plugin
99+
- ``WORDPRESS_WOOCOMMERCE_PLUGIN``: (default: "https://downloads.wordpress.org/plugin/woocommerce.9.4.2.zip")
100+
The WooCommerce plugin zip file URL. You can specify a different version if needed.
101+
- ``WORDPRESS_OFFICIAL_IMAGE``: (default: "wordpress:6.7.1-php8.1")
102+
The official WordPress Docker image used as the base for building the plugin's custom image.
103+
This image includes PHP and Apache server. You can specify a different version or PHP variant
104+
if needed.
105+
106+
Database Settings
107+
=================
108+
109+
- ``WORDPRESS_MYSQL_HOST``: MySQL host
110+
- ``WORDPRESS_MYSQL_PORT``: MySQL port
111+
- ``WORDPRESS_MYSQL_DATABASE``: Database name (default: wordpress)
112+
- ``WORDPRESS_MYSQL_USERNAME``: Database username
113+
- ``WORDPRESS_MYSQL_PASSWORD``: Database password (auto-generated)
114+
- ``WORDPRESS_TABLE_PREFIX``: Table prefix (default: wp_)
90115

91-
tutor config printvalue LMS_HOST
92-
tutor config printvalue WORDPRESS_OAUTH2_SECRET
93-
tutor config printvalue WORDPRESS_OAUTH2_KEY_SSO
94-
tutor config printvalue WORDPRESS_OAUTH2_KEY_SSO_DEV
116+
Storage Settings
117+
================
118+
119+
- ``WORDPRESS_DATA_VOLUME_SIZE``: Size of WordPress persistent volume (default: 5Gi)
120+
121+
OAuth2 Settings
122+
===============
123+
124+
- ``WORDPRESS_OAUTH2_SECRET``: OAuth2 secret key (auto-generated)
125+
- ``WORDPRESS_OAUTH2_KEY_SSO``: OAuth2 client ID (auto-generated)
126+
- ``WORDPRESS_OAUTH2_KEY_SSO_DEV``: OAuth2 development client ID (auto-generated)
95127

96128
Contributing
97-
------------
129+
************
98130

99-
We welcome all contributions! Feel free to open a Pull Request.
131+
We welcome all contributions! Feel free to open a Pull Request or an Issue.
100132

101133
License
102-
-------
134+
*******
103135

104136
This software is licensed under the terms of the `AGPLv3`_.
105137

106138
.. _Tutor: https://docs.tutor.edly.io
107-
.. _installation guide: https://docs.openedx.org/projects/wordpress-ecommerce-plugin/en/latest/plugin_quickstart.html
108139
.. _Open edX Commerce WordPress Plugin: https://github.com/openedx/openedx-wordpress-ecommerce
109140
.. _AGPLv3: https://github.com/codewithemad/tutor-contrib-wordpress/blob/master/LICENSE.txt
141+
.. _installation guide: https://docs.openedx.org/projects/wordpress-ecommerce-plugin/en/latest/plugin_quickstart.html
736 Bytes
Loading

setup.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,29 @@ def load_about():
3636
license="AGPLv3",
3737
author="Emad Rad",
3838
author_email="[email protected]",
39-
description="Tutor plugin for WooCommerce",
39+
description="Tutor plugin for WordPress.",
4040
long_description=load_readme(),
4141
long_description_content_type="text/x-rst",
4242
packages=find_packages(exclude=["tests*"]),
4343
include_package_data=True,
44-
python_requires=">=3.8",
45-
install_requires=["tutor>=14.0.0,<19.0.0"],
44+
python_requires=">=3.7",
45+
install_requires=[
46+
"tutor>=15.0.0,<19.0.0",
47+
"importlib_resources", # for older versions of tutor
48+
],
4649
extras_require={
4750
"dev": [
48-
"tutor[dev]>=14.0.0,<19.0.0",
49-
]
50-
},
51-
entry_points={
52-
"tutor.plugin.v1": [
53-
"wordpress = tutorwordpress.plugin"
51+
"tutor[dev]>=15.0.0,<19.0.0",
5452
]
5553
},
54+
entry_points={"tutor.plugin.v1": ["wordpress = tutorwordpress.plugin"]},
5655
classifiers=[
5756
"Development Status :: 3 - Alpha",
5857
"Intended Audience :: Developers",
5958
"License :: OSI Approved :: GNU Affero General Public License v3",
6059
"Operating System :: OS Independent",
6160
"Programming Language :: Python",
61+
"Programming Language :: Python :: 3.7",
6262
"Programming Language :: Python :: 3.8",
6363
"Programming Language :: Python :: 3.9",
6464
"Programming Language :: Python :: 3.10",

tutorwordpress/patches/caddyfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# WordPress
2+
{{ WORDPRESS_HOST }}{$default_site_port} {
3+
4+
import proxy "wordpress:{{ WORDPRESS_PORT }}"
5+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: wordpress
6+
labels:
7+
app.kubernetes.io/name: wordpress
8+
spec:
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: wordpress
12+
template:
13+
metadata:
14+
labels:
15+
app.kubernetes.io/name: wordpress
16+
spec:
17+
initContainers:
18+
- name: init-wordpress
19+
image: {{ WORDPRESS_DOCKER_IMAGE }}
20+
command: ['sh', '-c', 'chown -R www-data:www-data /var/www/html/wp-content']
21+
volumeMounts:
22+
- name: wordpress-data
23+
mountPath: /var/www/html/wp-content
24+
securityContext:
25+
runAsUser: 0
26+
containers:
27+
- name: wordpress
28+
image: {{ WORDPRESS_DOCKER_IMAGE }}
29+
ports:
30+
- containerPort: 8080
31+
env:
32+
- name: WORDPRESS_DB_HOST
33+
value: {{ WORDPRESS_MYSQL_HOST }}
34+
- name: WORDPRESS_DB_USER
35+
value: {{ WORDPRESS_MYSQL_USERNAME }}
36+
- name: WORDPRESS_DB_PASSWORD
37+
value: {{ WORDPRESS_MYSQL_PASSWORD }}
38+
- name: WORDPRESS_DB_NAME
39+
value: {{ WORDPRESS_MYSQL_DATABASE }}
40+
- name: WORDPRESS_TABLE_PREFIX
41+
value: {{ WORDPRESS_TABLE_PREFIX }}
42+
volumeMounts:
43+
- name: wordpress-data
44+
mountPath: /var/www/html/wp-content
45+
securityContext:
46+
runAsUser: 33
47+
runAsGroup: 33
48+
volumes:
49+
- name: wordpress-data
50+
persistentVolumeClaim:
51+
claimName: wordpress-data

tutorwordpress/patches/k8s-jobs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: wordpress-job
6+
labels:
7+
app.kubernetes.io/component: job
8+
spec:
9+
template:
10+
spec:
11+
restartPolicy: Never
12+
containers:
13+
- name: wordpress
14+
image: {{ WORDPRESS_DOCKER_IMAGE }}
15+
volumeMounts:
16+
- name: wordpress-data
17+
mountPath: /var/www/html/wp-content
18+
volumes:
19+
- name: wordpress-data
20+
persistentVolumeClaim:
21+
claimName: wordpress-data
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: wordpress
6+
spec:
7+
type: ClusterIP
8+
ports:
9+
- port: {{ WORDPRESS_PORT }}
10+
targetPort: 8080
11+
protocol: TCP
12+
selector:
13+
app.kubernetes.io/name: wordpress

0 commit comments

Comments
 (0)