Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit d5b4902

Browse files
committed
Add method to retrieve the REST API URL
1 parent 1ad04d4 commit d5b4902

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/wpxf/wordpress/urls.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,9 @@ def wordpress_url_uploads
111111
def wordpress_url_admin_profile
112112
normalize_uri(wordpress_url_admin, 'profile.php')
113113
end
114+
115+
# @return [String] the base path of the REST API introduced in WordPress 4.7.0.
116+
def wordpress_url_rest_api
117+
normalize_uri(full_uri, 'wp-json')
118+
end
114119
end

spec/wordpress/urls_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,11 @@
165165
expect(subject.wordpress_url_admin_profile).to eq url
166166
end
167167
end
168+
169+
describe '#wordpress_url_rest_api' do
170+
it 'returns the REST API base path' do
171+
url = 'http://127.0.0.1/wp/wp-json'
172+
expect(subject.wordpress_url_rest_api).to eq url
173+
end
174+
end
168175
end

0 commit comments

Comments
 (0)