{"id":39091,"date":"2015-09-25T06:50:36","date_gmt":"2015-09-25T06:50:36","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/only-rest-api\/"},"modified":"2015-12-07T15:12:51","modified_gmt":"2015-12-07T15:12:51","slug":"only-rest-api","status":"publish","type":"plugin","link":"https:\/\/fr-ca.wordpress.org\/plugins\/only-rest-api\/","author":13934819,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.0.0","stable_tag":"1.0.0","tested":"4.4.34","requires":"4.0","requires_php":"","requires_plugins":"","header_name":"Only REST API","header_author":"Braad Martin","header_description":"","assets_banners_color":"","last_updated":"2015-12-07 15:12:51","external_support_url":"","external_repository_url":"","donate_link":"http:\/\/braadmartin.com\/","header_plugin_uri":"https:\/\/wordpress.org\/plugins\/only-rest-api\/","header_author_uri":"http:\/\/braadmartin.com","rating":0,"author_block_rating":0,"active_installs":30,"downloads":2246,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":{"1.0.0":"<ul>\n<li>First Release<\/li>\n<\/ul>"},"ratings":{"1":0,"2":0,"3":0,"4":0,"5":0},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":"1253159","resolution":"1","location":"assets"}},"screenshots":{"1":"Customizable message shown on the front end for non-REST API requests"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[1556,1118,9149,2299],"plugin_category":[],"plugin_contributors":[80938],"plugin_business_model":[],"class_list":["post-39091","plugin","type-plugin","status-publish","hentry","plugin_tags-api","plugin_tags-json","plugin_tags-only","plugin_tags-rest","plugin_contributors-braad","plugin_committers-braad"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/only-rest-api.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/only-rest-api\/assets\/screenshot-1.png?rev=1253159","caption":"Customizable message shown on the front end for non-REST API requests"}],"raw_content":"<!--section=description-->\n<p>Got a WordPress install that serves only as the data layer and\/or admin UI of your web application?<\/p>\n\n<p>This plugin will effectively turn off all default front end output, redirect all front end urls to the main site url, and optionally display a message of your choice. The message can be a simple plain text message or you can use the included filters to completely control the HTML output.<\/p>\n\n<p>All activity in the wp-admin and all requests for assets like images, scripts, files, etc. will be unaffected by this plugin. Only requests that go through the <code>template_redirect<\/code> action will be affected.<\/p>\n\n<h4>Message Output<\/h4>\n\n<p>Rather than contaminate the data structures you might be using for your application (like posts and pages) this plugin includes a settings page with a simple textarea box where you can save any basic message you want to show. The message content is stored in the options table, and the textarea supports all the same HTML that you can use in post content.<\/p>\n\n<p>You can use the <code>only_rest_api_page_content<\/code> filter to include any custom HTML output you want inside the <code>&lt;body&gt;<\/code> tags, or you can use the <code>only_rest_api_page_html<\/code> filter to completely replace all HTML output of the message page, including the <code>&lt;html&gt;<\/code> and <code>&lt;head&gt;<\/code> tags.<\/p>\n\n<p>There is also an <code>only_rest_api_page_css<\/code> filter that allows you to override the 5 lines of CSS this plugin includes to center the message on the page.<\/p>\n\n<p>If you want a hook added or have a feature request let me know. Pull requests are welcome <a href=\"https:\/\/github.com\/BraadMartin\/only-rest-api\" title=\"Only REST API on Github\">on Github<\/a>.<\/p>\n\n<h4>Filter Examples<\/h4>\n\n<p>Use custom HTML inside the <code>&lt;body&gt;<\/code> tags:<\/p>\n\n<pre><code>add_filter( 'only_rest_api_page_content', 'xxx_page_content' );\nfunction xxx_page_content( $content ) {\n\n    $content = '&lt;div class=\"custom-output\"&gt;Sorry, I Only Speak REST. Please try again at a proper endpoint.&lt;\/div&gt;';\n\n    return $content;\n}\n<\/code><\/pre>\n\n<p>Add custom CSS to the default output:<\/p>\n\n<pre><code>add_filter( 'only_rest_api_page_css', 'xxx_page_css' );\nfunction xxx_page_css( $css ) {\n\n    $css .= '.page-content { color: red; font-size: 72px; }';\n\n    return $css;\n}\n<\/code><\/pre>\n\n<p>Replace the entire HTML output for the page:<\/p>\n\n<pre><code>add_filter( 'only_rest_api_page_html', 'xxx_page_html' );\nfunction xxx_page_html( $html ) {\n\n    ob_start();\n\n    ?&gt;\n    &lt;!doctype html&gt;\n    &lt;html lang=\"\"&gt;\n        &lt;head&gt;\n            &lt;meta charset=\"utf-8\"&gt;\n            &lt;meta http-equiv=\"x-ua-compatible\" content=\"ie=edge\"&gt;\n            &lt;title&gt;Call me back over the REST API yo!&lt;\/title&gt;\n            &lt;meta name=\"description\" content=\"\"&gt;\n            &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"&gt;\n            &lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"your-awesome-stylesheet.css\"&gt;\n            &lt;script type=\"text\/javascript\"&gt;\n                \/\/ Do neat stuff...\n            &lt;\/script&gt;\n        &lt;\/head&gt;\n        &lt;body&gt;\n            &lt;div class=\"page-content\"&gt;\n                Ain't nobody got time for non-REST API requests. Please try again at a proper endpoint. :)\n            &lt;\/div&gt;\n        &lt;\/body&gt;\n    &lt;\/html&gt;\n    &lt;?php\n\n    $html = ob_get_clean();\n\n    return $html;\n}\n<\/code><\/pre>\n\n<!--section=installation-->\n<h4>Manual Installation<\/h4>\n\n<ol>\n<li>Upload the entire <code>\/only-rest-api<\/code> directory to the <code>\/wp-content\/plugins\/<\/code> directory.<\/li>\n<li>Activate Only REST API through the 'Plugins' menu in WordPress.<\/li>\n<\/ol>\n\n<h4>Better Installation<\/h4>\n\n<ol>\n<li>Go to Plugins &gt; Add New in your WordPress admin and search for Only REST API.<\/li>\n<li>Click Install.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>Will this plugin affect assets like images, stylesheets, files, etc?<\/dt>\n<dd><p>No, this plugin hooks into the <code>template_redirect<\/code> action, which only fires when a front end page of some kind is being served.<\/p><\/dd>\n<dt>Does the plugin work with both v1 and v2 of the WP REST API?<\/dt>\n<dd><p>Yes! This plugin supports both versions of the WP REST API and will support the final version that gets merged into core.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>First Release<\/li>\n<\/ul>","raw_excerpt":"Redirects all front end, non-REST API requests to a single page.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/fr-ca.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/39091","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fr-ca.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/fr-ca.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/fr-ca.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=39091"}],"author":[{"embeddable":true,"href":"https:\/\/fr-ca.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/braad"}],"wp:attachment":[{"href":"https:\/\/fr-ca.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=39091"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/fr-ca.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=39091"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/fr-ca.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=39091"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/fr-ca.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=39091"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/fr-ca.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=39091"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/fr-ca.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=39091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}