Sensei_Welcome::welcome_screen()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 61
Code Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 61
rs 9.5147
cc 1
eloc 7
nc 1
nop 0

How to fix   Long Method   

Long Method

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:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 16 and the first side effect is on line 3.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
if ( ! defined( 'ABSPATH' ) ) {
3
    exit; // Exit if accessed directly
4
}
5
6
/**
7
 * Shows a feature overview for the new version (major)
8
 *
9
 * Adapted from code in EDD (Copyright (c) 2012, Pippin Williamson) and WooCommerce and WP
10
 *
11
 * @package Views
12
 * @author Automattic
13
 *
14
 * @version     1.8.0
15
*/
16
class Sensei_Welcome {
17
18
	/**
19
	 * Hook in tabs.
20
     * @since 1.8.0
21
	 */
22
	public function __construct() {
23
24
        add_action( 'admin_menu', array( $this, 'admin_menus') );
25
		add_action( 'admin_head', array( $this, 'admin_head' ) );
26
27
	}
28
29
    /**
30
     * Sends user to the welcome page on first activation.
31
     *
32
     * Hooked into activated_plugin
33
     * @since 1.8.0
34
     */
35
    public static function redirect( $plugin ) {
0 ignored issues
show
Unused Code introduced by
The parameter $plugin is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
37
        // Bail if activating from network, or bulk, or within an iFrame
38
        if ( is_network_admin() || isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) ) {
39
40
            return;
41
42
        }
43
        // don't run for upgrades and for pages already on the welcome screen
44
        if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] )
45
            || ( ! empty( $_GET['page'] ) && $_GET['page'] === 'sensei-welcome' ) ) {
46
47
            return;
48
49
        }
50
51
        wp_redirect( admin_url( 'index.php?page=sensei-welcome' ) );
52
        exit;
53
    }
54
55
	/**
56
	 * Add admin menus/screens.
57
     *
58
     * @since 1.8.0
59
	 */
60
	public function admin_menus() {
61
62
		if ( ! isset( $_GET['page'] ) || 'sensei-welcome' != $_GET[ 'page' ] ) {
63
			return;
64
		}
65
66
		$welcome_page_name  = __( 'Sensei Activation', 'woothemes-sensei' );
67
		$welcome_page_title = __( 'Welcome to Sensei', 'woothemes-sensei' );
68
        add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sensei-welcome', array( $this, 'welcome_screen' ) );
69
70
	}
71
72
    /**
73
     * Output the Welcome  screen.
74
     *
75
     * @since 1.8.0
76
     */
77
    public function welcome_screen() {
78
        ?>
79
        <div class="wrap about-wrap">
80
81
            <?php  $this->intro(); ?>
82
83
            <div class="feature-section two-col">
84
						<div class="col">
85
							<div class="media-container">
86
								<img src="https://docs.woothemes.com/wp-content/uploads/2015/12/Screen-Shot-2015-12-01-at-15.25.24.png">
87
							</div>
88
						</div>
89
						<div class="col">
90
							<h3>New Sensei Shortcodes</h3>
91
							<p>Display your Sensei courses, teachers and messages wherever you want them with a selection of new shortcodes, giving you much more control over the display of your Sensei content.</p>
92
						</div>
93
			</div>
94
			<div class="feature-section two-col">
95
						<div class="col">
96
							<div class="media-container">
97
								<img src="https://docs.woothemes.com/wp-content/uploads/2015/12/language.jpg">
98
							</div>
99
						</div>
100
						<div class="col">
101
							<h3>Sensei in Your Language</h3>
102
							<p>Language packs can now be downloaded directly from the dashboard, enabling one-click translation updates.</p>
103
						</div>
104
			</div>
105
106
            <div class="feature-section three-col">
107
						<div class="col">
108
				<div class="media-container">
109
										<img src="https://docs.woothemes.com/wp-content/uploads/2015/12/next.png">
110
									</div>
111
				<h3>Intuitive Lesson Navigation</h3>
112
				<p>When you complete a lesson, you will now see an obvious link to guide you to the next lesson.</p>
113
			</div>
114
						<div class="col">
115
				<div class="media-container">
116
										<img src="https://docs.woothemes.com/wp-content/uploads/2015/12/zero.png">
117
									</div>
118
				<h3>Zero-grade Questions</h3>
119
				<p>Not all questions require a grade. Now you have the option to assign a grade of zero to any question.</p>
120
			</div>
121
						<div class="col">
122
				<div class="media-container">
123
										<img src="https://docs.woothemes.com/wp-content/uploads/2015/12/templates.png">
124
									</div>
125
				<h3>Updated Template System</h3>
126
				<p>A revised and optimized template system, including a new default Course Archive page, complete with filters for quickly displaying free, paid and featured courses.</p>
127
			</div>
128
					</div>
129
130
            <hr />
131
132
            <div class="return-to-dashboard">
133
                <a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'woothemes-sensei-settings' ), 'admin.php' ) ) ); ?>"><?php _e( 'Go to Sensei Settings', 'woothemes-sensei' ); ?></a>
