Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"wordpress/wordpress": "^6.4",
"phpunit/phpunit": "^9.4",
"brain/monkey": "^2.6",
"newsuk/nuk-wp-phpcs-config": "^0.1.0",
"newsuk/nuk-wp-phpcs-config": "^0.2.0",
"newsuk/nuk-wp-phpstan-config": "^0.1.0",
"newsuk/nuk-wp-phpmd-config": "^0.1.0",
"yoast/wp-test-utils": "^1.2"
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions includes/Api/Flags.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public function register_routes(): void {
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_all_flags' ],
'permission_callback' => function () {
'permission_callback' => static function () {
return current_user_can( 'manage_options' );
},
],
[
'methods' => WP_REST_Server::EDITABLE,
'callback' => [ $this, 'post_flags' ],
'permission_callback' => function () {
'permission_callback' => static function () {
return current_user_can( 'manage_options' );
},
'validate_callback' => [ $this, 'validate_flag_input' ],
Expand Down Expand Up @@ -108,10 +108,11 @@ public function post_flags( WP_REST_Request $request ) {
* Validates flag input from POST method.
*
* @param WP_REST_Request $request Request object.
*
* @return bool
*
* @phpstan-param WP_REST_Request<array{flags?: array}> $request
*/
public function validate_flag_input( $request ) {
public function validate_flag_input( WP_REST_Request $request ) {
$input_data = $request->get_json_params();

if ( ! isset( $input_data['flags'] ) || gettype( $input_data['flags'] ) !== 'array' ) {
Expand Down
10 changes: 5 additions & 5 deletions includes/Flag.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class Flag {
* @since 1.0.0
*/
public static function is_enabled( string $flag ): bool {
$flags = get_option( self::$option_name );
$flags = get_option( self::$option_name, [] );

$helper = new Helper();
if ( $helper->search_flag( $flags, 'name', $flag ) ) {
return true;
if ( ! is_array( $flags ) ) {
return false;
}

return false;
$helper = new Helper();
return $helper->search_flag( $flags, 'name', $flag );
}
}
4 changes: 2 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
// Enqueure scripts, styles in settings page.
add_action(
'admin_enqueue_scripts',
function ( string $page ): void {
static function ( string $page ): void {
if ( 'toplevel_page_mr-feature-flags' === $page ) {
mr_feature_flags_load_settings_scripts();
}
Expand Down Expand Up @@ -130,7 +130,7 @@ function mr_feature_flags_scripts_enqueue(): void {
// Displays setting page link in plugin page.
add_filter(
'plugin_action_links_mr-feature-flags/plugin.php',
function ( $links ) {
static function ( $links ) {
$url = esc_url(
add_query_arg(
'page',
Expand Down