Completed
Push — update/add-csstidy-config-sett... ( 30eb4b...0a5859 )
by
unknown
19:15 queued 09:40
created

Atomic_Additional_CSS_Manager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 45
loc 45
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 3 3 1
A register_nudge() 12 12 1
A get_nudge_url() 3 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * WPORG_Additional_CSS_Manager file
4
 *
5
 * Responsible with replacing the Core Additional CSS section with an upgrade nudge on Atomic.
6
 *
7
 * @package Jetpack
8
 */
9
10
namespace Automattic\Jetpack\Dashboard_Customizations;
11
12
/**
13
 * Class Atomic_Additional_CSS_Manager
14
 *
15
 * @package Automattic\Jetpack\Dashboard_Customizations
16
 */
17 View Code Duplication
class Atomic_Additional_CSS_Manager {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
19
	/**
20
	 * The site domain.
21
	 *
22
	 * @var string
23
	 */
24
	private $domain;
25
26
	/**
27
	 * Atomic_Additional_CSS_Manager constructor.
28
	 *
29
	 * @param string $domain the Site domain.
30
	 */
31
	public function __construct( $domain ) {
32
		$this->domain = $domain;
33
	}
34
35
	/**
36
	 * Replace the Additional CSS section from Customiz¡er with an upgrade nudge.
37
	 *
38
	 * @param \WP_Customize_Manager $wp_customize_manager Core customize manager.
39
	 */
40
	public function register_nudge( \WP_Customize_Manager $wp_customize_manager ) {
41
42
		$nudge = new CSS_Customizer_Nudge(
43
			$this->get_nudge_url(),
44
			__( 'Purchase a Business Plan to<br> activate CSS customization', 'jetpack' )
45
		);
46
47
		$wp_customize_manager->remove_control( 'custom_css' );
48
		$wp_customize_manager->remove_section( 'custom_css' );
49
50
		$nudge->customize_register_nudge( $wp_customize_manager );
51
	}
52
53
	/**
54
	 * Get the Nudge URL.
55
	 *
56
	 * @return string
57
	 */
58
	private function get_nudge_url() {
59
		return '/checkout/' . $this->domain . '/business';
60
	}
61
}
62