134
            </div>
135
        </div>
136
    <?php
137
    }
138
139
	/**
140
	 * Add styles just for this page, and remove dashboard page links.
141
	 */
142
	public function admin_head() {
143
        // remove the menu page so it is not visible in the admin side bar
144
		remove_submenu_page( 'index.php', 'sensei-welcome' );
145
		?>
146
		<style type="text/css">
147
			/*<![CDATA[*/
148
			.sensei-badge:before {
149
				font-family: dashicons !important;
150
				content: "\f118";
151
				color: #fff;
152
				-webkit-font-smoothing: antialiased;
153
				-moz-osx-font-smoothing: grayscale;
154
				font-size: 80px;
155
				font-weight: normal;
156
				width: 165px;
157
				height: 165px;
158
				line-height: 165px;
159
				text-align: center;
160
				position: absolute;
161
				top: 0;
162
				<?php echo is_rtl() ? 'right' : 'left'; ?>: 0;
163
				margin: 0;
164
				vertical-align: middle;
165
			}
166
            .sensei-badge {
167
                position: relative;
168
                background: #71b02f;
169
                text-rendering: optimizeLegibility;
170
                padding-top: 150px;
171
                height: 52px;
172
                width: 165px;
173
                font-weight: 600;
174
                font-size: 14px;
175
                text-align: center;
176
                color: rgba(255,255,255,0.8);
177
                text-shadow: 0.05em 0.05em 1px rgba(0,0,0,0.1);
178
                margin: 5px 0 0 0;
179
                -webkit-box-shadow: 0 1px 3px rgba(0,0,0,.2);
180
                box-shadow: 0 1px 3px rgba(0,0,0,.2);
181
            }
182
			.about-wrap .sensei-badge {
183
				position: absolute;
184
				top: 0;
185
				<?php echo is_rtl() ? 'left' : 'right'; ?>: 0;
186
			}
187
			.about-wrap .sensei-feature {
188
				overflow: visible !important;
189
				*zoom:1;
190
			}
191
			.about-wrap h3 + .sensei-feature {
192
				margin-top: 0;
193
			}
194
			.about-wrap .sensei-feature:before,
195
			.about-wrap .sensei-feature:after {
196
				content: " ";
197
				display: table;
198
			}
199
			.about-wrap .sensei-feature:after {
200
				clear: both;
201
			}
202
			.about-wrap .feature-rest div {
203
				width: 50% !important;
204
				padding-<?php echo is_rtl() ? 'left' : 'right'; ?>: 100px;
205
				-moz-box-sizing: border-box;
206
				box-sizing: border-box;
207
				margin: 0 !important;
208
			}
209
			.about-wrap .feature-rest div.last-feature {
210
				padding-<?php echo is_rtl() ? 'right' : 'left'; ?>: 100px;
211
				padding-<?php echo is_rtl() ? 'left' : 'right'; ?>: 0;
212
			}
213
			.about-wrap div.icon {
214
				width: 0 !important;
215
				padding: 0;
216
				margin: 20px 0 !important;
217
			}
218
			.about-wrap .feature-rest div.icon:before {
219
				font-weight: normal;
220
				width: 100%;
221
				font-size: 170px;
222
				line-height: 125px;
223
				color: #9c5d90;
224
				display: inline-block;
225
				position: relative;
226
				text-align: center;
227
				speak: none;
228
				margin: <?php echo is_rtl() ? '0 -100px 0 0' : '0 0 0 -100px'; ?>;
229
				content: "\e01d";
230
				-webkit-font-smoothing: antialiased;
231
				-moz-osx-font-smoothing: grayscale;
232
			}
233
			.about-integrations {
234
				background: #fff;
235
				margin: 20px 0;
236
				padding: 1px 20px 10px;
237
			}
238
			.changelog h4 {
239
				line-height: 1.4;
240
			}
241
242
            p.sensei-actions a.button-primary {
243
                background: #42A2CE;
244
                border-color: #849DAD;
245
            }
246
247
            p.sensei-actions .twitter-share-button {
248
				margin-top: -3px;
249
				margin-left: 3px;
250
				vertical-align: middle;
251
			}
252
			/*]]>*/
253
		</style>
254
		<?php
255
	}
