wp/wp-includes/rest-api/class-wp-rest-response.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    74 	/**
    74 	/**
    75 	 * Removes a link from the response.
    75 	 * Removes a link from the response.
    76 	 *
    76 	 *
    77 	 * @since 4.4.0
    77 	 * @since 4.4.0
    78 	 *
    78 	 *
    79 	 * @param  string $rel  Link relation. Either an IANA registered type, or an absolute URL.
    79 	 * @param string $rel  Link relation. Either an IANA registered type, or an absolute URL.
    80 	 * @param  string $href Optional. Only remove links for the relation matching the given href.
    80 	 * @param string $href Optional. Only remove links for the relation matching the given href.
    81 	 *                      Default null.
    81 	 *                     Default null.
    82 	 */
    82 	 */
    83 	public function remove_link( $rel, $href = null ) {
    83 	public function remove_link( $rel, $href = null ) {
    84 		if ( ! isset( $this->links[ $rel ] ) ) {
    84 		if ( ! isset( $this->links[ $rel ] ) ) {
    85 			return;
    85 			return;
    86 		}
    86 		}
   152 
   152 
   153 		foreach ( $other as $key => $value ) {
   153 		foreach ( $other as $key => $value ) {
   154 			if ( 'title' === $key ) {
   154 			if ( 'title' === $key ) {
   155 				$value = '"' . $value . '"';
   155 				$value = '"' . $value . '"';
   156 			}
   156 			}
       
   157 
   157 			$header .= '; ' . $key . '=' . $value;
   158 			$header .= '; ' . $key . '=' . $value;
   158 		}
   159 		}
   159 		$this->header( 'Link', $header, false );
   160 		$this->header( 'Link', $header, false );
   160 	}
   161 	}
   161 
   162 
   229 		$error = new WP_Error;
   230 		$error = new WP_Error;
   230 
   231 
   231 		if ( is_array( $this->get_data() ) ) {
   232 		if ( is_array( $this->get_data() ) ) {
   232 			$data = $this->get_data();
   233 			$data = $this->get_data();
   233 			$error->add( $data['code'], $data['message'], $data['data'] );
   234 			$error->add( $data['code'], $data['message'], $data['data'] );
       
   235 
   234 			if ( ! empty( $data['additional_errors'] ) ) {
   236 			if ( ! empty( $data['additional_errors'] ) ) {
   235 				foreach ( $data['additional_errors'] as $err ) {
   237 				foreach ( $data['additional_errors'] as $err ) {
   236 					$error->add( $err['code'], $err['message'], $err['data'] );
   238 					$error->add( $err['code'], $err['message'], $err['data'] );
   237 				}
   239 				}
   238 			}
   240 			}
   283 		 * @since 4.5.0
   285 		 * @since 4.5.0
   284 		 *
   286 		 *
   285 		 * @param array $additional Additional CURIEs to register with the API.
   287 		 * @param array $additional Additional CURIEs to register with the API.
   286 		 */
   288 		 */
   287 		$additional = apply_filters( 'rest_response_link_curies', array() );
   289 		$additional = apply_filters( 'rest_response_link_curies', array() );
       
   290 
   288 		return array_merge( $curies, $additional );
   291 		return array_merge( $curies, $additional );
   289 	}
   292 	}
   290 }
   293 }