diff --git a/README.md b/README.md new file mode 100644 index 0000000..22e6216 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# Feature Flags + +Contributors: Mohan Raj Pachaiyappan +Tags: feature-flags, feature-flag, wp-feature-flags +Requires at least: 4.2 +Tested up to: 6.1 +Stable tag: 1.0.0 +Requires PHP: 5.6 +Contributor link: https://github.com/m0hanraj + +## Description + +Feature flags allows developers to configure features behind the feature flags on both Server(PHP) and Client(JS/TS) side. + +## Frequently Asked Questions + +### Does this plugin work with PHP 8? + +Yes, it's actively tested and working up to PHP 8.2 + +### Does this plugin work with latest WordPress? + +Yes, it's actively tested and working up to WordPress 6.1.1 + +## Changelog ## + +### 1.0.0 ### + +* Provides WP admin dashboard to manage (On/Off) feature flags +* Provides SDK for PHP and JavaScript with example code to add features behind the flag +* First class TypeScript support + + diff --git a/includes/Api/Flags.php b/includes/Api/Flags.php index 5a717af..e67b69e 100644 --- a/includes/Api/Flags.php +++ b/includes/Api/Flags.php @@ -110,10 +110,14 @@ public function validate_flag_input( $param ) { $input_data = $param->get_json_params(); $valid_keys = [ 'id', 'name', 'enabled' ]; - if ( ! isset( $input_data ) || ! is_array( $input_data ) || 0 === count( $input_data ) ) { + if ( ! isset( $input_data ) || ! is_array( $input_data ) ) { return false; } + if ( 0 === count( $input_data ) ) { + return true; + } + foreach ( $input_data as $flag_key => $flag ) { foreach ( $valid_keys as $key => $value ) { if ( ! array_key_exists( $value, $flag ) ) { diff --git a/yarn.lock b/yarn.lock index 6ef273e..d708bd0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6128,7 +6128,7 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== -husky@^8.0.3: +husky@^8.0.0: version "8.0.3" resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==