Conditions | 2 |
Paths | 2 |
Total Lines | 67 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
49 | function display_idc_notice() { |
||
50 | if ( ! $this->should_show_idc_notice() ) { |
||
51 | return; |
||
52 | } |
||
53 | |||
54 | $safe_mode_doc_link = 'https://jetpack.com/support/safe-mode'; |
||
55 | ?> |
||
56 | <div class="jp-idc notice notice-warning"> |
||
57 | <div class="jp-emblem"> |
||
58 | <?php echo Jetpack::get_jp_emblem(); ?> |
||
59 | </div> |
||
60 | <p class="msg-top"> |
||
61 | <?php esc_html_e( 'Jetpack Safe Mode.', 'jetpack' ); ?> |
||
62 | </p> |
||
63 | <hr /> |
||
64 | <div class="msg-bottom-head"> |
||
65 | <?php |
||
66 | echo wp_kses( |
||
67 | sprintf( |
||
68 | __( |
||
69 | 'Jetpack has been placed into <a href="%1$s">Safe mode</a> because we noticed this is an exact copy of %2$s. |
||
70 | Please confirm Safe Mode or fix the Jetpack connection. Select one of the options below or <a href="%1$s">learn |
||
71 | more about Safe Mode</a>.', |
||
72 | 'jetpack' |
||
73 | ), |
||
74 | esc_url( $safe_mode_doc_link ), |
||
75 | Jetpack::normalize_url_protocol_agnostic( esc_url_raw( self::$wpcom_home_url ) ) |
||
76 | ), |
||
77 | array( 'a' => array( 'href' => array() ) ) |
||
78 | ); |
||
79 | ?> |
||
80 | </div> |
||
81 | <div style="width: 49%; display: inline-block;"> |
||
82 | <?php |
||
83 | echo wp_kses( |
||
84 | sprintf( |
||
85 | __( |
||
86 | 'Is this website a temporary duplicate of <a href="%1$s">%2$s</a> for the purposes of testing, staging or development? If so, we recommend keeping it in Safe Mode.', |
||
87 | 'jetpack' |
||
88 | ), |
||
89 | esc_url( self::$wpcom_home_url ), |
||
90 | Jetpack::normalize_url_protocol_agnostic( esc_url_raw( self::$wpcom_home_url ) ) |
||
91 | ), |
||
92 | array( 'a' => array( 'href' => array() ) ) |
||
93 | ); |
||
94 | ?> |
||
95 | <button id="idc-confirm-safe-mode"><?php esc_html_e( 'Confirm Safe Mode' ); ?></button> |
||
96 | </div> |
||
97 | <div style="width: 49%; display: inline-block;"> |
||
98 | <?php |
||
99 | echo wp_kses( |
||
100 | sprintf( |
||
101 | __( |
||
102 | 'If this is a separate and new website, or the new home of <a href="%1$s">%2$s</a>, we recommend turning Safe Mode off, |
||
103 | and re-establishing your connection to WordPress.com.', |
||
104 | 'jetpack' |
||
105 | ), |
||
106 | esc_url( $safe_mode_doc_link ), |
||
107 | Jetpack::normalize_url_protocol_agnostic( esc_url_raw( self::$wpcom_home_url ) ) |
||
108 | ), |
||
109 | array( 'a' => array( 'href' => array() ) ) |
||
110 | ); |
||
111 | ?> |
||
112 | <button id="idc-fix-connection"><?php esc_html_e( "Fix Jetpack's Connection" ); ?></button> |
||
113 | </div> |
||
114 | </div> |
||
115 | <?php } |
||
116 | |||
152 |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.