LezWatch / lwtv-plugin

LezWatch TV Custom Plugin
https://lezwatchtv.com
GNU General Public License v3.0
2 stars 1 forks source link
lezwatchtv plugins

LezWatch.TV Plugin

Custom plugin for LezWatch.TV

Description

The LezWatch.TV plugin contains custom code for use with the site. Instead of having everything hardcoded into the theme, or shoved in a shared MU Plugin, it was moved to it's own plugin. This allows it to be updated outside of the theme and deploy new features as needed.

The code was written by Tracy Levesque and Mika Epstein, with assistance from Yikes!

Usage documentation can be found at docs.lezwatchtv.com

Requirements

It's recommended to use Homebrew on macOS or Chocolatey for Windows to install the project dependencies.

Code Editor and Git Client

This repository includes a list of suggested extensions for the Visual Studio Code editor and Xdebug support in the .vscode directory.

A user-friendly Git client such as GitHub Desktop or Tower enables smaller commits and simplifies merge conflict resolution.

Setup 🛠

  1. Clone this repository: git clone git@github.com:lezwatch/lwtv-plugin
  2. Move into the project directory: cd lwtv-plugin
  3. Install the project dependencies: npm install
  4. Update all the things (npm, composer, etc): npm run updater
  5. Run an initial build: npm run build

Shadow Taxonomies

In order to speed up front-end page loads, we use shadow taxonomies. This means every Character has a secret taxonomy term that can be added to shows, actors, or even characters. To properly set this up you will need to run the following on your local site:

wp shadow sync --cpt=post_type_characters --tax=shadow_tax_characters

The command will need to be run multiple times until there are no more posts left to process (it only handles 500 at a time).

Then you run these commands to connect the parts together (they'll run everyone):

wp lwtv shadow shows
wp lwtv shadow actors

This setup only needs to be performed once. Afterwards, the site will dynamically set a new shadow term for every new character/actor/show, and update when content is changed.

Contributing

All pull requests should be made to production.

  1. Using the production branch as base, create a new branch with a descriptive name like fixing-charts or fix/chartjs421 or feature/latest-posts . Commit your work to that branch until it's ready for full testing
  2. Open a pull request from your feature branch to the production branch.
  3. If you are not a main developer, your pull request will be reviewed before it can be merged. If there are issues or changes needed, you may be asked to do so, or they may be done for you.
  4. When the code passes review, run npm run merge-to-develop to push it to development (no extra PR needed).
  5. Once the code passes tests and is approved, the branch can be merged into production and the job is done!

All commits are linted automatically on commit via eslint and phpcs, to ensure nothing breaks when we push the code. PHPUnit testing is in it's nascent stages using WP-Tests-Strapon.

Libraries

JS and PHP libraries are included via NPM and Composer. WordPress plugins that have been forked are now included in the main code and managed by us to prevent breakage.

The vendor and node_module files are not synced to Github anymore (as of 2023-August) to minimize the amount of files stored on the servers, and the following libraries have their required code moved via Composer and npm's post-install process:

NPM

Composer

Deployment

Pushes to branches are automatically deployed via Github Actions as follows:

Development

As of 2024, we use Namespaces and auto-loading in order to properly generate and call new content dynamically.

Components

A component can be thought of as a sub-plugin. It is an atomic, independent module that stores business logic related to a specific feature. It may expose some template tags (functions) that can be called from within the theme.

All Components are stored in /php/ and the details of their use in /php/readme.md

Blocks

Development is fully documented in /php/blocks/README.md

Features

The follow is a description of all the files in the code and more or less what they do.

Assets

Stored in /assets/

CSS (css)

Images (images)

Javascript (js)

The Code

Stored in /php/

_Components

All top-level components, stored in /php/_components/ - Many components have 'sub-components' stored in a folder of the same name. For example, class-queeries.php calls code stored in /php/queeries/ and so on. As long as the proper namespaces are applied, they will be autoloaded.

_Helpers

Helper files are not used as 'code' per-sey but our code relies on them.

Admin Menu

Stored in /php/admin-menu/ -- Makes admin menu items

Validator

Stored in /php/validator/ -- Called by /php/admin-menu/class-validation.php

Blocks (aka Gutenberg)

Stored in /php/blocks/

Source (src)

Each block is broken up by folder with the following files:

Calendar

Stored in /php/calendar/:

Custom Post Types

Stored in /php/cpts/:

Actors (actors)

Characters (/characters/)

Shows (/shows/)

Debugger

Stored in /php/debugger/ -- a collection of all code used to debug and manage content.

Features

Stored in /php/features/ -- a collection of miscellaneous features.

Of The Day

Stored in /php/of-the-day/ - code used to generate character and show of the day.

Plugin Addons

Stored in /php/plugins/ - all files are used to enhance other plugins installed on the site.

The file _main.php acts as an autoloader.

Queeries

Stored in /php/queeries/ - Custom arrays and WP_Query calls that are repeated in multiple places.

Rest API

Stored in /php/rest-api/ - These files generate the REST API output.

Alexa Skills (/php/rest-api/alexa/)

Templates (/php/rest-api/templates/)

Statistics

Stored in /php/statistics/ - These files generate everything for stats, from graphs to the rest API stuff.

Build (/php/statistics/build/)

Each file has a make() function which build an array that will be passed to the formatter code and output.

Formats (/php/statistics/formats)

Each file has a build() function which formats the arrays build in the build section (above) for proper display.

Templates (/php/statistics/templates/)

Templates used by the shortcodes and Gutenberg (as well as when included on the pages themselves).

Theme

Stored in /php/theme/ - Code used to generate data primarily for the theme in weird ways. Each class file has a make() function that generates the output. Some have sub-sets.

This Year

Stored in /php/this-year/ - Technically a subset of statistics, This Year shows you just the data for the indicated year.

Build (/php/this-year/build/)

Each file has a make() function which build an array that will be passed to the formatter code and output.

Formats (/php/this-year/formats)

Each file has a make() function which formats the arrays build in the BUILD section (above) for proper display.

WP-CLI

Stored in /wp-cli/ -- All code for WP-CLI

Plugins

Tests

Stored in /tests/ -- Unit/Functionality Tests

Helper functions are in /helpers/:

All tests for the components are found in /components/:

Commonly used data is stored in /data/ (currently only images).

Node Scripts

Stored in /node_scripts/ - Scripts used by NPM (for anything in node_modules). This is removed by the builder script when pushed to production.

Developer Features

The following folders/files are for use by Developers. They are not pushed to the dev nor production servers.