| Conditions | 5 |
| Paths | 16 |
| Total Lines | 59 |
| 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 |
||
| 32 | public function edit_screen() { |
||
| 33 | if ( ! current_user_can( 'manage_options' ) ) { |
||
| 34 | wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) ); |
||
| 35 | } |
||
| 36 | |||
| 37 | $suffix = SCRIPT_DEBUG ? '' : '.min'; |
||
| 38 | |||
| 39 | wp_register_script( 'tabify-edit-screen-admin', plugins_url( '/js/admin' . $suffix . '.js', dirname( __FILE__ ) ), array( 'jquery', 'wp-backbone', 'jquery-ui-sortable', 'jquery-touch-punch' ), '1.0' ); |
||
| 40 | wp_enqueue_script( 'tabify-edit-screen-admin' ); |
||
| 41 | |||
| 42 | $data = array( |
||
| 43 | 'remove' => __( 'Remove', 'tabify-edit-screen' ), |
||
| 44 | 'cancel' => __( 'Cancel', 'tabify-edit-screen' ), |
||
| 45 | 'move_meta_boxes' => __( 'Move meta boxes to', 'tabify-edit-screen' ) |
||
| 46 | ); |
||
| 47 | wp_localize_script( 'tabify-edit-screen-admin', 'tabify_l10', $data ); |
||
| 48 | |||
| 49 | echo '<div class="wrap">'; |
||
| 50 | echo '<h1>' . esc_html( get_admin_page_title() ) . '</h1>'; |
||
| 51 | |||
| 52 | echo '<form id="tabify-form" method="post">'; |
||
| 53 | wp_nonce_field( plugin_basename( __FILE__ ), 'tabify_edit_screen_nonce' ); |
||
| 54 | |||
| 55 | echo '<input type="hidden" id="tabify_edit_screen_nojs" name="tabify_edit_screen_nojs" value="1" />'; |
||
| 56 | |||
| 57 | $tabs = array( |
||
| 58 | 'posttypes' => array( |
||
| 59 | 'title' => __('Post types', 'tabify-edit-screen' ), |
||
| 60 | 'class' => 'Tabify_Edit_Screen_Settings_Posttypes' |
||
| 61 | ) |
||
| 62 | ); |
||
| 63 | $tabs = apply_filters( 'tabify_settings_tabs', $tabs ); |
||
| 64 | |||
| 65 | $this->tabs = new Tabify_Edit_Screen_Tabs( $tabs, 'horizontal', 'tab', false ); |
||
| 66 | |||
| 67 | if ( count( $tabs ) > 1 ) { |
||
| 68 | echo $this->tabs->get_tabs_with_container(); |
||
| 69 | } |
||
| 70 | |||
| 71 | if ( isset( $tabs[ $this->tabs->get_current_tab() ] ) ) { |
||
| 72 | $class_name = $tabs[ $this->tabs->get_current_tab() ]['class']; |
||
| 73 | $settings_screen = new $class_name(); |
||
| 74 | |||
| 75 | $this->update_settings(); |
||
| 76 | |||
| 77 | echo '<div id="tabify-settings">'; |
||
| 78 | echo '<div id="tabify-submenu">'; |
||
| 79 | echo $settings_screen->get_sections_menu(); |
||
| 80 | echo '</div>'; |
||
| 81 | |||
| 82 | echo '<div id="tabifyboxes">'; |
||
| 83 | echo $settings_screen->get_sections_box(); |
||
| 84 | echo '</div>'; |
||
| 85 | echo '</div>'; |
||
| 86 | |||
| 87 | echo '</form>'; |
||
| 88 | echo '</div>'; |
||
| 89 | } |
||
| 90 | } |
||
| 91 | |||
| 117 |