Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 2
CRAP
n/a
0 / 0
jetpack_markdown_posting_always_on
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
jetpack_do_after_markdown_activation
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Module Name: Markdown
4 * Module Description: Write and format posts using clean, readable Markdown syntax.
5 * Sort Order: 31
6 * First Introduced: 2.8
7 * Requires Connection: No
8 * Auto Activate: No
9 * Module Tags: Writing
10 * Feature: Writing
11 * Additional Search Queries: md, markdown
12 *
13 * @package automattic/jetpack
14 */
15
16if ( ! defined( 'ABSPATH' ) ) {
17    exit( 0 );
18}
19
20// Require the markdown class file.
21require __DIR__ . '/markdown/easy-markdown.php';
22
23/**
24 * Remove checkbox set in modules/markdown/easy-markdown.php.
25 * We don't just remove the register_setting call there because the checkbox is
26 * needed on WordPress.com, where the file is sync'ed verbatim.
27 */
28function jetpack_markdown_posting_always_on() {
29    // why oh why isn't there a remove_settings_field?
30    global $wp_settings_fields;
31    if ( isset( $wp_settings_fields['writing']['default'][ WPCom_Markdown::POST_OPTION ] ) ) {
32        unset( $wp_settings_fields['writing']['default'][ WPCom_Markdown::POST_OPTION ] );
33    }
34}
35add_action( 'admin_init', 'jetpack_markdown_posting_always_on', 11 );
36
37if ( ! function_exists( 'jetpack_do_after_markdown_activation' ) ) {
38    /**
39     * Turn on Markdown for posts when the module is activated, by any path.
40     *
41     * Lives here because Modules::activate() loads this file before it fires the activation hook.
42     *
43     * @since 4.7.0
44     */
45    function jetpack_do_after_markdown_activation() {
46        update_option( 'wpcom_publish_posts_with_markdown', true );
47    }
48}
49add_action( 'jetpack_activate_module_markdown', 'jetpack_do_after_markdown_activation' );