Making WordPress.org


Ignore:
Timestamp:
02/10/2022 12:57:43 AM (5 years ago)
Author:
dd32
Message:

Plugin Directory: API: Turning off sections should turn off reviews unless explicitely turned on.

This allows for sections to be turned off, without also having to turn off reviews explicitly, while allowing reviews without sections.

Follow up to [11535].
See #6032.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api-request.php

    r11535 r11536  
    118118        );
    119119
     120        // Fields that affect other fields.
     121        // If the key is disabled, disable all of the values here unless client turns them on.
     122        static $field_interconnected = array(
     123                'sections' => [ 'reviews' ], // If sections is disabled, reviews should be disabled unless explicit.
     124        );
     125
    120126        public function __construct( $args ) {
    121127                $args = (object) $args;
     
    203209                        $field = self::$field_aliases[ $field ] ?? $field;
    204210
     211                        // Disable linked fields if required.
     212                        if ( ! $include && isset( self::$field_interconnected[ $field ] ) ) {
     213                                foreach ( self::$field_interconnected[ $field ] as $linked_field ) {
     214                                        if ( ! isset( $fields[ $linked_field ] ) ) {
     215                                                $requested_fields[ $linked_field ] = false;
     216                                        }
     217                                }
     218                        }
     219
    205220                        // If it's a valid field, include it.
    206221                        if ( isset( self::$fields[ $field ] ) ) {
Note: See TracChangeset for help on using the changeset viewer.