Completed
Pull Request — develop (#1350)
by Naveen
03:09
created

Import_Videos_Page   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 56
loc 56
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A admin_menu() 11 11 1
A render() 31 31 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Wordlift\Videoobject\Pages;
4
5 View Code Duplication
class Import_Videos_Page {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
6
7
	/**
8
	 * Sync_Page constructor.
9
	 */
10
	public function __construct() {
11
12
		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
13
14
	}
15
16
	public function admin_menu() {
17
18
		add_submenu_page( 'wl_admin_menu',
19
            __( 'Import all videos', 'wordlift' ),
20
            __( 'Import all videos', 'wordlift' ),
21
            'manage_options', 'wl_videos_import', array(
22
			$this,
23
			'render'
24
		) );
25
26
	}
27
28
	public function render() {
29
30
		wp_enqueue_style(
31
			'wl-tasks-page',
32
			plugin_dir_url( dirname( __FILE__ ) ) . 'tasks/admin/assets/tasks-page.css',
33
			array(),
34
			\Wordlift::get_instance()->get_version(),
35
			'all' );
36
		wp_enqueue_script(
37
			'wl-dataset-sync-page',
38
			plugin_dir_url( __FILE__ ) . 'assets/videoobject-import-page.js',
39
			array( 'wp-api' ),
40
			\Wordlift::get_instance()->get_version() );
41
42
		?>
43
        <div class="wrap">
44
            <h2><?php esc_html_e( 'Import all videos', 'wordlift' ); ?></h2>
45
46
            <div class="wl-task__progress" style="border: 1px solid #23282D; height: 20px; margin: 8px 0;">
47
                <div class="wl-task__progress__bar"
48
                     style="width:0;background: #0073AA; text-align: center; height: 100%; color: #fff;"></div>
49
            </div>
50
51
            <button id="wl-start-btn" type="button" class="button button-large button-primary"><?php
52
				esc_html_e( 'Start', 'wordlift' ); ?></button>
53
            <button id="wl-stop-btn" type="button" class="button button-large button-primary hidden"><?php
54
				esc_html_e( 'Stop', 'wordlift' ); ?></button>
55
56
        </div>
57
		<?php
58
	}
59
60
}