From d4a0644d1ce36ceaecd1a53642199a4bdfcc4123 Mon Sep 17 00:00:00 2001 From: Brian Lu Date: Sat, 9 Oct 2021 23:18:00 -0500 Subject: [PATCH 1/2] rename, add sno-gallery --- wp-ct-rest-api.php => wp-centraltimes.php | 37 ++++++++++++++++------ wp-centraltimes.zip | Bin 0 -> 1601 bytes 2 files changed, 27 insertions(+), 10 deletions(-) rename wp-ct-rest-api.php => wp-centraltimes.php (77%) create mode 100644 wp-centraltimes.zip diff --git a/wp-ct-rest-api.php b/wp-centraltimes.php similarity index 77% rename from wp-ct-rest-api.php rename to wp-centraltimes.php index 8a8b361..7521798 100644 --- a/wp-ct-rest-api.php +++ b/wp-centraltimes.php @@ -1,13 +1,13 @@ \d+)', array( 'methods' => 'GET', 'callback' => function ($data) { @@ -56,6 +56,23 @@ }, )); + // Register list of media for sno gallery + register_rest_route('centraltimes/v1', '/sno-gallery/(?P(\d+,*)+)', array( + 'methods' => 'GET', + 'callback' => function ($data) { + $images = array(); + // ids are in format id,id,id, + $ids = preg_split("/,/", $data["ids"]); + + foreach ($ids as $id) { + if (is_numeric($id)) + $images[] = get_post($id, ARRAY_A, "display"); + } + + return $images; + }, + )); + // Register raw data field for post register_rest_field( 'post', diff --git a/wp-centraltimes.zip b/wp-centraltimes.zip new file mode 100644 index 0000000000000000000000000000000000000000..1c43d363f169fbc1cd0d3d958d7c890afb34d635 GIT binary patch literal 1601 zcmV-H2EO@FO9KQH000080JgbFQ#Ou#qA&#j0QC_7022Us0C#XLV`Xl1a$#(AX>Db5 zE^ugYQ$%9`tN;K200;m}n$7oPWMF9!VPIe|V1NK0AZBC*Gg(D}gk}G_XK$u&z01z) zbo(VUemN$F1O^tcv;@O{MtKHCCWu-EAfW(ei$KH~A>u*|5V8G?!f-KesQ#4Otw#-bW*$$%2 zKGdxu6Pw_jyw-N0Xomm3*G_g-cmT)Hi}H{s za6@8t3YRQVf@Q_l;z8t21Skj7rAVC21N<_E>QTIydh83>*! zo+hWzfj?3~dxA*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mon Sep 17 00:00:00 2001 From: Brian Lu Date: Sat, 9 Oct 2021 23:22:23 -0500 Subject: [PATCH 2/2] v0.7.0 changelog --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 21991d9..2c3de6e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ This plugin currently performs the following changes to the REST API: - Registers a field, `ct_raw`, containing raw un-rendered post data, with shortcodes, to each post on `/wp/v2/posts` - Registers a new endpoint `/centraltimes/v1/shortcodes`, which returns an array of shortcode names. - Registers a new endpoint `/wp/v2/staff_profile` for the SNO `staff_profile` custom post type. -- Registers a new endpoint `/centraltimes/v1/ngg-gallery/(?P\d+)`, to return gallery image data. +- Registers a new endpoint `/centraltimes/v1/ngg-gallery/(?P\d+)`, to return NextGEN gallery image data. +- Registers a new endpoint `/centraltimes/v1/sno-gallery/(?P(\d+,*)+)`, to return SNO gallery image data - Registers metas of `post` (endpoint `posts` in namespace `wp/v2`): `writer`, `sno_deck`, `jobtitle`, `video`, & `videographer` to REST fields `ct_writer`, `ct_subtitle`, `ct_jobtitle`, `ct_video`, & `ct_videographer`, respectively. @@ -14,6 +15,10 @@ This plugin currently performs the following changes to the REST API: # Changelog +## v0.7.0 +- Project has been renamed from `wp_ct_rest_api` to `wp_centraltimes` +- Registered a new endpoint `/centraltimes/v1/sno-gallery/(?P(\d+,*)+)`, to return SNO gallery image data + ## v0.6.0 - Registered a new endpoint `/centraltimes/v1/ngg-gallery/(?P\d+)`, to return gallery image data - Modified `/centraltimes/v1/shortcodes` to return an array of shortcode names instead of shortcode keys