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