Completed
Push — branch-4.4 ( 3609d2...3dd542 )
by
unknown
14:00 queued 06:34
created

custom-css.php ➔ jetpack_load_custom_css()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 31
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 17
nc 7
nop 0
dl 0
loc 31
rs 8.439
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A custom-css.php ➔ jetpack_custom_css_undo_data_migration_cli() 0 4 1
1
<?php
2
3
/**
4
 * Module Name: Custom CSS
5
 * Module Description: Tweak your site’s CSS without modifying your theme.
6
 * Sort Order: 2
7
 * First Introduced: 1.7
8
 * Requires Connection: No
9
 * Auto Activate: Yes
10
 * Module Tags: Appearance
11
 * Feature: Appearance
12
 * Additional Search Queries: css, customize, custom, style, editor, less, sass, preprocessor, font, mobile, appearance, theme, stylesheet
13
 */
14
15
function jetpack_load_custom_css() {
16
	// If WordPress has the core version of Custom CSS, load our new version.
17
	// @see https://core.trac.wordpress.org/changeset/38829
18
	if ( function_exists( 'wp_get_custom_css' ) ) {
19
		if ( ! function_exists( 'wp_update_custom_css_post' ) ) {
20
			wp_die( 'Please run a SVN up to get the latest version of trunk, or update to at least 4.7 RC1' );
21
		}
22
		if ( ! Jetpack_Options::get_option( 'custom_css_4.7_migration' ) ) {
23
			include_once dirname( __FILE__ ) . '/custom-css/migrate-to-core.php';
24
		}
25
26
		// TODO: DELETE THIS
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
27
		else {
28
			if ( defined( 'WP_CLI' ) && WP_CLI ) {
29
				function jetpack_custom_css_undo_data_migration_cli() {
30
					Jetpack_Options::delete_option( 'custom_css_4.7_migration' );
31
					WP_CLI::success( __( 'Option deleted, re-migrate via `wp jetpack custom-css migrate`.', 'jetpack' ) );
32
				}
33
				WP_CLI::add_command( 'jetpack custom-css undo-migrate', 'jetpack_custom_css_undo_data_migration_cli' );
34
			}
35
		}
36
		// TODO: END DELETE THIS
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
37
38
		include_once dirname( __FILE__ ) . '/custom-css/custom-css/preprocessors.php';
39
		include_once dirname( __FILE__ ) . '/custom-css/custom-css-4.7.php';
40
		return;
41
	}
42
43
	include_once dirname( __FILE__ ) . "/custom-css/custom-css.php";
44
	add_action( 'init', array( 'Jetpack_Custom_CSS', 'init' ) );
45
}
46
47
add_action( 'jetpack_modules_loaded', 'custom_css_loaded' );
48
49
function custom_css_loaded() {
50
	Jetpack::enable_module_configurable( __FILE__ );
51
	Jetpack::module_configuration_load( __FILE__, 'custom_css_configuration_load' );
52
}
53
54
function custom_css_configuration_load() {
55
	wp_safe_redirect( admin_url( 'themes.php?page=editcss#settingsdiv' ) );
56
	exit;
0 ignored issues
show
Coding Style Compatibility introduced by
The function custom_css_configuration_load() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
57
}
58
59
jetpack_load_custom_css();
60