Completed
Push — master ( 2f95aa...1df65a )
by Evan
05:36
created

welcome.php ➔ yikes_easy_mc_welcome_tabs()   C

Complexity

Conditions 7
Paths 2

Size

Total Lines 22
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 19
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 22
rs 6.9811
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 9 and the first side effect is on line 40.

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
	/**
3
	 * Navigation tabs
4
	 *
5
	 * @access public
6
	 * @since 1.9
7
	 * @return void
8
	 */
9
	function yikes_easy_mc_welcome_tabs() {
0 ignored issues
show
Coding Style introduced by
yikes_easy_mc_welcome_tabs uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
10
		$section = isset( $_GET['section'] ) ? $_GET['section'] : 'getting-started';
11
		?>
12
		<h2 class="nav-tab-wrapper welcome-page-tabs">
13
			<a class="nav-tab <?php echo $section == 'getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url_raw( admin_url( add_query_arg( array( 'page' => 'yikes-mailchimp-welcome' , 'section' => 'getting-started' ), 'admin.php' ) ) ); ?>">
14
				<span class="dashicons dashicons-admin-home"></span> <?php _e( 'Getting Started', 'yikes-inc-easy-mailchimp-extender' ); ?>
15
			</a>
16
			<a class="nav-tab <?php echo $section == 'whats-new' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url_raw( admin_url( add_query_arg( array( 'page' => 'yikes-mailchimp-welcome' , 'section' => 'whats-new' ), 'admin.php' ) ) ); ?>">
17
				<span class="dashicons dashicons-warning"></span> <?php _e( "What's New", 'yikes-inc-easy-mailchimp-extender' ); ?>
18
			</a>
19
			<a class="nav-tab <?php echo $section == 'add-ons' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url_raw( admin_url( add_query_arg( array( 'page' => 'yikes-mailchimp-welcome' , 'section' => 'add-ons' ), 'admin.php' ) ) ); ?>">
20
				<span class="dashicons dashicons-admin-plugins"></span> <?php _e( "Add-Ons", 'yikes-inc-easy-mailchimp-extender' ); ?>
21
			</a>
22
			<a class="nav-tab <?php echo $section == 'knowledge-base' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url_raw( admin_url( add_query_arg( array( 'page' => 'yikes-mailchimp-welcome' , 'section' => 'knowledge-base' ), 'admin.php' ) ) ); ?>">
23
				<span class="dashicons dashicons-welcome-learn-more"></span> <?php _e( 'Knowledge Base', 'yikes-inc-easy-mailchimp-extender' ); ?>
24
			</a>
25
			<a class="nav-tab <?php echo $section == 'credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url_raw( admin_url( add_query_arg( array( 'page' => 'yikes-mailchimp-welcome' , 'section' => 'credits' ), 'admin.php' ) ) ); ?>">
26
				<span class="dashicons dashicons-arrow-left-alt2"></span><?php _e( 'Credits', 'yikes-inc-easy-mailchimp-extender' ); ?><span class="dashicons dashicons-arrow-right-alt2"></span>
27
			</a>
28
		</h2>
29
		<?php
30
	}
31
	
32
	function yikes_easy_mc_welcome_body() {
0 ignored issues
show
Coding Style introduced by
yikes_easy_mc_welcome_body uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
33
		$section = isset( $_GET['section'] ) ? $_GET['section'] : 'getting-started';
34
		if( isset( $section ) ) {
35
			include_once( plugin_dir_path( dirname( __FILE__ ) ) . '/welcome-page/welcome-sections/' . $section . '-section.php' );
36
		}
37
	}
38
		
39
	// Display custom PHP warning if <= 5.3
40
	do_action( 'yikes_easy_mc_php_warning' );
41
	?>
42
	<div class="wrap about-wrap welcome-page-about-wrap">
43
	
44
		<div id="yikes-mailchimp-logo"></div>
45
		
46
		<h2 class="welcome-title">
47
			Easy Forms for MailChimp by YIKES | <?php echo __( 'MailChimp Done Right' , 'yikes-inc-easy-mailchimp-extender' ); ?>
48
		</h2>		
49
		
50
		<p class="about-text">
51
			<?php 
52
				// check if this is a fresh install
53
				if( get_option( 'yikes_easy_mailchimp_activation_date', strtotime( 'now' ) ) == strtotime( 'now' ) ) {
54
					echo sprintf( __( 'Welcome to the most powerful MailChimp integration for WordPress. Easy Forms for MailChimp by YIKES v%s is ready to help take your mailing lists to the next level!' , 'yikes-inc-easy-mailchimp-extender' ) , $this->version ); 
55
				} else {
56
					// else thank you for updating :)
57
					echo sprintf( __( 'Thank you for updating to the latest version! Easy Forms for MailChimp by YIKES v%s is ready to help take your mailing lists to the next level!' , 'yikes-inc-easy-mailchimp-extender' ) , $this->version ); 
58
				}
59
			?>
60
		</p>
61
		
62
		<?php
63
			// Display our tabs	
64
			yikes_easy_mc_welcome_tabs();
65
			yikes_easy_mc_welcome_body();
66
		?>
67
		
68
	</div>