Skip to main content
  1. All Posts/

wp-google-auth

Tools Open Source Sync WordPress

ftek-google-auth

WordPress plugin for syncing WordPress users with Google Workspace users.

Dependencies

  • PHP (^7.4.x)
  • WordPress (>=5.9.x)

Contributing

VS Code

This project is set up for development with the editor/IDE VS Code. It is strongly recommended that you use this editor.

Devcontainer

The project includes a devcontainer configuration which contains all tools needed for development. To use this you need to install Docker (either CLI or Docker Desktop), and the remote development extension pack after which you can simply select “Clone Repository in Container Volume…” from the Remote Explorer tab.
After starting the devcontainer, WordPress will be accessable at http://localhost:8888 on your local machine. After installing composer and npm dependencies and building javascript files (see Getting Started) you may log in to WordPress and activate your plugin. To log in, visit http://localhost:8888/wp-login.php and entering the default credentials:

  • Username: admin
  • Password: password

Getting started

Before continuing you must install npm and Composer dependencies:

npm install
composer install

During development, the following command will automatically rebuild code as source files are changed.

npm run start

You should check for (stylistic) errors in your code by running

npm run lint

Format the code base by running

npm run format

Create a production build by running

npm run build

For simplicity when installing the plugin, we keep built files under version control. Lint, format and build your code before commiting any changes.

Visual Studio Code

If you encoder unexpected TypeScript errors in Visual Studio Code, make sure to use the workspace version of TypeScript.

Generate autoload files

To import PHP classes, we use the autoload file generated by Composer. After creating a new file containing a class you would like to import, regenerate the autoload file by running

composer dump-autoload

Internationalization

Run the command

npm run i18n

to scan the source code for translatable strings (which are stored in a POT file inside the languages folder) and update existing translations (PO files also stored inside languages) from the POT file. To edit an existing localization, edit the corresponding PO file. To create a new localization, copy the POT file to a new PO file inside languages. Assuming the POT file is named my-text-domain.pot, name the PO file my-text-domain-{locale}.po, for example my-text-domain-en_US.po. Lists of locale codes available in WordPress can be found online.

Releases

GitHub Actions is configured to automatically create a new release when a new tag is pushed. Some useful commands are

git tag                 # Lists existing tags
git tag -a vx.x.x       # Creates a new tag for the specified version number
git push --follow-tags  # Pushes commits and tags to the remote