WordPress Rest API Escapes Returned URLs Forward Slash

This is no different to when & in raw HTML is displayed as &, it’s standard JSON encoding, and is resolved by decoding the JSON. Any application that is unable to handle this has probably forgotten to parse the JSON response. For example: const url = JSON.parse( ‘”https:\/\/s.w.org\/plugins\/geopattern-icon\/action-scheduler.svg”‘ ); console.log( url ); Will print the … Read more

wordpress Ajax success doesn’t return the value

You can try this… …rather than returning the value, send a JSON success message. $response = new WP_REST_Response($final_price_return, 200); wp_send_json_success( $response ); wp_die(); //you have to end the process, so if you’re getting just a 0 returned in your JS success, it’s because of this. Then, in your JS/jQuery: success: function (success, data) { var … Read more

oneOf two possible objects in WP REST API?

Aight got it, the crucial missing thing was that you have to provide this part here: ‘type’ => ‘object’ twice; once when declaring the variable’s type, and once again when defining the possibilities. Otherwise, validation fails; so a proper example would be: ‘args’ => [ ‘data’ => [ ‘type’ => ‘object’, ‘oneOf’ => [ [ … Read more

Why does a super admin on multi site get a rest_user_invalid_id error code when requesting user details through REST?

Deleting users with the REST API isn’t supported for multisite, as seen in the source code: // We don’t support delete requests in multisite. if ( is_multisite() ) { return new WP_Error( ‘rest_cannot_delete’, __( ‘The user cannot be deleted.’ ), array( ‘status’ => 501 ) ); } For GET requests the user ID is checked … Read more

How many users/load can the rest API handle?

Can the WordPress rest API be used by thousands of public users at the same time Public users can use the REST API yes, though their access will be more restricted, e.g. you can see my sites rest API at tomjn.com/wp-json, but good luck trying to create a post without a login 🙂 or is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)