| Conditions | 7 |
| Paths | 13 |
| Total Lines | 68 |
| 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 |
||
| 88 | protected function inline_thickbox_html( $echo = true, array $data = [] ) { |
||
| 89 | if ( ! isset( $data['msls_import'] ) ) { |
||
| 90 | return ''; |
||
| 91 | } |
||
| 92 | |||
| 93 | $slug = str_replace( '|', '-', $data['msls_import'] ); |
||
| 94 | |||
| 95 | ob_start(); |
||
| 96 | ?> |
||
| 97 | <div style="display: none;" id="msls-import-dialog-<?php echo esc_attr( $slug ) ?>"> |
||
| 98 | <h3><?php esc_html_e( 'Select what should be imported and how', 'multisite-language-switcher' ) ?></h3> |
||
| 99 | |||
| 100 | <form action="<?php echo add_query_arg( [] ) ?>" method="post"> |
||
| 101 | |||
| 102 | <?php wp_nonce_field( MslsPlugin::path(), 'msls_noncename' ); ?> |
||
| 103 | |||
| 104 | <?php foreach ( $data as $key => $value ) : ?> |
||
| 105 | <input type="hidden" name="<?php echo esc_attr( $key ) ?>" value="<?php echo esc_attr( $value ) ?>"> |
||
| 106 | <?php endforeach; ?> |
||
| 107 | |||
| 108 | <?php /** @var ImportersFactory $factory */ |
||
| 109 | foreach ( Map::instance()->factories() as $slug => $factory ) : ?> |
||
| 110 | <?php $details = $factory->details() ?> |
||
| 111 | <h4><?php echo esc_html( $details->name ) ?></h4> |
||
| 112 | <?php if ( empty( $details->importers ) ) : ?> |
||
| 113 | <p><?php esc_html_e( 'No importers available for this type of content.', 'multisite-language-switcher' ) ?></p> |
||
| 114 | <?php else: ?> |
||
| 115 | <ul> |
||
| 116 | <li> |
||
| 117 | <label> |
||
| 118 | <input type="radio" name="msls_importers[<?php echo esc_attr( $details->slug ) ?>]"> |
||
| 119 | <?php esc_html_e( 'Off - Do not import this type of content in the destination post.', 'multisite-language-switcher' ) ?> |
||
| 120 | </label> |
||
| 121 | </li> |
||
| 122 | <?php foreach ( $details->importers as $importer_slug => $importer_info ) : ?> |
||
| 123 | <li> |
||
| 124 | <label> |
||
| 125 | <input type="radio" name="msls_importers[<?php echo esc_attr( $details->slug ) ?>]" |
||
| 126 | value="<?php echo esc_attr( $importer_slug ) ?>" |
||
| 127 | <?php checked( $details->selected, $importer_slug ) ?> |
||
| 128 | > |
||
| 129 | <?php echo( esc_html( sprintf( '%s - %s', $importer_info->name, $importer_info->description ) ) ) ?> |
||
| 130 | </label> |
||
| 131 | </li> |
||
| 132 | <?php endforeach; ?> |
||
| 133 | </ul> |
||
| 134 | <?php endif; ?> |
||
| 135 | <?php endforeach; ?> |
||
| 136 | |||
| 137 | <div> |
||
| 138 | <input |
||
| 139 | type="submit" |
||
| 140 | class="button button-primary" |
||
| 141 | value="<?php esc_html_e( 'Import Content', 'multisite-language-switcher' ) ?>" |
||
| 142 | > |
||
| 143 | </div> |
||
| 144 | </form> |
||
| 145 | </div> |
||
| 146 | |||
| 147 | <?php |
||
| 148 | $html = ob_get_clean(); |
||
| 149 | |||
| 150 | if ( $echo ) { |
||
| 151 | echo $html; |
||
| 152 | } |
||
| 153 | |||
| 154 | return $html; |
||
| 155 | } |
||
| 156 | } |
||
| 157 |