Questions tagged [api]

An application programming interface (API) specifies how some software components should interact with each other. In addition to accessing databases or computer hardware, such as hard disk drives or video cards, an API can be used to ease the work of programming graphical user interface components. In practice, most often an API is a library that includes specifications for routines, data structures, object classes, and variables.

Filter by
Sorted by
Tagged with
1
vote
0answers
272 views

Add basic authentication of WordPress on any external PHP file?

I have a file named upload.php that is an API which does the job of uploading images to the server. I want that file to have a basic authentication of WordPress, so that while accessing that php from ...
0
votes
1answer
709 views

Daily automatic update of stock quotes via REST API and Cronjob. Or is there a more sophisticated way?

I'm building a stock database with WordPress. There is a custom Post Type stocks with the fields last_price and ytd_return (ACF). The database will hold around 2000 stocks. For the stock quotes I ...
0
votes
0answers
33 views

Show sections based on a control in WordPress Customizer using JS API

I am trying to make the Customizer panel for a Slider in WordPress. I have Sections in a Panel. In the first section, I have a checkbox and a number field. I want to show the number of sections based ...
1
vote
1answer
4k views

utf8 encoding in json rest api

i create a custom REST API to get posts add_action( 'rest_api_init', 'custom_api_get_all_posts' ); function custom_api_get_all_posts() { register_rest_route( 'custom/v1', '/all-posts', array( ...
1
vote
0answers
164 views

Exclude objects from Wordpress API based from ACF field using rest_prepare_{$post_type}

Lets say i only want custom posts where (date('Y-m-d H:i:s')<{acf_date_field}) I tried to return null; from my_rest_prepare_post. It seems like its working, but is this good practice, or should i ...
1
vote
0answers
25 views

WordPress customizer get control

Is it possible to get a control arguments (title, transport, ...) dynamically when the control value changes? For example: When we change Site Title control, we can get its argument. api.bind( '...
0
votes
1answer
2k views

WordPress REST Api: update user

I have created an user via wordpress api, then after registration, I save user's username and password into the sessionStorage, and then, finaly, try to edit user's profile. Here's my post request ...
2
votes
1answer
5k views

Wordpress REST API 404

I have installed WP 4.9.5 using nginx and the following plugins: Gravity Forms (v2.3.1) by rocketgenius Advanced Custom Fields PRO (v5.6.10) by Elliot Condon Timber (v1.7.0) by Jared Novack + ...
1
vote
0answers
26 views

Store a default value for a transient on plugin activation

I'm creating a plugin which is dependent on an external API. And i have to make about a 1000 HTTP requests to the API in order to get a lot of data. And there has to be a 1 second delay between the ...
0
votes
1answer
57 views

How to Include Fields in Query String When Making Request of WordPress.org Plugin API?

I am running a query against the WordPress.org Plugin API that looks like this went built: https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[per_page]=10&request[...
0
votes
1answer
136 views

Hiding WordPress REST endpoints from public viewing using Basic Authentication

I have this function which register new endpoint. By default the end point is public. I'm using Application Passwords' plugin which create a basic authentication account, let's say Basic ...
-2
votes
1answer
246 views

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 or is it limited for only developers to use? I want to use the API to serve content to thousands of users, but am ...
1
vote
1answer
3k views

“rest_no_route” - Debug error

I am using Wordpress 4.9.5 and I want to create a custom endpoint like the following: <?php add_action('rest_api_init', 'miningRigsRoutes'); function miningRigsRoutes() { register_rest_route(...
2
votes
1answer
294 views

How do I perform a “get” call to an external API, and then display the JSON results on a page in my WordPress site?

A client has an external API that is storing all member info. My tasks are: a.) Create a 'Member Profile Search' page on his site, where users can search for members using certain keywords. b.) ...
5
votes
3answers
4k views

WP REST API only returning partial list of users

Started working with the WP REST API for the first time. Our ultimate goal is to dynamically load UI elements based on which user is presently logged in. However, my attempts to pull a list of all ...
0
votes
1answer
95 views

I would like to retrive JSON value and display it in wordpress page or widget

i am looking for a solution in wordpress on how to retrieve only one value from exchange api json json is avaible at: LINK TO JSON i would like to call value for Last variable in json and display it ...
2
votes
0answers
125 views

Building custom API and using wp_get_nav_menu_items to get menu items. Only works when logged in, returns nothing when I'm not

Working on a custom api for a site I'm building and I found a weird issue with wp_get_nav_menu_items. Essentially - wp_get_nav_menu_items only works and returns items when I'm logged in. If I'm not ...
1
vote
2answers
792 views

How to add a custom parameter to a WP API default route?

I have created an opps custom post type and registered a custom API field of closed for it with the following code: public function get_opp_state() { register_rest_field( 'opps', 'closed', array(...
1
vote
0answers
199 views

Limit post creation by role

Hi I want to limit post count a role can create. I am currently using Bainternet Posts Creation Limits. It works from dashboard but not for rest api.
0
votes
2answers
966 views

Using the JSON API via HTTPS and HTTP

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 ...
2
votes
1answer
3k views

fetching via fetch/ajax gutenberg block data from third party

I'm trying to use fetch to grab information from a 3rd party API which is rate-limited. Instead of doing the API on the front-end I'm trying to use fetch to do the API call in the edit function. I've ...
4
votes
3answers
5k views

Send data to 3rd party api with wp_remote_post on wp_login

Is it possible to use wp_remote_post to send http post requests to 3rd party api's? I wasn't able to successfully save the user object as a javascript variable, so I was hoping I could make an http ...
0
votes
1answer
3k views

How to add an endpoint for my custom post type? /wp-json/wp/v2/posts is working but it didn't in the custom post

function create_api_posts_meta_field() { // register_rest_field ( 'name-of-post-type', 'name-of-field-to-return', array-of-callbacks-and-schema() ) register_rest_field( 'post', 'post-meta-fields', ...
1
vote
1answer
2k views

Where to store OAuth 2.0 client id and secret?

I'm building some functionality within one of my WordPress sites that integrates with a third-party API, and that API uses OAuth 2.0. I use both the client ID and secret every time I need a new ...
6
votes
1answer
6k views

Fetch All Posts (Including Those Using a Custom Post Type) With Wordpress API

With the Wordpress API, we can use the following request to get all posts of the default 'post' type: http://example.com/wp-json/wp/v2/posts Supposing the 'books' and 'movies' custom post types ...
0
votes
1answer
406 views

.htaccess and proxy settings for routing a decoupled REST API consuming theme

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/...
0
votes
2answers
534 views

Use WP admin AJAX url to hide API key

Currently I am using AJAX to request a simple JSON response from an external API. The problem is, that the API key is exposed. I'm aware the best method is to process this through admin-ajax and set ...
0
votes
0answers
381 views

Is it possible to use 'wp_insert_post' function within a for loop?

I want to insert as a custom post type some data fethced from an API, I store that data and then pass it trough a for loop, then I use the loop data to create an array to pass it to wp_insert_post ...
0
votes
1answer
287 views

add pagination to wp_remote_get

I'm building a plugin for a client and it requires me to use wp_remote_get to retrieve records from their server. I have everything working but I can't seem to find any good examples of how you add ...
0
votes
1answer
58 views

Multisite functions to communicate with individual site functions

I have a multisite plugin that operates at the network level. It's job is to assign additional roles to different sites across the network. For example, I have three sites. Library Course (LMS) CRM ...
0
votes
1answer
452 views

Modify category listing API response

I have an existing site that uses a WordPress backend for publishing along with a custom Rails front end that displays the WP content (among other things). One of the things I'm doing with the ...
1
vote
1answer
443 views

Most performant way of fetching remote API data?

I am currently trying to speed optimise the fetching of the data via the remote API. I am using it in this way: $response = wp_remote_get('https://some-api.com/endpoint'); $response_body = ...
2
votes
2answers
3k views

How to stop WP API endpoint from caching?

I have a simple endpoint. Its GET, I pass it an ID parameter and it uses this ID to make a curl call. The endpoint then responds with a couple pieces of info json_encoded. The issue is that this ...
0
votes
1answer
128 views

Buik update custom field values from external API

I have many posts (about 1,000) where each contains a custom field with a value. I need to update these values periodically, hopefully at least once per day, from an external API. What is a ...
0
votes
1answer
210 views

How do I add a class to Customizer preview based on class of Customizer control? (Customizer Javascript API)

I am pretty weak with understanding the Customizer javascript API but I am trying. I have done a few things but now I need to send data to the Customizer preview based on the click of a control in the ...
0
votes
2answers
911 views

curl POST work with user meta but not the custom user meta

I created a custom user_meta, but I cant update it via curl. I can do this with user_meta curl --header "Authorization: Basic ACCESS_TOKEN" -X POST -d "description=New description" http://domain.com/...
0
votes
0answers
1k views

wp rest api (v2) filter not working (404 error - rest_no_route)

Filter for Wordpress rest api not working. I use simple permalink (another one-s not the variant) and my url looks like this: http://example.com/?rest_route=/wp/v2/posts this request works fine, but ...
1
vote
2answers
82 views

Widget - Store and update data

What is the best way to store data? Database, cache, etc? I want to build a widget, which will show some data from API, but I don't want to call API every time, because of limits. I'd like to call ...
0
votes
2answers
1k views

CRUD operations in wordpress

Recently volunteered (for a friend) to make a website for his business with same added features. I do have moderate web-dev experience but really wanted to try to use wordpress for this. Here are some ...
0
votes
1answer
402 views

Posting data from Ionic app to WordPress

Does anyone know? How can I post the blog post from ionic app to a WordPress back-end? My idea is to make a list of blog posts from ionic app (user will post data from app and create a post). Thank ...
2
votes
1answer
2k views

How to Securely and remotely Create new user in wordpress using Rest API

I am trying to create users in wordpress Version 4.9.1, remotely using the wordpress API. This is my PHP code below: $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_PORT => "8080", ...
0
votes
1answer
239 views

Sending customer an email with link to stripe to make payment

The site that I'm working on right now, has a ticket booking system which is custom coded with contact form 7. The way it works, when some one comes into the site and request for a quote on the ticket,...
0
votes
1answer
2k views

How to save woocommerce product?

I need to import products from third-party API to woocommerce. How to save data using wp_insert_post()? name = string sku = string type = string regular_price = double description = string weight = ...
0
votes
1answer
902 views

WP HTTP API call response

I have the function in php but in wordpress the HttpRequest method does not work and I did not understand how to transmit the information with the wordpress functions. My php function: $request = new ...
0
votes
0answers
763 views

Multisite and the JSON REST API: How to?

I have a simple scenario where I have to fetch posts including their metadata from the WordPress REST API: https://developer.wordpress.org/rest-api/ Within a normal WordPress website this is really ...
0
votes
1answer
284 views

Customizer JS API: Defining active_callback for a section

WordPress allows to use active_callback argument to display a section for a specific page(s) in the Customizer. In PHP it looks like this: $wp_customize->add_section( 'section_id', array( 'title'...
0
votes
1answer
320 views

Customizer JS API: Defining control settings

I am trying to create Customizer controls using JS API. What is a proper way to define control settings? Here is my current code: var mySetting = new api.Setting( 'section_title', 'Hello World!' ); ...
1
vote
1answer
377 views

Customizer JS API: Adding a “dropdown-pages” control

What is a proper way to add a list of pages (type: dropdown-pages) using Customizer JS API? Currently, I have this code but it does not display a control: api.control.add( new api.Control( 'custom-...
1
vote
0answers
633 views

TinyMCE - how to select tags node from the place where the caret is?

Hello to everyone! I've been wracking my brains, trying to find a solution for this. And here is what I have. Task: I want to detect in which tag my cursor(caret) is standing, and then to select ...
0
votes
1answer
71 views

Get a default customizeAction text for a section using Customizer JS API

What is the best way to get a default customizeAction label for the Customizer sections added via JavaScript? Here is a code with a custom action label: customSection = new api.Section( 'my_section'...

1
3 4
5
6 7
14