Developing a decoupled front-end consuming the REST API... I'm using create-react-app so can enter a proxy field corresponding to WP in my package.json and write my calls like fetch('/wp-json/v2/pages/...') if I run yarn start from the front-end directory... I'd love to actually have this theme in my wp-content/themes/my-theme directory though I'm no .htaccess god How can I make so that: Generic requests like mysite.com/jibble/jabble are handled by my SPA routing Protected routes like mysite.com/wp-admin/* and mysite.com/wp-content/uploads/* are still handled by …
I am trying to write a simple plugin that fetches some data from an API endpoint. I am planning to read the api key from a shortcode, but didn't get that far yet. I wrote the following piece of code. The noob question I have is how do I even trigger the code so that I could debug it to see what happens ? If that's a simple question, the follow up would be how to read the api key …
During my pentest of a client's websites I stumbled upon the WP with vulnerable WP Statistics plugin installed. To exploit this vulnerability, I should send a JSON-API request to endpoint /json-api/wp-statistics/v2/.... The problem is I must send correct _wpnonce along with my request. I found a cool explanation here: https://gist.github.com/Xib3rR4dAr/5dbd58b7f57a5037fe461fba8e696042 They recommend to extract the _wpnonce value from the legitimate URLs from the website page source. But I don't see similar URLs anywhere. My guess is that the plugin installed …
I'm writing my own php class and I have multiple functions within the class. Something like this: class JSON_API_Hello_Controller { public function test_cat(){ global $json_api; $posts = $json_api->introspector->get_posts(array( 'cat' => 3)); return $this->posts_object_result_bycat($posts); } public function test_cat1() { global $json_api; $posts = $json_api->introspector->get_posts(array( 'cat' => 2)); return $this->posts_object_result_bycat($posts); } protected function posts_object_result_bycat($posts) { global $wp_query; return array( 'count' => count($posts), 'pages' => (int) $wp_query->max_num_pages, 'posts' => $posts ); } public function mix_cat(){ $first_cat = $this->test_cat(); $second_cat = $this->test_cat1(); $json1 = …
I'm trying to determine if this is related to my having the latest version of PHP on my server while using the latest version of Wordpress. Or if I'm just doing it wrong: Here's my function that is correctly returning values (I can see them when I do an echo or a var dump): function my_Get_CURL (){ $url = 'http://someotherserver/event/94303?radius=30'; // Initiate curl $ch = curl_init(); // Disable SSL verification curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Will return the response, if false …
I have an AngularJS site that is pulling in posts from WordPress via the plugin "WP REST API (WP API)". I am testing a site on both dev and staging subdomains, and the WP API works on both. However, when I visit one domain, and then switch over to another domain immediately afterward, then the dynamically-generated Access-Control-Allow-Origin is "stuck" on the previous domain to make the API calls. It's not until I refresh the page, that the response header updates …
We have developed a mobile application using the JSON API plugin. The current website is running on HTTP, we are planning to change the website to HTTPS. Currently, mobile users on the live app are on HTTP; if we change the website to HTTPS then the app doesn't work so we have to publish a new app to work on HTTPS, but then the old app will not work, and we can't force a user to upgrade the app to …
I'm very new to this API, in fact I've only spent couple hours on it so far. I've done my research but cannot find anything about it... The issue is, I can't seem to get the featured image of a post. The JSON returns "featured_media: 0". getPosts: function() { var burl = "http://www.example.com/wp-json/wp/v2/posts"; var dataDiv = document.getElementById('cards'); $.ajax({ url: burl, data: data, type: 'GET', async: false, processData: false, beforeSend: function (xhr) { if (xhr && xhr.overrideMimeType) { xhr.overrideMimeType('application/json;charset=utf-8'); } }, …
Using the WP API and Backbone-based JS client, I'm trying to update a post's metadata as follows: var parentId = 96; // the post id var metaData = new wp.api.collections.PostMeta('', {parent: parentId}); metaData.fetch() .done(function(data) { var someKey = data.findWhere({key: 'someKey'}); someKey.set('value', 'newValue'); someKey.save(); }); Everything works fine until the calling of save(), which throws the following error: PUT http://example.org/wp-json/wp/v2/posts/undefined/meta/1901 404 (Not Found) Trying to sync the collection also fails. Any thoughts? Thanks!
Can anyone help me to login and sign up in reactnative app i have a Wordpress website and i want to link my wordpress site to reactnative app. search lots of solution but no one help me. i am using jwt auth plugin but don't know how to integrate this in reactapp.? import { SafeAreaView, StyleSheet, ScrollView, View, Alert, Text, StatusBar, Image, TextInput, TouchableOpacity, ImageBackground, ActivityIndicator, FlatList, Button, Linking } from 'react-native'; import AsyncStorage from '@react-native-community/async-storage'; import { createAppContainer } …
We're using a service called "Pandosearch" which indexes your website and provides a json-string with results after a call to the service. Example call: When you search for "pandosearch" in the "developer.pandosearch.com"-collection you can call -> https://public.pandosearch.com/developer.pandosearch.com/search?q=pandosearch. Example result: {"total":10,"hits":[{"type":"page","url":"https://developer.pandosearch.com/api/search/","fields":{"title":"Search","body":"When processing a request, <b>Pandosearch</b> is using multiple fields for each document in the collection. The exact fields depend on the specific configuration for the collection. Request To retrieve search results from <b>Pandosearch</b>, make a GET request to the…"}},{"type":"page","url":"https://developer.pandosearch.com/api/","fields":{"title":"Introduction","body":"Introduction The <b>Pandosearch</b> …
I'm trying to get the navigation menu from JSON response using WP REST API v2 plugin. There is no navigation menu plugin extension for the REST API v2, but only for V1. From codex WordPress Post Types, I learned that the navigation menu is treated as a post type. From Rest API Doc, this is how we get posts of a type: GET http://demo.wp-api.org/wp-json/wp/v2/types/<type> I tried to get it like so: URL : http://localhost/wptest/wp-json/wp/v2/types/nav_menu_item I received 403 error. {"code":"rest_cannot_read_type","message":"Cannot view …
I added custom image sizes in my WordPress theme: add_action( 'after_setup_theme', 'wpdocs_theme_setup' ); function wpdocs_theme_setup() { add_image_size( 'custom-size-1', 120, 120, true ); add_image_size( 'custom-size-2', 300, 200 ); } I made my custom sizes available across Wordpress in the image size select: add_filter( 'image_size_names_choose', 'my_custom_sizes' ); function my_custom_sizes( $sizes ) { return array_merge( $sizes, array( 'custom-size-1' => __( 'Custom Size 1' ), 'custom-size-2' => __( 'Custom Size 2' ) ) ); } When using the core image block, in the "Image …
I want to get all WooCommerce orders from given date range. I can retrieve all orders at once. But I am confusing with passing the date range via API URL. Can anybody help me with this? I know it's something like this but can't figure out the exact way to do it. Here is my route: add_action('rest_api_init', function() { register_rest_route('woo/v2', 'woocommerce/order_summary_by_date/(?P<start_date>/<end_date>)', array( 'methods' => 'GET', 'callback' => 'woocommerce_orders_by_dates' )); }); This is function to access: function woocommerce_orders_by_dates($start_date, $end_date) { $start_date …
I have extended WP API plugin to provide an API which can process documents. Routes public function register_routes($routes) { $documents_routes = array( '/v1/documents' => array( array(array($this, 'create_document'), WP_JSON_Server::CREATABLE), ) ); $new_routes = array_merge($routes, $documents_routes); return $new_routes; } callback function public function create_document($data, $_files = null){ if(!empty($_files)) { // process file } // how to retrieve } Request POST /api/v1/documents/ HTTP/1.1 Host: localhost Cache-Control: no-cache Postman-Token: d5277e1c-12ac-309a-034f-135173b7c7f2 Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ----WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="doc_id" 3268360 ----WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="PINS REST …
When requesting to WordPress API for any plugin or theme information for the versions field https://api.wordpress.org/themes/info/1.1/?action=theme_information&request[per_page]=12&request[slug]=twentyfifteen&request[fields][tags]=0&request[fields][sections]=0&request[fields][screenshot_url]=0&request[fields][versions]=1 I get JSON array response. Something like this: "1.0":"https://downloads.wordpress.org/theme/twentyfifteen.1.0.zip", "1.1":"https://downloads.wordpress.org/theme/twentyfifteen.1.1.zip", "1.2":"https://downloads.wordpress.org/theme/twentyfifteen.1.2.zip", Also These are Dynamically generated. So I want to dynamically convert the version number as simple text and the download link as a button href URL. Also I want to wrap the whole section into a nice table with two columns, one with the version number another with the download button. If anybody …
I have installed and activated the Wordpress JSON API (http://wordpress.org/plugins/json-api) in my self hosted WP site. Now my site content is open to the world via this API in JSON format. But, I want to restrict the access of this JSON API only to the requests that are coming from specific domain. Even though someone got to know that my site has JSON API enabled and the URL endpoint, they should see 'Access Denied' except the requests comes from a …
I tried to retrieve JSON data from a public instagram account using: wp_remote_get (). But the problem I have is that with the url: $url = https://www.instagram.com/USER/?__a=1 . If, I am connected to my Instagram account, the url returns the data correctly by entering the url in my browser. But, trying to send a request with the wp_remote_get ( $url) function , the response to the request returns the Login page - Instagram . do i need to add some …
I already get posts from categories with: http://domain.com/wp-json/wp/v2/posts?filter[category_name]=category-name but how can i retrieve content from page? - [page_name]=page-name for example but its not working. I have searched lot but cant found any solution. Thanks.
I'm getting started with a project that is making use of Backbone and the WP REST API, but I"m having a little trouble. Using the built in API JS for models and collections allows me to pretty easily update a post title or content. All I have to do is call: this.model.set({title: 'New Title'}); this.model.save(); And everything works really well. But for post meta, there doesn't appear to be an easy way to update an entry to the database. Does …