Skip to content

Commit

Permalink
Merge pull request #171 from plausible/self_provisioning_api
Browse files Browse the repository at this point in the history
v2.0.0
  • Loading branch information
Dan0sz authored Jan 24, 2024
2 parents edd64ef + 2c59953 commit dc321e2
Show file tree
Hide file tree
Showing 199 changed files with 62,738 additions and 3,231 deletions.
5 changes: 2 additions & 3 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"*.json": ["prettier --write", "git add"],
"*.php": ["npm run lint:textdomain", "npm run lint:php:fix", "git add"],
"*.{js,jsx}": ["eslint --fix", "git add"],
"*.scss": ["stylelint --fix", "git add"]
"*.php": ["npm run lint:textdomain", "git add"],
"*.{js,jsx}": ["git add"]
}
6 changes: 2 additions & 4 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": ["stylelint-config-standard-scss", "@wordpress/stylelint-config", "stylelint-prettier/recommended"],
"extends": ["@wordpress/stylelint-config", "stylelint-prettier/recommended"],
"rules": {
"at-rule-no-unknown": null,
"rule-empty-line-before": null,
"scss/at-import-no-partial-leading-underscore": null,
"scss/at-rule-no-unknown": true
"rule-empty-line-before": null
}
}
61 changes: 47 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

