Completed
Push — master ( 02b793...7006ed )
by Warwick
10:41 queued 02:31
created

Welcome::destination_block()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 15
loc 15
rs 9.7666
c 0
b 0
f 0
1
<?php
2
/**
3
 * The Welcome Screen for the Importer Plugin
4
 *
5
 * @package   wetu_importer
6
 * @author    LightSpeed
7
 * @license   GPL-2.0+
8
 * @link
9
 * @copyright 2019 LightSpeed
10
 **/
11
12
namespace wetu_importer\classes;
13
14
/**
15
 * The Welcome Screen for the Importer Plugin
16
 */
17
class Welcome {
18
19
	/**
20
	 * Holds instance of the class
21
	 *
22
	 * @var object
23
	 */
24
	private static $instance;
25
26
	/**
27
	 * Initialize the plugin by setting localization, filters, and administration functions.
28
	 *
29
	 * @since 1.0.0
30
	 *
31
	 * @access private
32
	 */
33
	public function __construct() {
34
	}
35
36
	/**
37
	 * Return an instance of this class.
38
	 *
39
	 * @return  object
40
	 */
41
	public static function get_instance() {
42
		// If the single instance hasn't been set, set it now.
43
		if ( ! isset( self::$instance ) ) {
44
			self::$instance = new self();
45
		}
46
		return self::$instance;
47
	}
48
49
	/**
50
	 * Display the importer welcome screen
51
	 */
52
	public function display_page() {
53
		?>
54
		<div class="row section">
55
			<h1><?php esc_html_e( 'Welcome to the LSX Wetu Importer', 'wetu-importer' ); ?></h1>
56
			<p><?php esc_html_e( 'If this is the first time running the import, please follow the steps below.', 'wetu-importer' ); ?></p>
57
		</div>
58
		<?php
59
		$this->importer_steps();
60
		$this->welcome_blocks();
61
	}
62
63
	/**
64
	 * Undocumented function
65
	 *
66
	 * @return void
67
	 */
68
	public function importer_steps() {
69
		?>
70
		<div class="row section postbox">
71
			<div class="welcome-block-header">
72
				<p class="heading"><?php esc_html_e( 'Import your tours', 'wetu-importer' ); ?></p>
73
				<p class="value"><span>1</span></p>
74
			</div>
75
			<div class="welcome-block-header">
76
				<p class="heading"><?php esc_html_e( 'Import accommodation', 'wetu-importer' ); ?></p>
77
				<p class="value"><span>2</span></p>
78
			</div>
79
			<div class="welcome-block-header">
80
				<p class="heading"><?php esc_html_e( 'Import destination', 'wetu-importer' ); ?></p>
81
				<p class="value"><span>3</span></p>
82
			</div>
83
			<div class="welcome-block-header">
84
				<p class="heading"><?php esc_html_e( 'Done', 'wetu-importer' ); ?></p>
85
				<p class="value"><span class="dashicons dashicons-yes"></span></p>
86
			</div>
87
			<div class="spacer"></div>
88
		</div>
89
		<?php
90
	}
91
92
	/**
93
	 * Outputs the welcome blocks on the welcome screen
94
	 *
95
	 * @return void
96
	 */
97
	public function welcome_blocks() {
98
		?>
99
		<div class="row section">
100
			<div class="welcome-block postbox">
101
				<?php $this->tour_block(); ?>
102
			</div>
103
			<div class="welcome-block postbox">
104
				<?php $this->accommodation_block(); ?>
105
			</div>
106
			<div class="welcome-block postbox">
107
				<?php $this->destination_block(); ?>
108
			</div>
109
			<div class="welcome-block postbox">
110
				<?php $this->end_block(); ?>
111
			</div>
112
		</div>
113
		<?php
114
	}
115
116
	/**
117
	 * Outputs the Tour Block.
118
	 * 
119
	 * @return void
120
	 */
121
	public function tour_block() {
122
		?>
123
			<h2 class="title"><?php esc_html_e( 'Importing tours', 'wetu-importer' ); ?></h2>
124
			<p class="excerpt"><?php esc_html_e( 'Search for tours, select the ones you want to import and choose the data you want to sync on import. All connected accommodadtions will be imported as drafts to be pubished after completing the tour import.', 'wetu-importer' ); ?></p>
125
			<p><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=tour' ); ?>" class="button button-primary"><?php esc_html_e( 'Import Tours', 'wetu-importer' ); ?></a></p>
126
			<p>
127
				<ul class="link-list">
128
					<li><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=tour' ); ?>#publish"><?php esc_html_e( 'Published', 'wetu-importer' ); ?>  (<?php echo esc_attr( \wetu_importer\includes\helpers\get_post_count( 'tour', 'publish ' ) ); ?>)</a></li>
129
					<li><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=tour' ); ?>#pending"><?php esc_html_e( 'Pending', 'wetu-importer' ); ?>  (<?php echo esc_attr( \wetu_importer\includes\helpers\get_post_count( 'tour', 'pending ' ) ); ?>)</a></li>
130
					<li><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=tour' ); ?>#draft"><?php esc_html_e( 'Draft', 'wetu-importer' ); ?>  (<?php echo esc_attr( \wetu_importer\includes\helpers\get_post_count( 'tour', 'draft ' ) ); ?>)</a></li>
131
				</ul>
132
			</p>			
133
		<?php
134
	}
135
	/**
136
	 * Outputs the Accommodation Block.
137
	 *
138
	 * @return void
139
	 */
140 View Code Duplication
	public function accommodation_block() {
0 ignored issues
show
Duplication introduced by
This method 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...
141
		?>
142
			<h2 class="title"><?php esc_html_e( 'Import and publish accommodation', 'wetu-importer' ); ?></h2>
143
			<p class="excerpt"><?php esc_html_e( 'All accommodations connnected to your tours have been imported as drafts. Review the imported accommodations, sync selected data and publish.', 'wetu-importer' ); ?></p>
144
			<p><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=accommodation' ); ?>" class="button button-primary"><?php esc_html_e( 'Sync accommodation', 'wetu-importer' ); ?></a></p>
145
146
			<p>
147
				<ul class="link-list">
148
					<li><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=accommodation' ); ?>#publish"><?php esc_html_e( 'Published', 'wetu-importer' ); ?> (<?php echo esc_attr( \wetu_importer\includes\helpers\get_post_count( 'accommodation', 'publish ' ) ); ?>)</a></li>
149
					<li><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=accommodation' ); ?>#pending"><?php esc_html_e( 'Pending', 'wetu-importer' ); ?> (<?php echo esc_attr( \wetu_importer\includes\helpers\get_post_count( 'accommodation', 'pending ' ) ); ?>)</a></li>
150
					<li><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=accommodation' ); ?>#draft"><?php esc_html_e( 'Draft', 'wetu-importer' ); ?> (<?php echo esc_attr( \wetu_importer\includes\helpers\get_post_count( 'accommodation', 'draft ' ) ); ?>)</a></li>
151
					<li><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=accommodation' ); ?>#import"><?php esc_html_e( 'Wetu Queue', 'wetu-importer' ); ?>  (<?php echo esc_attr( \wetu_importer\includes\helpers\get_wetu_queue_count( 'accommodation' ) ); ?>)</a></li>
152
				</ul>
153
			</p>			
154
		<?php
155
	}
156
	/**
157
	 * Outputs the Destination Block.
158
	 *
159
	 * @return void
160
	 */
161 View Code Duplication
	public function destination_block() {
0 ignored issues
show
Duplication introduced by
This method 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...
162
		?>
163
			<h2 class="title"><?php esc_html_e( 'Import and publish destinations', 'wetu-importer' ); ?></h2>
164
			<p class="excerpt"><?php esc_html_e( 'All destinations and regions connnected to your tours & accommodations have been imported as drafts. Review the imported accommodations, sync selected data and publish.', 'wetu-importer' ); ?></p>
165
			<p><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=destination' ); ?>" class="button button-primary"><?php esc_html_e( 'Sync destinations', 'wetu-importer' ); ?></a></p>
166
			<p>
167
				<ul class="link-list">
168
					<li><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=destination' ); ?>#publish"><?php esc_html_e( 'Published', 'wetu-importer' ); ?> (<?php echo esc_attr( \wetu_importer\includes\helpers\get_post_count( 'destination', 'publish ' ) ); ?>)</a></li>
169
					<li><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=destination' ); ?>#pending"><?php esc_html_e( 'Pending', 'wetu-importer' ); ?> (<?php echo esc_attr( \wetu_importer\includes\helpers\get_post_count( 'destination', 'pending ' ) ); ?>)</a></li>
170
					<li><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=destination' ); ?>#draft"><?php esc_html_e( 'Draft', 'wetu-importer' ); ?> (<?php echo esc_attr( \wetu_importer\includes\helpers\get_post_count( 'destination', 'draft ' ) ); ?>)</a></li>
171
					<li><a href="<?php echo esc_attr( admin_url( 'admin.php' ) . '?page=wetu-importer&tab=destination' ); ?>#import"><?php esc_html_e( 'Wetu Queue', 'wetu-importer' ); ?>  (<?php echo esc_attr( \wetu_importer\includes\helpers\get_wetu_queue_count( 'destination' ) ); ?>)</a></li>
172
				</ul>
173
			</p>
174
		<?php
175
	}
176
	/**
177
	 * Outputs the last welcome block
178
	 *
179
	 * @return void
180
	 */
181
	public function end_block() {
182
		?>
183
			<h2 class="title"><?php esc_html_e( 'Done! Check out your imported content', 'wetu-importer' ); ?></h2>
184
			<p><?php esc_html_e( 'If you’ve updated your content on Wetu then you can return to these steps at any stage to import and re-sync any updates', 'wetu-importer' ); ?></p>
185
		<?php
186
	}
187
}
188