Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.58k stars 800 forks source link

Newsletter: allow defaulting to "post only" for the site #37821

Open simison opened 2 months ago

simison commented 2 months ago
Screenshot 2024-06-11 at 19 13 15 Screenshot 2024-06-11 at 19 15 20

Could be a PHP filter for starters, or a setting somewhere next up.

simison commented 2 months ago

This snippet of code sets the default to "do not send":

function register_meta_args_filter_jetpack_dont_send_post_by_default( $args, $defaults, $object_type, $meta_key ) {
    if ( $meta_key !== '_jetpack_dont_email_post_to_subs' ) {
        return $args;
    }

    $args['default'] = 1;

    return $args;
}
add_filter( 'register_meta_args', 'register_meta_args_filter_jetpack_dont_send_post_by_default', 10, 4 );

Now when you hit publish on new posts:

Screenshot 2024-06-21 at 15 44 45

If we would want to add more straightforward filter, we'd add it here:

https://github.com/Automattic/jetpack/blob/f8ce5bc19593297b09dfb1ffaed4251ca9df4927/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php#L96-L100