Completed
Push — master ( 368e6c...0f28ec )
by
unknown
02:19
created

tour::draw_tour()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 40
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 15
c 2
b 0
f 0
nc 2
nop 0
dl 0
loc 40
rs 8.8571
1
<?php
2
/**
3
 * Class responsible for creating the welcome walkthrough on the editor
4
 *
5
 * @since 0.6
6
 */
7
8
namespace lasso_public_facing;
9
10
class tour {
11
12
	public function __construct() {
13
14
	    $disable_tour = lasso_editor_get_option('disable_tour', 'lasso_editor');
0 ignored issues
show
Documentation introduced by
'disable_tour' is of type string, but the function expects a object<unknown>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
'lasso_editor' is of type string, but the function expects a object<unknown>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
15
		if (!$disable_tour) {
16
		    add_action( 'wp_footer',       array( $this, 'draw_tour' ) );
17
		}
18
	}
19
20
	/**
21
	*	Draw the modal used to house the walk through
22
	*	@since 0.6
23
	*/
24
	public function draw_tour() {
25
26
		$tour_hidden = get_user_meta( get_current_user_ID(), 'lasso_hide_tour', true );
27
28
		if ( lasso_user_can() && !$tour_hidden ) {
29
30
			global $post;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
31
32
			$nonce = wp_create_nonce( 'lasso-editor-tour' );
33
34
			// let users add custom css classes
35
			$custom_classes = apply_filters( 'lasso_modal_tour_classes', '' );
36
37
			?>
38
			<div id="lasso--tour__modal" class="lasso--modal lasso--tour__modal lasso--modal__checkbox <?php echo sanitize_html_class( $custom_classes );?>">
39
				<div class="lasso--modal__inner">
40
41
					<?php echo self::tour_slides();?>
42
43
					<div class="lasso--postsettings__footer">
44
45
						<div class="lasso--postsettings__option">
46
							<label for="hide_tour" class="checkbox-control checkbox">
47
					        	<input type="checkbox" id="hide_tour" name="hide_tour" <?php checked( $tour_hidden, 1 ); ?>>
48
					        	<span class="control-indicator"></span>
49
								<?php _e('Don\'t show this again','lasso');?>
50
					        </label>
51
						</div>
52
53
						<input type="submit" value="<?php _e( 'Okay, got it!', 'lasso' );?>" data-nonce="<?php echo $nonce;?>" >
54
					</div>
55
56
				</div>
57
58
			</div>
59
			<div id="lasso--modal__overlay"></div>
60
			<?php
61
62
		}
63
	}
64
65
	/**
66
	*	Draw the inner slides for the welcome walkthrough
67
	*	@since 0.6
68
	*/
69
	public function tour_slides() { ?>
70
71
		<div id="lasso--loading" class="lasso--loading"><div class="lasso--loader"></div></div>
72
		<div id="lasso--tour__slides">
73
74
			<?php
75
76
			$out = '<ul><li>';
77
			$out .= sprintf( '<img src="%s">', LASSO_URL.'/public/assets/img/s-1.jpg' );
78
			$out .= '<p>'.__('Access posts by clicking the list icon. Create a new post by clicking the new post icon.','lasso').'</p>';
79
			$out .= '</li><li>';
80
			$out .= sprintf( '<img src="%s">', LASSO_URL.'/public/assets/img/s-2.jpg' );
81
			$out .= '<p>'.__('While on a single post, edit by clicking the Pen icon. Access post settings with the settings icon. Press escape to exit any modal.','lasso').'</p>';
82
			$out .= '</li><li>';
83
			$out .= sprintf( '<img src="%s">', LASSO_URL.'/public/assets/img/s-3.jpg' );
84
			$out .= '<p>'.__('Highlight a piece of text, and click on a formatting option to style it. Click the Disk icon or CMD-S to save. Click the orange "X" button to exit the editor.','lasso').'</p>';
85
			$out .= '</li><li>';
86
			$out .= sprintf( '<img src="%s">', LASSO_URL.'/public/assets/img/s-4.jpg' );
87
			$out .= '<p>'.__('Story components can be added by clicking the plus icon, and dragging any component from the component tray into the story.','lasso').'</p>';
88
			$out .= '</li></ul>';
89
90
			echo apply_filters( 'lasso_tour_slides', $out );
91
92
		?></div><?php
93
94
	}
95
96
}
97