diff --git a/.forgejo/workflows/package.yml b/.forgejo/workflows/package.yml new file mode 100644 index 0000000..f6325b8 --- /dev/null +++ b/.forgejo/workflows/package.yml @@ -0,0 +1,94 @@ +# Building and releasing Wordpress plugins is pretty simple +# It's just zipping up some PHP. This doesn't contain any unit tests +# this is just zipping and shipping. +# +# Generally speaking your directory structure would be: +# . +# ├── README.md +# └── src +# └── wordpress-plugin.php +# +# With the repository name being the name of your plugin to make it easier +# to Google for. Up to you though; you can configure the source dir below. +# +# When you tag a commit and the tag stats with 'v', this workflow will +# zip and ship the Wordpress plugin to the 'releases' tab of Github or Forgejo + +name: Build & Release WordPress Plugin + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: docker + container: debian:12 + + env: + SOURCE_DIR: "src" + + + steps: + + - name: Prepare Build Environment + run: | + apt update && apt -y install zip unzip nodejs curl jq + + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Package plugin + run: | + # Set plugin name like this because it's easier than inline + PLUGIN_NAME=$(echo $GITHUB_REPOSITORY | awk -F'/' '{ print $2 }') + + # Create a build directory to ensure that we're correctly creating + # a single child directory in the zip. + mkdir -p build + cp -r ${SOURCE_DIR} "build/${PLUGIN_NAME}" + + # Zip it up for shipping + cd build + zip -r "../${PLUGIN_NAME}.zip" "${PLUGIN_NAME}" + cd - + unzip -l "${PLUGIN_NAME}.zip" + + - name: Create Release if not exists + run: | + # Curl request that uses the repos token & Forgejo's built-in variables + # to create a new release based on the tag that you have pushed + # + # It doesn't care if the release exists or not. + curl -X POST "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases" \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d '{ + "tag_name": "'"${GITHUB_REF##*/}"'", + "target_commitish": "main", + "name": "'"${GITHUB_REF##*/}"'", + "body": "Auto release", + "draft": false, + "prerelease": false + }' || true + + - name: Upload Plugin Zip to Release + run: | + # Set some variables because it's cleaner than in-line + TAG_NAME="${GITHUB_REF##*/}" + REPO_NAME="$(basename $GITHUB_REPOSITORY)" + PLUGIN_NAME=$(echo $GITHUB_REPOSITORY | awk -F'/' '{ print $2 }') + + # Get the release ID created in the last step + RELEASE_ID=$(curl -s \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG_NAME}" \ + | jq -r '.id') + + # Pushes he zip file to be shown in the "Releases" tab under this release. + curl -X POST "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets" \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -F "name=${PLUGIN_NAME}.zip" \ + -F "attachment=@${PLUGIN_NAME}.zip" + diff --git a/README.md b/README.md index 7fe8746..8c28be6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,42 @@ -# fwp-recaptcha +# fwp-calendar -Provides basic Google Recaptcha protections for your Wordpress blog. \ No newline at end of file +Originally created for a customer, I imagine that this would help some people +wanting to avoid Wordpresses increasing "pay to use" direction. + +Accepts a list of iCal URLs (without auth) and publishes to a page. + +Almost entirely generated with ChatGPT. I lay no claim that I have manually +written this entire thing myself. I just need something working and fast. + +## MVP + +The MVP has very basic functionality. We leverage two external libraries however +have included them within the plugin: + +1. [FullCalendar](https://github.com/fullcalendar/fullcalendar) +2. [ics-parser](https://github.com/u01jmg3/ics-parser) + +We pull from a public iCal/ICS URL via the server. We then process and display +this information when a shortcode (`[event-calendar]`) is called. + +We store a list/array of URLs to pull from, so you should be able to add a +couple. + +## Usage + +Just install then look in "Settings" for the "FWP Calendar" section. + +You can add a simple list of ICS/iCal URLs there however they must be publicly +accessible. I tested and it works with Google calendars. + +I created this for a customer who had a list of upcoming events displayed on +their website. They were manually updating the events calendar entirely through +Wordpress, which seemed clunky. + +This plugin allows you to maintain a community events calendar from within your +Orgs typical public calendar. Visitors can see events spread out on a calendar +and upcoming events below. + +This is good because you can provide the calendar for people to add to their +phones or import into their own calendars. Your options are endless when you +don't use shitty proprietary standards! diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..ffa0e54 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,34 @@ +services: + db: + image: mysql:8.0 + container_name: wp_test_db + restart: unless-stopped + environment: + MYSQL_ROOT_PASSWORD: rootpassword + MYSQL_DATABASE: wordpress + MYSQL_USER: wordpress + MYSQL_PASSWORD: wordpress + volumes: + - db_data:/var/lib/mysql + + wordpress: + image: wordpress:latest + container_name: wp_test_app + depends_on: + - db + ports: + - "8080:80" + restart: unless-stopped + environment: + WORDPRESS_DB_HOST: db:3306 + WORDPRESS_DB_USER: wordpress + WORDPRESS_DB_PASSWORD: wordpress + WORDPRESS_DB_NAME: wordpress + WORDPRESS_DEBUG: 'true' + WORDPRESS_DEBUG_LOG: 'true' + WORDPRESS_DEBUG_DISPLAY: 'false' + volumes: + - ./src:/var/www/html/wp-content/plugins/fwp-recaptcha +volumes: + db_data: + diff --git a/src/funcs/settings.php b/src/funcs/settings.php new file mode 100644 index 0000000..6cd4aa6 --- /dev/null +++ b/src/funcs/settings.php @@ -0,0 +1,74 @@ + +