| Conditions | 13 |
| Paths | 129 |
| Total Lines | 131 |
| Code Lines | 67 |
| 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 | function page_render() { |
||
| 21 | $list_table = new Jetpack_Modules_List_Table; |
||
| 22 | |||
| 23 | $static_html = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static.html' ); |
||
| 24 | |||
| 25 | // If static.html isn't there, there's nothing else we can do. |
||
| 26 | if ( false === $static_html ) { |
||
| 27 | esc_html_e( 'Error fetching static.html.', 'jetpack' ); |
||
| 28 | return; |
||
| 29 | } |
||
| 30 | |||
| 31 | // We have static.html so let's continue trying to fetch the others |
||
| 32 | $noscript_notice = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-noscript-notice.html' ); |
||
| 33 | $version_notice = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-version-notice.html' ); |
||
| 34 | $ie_notice = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-ie-notice.html' ); |
||
| 35 | |||
| 36 | $noscript_notice = str_replace( |
||
| 37 | '#HEADER_TEXT#', |
||
| 38 | esc_html( __( 'You have JavaScript disabled', 'jetpack' ) ), |
||
| 39 | $noscript_notice |
||
| 40 | ); |
||
| 41 | $noscript_notice = str_replace( |
||
| 42 | '#TEXT#', |
||
| 43 | esc_html( __( "Turn on JavaScript to unlock Jetpack's full potential!", 'jetpack' ) ), |
||
| 44 | $noscript_notice |
||
| 45 | ); |
||
| 46 | |||
| 47 | $version_notice = str_replace( |
||
| 48 | '#HEADER_TEXT#', |
||
| 49 | esc_html( __( 'You are using an outdated version of WordPress', 'jetpack' ) ), |
||
| 50 | $version_notice |
||
| 51 | ); |
||
| 52 | $version_notice = str_replace( |
||
| 53 | '#TEXT#', |
||
| 54 | esc_html( __( "Update WordPress to unlock Jetpack's full potential!", 'jetpack' ) ), |
||
| 55 | $version_notice |
||
| 56 | ); |
||
| 57 | |||
| 58 | $ie_notice = str_replace( |
||
| 59 | '#HEADER_TEXT#', |
||
| 60 | esc_html( __( 'You are using an unsupported browser version.', 'jetpack' ) ), |
||
| 61 | $ie_notice |
||
| 62 | ); |
||
| 63 | $ie_notice = str_replace( |
||
| 64 | '#TEXT#', |
||
| 65 | esc_html( __( "Update your browser to unlock Jetpack's full potential!", 'jetpack' ) ), |
||
| 66 | $ie_notice |
||
| 67 | ); |
||
| 68 | |||
| 69 | ob_start(); |
||
| 70 | |||
| 71 | $this->admin_page_top(); |
||
| 72 | |||
| 73 | if ( $this->is_wp_version_too_old() ) { |
||
| 74 | echo $version_notice; |
||
| 75 | } |
||
| 76 | echo $noscript_notice; |
||
| 77 | echo $ie_notice; |
||
| 78 | ?> |
||
| 79 | |||
| 80 | <div class="page-content configure"> |
||
| 81 | <div class="frame top hide-if-no-js"> |
||
| 82 | <div class="wrap"> |
||
| 83 | <div class="manage-left"> |
||
| 84 | <table class="table table-bordered fixed-top"> |
||
| 85 | <thead> |
||
| 86 | <tr> |
||
| 87 | <th class="check-column"><input type="checkbox" class="checkall"></th> |
||
| 88 | <th colspan="2"> |
||
| 89 | <?php $list_table->unprotected_display_tablenav( 'top' ); ?> |
||
| 90 | <span class="filter-search"> |
||
| 91 | <button type="button" class="button">Filter</button> |
||
| 92 | </span> |
||
| 93 | </th> |
||
| 94 | </tr> |
||
| 95 | </thead> |
||
| 96 | </table> |
||
| 97 | </div> |
||
| 98 | </div><!-- /.wrap --> |
||
| 99 | </div><!-- /.frame --> |
||
| 100 | <div class="frame bottom"> |
||
| 101 | <div class="wrap"> |
||
| 102 | <div class="manage-right" style="display: none;"> |
||
| 103 | <div class="bumper"> |
||
| 104 | <form class="navbar-form" role="search"> |
||
| 105 | <input type="hidden" name="page" value="jetpack_modules" /> |
||
| 106 | <?php $list_table->search_box( __( 'Search', 'jetpack' ), 'srch-term' ); ?> |
||
| 107 | <p><?php esc_html_e( 'View:', 'jetpack' ); ?></p> |
||
| 108 | <div class="button-group filter-active"> |
||
| 109 | <button type="button" class="button <?php if ( empty( $_GET['activated'] ) ) echo 'active'; ?>"><?php esc_html_e( 'All', 'jetpack' ); ?></button> |
||
| 110 | <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> |
||
| 111 | <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> |
||
| 112 | </div> |
||
| 113 | <p><?php esc_html_e( 'Sort by:', 'jetpack' ); ?></p> |
||
| 114 | <div class="button-group sort"> |
||
| 115 | <button type="button" class="button <?php if ( empty( $_GET['sort_by'] ) ) echo 'active'; ?>" data-sort-by="name"><?php esc_html_e( 'Alphabetical', 'jetpack' ); ?></button> |
||
| 116 | <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> |
||
| 117 | <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> |
||
| 118 | </div> |
||
| 119 | <p><?php esc_html_e( 'Show:', 'jetpack' ); ?></p> |
||
| 120 | <?php $list_table->views(); ?> |
||
| 121 | </form> |
||
| 122 | </div> |
||
| 123 | </div> |
||
| 124 | <div class="manage-left" style="width: 100%;"> |
||
| 125 | <form class="jetpack-modules-list-table-form" onsubmit="return false;"> |
||
| 126 | <table class="<?php echo implode( ' ', $list_table->get_table_classes() ); ?>"> |
||
| 127 | <tbody id="the-list"> |
||
| 128 | <?php $list_table->display_rows_or_placeholder(); ?> |
||
| 129 | </tbody> |
||
| 130 | </table> |
||
| 131 | </form> |
||
| 132 | </div> |
||
| 133 | </div><!-- /.wrap --> |
||
| 134 | </div><!-- /.frame --> |
||
| 135 | </div><!-- /.content --> |
||
| 136 | <?php |
||
| 137 | |||
| 138 | $this->admin_page_bottom(); |
||
| 139 | |||
| 140 | $page_content = ob_get_contents(); |
||
| 141 | ob_end_clean(); |
||
| 142 | |||
| 143 | echo str_replace( |
||
| 144 | '<div class="jp-loading-placeholder"><span class="dashicons dashicons-wordpress-alt"></span></div>', |
||
| 145 | $page_content, |
||
| 146 | $static_html |
||
| 147 | ); |
||
| 148 | |||
| 149 | JetpackTracking::record_user_event( 'wpa_page_view', array( 'path' => 'old_settings' ) ); |
||
| 150 | } |
||
| 151 | |||
| 168 |