diff --git a/README.md b/README.md index e028e26..f8a6206 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ The filter controls whether the new flag is enabled by default or not. Default ` Example usage: ```js -addFilter('mrFeatureFlags.newFlag.defaultStatus', 'mr-feature-flags', () => { +addFilter('mrFeatureFlags.newFlag.defaultStatus', 'codeb-feature-flags', () => { return false; }); ``` diff --git a/composer.json b/composer.json index 0d0e649..9432d81 100644 --- a/composer.json +++ b/composer.json @@ -1,23 +1,26 @@ { "name": "codeb/wp-feature-flags", "description": "Allows developers to enable / disable features based on flags.", - "type": "wordpress-plugin", "license": "MIT", - "repositories": [ - { - "type": "vcs", - "url": "https://git@github.com/WordPress/wordpress-develop" - } - ], + "type": "wordpress-plugin", + "require": { + "php": ">=8.1" + }, "require-dev": { - "wordpress/wordpress": "^6.4", - "phpunit/phpunit": "^9.4", "brain/monkey": "^2.6", "newsuk/nuk-wp-phpcs-config": "^0.2.0", - "newsuk/nuk-wp-phpstan-config": "^0.1.0", "newsuk/nuk-wp-phpmd-config": "^0.1.0", + "newsuk/nuk-wp-phpstan-config": "^0.1.0", + "phpunit/phpunit": "^9.4", + "wordpress/wordpress": "^6.4", "yoast/wp-test-utils": "^1.2" }, + "repositories": [ + { + "type": "vcs", + "url": "https://git@github.com/WordPress/wordpress-develop" + } + ], "autoload": { "psr-4": { "CodeB\\FeatureFlags\\": [ @@ -34,16 +37,19 @@ "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true, "phpstan/extension-installer": true + }, + "platform": { + "php": "8.1" } }, "scripts": { "lint": "phpcs .", "lint:fix": "phpcbf .", - "test:unit": "phpunit --dont-report-useless-tests --configuration ./phpunit.xml --testsuite unit --testdox --coverage-text", - "test:integration": "phpunit --dont-report-useless-tests --configuration ./phpunit-integration.xml --testsuite integration --testdox --coverage-text", - "test:multisite": "phpunit --dont-report-useless-tests --configuration ./phpunit-integration-multisite.xml --testsuite integration --testdox --coverage-text", + "phpmd": "phpmd plugin.php,includes text phpmd.xml.dist --color", "phpstan": "phpstan analyse --memory-limit=2048M", "phpstan-baseline": "phpstan analyse -b --allow-empty-baseline --memory-limit=2048M", - "phpmd": "phpmd plugin.php,includes text phpmd.xml.dist --color" + "test:integration": "phpunit --dont-report-useless-tests --configuration ./phpunit-integration.xml --testsuite integration --testdox --coverage-text", + "test:multisite": "phpunit --dont-report-useless-tests --configuration ./phpunit-integration-multisite.xml --testsuite integration --testdox --coverage-text", + "test:unit": "phpunit --dont-report-useless-tests --configuration ./phpunit.xml --testsuite unit --testdox --coverage-text" } } diff --git a/composer.lock b/composer.lock index fc51551..89e9f9a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "38c76af14c393316f9746c3dcceb88c4", + "content-hash": "184bc1b9afe3bddb1872a436264d8f1d", "packages": [], "packages-dev": [ { @@ -4631,7 +4631,12 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": ">=8.1" + }, "platform-dev": [], + "platform-overrides": { + "php": "8.1" + }, "plugin-api-version": "2.6.0" } diff --git a/includes/Api/Flags.php b/includes/Api/Flags.php index 80357e6..7a8cb8e 100644 --- a/includes/Api/Flags.php +++ b/includes/Api/Flags.php @@ -2,7 +2,7 @@ /** * API class for feature flags options * - * @package mr-feature-flags + * @package codeb-feature-flags * @since 0.1.0 */ @@ -17,7 +17,7 @@ /** * Class Settings * - * @package mr-feature-flags + * @package codeb-feature-flags * @since 0.1.0 */ class Flags { @@ -105,7 +105,7 @@ public function post_flags( WP_REST_Request $request ) { $max_allowed_flags = apply_filters( 'mr_feature_flags_max_allowed', self::$max_flags ); if ( count( $input_data['flags'] ) > $max_allowed_flags ) { // translators: %d is a placeholder for the maximum allowed flags. - $error_message = sprintf( __( 'Cannot add more than %d flags', 'mr-feature-flags' ), $max_allowed_flags ); + $error_message = sprintf( __( 'Cannot add more than %d flags', 'codeb-feature-flags' ), $max_allowed_flags ); return new WP_Error( 'flag_limit_exceeded', $error_message, array( 'status' => 400 ) ); } @@ -118,7 +118,7 @@ public function post_flags( WP_REST_Request $request ) { ); } - return new WP_Error( 'invalid_input', __( 'Cannot update flags', 'mr-feature-flags' ), array( 'status' => 400 ) ); + return new WP_Error( 'invalid_input', __( 'Cannot update flags', 'codeb-feature-flags' ), array( 'status' => 400 ) ); } /** diff --git a/includes/Flag.php b/includes/Flag.php index 1293855..86da8f4 100644 --- a/includes/Flag.php +++ b/includes/Flag.php @@ -2,7 +2,7 @@ /** * Utility class to expose flag methods. * - * @package mr-feature-flags + * @package codeb-feature-flags * @since 0.1.0 */ @@ -13,7 +13,7 @@ /** * Utils class for feature flags * - * @package mr-feature-flags + * @package codeb-feature-flags * @since 0.1.0 */ class Flag { diff --git a/includes/Helper.php b/includes/Helper.php index 8138e4d..db30568 100644 --- a/includes/Helper.php +++ b/includes/Helper.php @@ -2,7 +2,7 @@ /** * This is the init file for the plugin * - * @package mr-feature-flags + * @package codeb-feature-flags * @since 0.1.0 */ @@ -13,7 +13,7 @@ /** * Class FeatureFlags * - * @package mr-feature-flags + * @package codeb-feature-flags * @since 0.1.0 */ class Helper { diff --git a/includes/Settings.php b/includes/Settings.php index b586056..d14f0cd 100644 --- a/includes/Settings.php +++ b/includes/Settings.php @@ -2,7 +2,7 @@ /** * Admin setting page for feature flags * - * @package mr-feature-flags + * @package codeb-feature-flags * @since 0.1.0 */ @@ -13,7 +13,7 @@ /** * Class Settings * - * @package mr-feature-flags + * @package codeb-feature-flags * @since 0.1.0 */ class Settings { @@ -37,10 +37,10 @@ public function register_feature_settings() { public function register_settings() { add_menu_page( - __( 'Feature Flags', 'mr-feature-flags' ), - __( 'Feature Flags', 'mr-feature-flags' ), + __( 'Feature Flags', 'codeb-feature-flags' ), + __( 'Feature Flags', 'codeb-feature-flags' ), 'manage_options', - 'mr-feature-flags', + 'codeb-feature-flags', [ $this, 'render_page' ], 'data:image/svg+xml;base64,' . base64_encode( '' ) ); diff --git a/package.json b/package.json index 6c7b21c..81c032e 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "mr-feature-flags", + "name": "codeb-feature-flags", "version": "0.1.0", "description": "Allows developers to enable / disable features based on flags.", "scripts": { diff --git a/phpcs.xml b/phpcs.xml index 395ec0b..e18be3f 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -4,7 +4,7 @@ - + diff --git a/plugin.php b/plugin.php index 10facd6..a72742b 100644 --- a/plugin.php +++ b/plugin.php @@ -3,18 +3,20 @@ * The plugin bootstrap file * * @since 0.1.0 - * @package mr-feature-flags + * @package codeb-feature-flags * * @wordpress-plugin * Plugin Name: Feature Flags * Plugin URI: https://github.com/codebtech/wp-feature-flags * Description: Allows developers to enable / disable features based on flags. * Version: 0.1.0 + * Requires at least: 6.4 + * Requires PHP: 8.1 * Author: Mohan Raj * Author URI: https://mohanraj.dev * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt - * Text Domain: mr-feature-flags + * Text Domain: codeb-feature-flags */ declare( strict_types = 1 ); @@ -41,7 +43,7 @@ add_action( 'admin_enqueue_scripts', static function ( string $page ): void { - if ( 'toplevel_page_mr-feature-flags' === $page ) { + if ( 'toplevel_page_codeb-feature-flags' === $page ) { mr_feature_flags_load_settings_scripts(); } } @@ -58,7 +60,7 @@ function mr_feature_flags_load_settings_scripts(): void { $settings_asset_file = require_once plugin_dir_path( MR_FEATURE_FLAGS_PLUGIN_PATH ) . 'build/settings.asset.php'; // @phpcs:ignore wp_enqueue_script( - 'mr-feature-flags', + 'codeb-feature-flags', $plugin_url . 'build/settings.js', $settings_asset_file['dependencies'], $settings_asset_file['version'], @@ -68,7 +70,7 @@ function mr_feature_flags_load_settings_scripts(): void { wp_enqueue_style( 'wp-edit-blocks' ); wp_enqueue_style( - 'mr-feature-flags', + 'codeb-feature-flags', $plugin_url . 'build/settings.css', [], $settings_asset_file['version'] @@ -95,7 +97,7 @@ function mr_feature_flags_scripts_enqueue(): void { $script_asset_file = include_once plugin_dir_path( MR_FEATURE_FLAGS_PLUGIN_PATH ) . 'build/index.asset.php'; wp_enqueue_script( - 'mr-feature-flags-script', + 'codeb-feature-flags-script', $plugin_url . 'build/index.js', $script_asset_file['dependencies'], $script_asset_file['version'], @@ -111,7 +113,7 @@ function mr_feature_flags_scripts_enqueue(): void { } wp_localize_script( - 'mr-feature-flags-script', + 'codeb-feature-flags-script', 'mrFeatureFlags', [ 'flags' => $flags_list, @@ -130,17 +132,17 @@ function mr_feature_flags_scripts_enqueue(): void { // Displays setting page link in plugin page. add_filter( - 'plugin_action_links_mr-feature-flags/plugin.php', + 'plugin_action_links_codeb-feature-flags/plugin.php', static function ( $links ) { $url = esc_url( add_query_arg( 'page', - 'mr-feature-flags', + 'codeb-feature-flags', get_admin_url() . 'admin.php' ) ); - $settings_link = "" . __( 'Settings', 'mr-feature-flags' ) . ''; + $settings_link = "" . __( 'Settings', 'codeb-feature-flags' ) . ''; array_push( $links, diff --git a/src/components/FlagRow.tsx b/src/components/FlagRow.tsx index 52223fe..8edc3ba 100644 --- a/src/components/FlagRow.tsx +++ b/src/components/FlagRow.tsx @@ -60,7 +60,7 @@ const FlagRow = ({ const handleFlagEdit = (value: string, flagId: number) => { if (checkIfFlagExists(flags, value)) { // eslint-disable-next-line @wordpress/i18n-no-variables - setErrorMessage(__(ERROR_FLAG_EXISTS, 'mr-feature-flags')); + setErrorMessage(__(ERROR_FLAG_EXISTS, 'codeb-feature-flags')); setDisableSave(true); } //Alphanumeric,hypen and underscore validation else if (value.match(/^[a-zA-Z0-9\_-]*$/)) { @@ -68,7 +68,7 @@ const FlagRow = ({ setDisableSave(false); } else { // eslint-disable-next-line @wordpress/i18n-no-variables - setErrorMessage(__(ERROR_FLAG_INVALID, 'mr-feature-flags')); + setErrorMessage(__(ERROR_FLAG_INVALID, 'codeb-feature-flags')); setDisableSave(true); } @@ -112,13 +112,13 @@ const FlagRow = ({ handleFlagEdit(value, item.id)} /> - + - + - + {lastFlag > 0 && ( @@ -66,8 +66,8 @@ const SubmitControls = ({ disabled={disableSave || isSaving} > {isSaving - ? __('Saving', 'mr-feature-flags') - : __('Save', 'mr-feature-flags')} + ? __('Saving', 'codeb-feature-flags') + : __('Save', 'codeb-feature-flags')} @@ -75,7 +75,7 @@ const SubmitControls = ({ variant="tertiary" onClick={() => location.reload()} > - {__('Cancel', 'mr-feature-flags')} + {__('Cancel', 'codeb-feature-flags')} diff --git a/src/components/common/Clipboard.tsx b/src/components/common/Clipboard.tsx index c491ad5..08fec9f 100644 --- a/src/components/common/Clipboard.tsx +++ b/src/components/common/Clipboard.tsx @@ -29,7 +29,7 @@ const Clipboard = ({ text }: { text: string }): JSX.Element => { <> ); diff --git a/src/components/snippets/JsSnippet.tsx b/src/components/snippets/JsSnippet.tsx index 384b9f9..377ead3 100644 --- a/src/components/snippets/JsSnippet.tsx +++ b/src/components/snippets/JsSnippet.tsx @@ -17,7 +17,7 @@ domReady(function () { }, [flag]); return (
-

{__('JavaScript Snippet', 'mr-feature-flags')}

+

{__('JavaScript Snippet', 'codeb-feature-flags')}

diff --git a/src/components/snippets/PhpSnippet.tsx b/src/components/snippets/PhpSnippet.tsx index e872f3f..96c4c79 100644 --- a/src/components/snippets/PhpSnippet.tsx +++ b/src/components/snippets/PhpSnippet.tsx @@ -12,7 +12,7 @@ if ( class_exists( '\\CodeB\\FeatureFlags\\Flag' ) && Flag::is_enabled( '${flag} }, [flag]); return (
-

{__('PHP Snippet', 'mr-feature-flags')}

+

{__('PHP Snippet', 'codeb-feature-flags')}

diff --git a/src/components/snippets/TsSupport.tsx b/src/components/snippets/TsSupport.tsx index 7f14ebb..e5d9493 100644 --- a/src/components/snippets/TsSupport.tsx +++ b/src/components/snippets/TsSupport.tsx @@ -20,13 +20,13 @@ export {};`; }, []); return ( -
-

{__('TypeScript support', 'mr-feature-flags')}

+
+

{__('TypeScript support', 'codeb-feature-flags')}

Create a file named{' '} - flags.d.ts at + flags.d.ts at the entrypoint of TypeScript code for the plugin/theme ( usually - src directory ) + src directory ) and add the following declaration.