![WordPress version](https://img.shields.io/wordpress/plugin/v/plausible-analytics.svg) ![WordPress Rating](https://img.shields.io/wordpress/plugin/r/plausible-analytics.svg) ![WordPress Downloads](https://img.shields.io/wordpress/plugin/dt/plausible-analytics.svg)

Welcome to the Plausible Analytics WordPress Plugin GitHub repository. This is the code source and the center of active development. Here you can browse the source, look at open issues, and contribute to the project.
Welcome to the Plausible Analytics WordPress Plugin GitHub repository. This is the code source and the center of active development. Here you can
browse the source, look at open issues, and contribute to the project.

## Getting Started
## Getting Started

If you're looking to contribute or actively develop on Plausible Analytics then skip ahead to the [Local Development](https://github.com/plausible/wordpress/#local-development) section below. The following is if you're looking to actively use the plugin on your WordPress site.
If you're looking to contribute or actively develop on Plausible Analytics then skip ahead to
the [Local Development](https://github.com/plausible/wordpress/#local-development) section below. The following is if you're looking to actively use
the plugin on your WordPress site.

### Minimum Requirements

Expand All @@ -18,37 +21,49 @@ If you're looking to contribute or actively develop on Plausible Analytics then

### Automatic installation

Automatic installation is the easiest option as WordPress handles the file transfers itself and you don't need to leave your web browser. To do an automatic install of Plausible Analytics, log in to your WordPress dashboard, navigate to the Plugins menu and click "Add New".
Automatic installation is the easiest option as WordPress handles the file transfers itself and you don't need to leave your web browser. To do an
automatic install of Plausible Analytics, log in to your WordPress dashboard, navigate to the Plugins menu and click "Add New".

In the search field type "Plausible Analytics" and click Search Plugins. Once you have found the plugin you can view details about it such as the point release, rating and description. Most importantly of course, you can install it by simply clicking "Install Now".
In the search field type "Plausible Analytics" and click Search Plugins. Once you have found the plugin you can view details about it such as the
point release, rating and description. Most importantly of course, you can install it by simply clicking "Install Now".

### Manual installation

The manual installation method involves downloading our donation plugin and uploading it to your server via your favorite FTP application. The WordPress codex contains [instructions on how to do this here](https://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation).
The manual installation method involves downloading our donation plugin and uploading it to your server via your favorite FTP application. The
WordPress codex contains [instructions on how to do this here](https://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation).

### Support

This repository is not suitable for support. Please don't use GitHub issues for support requests. To get support please use the following channels:

* [WP.org Support Forums](https://wordpress.org/support/plugin/plausible-analytics) - for all users

## Available Actions, Filters and Toggles

### Filters

- `plausible_load_js_in_footer`: Allows you to load the JS code snippet in the footer.
- `plausible_analytics_script_params`: Allows you to modify the `script` element, loading the Plausible JS library.
- Example: using this filter and the `file-types` attribute will allow you to track downloads of certain file types when File Downloads tracking is enabled.
- Example: using this filter and the `file-types` attribute will allow you to track downloads of certain file types when File Downloads tracking is
enabled.

### Actions

- `plausible_analytics_settings_saved`: Trigger additional tasks directly after settings are saved.
- `plausible_analytics_after_register_assets`: This action allows you to trigger additional tasks or add custom JS (e.g. events) to the tracking code.

### Toggles
Using constants, you can modify the behavior of the plugin. `wp-config.php` is the best place to define constants. If you're using a custom plugin, make sure its code is loaded before this plugin.

- `PLAUSIBLE_SELF_HOSTED_DOMAIN`: Especially useful for Multisite instances using the self-hosted version of Plausible, this constant allows you to specify the Self-Hosted Domain for all subsites at once. **IMPORTANT**: this constant takes precedence over the plugin's setting. So, if this constant is defined, changing the setting won't have any effect.
- `plausible_proxy`: Appending this `GET`-parameter will force enable the proxy on the page you\'re calling it. This'll allow you to test your proxy in the frontend, before enabling the option.
Using constants, you can modify the behavior of the plugin. `wp-config.php` is the best place to define constants. If you're using a custom plugin,
make sure its code is loaded before this plugin.

- `PLAUSIBLE_SELF_HOSTED_DOMAIN`: Especially useful for Multisite instances using the self-hosted version of Plausible, this constant allows you to
specify the Self-Hosted Domain for all subsites at once. **IMPORTANT**: this constant takes precedence over the plugin's setting. So, if this
constant is defined, changing the setting won't have any effect.
- `plausible_proxy`: Appending this `GET`-parameter will force enable the proxy on the page you\'re calling it. This'll allow you to test your proxy
in the frontend, before enabling the option.

## Local Development
## Local Development

To get started developing on the Plausible Analytics WordPress Plugin you will need to perform the following steps:

Expand All @@ -65,7 +80,8 @@ That's it. You're now ready to start development.

Plausible Analytics relies on several npm commands to get you started:

* `npm run watch` - Live reloads JS and SASS files. Typically you'll run this command before you start development. It's necessary to build the JS/CSS however if you're working strictly within PHP it may not be necessary to run.
* `npm run watch` - Live reloads JS and SASS files. Typically you'll run this command before you start development. It's necessary to build the JS/CSS
however if you're working strictly within PHP it may not be necessary to run.
* `npm run dev` - Runs a one time build for development. No production files are created.
* `npm run production` - Builds the minified production files for release.

Expand All @@ -82,5 +98,22 @@ Plausible Analytics relies on several npm commands to get you started:
// Loads unminified core files
define( 'SCRIPT_DEBUG', true );
```
* Commit the `package.lock` file. Read more about why [here](https://docs.npmjs.com/files/package-lock.json).
* Your editor should recognize the `.eslintrc` and `.editorconfig` files within the Repo's root directory. Please only submit PRs following those coding style rulesets.
* Commit the `package.lock` file. Read more about why [here](https://docs.npmjs.com/files/package-lock.json).
* Your editor should recognize the `.eslintrc` and `.editorconfig` files within the Repo's root directory. Please only submit PRs following those
coding style rulesets.
### Regenerating the OpenAPI PHP Client
This plugin uses a OpenAPI PHP Client which is autogenerated by the OpenAPI generator to reduce contract violations, etc. to a minimum. But, since
this is a WordPress plugin, some manual modifications need to be done to make sure it doesn't conflict with other plugins:
- (Re)generate the PHP client using the following command (trigger it from the Plugin's root dir as output will be saved to `src/Client`):
`openapi-generator-cli generate -i https://plausible.io/api/plugins/spec/openapi -g php -o src/Client --additional-properties=identifierNamingConvention=snake_case,invokerPackage="Plausible\Analytics\WP\Client" --global-property=apis,models,supportingFiles,modelDocs=false,modelTests=false,apiDocs=false,apiTests=false`
- (When regenerating the PHP client this step can be skipped) Navigate to the `src/Client` director and install Composer
dependencies: `composer install --no-dev`
- (When regenerating the PHP client this step can be skipped) Run `mozart compose` from the `src/Client` directory (Make sure Mozart is installed
globally)
- In the `Client/lib` directory, replace all occurences of ` GuzzleHttp` (mind the space) with ` Plausible\Analytics\WP\Client\Lib\GuzzleHttp` (again,
mind the space at the beginning)
- In the same directory, replace all occurences of ` \GuzzleHttp` (mind the space and backslash)
with ` \Plausible\Analytics\WP\Client\Lib\GuzzleHttp`.
22 changes: 0 additions & 22 deletions assets/src/css/admin/_mixins.scss

This file was deleted.

4 changes: 0 additions & 4 deletions assets/src/css/admin/_variables.scss

This file was deleted.

125 changes: 0 additions & 125 deletions assets/src/css/admin/general.scss

This file was deleted.

39 changes: 0 additions & 39 deletions assets/src/css/admin/header.scss

This file was deleted.

3 changes: 3 additions & 0 deletions assets/src/css/admin/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
9 changes: 0 additions & 9 deletions assets/src/css/admin/main.scss

This file was deleted.

48 changes: 0 additions & 48 deletions assets/src/css/admin/menu.scss

This file was deleted.

Loading

0 comments on commit dc321e2

Please sign in to comment.