Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Site Settings API: Expose Jetpack's related posts 'show_date' and 'show_context' options
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
'blog_public' => '(string) Site visibility; -1: private, 0: discourage search engines, 1: allow search engines',
'jetpack_sync_non_public_post_stati' => '(bool) allow sync of post and pages with non-public posts stati',
'jetpack_relatedposts_enabled' => '(bool) Enable related posts?',
'jetpack_relatedposts_show_context' => '(bool) Show post\'s tags and category in related posts?',
'jetpack_relatedposts_show_date' => '(bool) Show date in related posts?',
'jetpack_relatedposts_show_headline' => '(bool) Show headline in related posts?',
'jetpack_relatedposts_show_thumbnails' => '(bool) Show thumbnails in related posts?',
'jetpack_protect_whitelist' => '(array) List of IP addresses to whitelist',
Expand Down Expand Up @@ -356,17 +358,19 @@ public function get_settings_response() {
$response[ $key ] = array(
// also exists as "options".
'admin_url' => get_admin_url(),
'default_ping_status' => (bool) ( 'closed' !== get_option( 'default_ping_status' ) ),
'default_comment_status' => (bool) ( 'closed' !== get_option( 'default_comment_status' ) ),
'default_ping_status' => 'closed' !== get_option( 'default_ping_status' ),
'default_comment_status' => 'closed' !== get_option( 'default_comment_status' ),

// new stuff starts here.
'instant_search_enabled' => (bool) get_option( 'instant_search_enabled' ),
'blog_public' => (int) get_option( 'blog_public' ),
'jetpack_sync_non_public_post_stati' => (bool) Jetpack_Options::get_option( 'sync_non_public_post_stati' ),
'jetpack_relatedposts_allowed' => (bool) $this->jetpack_relatedposts_supported(),
'jetpack_relatedposts_enabled' => (bool) $jetpack_relatedposts_options['enabled'],
'jetpack_relatedposts_show_headline' => (bool) isset( $jetpack_relatedposts_options['show_headline'] ) ? $jetpack_relatedposts_options['show_headline'] : false,
'jetpack_relatedposts_show_thumbnails' => (bool) isset( $jetpack_relatedposts_options['show_thumbnails'] ) ? $jetpack_relatedposts_options['show_thumbnails'] : false,
'jetpack_relatedposts_show_context' => ! empty( $jetpack_relatedposts_options['show_context'] ),
'jetpack_relatedposts_show_date' => ! empty( $jetpack_relatedposts_options['show_date'] ),
'jetpack_relatedposts_show_headline' => ! empty( $jetpack_relatedposts_options['show_headline'] ),
'jetpack_relatedposts_show_thumbnails' => ! empty( $jetpack_relatedposts_options['show_thumbnails'] ),
'jetpack_search_enabled' => (bool) $jetpack_search_active,
'jetpack_search_supported' => (bool) $jetpack_search_supported,
'default_category' => (int) get_option( 'default_category' ),
Expand Down Expand Up @@ -645,6 +649,8 @@ public function update_settings() {
$updated[ $key ] = (bool) $value;
break;
case 'jetpack_relatedposts_enabled':
case 'jetpack_relatedposts_show_context':
case 'jetpack_relatedposts_show_date':
case 'jetpack_relatedposts_show_thumbnails':
case 'jetpack_relatedposts_show_headline':
if ( ! $this->jetpack_relatedposts_supported() ) {
Expand Down Expand Up @@ -1071,7 +1077,14 @@ function ( &$value ) {
$old_relatedposts_options = Jetpack_Options::get_option( 'relatedposts' );
if ( Jetpack_Options::update_option( 'relatedposts', $jetpack_relatedposts_options ) ) {
foreach ( $jetpack_relatedposts_options as $key => $value ) {
if ( isset( $old_relatedposts_options[ $key ] ) && $value !== $old_relatedposts_options[ $key ] ) {
if ( in_array( $key, array( 'show_context', 'show_date' ), true ) ) {
$has_initialized_option = ! isset( $old_relatedposts_options[ $key ] ) && $value;
$has_updated_option = isset( $old_relatedposts_options[ $key ] ) && $value !== $old_relatedposts_options[ $key ];

if ( $has_initialized_option || $has_updated_option ) {
$updated[ 'jetpack_relatedposts_' . $key ] = (bool) $value;
}
} elseif ( isset( $old_relatedposts_options[ $key ] ) && $value !== $old_relatedposts_options[ $key ] ) {
$updated[ 'jetpack_relatedposts_' . $key ] = $value;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
'blog_public' => '(string) Site visibility; -1: private, 0: discourage search engines, 1: allow search engines',
'jetpack_sync_non_public_post_stati' => '(bool) allow sync of post and pages with non-public posts stati',
'jetpack_relatedposts_enabled' => '(bool) Enable related posts?',
'jetpack_relatedposts_show_context' => '(bool) Show post\'s tags and category in related posts?',
'jetpack_relatedposts_show_date' => '(bool) Show date in related posts?',
'jetpack_relatedposts_show_headline' => '(bool) Show headline in related posts?',
'jetpack_relatedposts_show_thumbnails' => '(bool) Show thumbnails in related posts?',
'instant_search_enabled' => '(bool) Enable the new Jetpack Instant Search interface',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
'blog_public' => '(string) Site visibility; -1: private, 0: discourage search engines, 1: allow search engines',
'jetpack_sync_non_public_post_stati' => '(bool) allow sync of post and pages with non-public posts stati',
'jetpack_relatedposts_enabled' => '(bool) Enable related posts?',
'jetpack_relatedposts_show_context' => '(bool) Show post\'s tags and category in related posts?',
'jetpack_relatedposts_show_date' => '(bool) Show date in related posts?',
'jetpack_relatedposts_show_headline' => '(bool) Show headline in related posts?',
'jetpack_relatedposts_show_thumbnails' => '(bool) Show thumbnails in related posts?',
'instant_search_enabled' => '(bool) Enable the new Jetpack Instant Search interface',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
'blog_public' => '(string) Site visibility; -1: private, 0: discourage search engines, 1: allow search engines',
'jetpack_sync_non_public_post_stati' => '(bool) allow sync of post and pages with non-public posts stati',
'jetpack_relatedposts_enabled' => '(bool) Enable related posts?',
'jetpack_relatedposts_show_context' => '(bool) Show post\'s tags and category in related posts?',
'jetpack_relatedposts_show_date' => '(bool) Show date in related posts?',
'jetpack_relatedposts_show_headline' => '(bool) Show headline in related posts?',
'jetpack_relatedposts_show_thumbnails' => '(bool) Show thumbnails in related posts?',
'instant_search_enabled' => '(bool) Enable the new Jetpack Instant Search interface',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public function make_post_request( $setting ) {
'blog_public' => '(string) Site visibility; -1: private, 0: discourage search engines, 1: allow search engines',
'jetpack_sync_non_public_post_stati' => '(bool) allow sync of post and pages with non-public posts stati',
'jetpack_relatedposts_enabled' => '(bool) Enable related posts?',
'jetpack_relatedposts_show_context' => '(bool) Show post\'s tags and category in related posts?',
'jetpack_relatedposts_show_date' => '(bool) Show date in related posts?',
'jetpack_relatedposts_show_headline' => '(bool) Show headline in related posts?',
'jetpack_relatedposts_show_thumbnails' => '(bool) Show thumbnails in related posts?',
'instant_search_enabled' => '(bool) Enable the new Jetpack Instant Search interface',
Expand Down