Conditions | 12 |
Paths | 128 |
Total Lines | 107 |
Code Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Changes | 5 | ||
Bugs | 1 | Features | 2 |
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 | function page_render() { |
||
21 | $list_table = new Jetpack_Modules_List_Table; |
||
22 | $static_html = file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static.html' ); |
||
23 | $noscript_notice = file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-noscript-notice.html' ); |
||
24 | $version_notice = file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-version-notice.html' ); |
||
25 | |||
26 | $noscript_notice = str_replace( |
||
27 | '#HEADER_TEXT#', |
||
28 | esc_html( __( 'You have JavaScript disabled', 'jetpack' ) ), |
||
29 | $noscript_notice |
||
30 | ); |
||
31 | $noscript_notice = str_replace( |
||
32 | '#TEXT#', |
||
33 | esc_html( __( "Turn on JavaScript to unlock Jetpack's full potential!", 'jetpack' ) ), |
||
34 | $noscript_notice |
||
35 | ); |
||
36 | |||
37 | $version_notice = str_replace( |
||
38 | '#HEADER_TEXT#', |
||
39 | esc_html( __( 'You are using an outdated version of WordPress', 'jetpack' ) ), |
||
40 | $version_notice |
||
41 | ); |
||
42 | $version_notice = str_replace( |
||
43 | '#TEXT#', |
||
44 | esc_html( __( "Update WordPress to unlock Jetpack's full potential!", 'jetpack' ) ), |
||
45 | $version_notice |
||
46 | ); |
||
47 | |||
48 | ob_start(); |
||
49 | |||
50 | $this->admin_page_top(); |
||
51 | |||
52 | if ( $this->is_wp_version_too_old() ) { |
||
53 | echo $version_notice; |
||
54 | } |
||
55 | echo $noscript_notice; |
||
56 | ?> |
||
57 | |||
58 | <div class="page-content configure"> |
||
59 | <div class="frame top hide-if-no-js"> |
||
60 | <div class="wrap"> |
||
61 | <div class="manage-left"> |
||
62 | <table class="table table-bordered fixed-top"> |
||
63 | <thead> |
||
64 | <tr> |
||
65 | <th class="check-column"><input type="checkbox" class="checkall"></th> |
||
66 | <th colspan="2"> |
||
67 | <?php $list_table->unprotected_display_tablenav( 'top' ); ?> |
||
68 | <span class="filter-search"> |
||
69 | <button type="button" class="button">Filter</button> |
||
70 | </span> |
||
71 | </th> |
||
72 | </tr> |
||
73 | </thead> |
||
74 | </table> |
||
75 | </div> |
||
76 | </div><!-- /.wrap --> |
||
77 | </div><!-- /.frame --> |
||
78 | <div class="frame bottom"> |
||
79 | <div class="wrap"> |
||
80 | <div class="manage-right" style="display: none;"> |
||
81 | <div class="bumper"> |
||
82 | <form class="navbar-form" role="search"> |
||
83 | <input type="hidden" name="page" value="jetpack_modules" /> |
||
84 | <?php $list_table->search_box( __( 'Search', 'jetpack' ), 'srch-term' ); ?> |
||
85 | <p><?php esc_html_e( 'View:', 'jetpack' ); ?></p> |
||
86 | <div class="button-group filter-active"> |
||
87 | <button type="button" class="button <?php if ( empty( $_GET['activated'] ) ) echo 'active'; ?>"><?php esc_html_e( 'All', 'jetpack' ); ?></button> |
||
88 | <button type="button" class="button <?php if ( ! empty( $_GET['activated'] ) && 'true' == $_GET['activated'] ) echo 'active'; ?>" data-filter-by="activated" data-filter-value="true"><?php esc_html_e( 'Active', 'jetpack' ); ?></button> |
||
89 | <button type="button" class="button <?php if ( ! empty( $_GET['activated'] ) && 'false' == $_GET['activated'] ) echo 'active'; ?>" data-filter-by="activated" data-filter-value="false"><?php esc_html_e( 'Inactive', 'jetpack' ); ?></button> |
||
90 | </div> |
||
91 | <p><?php esc_html_e( 'Sort by:', 'jetpack' ); ?></p> |
||
92 | <div class="button-group sort"> |
||
93 | <button type="button" class="button <?php if ( empty( $_GET['sort_by'] ) ) echo 'active'; ?>" data-sort-by="name"><?php esc_html_e( 'Alphabetical', 'jetpack' ); ?></button> |
||
94 | <button type="button" class="button <?php if ( ! empty( $_GET['sort_by'] ) && 'introduced' == $_GET['sort_by'] ) echo 'active'; ?>" data-sort-by="introduced" data-sort-order="reverse"><?php esc_html_e( 'Newest', 'jetpack' ); ?></button> |
||
95 | <button type="button" class="button <?php if ( ! empty( $_GET['sort_by'] ) && 'sort' == $_GET['sort_by'] ) echo 'active'; ?>" data-sort-by="sort"><?php esc_html_e( 'Popular', 'jetpack' ); ?></button> |
||
96 | </div> |
||
97 | <p><?php esc_html_e( 'Show:', 'jetpack' ); ?></p> |
||
98 | <?php $list_table->views(); ?> |
||
99 | </form> |
||
100 | </div> |
||
101 | </div> |
||
102 | <div class="manage-left" style="width: 100%;"> |
||
103 | <form class="jetpack-modules-list-table-form" onsubmit="return false;"> |
||
104 | <table class="<?php echo implode( ' ', $list_table->get_table_classes() ); ?>"> |
||
105 | <tbody id="the-list"> |
||
106 | <?php $list_table->display_rows_or_placeholder(); ?> |
||
107 | </tbody> |
||
108 | </table> |
||
109 | </form> |
||
110 | </div> |
||
111 | </div><!-- /.wrap --> |
||
112 | </div><!-- /.frame --> |
||
113 | </div><!-- /.content --> |
||
114 | <?php |
||
115 | |||
116 | $this->admin_page_bottom(); |
||
117 | |||
118 | $page_content = ob_get_contents(); |
||
119 | ob_end_clean(); |
||
120 | |||
121 | echo str_replace( |
||
122 | '<div id="jetpack-static-container"></div>', |
||
123 | $page_content, |
||
124 | $static_html |
||
125 | ); |
||
126 | } |
||
127 | |||
135 |