Skip to content

Commit 5f35691

Browse files
authored
Merge pull request #31 from codebtech/chore/remove-build
update readme, reset version
2 parents 9c350ee + 53b998e commit 5f35691

File tree

10 files changed

+94
-34
lines changed

10 files changed

+94
-34
lines changed

.env.dist

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
# Basic Wordpress Data
2-
1+
# ./local env vars
32
DB_HOST=mysql
43
DB_PORT=3306
54
DB_PASSWORD=p@55w0rd
65
DB_NAME=wordpress
76
DB_USER=root
7+
8+
# wp-env env vars
9+
WP_BASE_URL=http://localhost:8888
10+
WP_USERNAME=admin
11+
WP_PASSWORD=password
12+
WP_AUTH_STORAGE=.auth/wordpress.json

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
. "$(dirname -- "$0")/_/husky.sh"
33

44
yarn lint:js && yarn test:js
5+
yarn lint:css
56
composer lint
67
composer test:unit

README.md

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,74 @@
44
[![JS lint & test](https://github.com/codebtech/wp-feature-flags/actions/workflows/js.yml/badge.svg)](https://github.com/codebtech/wp-feature-flags/actions/workflows/js.yml)
55
[![E2E Tests](https://github.com/codebtech/wp-feature-flags/actions/workflows/e2e.yml/badge.svg)](https://github.com/codebtech/wp-feature-flags/actions/workflows/e2e.yml)
66

7-
Contributors: Mohan Raj Pachaiyappan
8-
Tags: feature-flags, feature-flag, wp-feature-flags
9-
Requires at least: 6.2
10-
Tested up to: 6.4
11-
Stable tag: 1.0.0
12-
Requires PHP: 7.4
13-
Contributor link: https://github.com/m0hanraj
7+
Feature flags allows developers to configure features in plugins/themes behind the feature flags on both Server(PHP) and Client(JS/TS) side.Feature flags allow developers to configure features in plugins/themes behind the feature flags on both the server (PHP) and client (JS/TS) side.
148

15-
## Description
9+
## Hooks
1610

17-
Feature flags allows developers to configure features behind the feature flags on both Server(PHP) and Client(JS/TS) side.
11+
### JS Filters
1812

19-
## Frequently Asked Questions
13+
##### mrFeatureFlags.newFlag.defaultStatus
2014

21-
### Does this plugin work with PHP 8?
15+
The filter controls whether the new flag is enabled by default or not. Default `true`
2216

23-
Yes, it's actively tested and working up to PHP 8.3
17+
Example usage:
2418

25-
### Does this plugin work with latest WordPress?
19+
```js
20+
addFilter('mrFeatureFlags.newFlag.defaultStatus', 'mr-feature-flags', () => {
21+
return false;
22+
});
23+
```
2624

27-
Yes, it's actively tested and working up to WordPress 6.4.3
25+
## Development setup
26+
27+
To build the plugin
28+
29+
PHP setup
30+
31+
- `composer install`
32+
33+
JS setup
34+
35+
- `yarn install`
36+
- `yarn build` to create the build
37+
- `yarn start` to start the development watch mode
38+
39+
## Linting and formatting
40+
41+
PHP
42+
43+
- `composer lint`
44+
- To auto fix the linting errors `composer lint:fix`
45+
46+
💡 [VSCode extension](https://marketplace.visualstudio.com/items?itemName=shevaua.phpcs) to auto format PHP files based on `phpcs.xml.dist` configuration
47+
48+
JS
49+
50+
- `yarn lint:js`
51+
52+
💡 [VSCode extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) to auto format JS / TS files based on `.prettierrc` configuration
53+
54+
CSS
55+
56+
- `yarn lint:css`
57+
- To auto fix the css linting errors `yarn lint:css:fix`
58+
59+
## Testing
60+
61+
### PHP
62+
63+
- Run `./local` from your preferred CLI. Ensure you have Docker installed and running.
64+
- The setup will automatically ssh into the container.
65+
- To run unit tests `composer run test:unit`
66+
- To run integrations tests `composer run test:integration`
67+
- To run integrations tests as multisite `composer run test:multisite`
68+
69+
### JS
70+
71+
- Run `yarn test:js` which will run all jest and React Testing Library tests
72+
73+
### E2E
74+
75+
The E2E tests depends on `wp-env` setup. Ensure you run `wp-env start` before running the tests.
76+
77+
- Run `yarn test:e2e` which will run all Playwright e2e tests.

includes/Api/Flags.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* API class for feature flags options
44
*
55
* @package mr-feature-flags
6-
* @since 1.0.0
6+
* @since 0.1.0
77
*/
88

99
declare(strict_types = 1);
@@ -18,7 +18,7 @@
1818
* Class Settings
1919
*
2020
* @package mr-feature-flags
21-
* @since 1.0.0
21+
* @since 0.1.0
2222
*/
2323
class Flags {
2424

@@ -32,7 +32,7 @@ class Flags {
3232
/**
3333
* Register feature flag endpoints.
3434
*
35-
* @since 1.0.0
35+
* @since 0.1.0
3636
*/
3737
public function register(): void {
3838
add_action(
@@ -44,7 +44,7 @@ public function register(): void {
4444
/**
4545
* Register routes.
4646
*
47-
* * @since 1.0.0
47+
* * @since 0.1.0
4848
*/
4949
public function register_routes(): void {
5050
register_rest_route(

includes/Flag.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Utility class to expose flag methods.
44
*
55
* @package mr-feature-flags
6-
* @since 1.0.0
6+
* @since 0.1.0
77
*/
88

99
declare(strict_types = 1);
@@ -14,7 +14,7 @@
1414
* Utils class for feature flags
1515
*
1616
* @package mr-feature-flags
17-
* @since 1.0.0
17+
* @since 0.1.0
1818
*/
1919
class Flag {
2020

@@ -31,7 +31,7 @@ class Flag {
3131
*
3232
* @param string $flag name of the flag.
3333
* @return bool
34-
* @since 1.0.0
34+
* @since 0.1.0
3535
*/
3636
public static function is_enabled( string $flag ): bool {
3737
$flags = get_option( self::$option_name, [] );

includes/Helper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* This is the init file for the plugin
44
*
55
* @package mr-feature-flags
6-
* @since 1.0.0
6+
* @since 0.1.0
77
*/
88

99
declare(strict_types = 1);
@@ -14,7 +14,7 @@
1414
* Class FeatureFlags
1515
*
1616
* @package mr-feature-flags
17-
* @since 1.0.0
17+
* @since 0.1.0
1818
*/
1919
class Helper {
2020

@@ -25,7 +25,7 @@ class Helper {
2525
* @param string $field field to search.
2626
* @param string $flag name of the flag.
2727
* @return boolean
28-
* @since 1.0.0
28+
* @since 0.1.0
2929
*/
3030
public function search_flag( $flags, $field, $flag ) {
3131

includes/Settings.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Admin setting page for feature flags
44
*
55
* @package mr-feature-flags
6-
* @since 1.0.0
6+
* @since 0.1.0
77
*/
88

99
declare(strict_types = 1);
@@ -14,15 +14,15 @@
1414
* Class Settings
1515
*
1616
* @package mr-feature-flags
17-
* @since 1.0.0
17+
* @since 0.1.0
1818
*/
1919
class Settings {
2020

2121
/**
2222
* Register feature flag settings page.
2323
*
2424
* @return void
25-
* @since 1.0.0
25+
* @since 0.1.0
2626
*/
2727
public function register_feature_settings() {
2828
add_action( 'admin_menu', [ $this, 'register_settings' ] );
@@ -32,7 +32,7 @@ public function register_feature_settings() {
3232
* Register settings action method.
3333
*
3434
* @return void
35-
* @since 1.0.0
35+
* @since 0.1.0
3636
*/
3737
public function register_settings() {
3838

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
22
"name": "mr-feature-flags",
3-
"version": "1.0.0",
3+
"version": "0.1.0",
44
"description": "Allows developers to enable / disable features based on flags.",
55
"scripts": {
66
"start": "wp-scripts start",
77
"build": "wp-scripts build",
88
"lint:js": "wp-scripts lint-js",
9+
"lint:css": "wp-scripts lint-style",
10+
"lint:css:fix": "npm run lint:css -- --fix",
911
"test:js": "wp-scripts test-unit-js",
1012
"test:watch": "wp-scripts test-unit-js --watch",
1113
"prepare": "husky install",

plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
/**
33
* The plugin bootstrap file
44
*
5-
* @since 1.0.0
5+
* @since 0.1.0
66
* @package mr-feature-flags
77
*
88
* @wordpress-plugin
99
* Plugin Name: Feature Flags
1010
* Description: Allows developers to enable / disable features based on flags.
11-
* Version: 1.0.0
11+
* Version: 0.1.0
1212
* Author: Mohan Raj
1313
* Author URI: https://mohanraj.dev
1414
* License: GPL-2.0+

src/styles/settings.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
.feature-flag-snackbar {
1010
bottom: 3.5rem;
1111
position: fixed;
12+
1213
.components-snackbar__icon {
1314
left: 18px;
1415
top: auto;
1516
}
1617
}
1718

1819
.feature-flag-loader {
20+
1921
.components-spinner {
2022
width: 20px;
2123
height: 20px;
@@ -40,7 +42,7 @@
4042
}
4143

4244
.mr-feature-flags-clipboard-base {
43-
color: darkgray !important;
45+
color: #a9a9a9 !important;
4446
float: right;
4547
position: relative;
4648
right: 40px;

0 commit comments

Comments
 (0)