summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury German <blueknight@gentoo.org>2022-06-15 12:08:35 -0400
committerYury German <blueknight@gentoo.org>2022-06-15 12:08:35 -0400
commit36d7691c33cb64ece817246e47a779ec648d10b0 (patch)
tree08f2fb95303a1d8eeba2c8629a24b35a91fb1cac /plugins/jetpack/modules/shortlinks.php
parenttwentyfourteen upg 2.7 to 3.2 and twentysixteen from 2.0 to 2.5 (diff)
downloadblogs-gentoo-36d7691c33cb64ece817246e47a779ec648d10b0.tar.gz
blogs-gentoo-36d7691c33cb64ece817246e47a779ec648d10b0.tar.bz2
blogs-gentoo-36d7691c33cb64ece817246e47a779ec648d10b0.zip
Openid-3.6.1 and jetpack-11.0 upgrade
Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules/shortlinks.php')
-rw-r--r--plugins/jetpack/modules/shortlinks.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/plugins/jetpack/modules/shortlinks.php b/plugins/jetpack/modules/shortlinks.php
index 989271d7..fd541a48 100644
--- a/plugins/jetpack/modules/shortlinks.php
+++ b/plugins/jetpack/modules/shortlinks.php
@@ -131,12 +131,25 @@ function wpme_get_shortlink_handler( $shortlink, $id, $context, $allow_slugs ) {
* @uses register_rest_field, wpme_rest_get_shortlink
*/
function wpme_rest_register_shortlinks() {
+ // Post types that support shortlinks by default.
+ $supported_post_types = array(
+ 'attachment',
+ 'page',
+ 'post',
+ );
+
+ // Add any CPT that may have declared support for shortlinks.
+ foreach ( get_post_types() as $post_type ) {
+ if (
+ post_type_supports( $post_type, 'shortlinks' )
+ && post_type_supports( $post_type, 'editor' )
+ ) {
+ $supported_post_types[] = $post_type;
+ }
+ }
+
register_rest_field(
- array(
- 'attachment',
- 'page',
- 'post',
- ),
+ $supported_post_types,
'jetpack_shortlink',
array(
'get_callback' => 'wpme_rest_get_shortlink',