Can I use the Backbone REST API client outside WordPress?

I haven’t tried this directly, but I’m pretty positive you can — after all, it’s a Javascript library. As long as you: Load any required dependencies; Provide any settings expected by the library; You should be good. A quick code search brings up these results from the /wp-includes/script-loader.php file: $scripts->add( ‘wp-api’, “/wp-includes/js/wp-api$suffix.js”, array( ‘jquery’, ‘backbone’, … Read more

Problem with custom WordPress Rest API search route with query parameters

It isn’t reading the acceptable image type parameter because there is no code to read it, and the acceptable image types have been hardcoded here: array( ‘key’ => ‘accepted_image_type’, ‘value’ => array(‘print’, ‘glass-plate’), ‘compare’ => ‘IN’, ), Much like you did here for the search parameter: $search_query = $data[‘s’]; It needs to do the same … Read more

WordPress REST API won’t allow me to filter by author ID when called internally, works externally in Postman

My approach to this was wrong, and I didn’t understand the error properly. After taking another look at this, I was able to fix it by replacing this code: if($request->get_param(‘id’)){ // $author = $request->get_param(‘author’); $podcastsRequest = new WP_REST_Request( ‘GET’, ‘/wp/v2/podcasts?author=1’); $articlesRequest = new WP_REST_Request( ‘GET’, ‘/wp/v2/articles?author=1’); $webinarsRequest = new WP_REST_Request( ‘GET’, ‘/wp/v2/webinars?author=1’); $expertInterviewsRequest = new … Read more

Restrict Image Sizes and Dimensions when Uploading via the WP Mobile App

Try this code in function.php I hope this help. add_action( ‘rest_api_init’, ‘set_image_dimension_limit’ ); function set_image_dimension_limit() { add_filter( ‘wp_handle_upload_prefilter’, function( $file ) { $mimes = array( ‘image/jpeg’, ‘image/png’, ‘image/gif’ ); if( !in_array( $file[‘type’], $mimes ) ) return $file; $img = getimagesize( $file[‘tmp_name’] ); $maximum = array( ‘width’ => 500, ‘height’ => 700 ); if ( $img[0] … Read more