From f0dcc5c8f5f4f49abd8126f424fa16ea36104541 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Fri, 13 Nov 2026 12:34:16 -0300 Subject: [PATCH 1/2] Markdown: Keep Markdown for posts off after a Jetpack update The upgrade turned wpcom_publish_posts_with_markdown back on at every version change. It was a one-time fix for sites upgrading to 4.7, so it now runs only for upgrades from before 4.7. Co-Authored-By: Claude Opus 5.5 --- .../fix-markdown-posts-reset-on-upgrade | 4 ++ projects/plugins/jetpack/class.jetpack.php | 21 ++++++-- .../general/Jetpack_Markdown_Upgrade_Test.php | 49 +++++++++++++++++++ 3 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/fix-markdown-posts-reset-on-upgrade create mode 100644 projects/plugins/jetpack/tests/php/general/Jetpack_Markdown_Upgrade_Test.php diff --git a/projects/plugins/jetpack/changelog/fix-markdown-posts-reset-on-upgrade b/projects/plugins/jetpack/changelog/fix-markdown-posts-reset-on-upgrade new file mode 100644 index 000000000000..3901b2f94c71 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-markdown-posts-reset-on-upgrade @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Markdown: Keep Markdown for posts off after a Jetpack update when it was turned off. diff --git a/projects/plugins/jetpack/class.jetpack.php b/projects/plugins/jetpack/class.jetpack.php index e4451d50bee8..b1b694c844fa 100644 --- a/projects/plugins/jetpack/class.jetpack.php +++ b/projects/plugins/jetpack/class.jetpack.php @@ -499,10 +499,7 @@ public function plugin_upgrade() { Jetpack_Options::delete_option( 'identity_crisis_whitelist' ); } - // Make sure Markdown for posts gets turned back on. - if ( ! get_option( 'wpcom_publish_posts_with_markdown' ) ) { - update_option( 'wpcom_publish_posts_with_markdown', true ); - } + self::enable_markdown_for_posts_after_upgrade( $version ); /* * Minileven deprecation. 8.3.0. @@ -3124,6 +3121,22 @@ public static function activate_subscriptions_module_for_existing_sites( $versio } } + /** + * Turn Markdown for posts back on for sites upgrading from before 4.7, which stopped forcing it on. + * + * Later upgrades leave it alone, so a site that turned it off keeps it off. + * + * @since $$next-version$$ + * + * @param string $previous_version The Jetpack version the site upgrades from. + * @return void + */ + public static function enable_markdown_for_posts_after_upgrade( $previous_version ) { + if ( version_compare( $previous_version, '4.7', '<' ) && ! get_option( 'wpcom_publish_posts_with_markdown' ) ) { + update_option( 'wpcom_publish_posts_with_markdown', true ); + } + } + /** * Option flag that records the AI master-switch opt-out reconciliation has run, * so it never runs twice. diff --git a/projects/plugins/jetpack/tests/php/general/Jetpack_Markdown_Upgrade_Test.php b/projects/plugins/jetpack/tests/php/general/Jetpack_Markdown_Upgrade_Test.php new file mode 100644 index 000000000000..9108e5090284 --- /dev/null +++ b/projects/plugins/jetpack/tests/php/general/Jetpack_Markdown_Upgrade_Test.php @@ -0,0 +1,49 @@ + array( '4.6', true ), + 'from 4.7' => array( '4.7', false ), + 'from a recent 15' => array( '15.9', false ), + ); + } + + /** + * An upgrade turns Markdown for posts back on only for sites from before 4.7. + * + * @dataProvider provide_previous_versions + * + * @param string $previous_version The version the site upgrades from. + * @param bool $expected Whether the option is on afterwards. + */ + #[DataProvider( 'provide_previous_versions' )] + public function test_upgrade_keeps_markdown_for_posts_off_after_4_7( $previous_version, $expected ) { + update_option( 'wpcom_publish_posts_with_markdown', false ); + + Jetpack::enable_markdown_for_posts_after_upgrade( $previous_version ); + + $this->assertSame( $expected, (bool) get_option( 'wpcom_publish_posts_with_markdown' ) ); + } +} From ad6b62520ed4b3985fdc72507389f5ff59f74767 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Mon, 16 Nov 2026 11:44:21 -0300 Subject: [PATCH 2/2] Markdown: Delete the upgrade reset and turn posts on for every activation path Every site on 4.7.1 or later already got the one-time reset, so delete it instead of adding a version check. Move the activation listener into modules/markdown.php, which Modules::activate() loads before it fires the hook, so CLI and wpcom JSON API activations turn posts on too. Guard the function with function_exists(). Co-Authored-By: Claude Opus 5.5 --- ...lass.jetpack-core-api-module-endpoints.php | 12 ----- projects/plugins/jetpack/class.jetpack.php | 18 ------- projects/plugins/jetpack/modules/markdown.php | 14 ++++++ .../general/Jetpack_Markdown_Upgrade_Test.php | 49 ------------------- 4 files changed, 14 insertions(+), 79 deletions(-) delete mode 100644 projects/plugins/jetpack/tests/php/general/Jetpack_Markdown_Upgrade_Test.php diff --git a/projects/plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php b/projects/plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php index a71d8159b560..4a25a61448a4 100644 --- a/projects/plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php +++ b/projects/plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php @@ -1829,15 +1829,3 @@ function jetpack_do_after_gravatar_hovercards_deactivation() { update_option( 'gravatar_disable_hovercards', 'disabled' ); } add_action( 'jetpack_deactivate_module_gravatar-hovercards', 'jetpack_do_after_gravatar_hovercards_deactivation' ); - -/** - * Actions performed only when Markdown is activated through the endpoint call. - * - * @since 4.7.0 - */ -function jetpack_do_after_markdown_activation() { - - // When Markdown is activated, enable support for post editing automatically. - update_option( 'wpcom_publish_posts_with_markdown', true ); -} -add_action( 'jetpack_activate_module_markdown', 'jetpack_do_after_markdown_activation' ); diff --git a/projects/plugins/jetpack/class.jetpack.php b/projects/plugins/jetpack/class.jetpack.php index b1b694c844fa..6644f2a08a57 100644 --- a/projects/plugins/jetpack/class.jetpack.php +++ b/projects/plugins/jetpack/class.jetpack.php @@ -499,8 +499,6 @@ public function plugin_upgrade() { Jetpack_Options::delete_option( 'identity_crisis_whitelist' ); } - self::enable_markdown_for_posts_after_upgrade( $version ); - /* * Minileven deprecation. 8.3.0. * Only delete options if not using @@ -3121,22 +3119,6 @@ public static function activate_subscriptions_module_for_existing_sites( $versio } } - /** - * Turn Markdown for posts back on for sites upgrading from before 4.7, which stopped forcing it on. - * - * Later upgrades leave it alone, so a site that turned it off keeps it off. - * - * @since $$next-version$$ - * - * @param string $previous_version The Jetpack version the site upgrades from. - * @return void - */ - public static function enable_markdown_for_posts_after_upgrade( $previous_version ) { - if ( version_compare( $previous_version, '4.7', '<' ) && ! get_option( 'wpcom_publish_posts_with_markdown' ) ) { - update_option( 'wpcom_publish_posts_with_markdown', true ); - } - } - /** * Option flag that records the AI master-switch opt-out reconciliation has run, * so it never runs twice. diff --git a/projects/plugins/jetpack/modules/markdown.php b/projects/plugins/jetpack/modules/markdown.php index c579bbace558..04d29ba14e4d 100644 --- a/projects/plugins/jetpack/modules/markdown.php +++ b/projects/plugins/jetpack/modules/markdown.php @@ -33,3 +33,17 @@ function jetpack_markdown_posting_always_on() { } } add_action( 'admin_init', 'jetpack_markdown_posting_always_on', 11 ); + +if ( ! function_exists( 'jetpack_do_after_markdown_activation' ) ) { + /** + * Turn on Markdown for posts when the module is activated, by any path. + * + * Lives here because Modules::activate() loads this file before it fires the activation hook. + * + * @since 4.7.0 + */ + function jetpack_do_after_markdown_activation() { + update_option( 'wpcom_publish_posts_with_markdown', true ); + } +} +add_action( 'jetpack_activate_module_markdown', 'jetpack_do_after_markdown_activation' ); diff --git a/projects/plugins/jetpack/tests/php/general/Jetpack_Markdown_Upgrade_Test.php b/projects/plugins/jetpack/tests/php/general/Jetpack_Markdown_Upgrade_Test.php deleted file mode 100644 index 9108e5090284..000000000000 --- a/projects/plugins/jetpack/tests/php/general/Jetpack_Markdown_Upgrade_Test.php +++ /dev/null @@ -1,49 +0,0 @@ - array( '4.6', true ), - 'from 4.7' => array( '4.7', false ), - 'from a recent 15' => array( '15.9', false ), - ); - } - - /** - * An upgrade turns Markdown for posts back on only for sites from before 4.7. - * - * @dataProvider provide_previous_versions - * - * @param string $previous_version The version the site upgrades from. - * @param bool $expected Whether the option is on afterwards. - */ - #[DataProvider( 'provide_previous_versions' )] - public function test_upgrade_keeps_markdown_for_posts_off_after_4_7( $previous_version, $expected ) { - update_option( 'wpcom_publish_posts_with_markdown', false ); - - Jetpack::enable_markdown_for_posts_after_upgrade( $previous_version ); - - $this->assertSame( $expected, (bool) get_option( 'wpcom_publish_posts_with_markdown' ) ); - } -}