Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php

    r46821 r47122  
    8888                $taxonomies = get_taxonomies( '', 'objects' );
    8989            }
     90
    9091            foreach ( $taxonomies as $taxonomy ) {
    9192                if ( ! empty( $taxonomy->show_in_rest ) && current_user_can( $taxonomy->cap->assign_terms ) ) {
     
    9394                }
    9495            }
    95             return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) );
    96         }
     96
     97            return new WP_Error(
     98                'rest_cannot_view',
     99                __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ),
     100                array( 'status' => rest_authorization_required_code() )
     101            );
     102        }
     103
    97104        return true;
    98105    }
     
    116123            $taxonomies = get_taxonomies( '', 'objects' );
    117124        }
     125
    118126        $data = array();
     127
    119128        foreach ( $taxonomies as $tax_type => $value ) {
    120129            if ( empty( $value->show_in_rest ) || ( 'edit' === $request['context'] && ! current_user_can( $value->cap->assign_terms ) ) ) {
    121130                continue;
    122131            }
     132
    123133            $tax               = $this->prepare_item_for_response( $value, $request );
    124134            $tax               = $this->prepare_response_for_collection( $tax );
     
    150160                return false;
    151161            }
     162
    152163            if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->assign_terms ) ) {
    153                 return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) );
     164                return new WP_Error(
     165                    'rest_forbidden_context',
     166                    __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ),
     167                    array( 'status' => rest_authorization_required_code() )
     168                );
    154169            }
    155170        }
     
    168183    public function get_item( $request ) {
    169184        $tax_obj = get_taxonomy( $request['taxonomy'] );
     185
    170186        if ( empty( $tax_obj ) ) {
    171             return new WP_Error( 'rest_taxonomy_invalid', __( 'Invalid taxonomy.' ), array( 'status' => 404 ) );
    172         }
     187            return new WP_Error(
     188                'rest_taxonomy_invalid',
     189                __( 'Invalid taxonomy.' ),
     190                array( 'status' => 404 )
     191            );
     192        }
     193
    173194        $data = $this->prepare_item_for_response( $tax_obj, $request );
     195
    174196        return rest_ensure_response( $data );
    175197    }
     
    380402
    381403        $this->schema = $schema;
     404
    382405        return $this->add_additional_fields_schema( $this->schema );
    383406    }
Note: See TracChangeset for help on using the changeset viewer.