<?php /* Template Name: Get Options @desc Will retrieve options from WordPress when sent in semicolon delimited list in the querystring. Example: Create a page with the slug 'my-options' and make it a 'Get Options' template in WP Admin. Call the page with the following URL: my-options/?page_on_front;page_for_posts;posts_per_page Will print a JSON object with the options as entered into WordPress Settings in the WP Admin. @see http://codex.wordpress.org/Option_Reference */ $BBID_JSON = new BBID_JSON(); $json = $BBID_JSON->getOptions($_SERVER['QUERY_STRING']); $etag = md5(serialize($json)); header('Etag: "' . $etag . '"'); header('Content-type: application/json'); echo json_encode($json);
<?php /* Template Name: Get Archives @desc Will print wp_get_archives as JSON. Will take parameters passed in querystring. Example: Create a page with the slug 'get-archives' and make it a 'Get Archives' template. Call the page with the following URL: get-archives/?type=monthly @see https://developer.wordpress.org/reference/functions/wp_get_archives/ */ $BBID_JSON = new BBID_JSON(); $json = $BBID_JSON->getArchives(); $etag = md5(serialize($json)); header('Etag: "' . $etag . '"'); header('Content-type: application/json'); echo json_encode($json);
<?php /* Template Name: Get Menu @desc Prints out JSON of the menu location sent in querystring after a page is set up in WP Admin. Menu slugs are set in functions.php Example: /my-menus/?menu1 @see http://ub4.underblob.com/wordpress-menu-posts/ @see http://codex.wordpress.org/Function_Reference/register_nav_menus */ $BBID_JSON = new BBID_JSON(); $BBID_JSON->setCurrentMenu($_SERVER['QUERY_STRING']); $json = $BBID_JSON->getMenu(); $etag = md5(serialize($json)); header('Etag: "' . $etag . '"'); header('Content-type: application/json'); echo json_encode($json);
<?php /* Template Name: Get Blog Info @desc Will retrieve blog info values from WordPress when sent in semicolon delimited list in the querystring. Example: Create a page with the slug 'my-blog-info' and make it a 'Get Blog Info' template. Call the page with the following URL: my-blog-info/?name;description;admin_email Will print a JSON object with the name, description, and admin_email as entered into WordPress. @see http://codex.wordpress.org/Function_Reference/get_bloginfo */ $BBID_JSON = new BBID_JSON(); $json = $BBID_JSON->getBlogInfo($_SERVER['QUERY_STRING']); $etag = md5(serialize($json)); header('Etag: "' . $etag . '"'); header('Content-type: application/json'); echo json_encode($json);
<?php /* Template Name: Get Links @desc Will retrieve links from WordPress. Can optionally send arguments in querystring. @see http://codex.wordpress.org/Function_Reference/get_bookmarks */ $BBID_JSON = new BBID_JSON(); $json = $BBID_JSON->getLinks($_GET); $etag = md5(serialize($json)); header('Etag: "' . $etag . '"'); header('Content-type: application/json'); echo json_encode($json);
<?php $BBID_JSON = new BBID_JSON(); $BBID_JSON->updateQueryPosts(); $json = array(); if (!is_404()) { while (have_posts()) { the_post(); $post = $BBID_JSON->getPostExtras($post); $json[] = $post; } } $etag = md5(serialize($json)); header('Etag: "' . $etag . '"'); header('Content-type: application/json'); echo json_encode($json);