Code Duplication    Length = 43-43 lines in 2 locations

classes/stencil/config.php 2 locations

@@ 221-263 (lines=43) @@
218
	/**
219
	 * Install selected plugins
220
	 */
221
	public function maybe_install_plugins() {
222
		/**
223
		 * When a plugin can be updated; the field will be check on the settings
224
		 * When all plugins have been installed, they disappear from the list.
225
		 */
226
		$install_plugins = get_option( $this->option_name );
227
228
		if (
229
			empty( $install_plugins ) ||
230
			! isset( $install_plugins['plugin'] ) ||
231
			! is_array( $install_plugins['plugin'] )
232
		) {
233
			return;
234
		}
235
236
		printf( '<h2>%s</h2>', __( 'Installing plugins...', 'stencil' ) );
237
238
		foreach ( $install_plugins['plugin'] as $slug => $on ) {
239
240
			$installed = $this->install_plugin( $slug );
241
242
			if ( ! $installed ) {
243
				printf(
244
					'<em>%s</em><br>',
245
					sprintf(
246
						__( 'Plugin %s could not be installed!', 'stencil' ),
247
						$this->known_implementations[ $slug ]
248
					)
249
				);
250
			}
251
252
			unset( $install_plugins['plugin'][ $slug ] );
253
		}
254
255
		printf( '<b>%s</b>', __( 'Done.', 'stencil' ) );
256
257
		if ( empty( $install_plugins['plugin'] ) ) {
258
			unset( $install_plugins['plugin'] );
259
		}
260
261
		update_option( $this->option_name, $install_plugins );
262
263
	}
264
265
	/**
266
	 * Install selected themes
@@ 268-310 (lines=43) @@
265
	/**
266
	 * Install selected themes
267
	 */
268
	public function maybe_install_themes() {
269
		/**
270
		 * When a plugin can be updated; the field will be check on the settings
271
		 * When all plugins have been installed, they disappear from the list.
272
		 */
273
		$install_plugins = get_option( $this->option_name );
274
275
		if (
276
			empty( $install_plugins ) ||
277
			! isset( $install_plugins['theme'] ) ||
278
			! is_array( $install_plugins['theme'] )
279
		) {
280
			return;
281
		}
282
283
		printf( '<h2>%s</h2>', __( 'Installing themes...', 'stencil' ) );
284
285
		foreach ( $install_plugins['theme'] as $slug => $on ) {
286
287
			$installed = $this->install_theme( $slug );
288
289
			if ( ! $installed ) {
290
				printf(
291
					'<em>%s</em><br>',
292
					sprintf(
293
						__( 'Theme %s could not be installed!', 'stencil' ),
294
						$this->known_implementations[ $slug ]
295
					)
296
				);
297
			}
298
299
			unset( $install_plugins['theme'][ $slug ] );
300
		}
301
302
		printf( '<b>%s</b>', __( 'Done.', 'stencil' ) );
303
304
		if ( empty( $install_plugins['theme'] ) ) {
305
			unset( $install_plugins['theme'] );
306
		}
307
308
		update_option( $this->option_name, $install_plugins );
309
310
	}
311
312
	/**
313
	 * Install plugin by slug