Skip to content

Commit

Permalink
Newsletter: change default reply-to option from "no reply" to "commen…
Browse files Browse the repository at this point in the history
…ts" (#39657)
  • Loading branch information
simison authored Oct 8, 2024
1 parent 70eae9f commit d01e66f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,32 +410,32 @@ const EmailSettings = props => {
</p>
<RadioControl
className="jp-form-radio-gap"
selected={ subscriptionReplyTo || 'no-reply' }
selected={ subscriptionReplyTo || 'comment' }
disabled={ replyToInputDisabled }
options={ [
{
label: (
<span className="jp-form-toggle-explanation">
{ __( 'Replies are not allowed', 'jetpack' ) }
{ __( 'Replies will be a public comment on the post', 'jetpack' ) }
</span>
),
value: 'no-reply',
value: 'comment',
},
{
label: (
<span className="jp-form-toggle-explanation">
{ __( 'Replies will be a public comment on the post', 'jetpack' ) }
{ __( "Replies will be sent to the post author's email", 'jetpack' ) }
</span>
),
value: 'comment',
value: 'author',
},
{
label: (
<span className="jp-form-toggle-explanation">
{ __( "Replies will be sent to the post author's email", 'jetpack' ) }
{ __( 'Replies are not allowed', 'jetpack' ) }
</span>
),
value: 'author',
value: 'no-reply',
},
] }
onChange={ handleSubscriptionReplyToChange }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
// Each of these is a class that will register its own routes on 'rest_api_init'.
require_once JETPACK__PLUGIN_DIR . '_inc/lib/core-api/load-wpcom-endpoints.php';

require_once JETPACK__PLUGIN_DIR . 'modules/subscriptions/class-settings.php';

/**
* Class Jetpack_Core_Json_Api_Endpoints
*
Expand Down Expand Up @@ -2704,7 +2706,7 @@ public static function get_updateable_data_list( $selector = '' ) {
'jetpack_subscriptions_reply_to' => array(
'description' => esc_html__( 'Reply to email behaviour for newsletters emails', 'jetpack' ),
'type' => 'string',
'default' => 'no-reply',
'default' => Automattic\Jetpack\Modules\Subscriptions\Settings::$default_reply_to,
'validate_callback' => __CLASS__ . '::validate_subscriptions_reply_to',
'jp_group' => 'subscriptions',
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ public function update_data( $request ) {
require_once JETPACK__PLUGIN_DIR . 'modules/subscriptions/class-settings.php';
$sub_value = Automattic\Jetpack\Modules\Subscriptions\Settings::is_valid_reply_to( $value )
? $value
: Automattic\Jetpack\Modules\Subscriptions\Settings::get_default_reply_to();
: Automattic\Jetpack\Modules\Subscriptions\Settings::$default_reply_to;

$updated = (string) get_option( $option ) !== (string) $sub_value ? update_option( $option, $sub_value ) : true;
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: enhancement

Newsletter: change default reply-to option from "no reply" to "comments"
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ function ( &$value ) {
require_once JETPACK__PLUGIN_DIR . 'modules/subscriptions/class-settings.php';
$to_set_value = Automattic\Jetpack\Modules\Subscriptions\Settings::is_valid_reply_to( $value )
? (string) $value
: Automattic\Jetpack\Modules\Subscriptions\Settings::get_default_reply_to();
: Automattic\Jetpack\Modules\Subscriptions\Settings::$default_reply_to;

if ( update_option( $key, $to_set_value ) ) {
$updated[ $key ] = $to_set_value;
Expand Down Expand Up @@ -1302,7 +1302,7 @@ protected function get_subscriptions_reply_to_option() {
$reply_to = get_option( 'jetpack_subscriptions_reply_to', null );
if ( $reply_to === null ) {
require_once JETPACK__PLUGIN_DIR . 'modules/subscriptions/class-settings.php';
return Automattic\Jetpack\Modules\Subscriptions\Settings::get_default_reply_to();
return Automattic\Jetpack\Modules\Subscriptions\Settings::$default_reply_to;
}
return $reply_to;
}
Expand Down
20 changes: 6 additions & 14 deletions projects/plugins/jetpack/modules/subscriptions/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@

namespace Automattic\Jetpack\Modules\Subscriptions;

use Automattic\Jetpack\Status\Host;

/**
* Class Settings
*/
class Settings {
/**
* The default reply-to option.
*
* @var string
*/
public static $default_reply_to = 'comment';

/**
* Validate the reply-to option.
Expand All @@ -29,16 +33,4 @@ public static function is_valid_reply_to( $reply_to ) {
}
return false;
}
/**
* Get the default reply-to option.
*
* @return string The default reply-to option.
*/
public static function get_default_reply_to() {
if ( ( new Host() )->is_wpcom_simple() ) {
return 'comment';
}

return 'no-reply';
}
}

0 comments on commit d01e66f

Please sign in to comment.