256
257
	/**
258
	 * Intro text/links shown on all about pages.
259
	 */
260
	private function intro() {
261
262
		// Drop minor version if 0
263
		$major_version = substr( Sensei()->version, 0, 3 );
264
265
		// Random tweet - must be kept to 102 chars to "fit"
266
		$tweets        = array(
267
            'I\'ve just installed Sensei - A premium Learning Management plugin for #WordPress.'
268
		);
269
		shuffle( $tweets );
270
		?>
271
		<h1><?php printf( __( 'Welcome to Sensei %s', 'woothemes-sensei' ), $major_version ); ?></h1>
272
273
		<div class="about-text sensei-about-text">
274
			<?php
275
				if ( ! empty( $_GET['sensei-installed'] ) ) {
276
					$message = __( 'Thanks, all done!', 'woothemes-sensei' );
277
				} elseif ( ! empty( $_GET['sensei-updated'] ) ) {
278
					$message = __( 'Thank you for updating to the latest version!', 'woothemes-sensei' );
279
				} else {
280
					$message = __( 'Thanks for installing!', 'woothemes-sensei' );
281
				}
282
283
				printf( __( '%s We hope you enjoy using Sensei %s.', 'woothemes-sensei' ), $message, $major_version );
284
			?>
285
		</div>
286
287
		<div class="sensei-badge">
288
            <?php
289
                _e('Sensei by WooThemes','woothemes-sensei');
290
                echo '<br />';
291
292
                printf( __( 'Version %s', 'woothemes-sensei' ), Sensei()->version );
293
            ?>
294
        </div>
295
296
		<p class="sensei-actions">
297
			<a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button button-primary"><?php _e( 'Settings', 'woothemes-sensei' ); ?></a>
298
			<a href="<?php echo esc_url( apply_filters( 'sensei_docs_url', 'http://docs.woothemes.com/documentation/plugins/sensei/', 'woothemes-sensei' ) ); ?>" class="docs button button-primary"><?php _e( 'Docs', 'woothemes-sensei' ); ?></a>
299
			<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/products/sensei" data-text="<?php echo esc_attr( $tweets[0] ); ?>" data-via="WooThemes" data-size="large">Tweet</a>
300
			<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
301
		</p>
302
303
		<h2 > <?php _e( "What's New", 'woothemes-sensei' ); ?> </h2>
304
305
		<?php
306
	}
307
} // end class sensei welcome
308