diff options
author | Yury German <blueknight@gentoo.org> | 2019-04-28 17:39:03 -0400 |
---|---|---|
committer | Yury German <blueknight@gentoo.org> | 2019-04-28 17:39:03 -0400 |
commit | 2ab16973706e120bc344c83be6295b54fd908c57 (patch) | |
tree | 358267a52d9542c77c90e3663cea32d13b8cb639 /plugins/jetpack/modules/shortlinks.php | |
parent | Update twentysixteen 1.7 (diff) | |
download | blogs-gentoo-2ab16973706e120bc344c83be6295b54fd908c57.tar.gz blogs-gentoo-2ab16973706e120bc344c83be6295b54fd908c57.tar.bz2 blogs-gentoo-2ab16973706e120bc344c83be6295b54fd908c57.zip |
Updating packages for 5.1.1
Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules/shortlinks.php')
-rw-r--r-- | plugins/jetpack/modules/shortlinks.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/plugins/jetpack/modules/shortlinks.php b/plugins/jetpack/modules/shortlinks.php index 54e30b94..cd06f43d 100644 --- a/plugins/jetpack/modules/shortlinks.php +++ b/plugins/jetpack/modules/shortlinks.php @@ -87,3 +87,50 @@ function wpme_get_shortlink( $id = 0, $context = 'post', $allow_slugs = true ) { function wpme_get_shortlink_handler( $shortlink, $id, $context, $allow_slugs ) { return wpme_get_shortlink( $id, $context, $allow_slugs ); } + +/** + * Add Shortlinks to the REST API Post response. + * + * @since 6.9.0 + * + * @action rest_api_init + * @uses register_rest_field, wpme_rest_get_shortlink + */ +function wpme_rest_register_shortlinks() { + register_rest_field( + 'post', + 'jetpack_shortlink', + array( + 'get_callback' => 'wpme_rest_get_shortlink', + 'update_callback' => null, + 'schema' => null, + ) + ); +} + +/** + * Get the shortlink of a post. + * + * @since 6.9.0 + * + * @param array $object Details of current post. + * + * @uses wpme_get_shortlink + * + * @return string + */ +function wpme_rest_get_shortlink( $object ) { + return wpme_get_shortlink( $object['id'], array() ); +} + +// Add shortlinks to the REST API Post response. +add_action( 'rest_api_init', 'wpme_rest_register_shortlinks' ); + +/** + * Set the Shortlink Gutenberg extension as available. + */ +function wpme_set_extension_available() { + Jetpack_Gutenberg::set_extension_available( 'jetpack/shortlinks' ); +} + +add_action( 'init', 'wpme_set_extension_available' ); |