Conditions | 3 |
Paths | 4 |
Total Lines | 51 |
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 |
||
20 | private function get_raw_messages() { |
||
21 | $button_caption = __( 'Set up Jetpack', 'jetpack' ); |
||
22 | /* Translators: placeholders are links. */ |
||
23 | $media_description = __( 'Click on the <strong>Set up Jetpack</strong> button to agree to our <a href="%1$s" target="_blank" rel="noopener noreferrer">Terms of Service</a> and to <a href="%2$s" target="_blank" rel="noopener noreferrer">share details</a> with WordPress.com, and gain access to Site Accelerator.', 'jetpack' ); |
||
24 | /* Translators: placeholders are links. */ |
||
25 | $widgets_description = __( 'Click on the <strong>Set up Jetpack</strong> button to agree to our <a href="%1$s" target="_blank" rel="noopener noreferrer">Terms of Service</a> and to <a href="%2$s" target="_blank" rel="noopener noreferrer">share details</a> with WordPress.com, and gain access to great additional widgets.', 'jetpack' ); |
||
26 | /* Translators: placeholders are links. */ |
||
27 | $posts_description = __( 'Click on the <strong>Set up Jetpack</strong> button to agree to our <a href="%1$s" target="_blank" rel="noopener noreferrer">Terms of Service</a> and to <a href="%2$s" target="_blank" rel="noopener noreferrer">share details</a> with WordPress.com, and gain access to in-depth stats about your site.', 'jetpack' ); |
||
28 | |||
29 | $messages = array( |
||
30 | array( |
||
31 | 'id' => 'jpsetup-upload', |
||
32 | 'message_path' => '/wp:upload:admin_notices/', |
||
33 | 'message' => __( 'Do you want lightning-fast images?', 'jetpack' ), |
||
34 | 'description' => $this->generate_description_with_tos( $media_description ), |
||
35 | 'button_caption' => $button_caption, |
||
36 | ), |
||
37 | array( |
||
38 | 'id' => 'jpsetup-widgets', |
||
39 | 'message_path' => '/wp:widgets:admin_notices/', |
||
40 | 'message' => __( 'Looking for even more widgets?', 'jetpack' ), |
||
41 | 'description' => $this->generate_description_with_tos( $widgets_description ), |
||
42 | 'button_caption' => $button_caption, |
||
43 | ), |
||
44 | ); |
||
45 | |||
46 | if ( wp_count_posts()->publish >= 5 ) { |
||
47 | $messages[] = array( |
||
48 | 'id' => 'jpsetup-posts', |
||
49 | 'message_path' => '/wp:edit-post:admin_notices/', |
||
50 | 'message' => __( 'Do you know which of these posts gets the most traffic?', 'jetpack' ), |
||
51 | 'description' => $this->generate_description_with_tos( $posts_description ), |
||
52 | 'button_caption' => $button_caption, |
||
53 | ); |
||
54 | } |
||
55 | |||
56 | foreach ( $messages as $key => $message ) { |
||
57 | /* |
||
58 | * Add Connect URL to each message, with from including jitm id. |
||
59 | */ |
||
60 | $jetpack_setup_url = $this->generate_admin_url( |
||
61 | array( |
||
62 | 'page' => 'jetpack#/setup', |
||
63 | 'from' => sprintf( 'pre-connection-jitm-%s', $message['id'] ), |
||
64 | ) |
||
65 | ); |
||
66 | $messages[ $key ]['button_link'] = $jetpack_setup_url; |
||
67 | } |
||
68 | |||
69 | return $messages; |
||
70 | } |
||
71 | |||
131 |