diff --git a/src/styles/settings.scss b/src/styles/settings.scss index ae2ab99..bb0e59c 100644 --- a/src/styles/settings.scss +++ b/src/styles/settings.scss @@ -33,41 +33,41 @@ margin-top: 20px; } -.mr-feature-flags-filename { +.codeb-feature-flags-filename { background-color: #007cba; border-radius: 6px; padding: 3px; color: #fff; } -.mr-feature-flags-slug { +.codeb-feature-flags-slug { background-color: #d7d8d9; border-radius: 6px; padding: 2px; } -.mr-feature-flags-clipboard-base { +.codeb-feature-flags-clipboard-base { color: #a9a9a9 !important; float: right; position: relative; right: 40px; } -.mr-feature-flags-input { +.codeb-feature-flags-input { width: 180px; } -.mr-feature-flags-toggle { +.codeb-feature-flags-toggle { margin-top: 7px; margin-left: 40px; min-width: 130px !important; } -.mr-feature-flags-sdk { +.codeb-feature-flags-sdk { margin-left: 80px; } -.mr-feature-flags-delete { +.codeb-feature-flags-delete { margin-bottom: 6px; margin-left: 50px; } diff --git a/tests/integration/bootstrap.php b/tests/integration/bootstrap.php index 28fa251..e49f9e3 100644 --- a/tests/integration/bootstrap.php +++ b/tests/integration/bootstrap.php @@ -5,7 +5,7 @@ /** * Bootstap file for PHPUnit integration tests. * - * @package mr-feature-flags + * @package codeb-feature-flags */ use function Yoast\WPTestUtils\WPIntegration\bootstrap_it; diff --git a/tests/unit/SettingsTest.php b/tests/unit/SettingsTest.php index 933a24e..2d029a7 100644 --- a/tests/unit/SettingsTest.php +++ b/tests/unit/SettingsTest.php @@ -40,7 +40,7 @@ public function testRegisterSettings() { 'Feature Flags', 'Feature Flags', 'manage_options', - 'mr-feature-flags', + 'codeb-feature-flags', [$settings, 'render_page'], 'data:image/svg+xml;base64,' . base64_encode( '' ) ); diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php index 733abc3..69bd1e4 100644 --- a/tests/unit/bootstrap.php +++ b/tests/unit/bootstrap.php @@ -5,7 +5,7 @@ /** * Bootstap file for PHPUnit test. * - * @package mr-feature-flags + * @package codeb-feature-flags */ if ( file_exists( __DIR__ . '/../vendor/autoload.php' ) ) {