| Conditions | 2 |
| Paths | 2 |
| Total Lines | 53 |
| 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 |
||
| 50 | public function add_fab_icon() { |
||
| 51 | |||
| 52 | if ( wp_doing_ajax() ) { |
||
| 53 | return; |
||
| 54 | } |
||
| 55 | |||
| 56 | $svg_allowed = array( |
||
| 57 | 'svg' => array( |
||
| 58 | 'id' => true, |
||
| 59 | 'class' => true, |
||
| 60 | 'aria-hidden' => true, |
||
| 61 | 'aria-labelledby' => true, |
||
| 62 | 'role' => true, |
||
| 63 | 'xmlns' => true, |
||
| 64 | 'width' => true, |
||
| 65 | 'height' => true, |
||
| 66 | 'viewbox' => true, // <= Must be lower case! |
||
| 67 | ), |
||
| 68 | 'g' => array( 'fill' => true ), |
||
| 69 | 'title' => array( 'title' => true ), |
||
| 70 | 'path' => array( |
||
| 71 | 'd' => true, |
||
| 72 | 'fill' => true, |
||
| 73 | ), |
||
| 74 | ); |
||
| 75 | |||
| 76 | $gridicon_help = file_get_contents( __DIR__ . '/gridicon-help.svg', true ); |
||
| 77 | |||
| 78 | // Add tracking data to link to be picked up by Calypso for GA and Tracks usage. |
||
| 79 | $tracking_href = add_query_arg( |
||
| 80 | array( |
||
| 81 | 'utm_source' => 'wp_admin', |
||
| 82 | 'utm_medium' => 'other', |
||
| 83 | 'utm_content' => 'jetpack_masterbar_inline_help_click', |
||
| 84 | 'flags' => 'a8c-analytics.on', |
||
| 85 | ), |
||
| 86 | 'https://wordpress.com/help' |
||
| 87 | ); |
||
| 88 | |||
| 89 | // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped |
||
| 90 | // We trust that output in the template has been escaped. |
||
| 91 | echo load_template( |
||
| 92 | __DIR__ . '/inline-help-template.php', |
||
| 93 | true, |
||
| 94 | array( |
||
| 95 | 'href' => $tracking_href, |
||
| 96 | 'icon' => $gridicon_help, |
||
| 97 | 'svg_allowed' => $svg_allowed, |
||
| 98 | ) |
||
| 99 | ); |
||
| 100 | // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped |
||
| 101 | |||
| 102 | } |
||
| 103 | |||
| 113 |