Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 29 |
Lines | 52 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
19 | View Code Duplication | static function dashboard_ui() { |
|
20 | $strings = json_encode( array( |
||
21 | 'WAITING' => array( |
||
22 | 'action' => __( 'Refresh Status', 'jetpack' ), |
||
23 | 'status' => __( 'Indexing request queued and waiting…', 'jetpack' ), |
||
24 | ), |
||
25 | 'INDEXING' => array( |
||
26 | 'action' => __( 'Refresh Status', 'jetpack' ), |
||
27 | 'status' => __( 'Indexing posts', 'jetpack' ), |
||
28 | ), |
||
29 | 'DONE' => array( |
||
30 | 'action' => __( 'Reindex Posts', 'jetpack' ), |
||
31 | 'status' => __( 'Posts indexed.', 'jetpack' ), |
||
32 | ), |
||
33 | 'ERROR' => array( |
||
34 | 'action' => __( 'Refresh Status', 'jetpack' ), |
||
35 | 'status' => __( 'Status unknown.', 'jetpack' ), |
||
36 | ), |
||
37 | 'ERROR:LARGE' => array( |
||
38 | 'action' => __( 'Refresh Status', 'jetpack' ), |
||
39 | 'status' => __( 'This site is too large, please contact Jetpack support to sync.', 'jetpack' ), |
||
40 | ), |
||
41 | ) ); |
||
42 | |||
43 | wp_enqueue_script( |
||
44 | 'jetpack_sync_reindex_control', |
||
45 | plugins_url( '_inc/jquery.jetpack-sync.js', JETPACK__PLUGIN_FILE ), |
||
46 | array( 'jquery' ), |
||
47 | JETPACK__VERSION |
||
48 | ); |
||
49 | |||
50 | // $template = <<<EOT |
||
51 | // <p class="jetpack_sync_reindex_control" id="jetpack_sync_reindex_control" data-strings="%s"> |
||
52 | // <input type="submit" class="jetpack_sync_reindex_control_action button" value="%s" disabled /> |
||
53 | // <span class="jetpack_sync_reindex_control_status">…</span> |
||
54 | // </p> |
||
55 | // EOT; |
||
56 | |||
57 | $template = <<<EOT |
||
58 | <p class="jetpack_sync_reindex_control" id="jetpack_sync_reindex_control" data-strings="%s"> |
||
59 | This is a test |
||
60 | <input type="submit" class="jetpack_sync_reindex_control_action button" value="%s" disabled /> |
||
61 | <span class="jetpack_sync_reindex_control_status">…</span> |
||
62 | </p> |
||
63 | EOT; |
||
64 | |||
65 | return sprintf( |
||
66 | $template, |
||
67 | esc_attr( $strings ), |
||
68 | esc_attr__( 'Refresh Status', 'jetpack' ) |
||
69 | ); |
||
70 | } |
||
71 | |||
73 |