| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName) |
| 2 | 2 | /** |
| 3 | 3 | * Module Name: Newsletter |
| 4 | - * Module Description: Let visitors subscribe to new posts and comments via email | |
| 4 | + * Module Description: Grow your subscriber list and deliver your content directly to their email inbox. | |
| 5 | 5 | * Sort Order: 9 |
| 6 | 6 | * Recommendation Order: 8 |
| 7 | 7 | * First Introduced: 1.2 |
| 8 | 8 | * Requires Connection: Yes |
| @@ -20,8 +20,9 @@ | ||
| 20 | 20 | use Automattic\Jetpack\Connection\XMLRPC_Async_Call; |
| 21 | 21 | use Automattic\Jetpack\Redirect; |
| 22 | 22 | use Automattic\Jetpack\Status; |
| 23 | 23 | use Automattic\Jetpack\Status\Host; |
| 24 | +use Automattic\Jetpack\Subscribers_Dashboard\Dashboard as Subscribers_Dashboard; | |
| 24 | 25 | |
| 25 | 26 | add_action( 'jetpack_modules_loaded', 'jetpack_subscriptions_load' ); |
| 26 | 27 | |
| 27 | 28 | // Loads the User Content Link Redirection feature. |
| @@ -58,8 +59,10 @@ | ||
| 58 | 59 | } |
| 59 | 60 | |
| 60 | 61 | /** |
| 61 | 62 | * Main class file for the Subscriptions module. |
| 63 | + * | |
| 64 | + * @phan-constructor-used-for-side-effects | |
| 62 | 65 | */ |
| 63 | 66 | class Jetpack_Subscriptions { |
| 64 | 67 | /** |
| 65 | 68 | * Whether Jetpack has been instantiated or not. |
| @@ -128,8 +131,9 @@ | ||
| 128 | 131 | add_filter( 'post_updated_messages', array( $this, 'update_published_message' ), 18, 1 ); |
| 129 | 132 | |
| 130 | 133 | // Set "social_notifications_subscribe" option during the first-time activation. |
| 131 | 134 | add_action( 'jetpack_activate_module_subscriptions', array( $this, 'set_social_notifications_subscribe' ) ); |
| 135 | + add_action( 'jetpack_activate_module_subscriptions', array( $this, 'set_featured_image_in_email_default' ) ); | |
| 132 | 136 | |
| 133 | 137 | // Hide subscription messaging in Publish panel for posts that were published in the past |
| 134 | 138 | add_action( 'init', array( $this, 'register_post_meta' ), 20 ); |
| 135 | 139 | add_action( 'transition_post_status', array( $this, 'maybe_set_first_published_status' ), 10, 3 ); |
| @@ -146,8 +150,10 @@ | ||
| 146 | 150 | ); |
| 147 | 151 | |
| 148 | 152 | // Track categories created through the category editor page |
| 149 | 153 | add_action( 'wp_ajax_add-tag', array( $this, 'track_newsletter_category_creation' ), 1 ); |
| 154 | + $subscribers_dashboard = new Subscribers_Dashboard(); | |
| 155 | + $subscribers_dashboard::init(); | |
| 150 | 156 | } |
| 151 | 157 | |
| 152 | 158 | /** |
| 153 | 159 | * Jetpack_Subscriptions::xmlrpc_methods() |
| @@ -694,9 +700,9 @@ | ||
| 694 | 700 | */ |
| 695 | 701 | do_action( 'jetpack_subscriptions_form_submission', $result ); |
| 696 | 702 | |
| 697 | 703 | wp_safe_redirect( "$redirect#$redirect_fragment" ); |
| 698 | - exit; | |
| 704 | + exit( 0 ); | |
| 699 | 705 | } |
| 700 | 706 | |
| 701 | 707 | /** |
| 702 | 708 | * Jetpack_Subscriptions::comment_subscribe_init() |
| @@ -856,9 +862,9 @@ | ||
| 856 | 862 | public function set_cookies( $subscribe_to_post = false, $post_id = null, $subscribe_to_blog = false ) { |
| 857 | 863 | $post_id = (int) $post_id; |
| 858 | 864 | |
| 859 | 865 | /** This filter is already documented in core/wp-includes/comment-functions.php */ |
| 860 | - $cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 ); | |
| 866 | + $cookie_lifetime = apply_filters( 'comment_cookie_lifetime', YEAR_IN_SECONDS ); | |
| 861 | 867 | |
| 862 | 868 | /** |
| 863 | 869 | * Filter the Jetpack Comment cookie path. |
| 864 | 870 | * |
| @@ -907,8 +913,17 @@ | ||
| 907 | 913 | } |
| 908 | 914 | } |
| 909 | 915 | |
| 910 | 916 | /** |
| 917 | + * Set the featured image in email option to `1` when the Subscriptions module is activated in the first time. | |
| 918 | + * | |
| 919 | + * @return void | |
| 920 | + */ | |
| 921 | + public function set_featured_image_in_email_default() { | |
| 922 | + add_option( 'wpcom_featured_image_in_email', 1 ); | |
| 923 | + } | |
| 924 | + | |
| 925 | + /** | |
| 911 | 926 | * Save a flag when a post was ever published. |
| 912 | 927 | * |
| 913 | 928 | * It saves the post meta when the post was published and becomes a draft. |
| 914 | 929 | * Then this meta is used to hide subscription messaging in Publish panel. |
| @@ -972,8 +987,19 @@ | ||
| 972 | 987 | * |
| 973 | 988 | * @return void |
| 974 | 989 | */ |
| 975 | 990 | public function add_subscribers_menu() { |
| 991 | + /** | |
| 992 | + * Enables the new in development subscribers in wp-admin dashboard. | |
| 993 | + * | |
| 994 | + * @since 9.5.0 | |
| 995 | + * | |
| 996 | + * @param bool If the new dashboard is enabled. Default false. | |
| 997 | + */ | |
| 998 | + if ( apply_filters( 'jetpack_wp_admin_subscriber_management_enabled', false ) ) { | |
| 999 | + return; | |
| 1000 | + } | |
| 1001 | + | |
| 976 | 1002 | /* |
| 977 | 1003 | * Do not display any menu on WoA and WordPress.com Simple sites (unless Classic wp-admin is enabled). |
| 978 | 1004 | * They already get a menu item under Users via nav-unification. |
| 979 | 1005 | */ |
| @@ -1047,4 +1073,5 @@ | ||
| 1047 | 1073 | require __DIR__ . '/subscriptions/views.php'; |
| 1048 | 1074 | require __DIR__ . '/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php'; |
| 1049 | 1075 | require __DIR__ . '/subscriptions/subscribe-overlay/class-jetpack-subscribe-overlay.php'; |
| 1050 | 1076 | require __DIR__ . '/subscriptions/subscribe-floating-button/class-jetpack-subscribe-floating-button.php'; |
| 1077 | +require __DIR__ . '/subscriptions/newsletter-widget/class-jetpack-newsletter-dashboard-widget.php'; | |