Code Duplication    Length = 39-40 lines in 2 locations

includes/class-sensei-updates.php 2 locations

@@ 136-175 (lines=40) @@
133
            // Check for updates to run
134
            if (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) {
135
136
                foreach ($_POST['checked'] as $key => $function_name) {
137
138
                    if( ! isset(  $_POST[ $function_name.'_nonce_field' ] ) 
139
                        || ! wp_verify_nonce( $_POST[ $function_name.'_nonce_field' ] , 'run_'.$function_name ) ){
140
141
                        wp_die(
142
                            '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
143
                            '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>',
144
                            403
145
                        );
146
147
                    }
148
149
                    // Dynamic function call
150
                    if (method_exists($this, $function_name)) {
151
152
                        $done_processing = call_user_func_array(array($this, $function_name), array(50, $n));
153
154
                    } elseif ($this->function_in_whitelist($function_name)) {
155
156
                        $done_processing = call_user_func_array($function_name, array(50, $n));
157
158
                    } else {
159
160
                        _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
161
                        return;
162
163
                    }// End If Statement
164
165
                // Add to functions list get args
166
                if ('' == $functions_list) {
167
                    $functions_list .= $function_name;
168
                } else {
169
                    $functions_list .= '+' . $function_name;
170
                } // End If Statement
171
172
                // Mark update has having been run
173
                $this->set_update_run($function_name);
174
175
            } // End For Loop
176
177
        } // End If Statement
178
@@ 185-223 (lines=39) @@
182
            // Existing functions from GET variables instead of POST
183
            $functions_array = $_GET['functions'];
184
185
            foreach ($functions_array as $key => $function_name) {
186
187
                if( ! isset( $_GET[ $function_name.'_nonce' ] )
188
                    || ! wp_verify_nonce( $_GET[ $function_name.'_nonce' ] , 'run_'.$function_name ) ){
189
190
                    wp_die(
191
                        '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
192
                        '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>',
193
                        403
194
                    );
195
196
                }
197
198
                // Dynamic function call
199
                if (method_exists($this, $function_name)) {
200
201
                    $done_processing = call_user_func_array(array($this, $function_name), array(50, $n));
202
203
                } elseif ($this->function_in_whitelist($function_name)) {
204
205
                    $done_processing = call_user_func_array($function_name, array(50, $n));
206
207
                } else {
208
209
                    _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
210
                    return;
211
212
                } // End If Statement
213
214
                // Add to functions list get args
215
                if ('' == $functions_list) {
216
                    $functions_list .= $function_name;
217
                } else {
218
                    $functions_list .= '+' . $function_name;
219
                } // End If Statement
220
221
                $this->set_update_run($function_name);
222
223
            } // End For Loop
224
225
        } // End If Statement
226