Conditions | 1 |
Paths | 1 |
Total Lines | 60 |
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 |
||
53 | public function render_ui() { |
||
54 | wp_localize_script( |
||
55 | 'wp-api', |
||
56 | 'wpApiSettings', |
||
57 | array( |
||
58 | 'root' => esc_url_raw( rest_url() ), |
||
59 | 'nonce' => wp_create_nonce( 'wp_rest' ), |
||
60 | ) |
||
61 | ); |
||
62 | |||
63 | ?> |
||
64 | <h1>REST API Tester</h1> |
||
65 | |||
66 | <div class="jetpack-debug-api-tester"> |
||
67 | <form method="post" id="jetpack-debug-api-tester-form"> |
||
68 | <div class="api-tester-block"> |
||
69 | <label for="api-tester-method">Method:</label> |
||
70 | <div class="api-tester-field"> |
||
71 | <select name="method" id="api-tester-method"> |
||
72 | <option value="get">GET</option> |
||
73 | <option value="post">POST</option> |
||
74 | <option value="put">PUT</option> |
||
75 | <option value="delete">DELETE</option> |
||
76 | </select> |
||
77 | </div> |
||
78 | </div> |
||
79 | |||
80 | <div class="api-tester-block"> |
||
81 | <label for="api-tester-url">REST Route:</label> |
||
82 | <div class="api-tester-field"> |
||
83 | <span class="rest-route-prefix">/jetpack/v4/</span> |
||
84 | <input type="text" name="url" class="input-url" id="api-tester-url"> |
||
85 | </div> |
||
86 | </div> |
||
87 | |||
88 | <div class="api-tester-block api-tester-filter-post block-hide"> |
||
89 | <label for="api-tester-content-type">Content-Type:</label> |
||
90 | <div class="api-tester-field"> |
||
91 | <select name="content-type" id="api-tester-content-type"> |
||
92 | <option name="application/json">application/json</option> |
||
93 | </select> |
||
94 | </div> |
||
95 | </div> |
||
96 | |||
97 | <div class="api-tester-block api-tester-filter-post block-hide"> |
||
98 | <label for="api-tester-body">Body:</label> |
||
99 | <div class="api-tester-field"> |
||
100 | <textarea name="body" id="api-tester-body"></textarea> |
||
101 | </div> |
||
102 | </div> |
||
103 | |||
104 | <div class="api-tester-block align-right"> |
||
105 | <button type="submit" class="button-right" id="api-tester-submit">Send</button> |
||
106 | </div> |
||
107 | |||
108 | <div id="api-tester-response" class="block-hide"></div> |
||
109 | </form> |
||
110 | </div> |
||
111 | <?php |
||
112 | } |
||
113 | |||
135 |