Completed
Push — master ( a6086b...51c0b5 )
by
unknown
01:57
created

editor-modules.php ➔ lasso_editor_component_modal()   D

Complexity

Conditions 13
Paths 256

Size

Total Lines 148

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 13
nc 256
nop 0
dl 0
loc 148
rs 4.0666
c 0
b 0
f 0

How to fix   Long Method    Complexity   

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 15 and the first side effect is on line 14.

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
/**
4
 * These functions are then localized and then appended with JS in enter-editor.js
5
 *
6
 * @since 1.0
7
 */
8
9
/**
10
 * Add the editor controls to any singular post object
11
 *
12
 * @since 1.0
13
 */
14
add_action( 'wp_footer', 'lasso_editor_controls' );
15
function lasso_editor_controls() {
16
17
	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...
18
19
	if ( lasso_user_can('edit_posts') ) {
20
21
		$status = get_post_status( get_the_ID() );
22
23
		// let users add custom css classes
24
		$custom_classes = apply_filters( 'lasso_control_classes', '' );
25
26
		$post_access_class   = '';
27
		$post_new_disabled   = lasso_editor_get_option( 'post_adding_disabled', 'lasso_editor' );
28
		$post_settings_disabled = lasso_editor_get_option( 'post_settings_disabled', 'lasso_editor' );
29
		$shortcodify_disabled = lasso_editor_get_option( 'shortcodify_disabled', 'lasso_editor' );
30
31
32
		// CSS class if adding new post objects is disabled
33
		if ( 'on' == $post_new_disabled ) { $post_access_class = 'lasso--post-new-disabled'; }
34
35
		// CSS class if adjust settings is disabled
36
		if ( 'on' == $post_settings_disabled ) { $post_access_class = 'lasso--post-settings-disabled'; }
37
38
		// CSS class if adding new post objects AND settings are disabled
39
		if ( 'on' == $post_new_disabled && 'on' == $post_settings_disabled ) { $post_access_class = 'lasso--post-all-disabled'; }
40
41
		// CSS class if shortcodify or (Aesop Shortcode Conversion) is disabled
42
		$sc_saving_class = 'on' == $shortcodify_disabled ? 'shortcodify-disabled' : 'shortcodify-enabled';
43
44
		// user is capable
45
		$is_capable = is_singular() && lasso_user_can('edit_post');
46
		$is_mobile = wp_is_mobile();
47
		
48
		$mobile_style = $is_mobile ? 'style="bottom:0px;"' : null;
49
		
50
51
		?><div id="lasso--controls" class="lasso-post-status--<?php echo sanitize_html_class( $status );?> <?php echo sanitize_html_class( $custom_classes );?>" data-post-id="<?php echo get_the_ID();?>" >
52
53
			<ul class="lasso--controls__center lasso-editor-controls lasso-editor-controls--wrap <?php echo $post_access_class;?> "  <?php echo $mobile_style ?> >
54
55
				<?php do_action( 'lasso_editor_controls_before' );
56
57
				if ( $is_capable ) { ?>
58
59
					<li id="lasso--edit" title="<?php esc_attr_e( 'Edit Post', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
60
61
					<?php if ( 'off' == $post_settings_disabled || empty( $post_settings_disabled ) ) { ?>
62
						<li id="lasso--post-settings" title="<?php esc_attr_e( 'Post Settings', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
63
					<?php }
64
65
				} ?>
66
67
				<li id="lasso--post-all" title="<?php esc_attr_e( 'All Posts', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
68
69
				<?php if ( $is_capable && wp_revisions_enabled( $post ) ) { ?>
70
					<li id="lasso--post-revisions" title="<?php esc_attr_e( 'Revisions', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
71
				<?php } ?>
72
73
				<?php if ( ( 'off' == $post_new_disabled || empty( $post_new_disabled ) && lasso_user_can('publish_posts') ) ) { ?>
74
					<li id="lasso--post-new" title="<?php esc_attr_e( 'Add Post', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
75
				<?php } ?>
76
77
				<?php do_action( 'lasso_editor_controls_after' );?>
78
79
			</ul>
80
81 View Code Duplication
			<?php if ( is_singular() && !$is_mobile ) { ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
82
83
				<div class="lasso--controls__right" data-posttype="<?php echo get_post_type( get_the_ID() );?>" data-status="<?php echo $status;?>">
84
85
					<a href="#" title="<?php esc_attr_e( 'Save Post', 'lasso' );?>" id="lasso--save" class="lasso-save-post lasso--button <?php echo $sc_saving_class;?>"></a>
86
87
					<?php if ( 'draft' == $status && ( lasso_user_can('publish_posts') || lasso_user_can('publish_pages') )  ) { ?>
88
						<a href="#" title="<?php esc_attr_e( 'Publish Post', 'lasso' );?>" id="lasso--publish" class="lasso-publish-post lasso--button <?php echo $sc_saving_class;?>"></a>
89
					<?php } ?>
90
91
				</div>
92
93
			<?php } ?>
94
95
		</div>
96
97
	<?php }
98
}
99
100
/**
101
 * Draw the side panel that houses the component settings
102
 * This is opened when the settings icon is clicked on a single component
103
 * JS detects the type and will fill in the necessary options for the shortcode based on  lasso_editor_options_blob() at the end of this file
104
 *
105
 * @since 1.0
106
 */
107
function lasso_editor_component_sidebar() {
108
109
	ob_start();
110
111
112
	// let users add custom css classes
113
	$custom_classes = apply_filters( 'lasso_sidebar_classes', '' );
114
	?>
115
	<div id="lasso--sidebar" class="<?php echo sanitize_html_class( $custom_classes );?>" >
116
		<div class="lasso--sidebar__inner">
117
			<div id="lasso--component__settings"></div>
118
		</div>
119
	</div>
120
121
	<?php return ob_get_clean();
122
}
123
124
/**
125
 * Draw the main toolbar used to edit the text
126
 *
127
 * @since 1.0
128
 */
129
function lasso_editor_text_toolbar() {
130
131
	ob_start();
132
133
	
134
	$is_mobile = wp_is_mobile();
135
136
	// check for lasso story engine and add a class doniting this
137
	$ase_status = class_exists( 'Aesop_Core' ) || defined( 'LASSO_CUSTOM' ) ? 'ase-active' : 'ase-not-active';
138
139
	// let users add custom css classes
140
	$custom_classes = apply_filters( 'lasso_toolbar_classes', '' );
141
142
	// are toolbar headings enabled
143
	$toolbar_headings      = lasso_editor_get_option( 'toolbar_headings', 'lasso_editor' );
144
	$toolbar_headings_h4      = lasso_editor_get_option( 'toolbar_headings_h4', 'lasso_editor' );
145
146
	$toolbar_class  = $toolbar_headings ? 'toolbar-extended' : false;
147
	
148
	// mobile styles
149
    $mobile_class = $is_mobile ? 'lasso-mobile' : false;
150
	$mobile_style =$is_mobile ? 'style="bottom:0px;"' : null;
151
	
152
	//show color
153
	$show_color = lasso_editor_get_option('toolbar_show_color', 'lasso_editor');
154
	
155
	//show alignment
156
	$show_align = lasso_editor_get_option('toolbar_show_alignment', 'lasso_editor');
157
	
158
	$status = get_post_status( get_the_ID() );
159
160
161
	?>
162
	<div class="lasso--toolbar_wrap lasso-editor-controls--wrap <?php echo $toolbar_class.' '.$mobile_class.' '.$ase_status.' '.sanitize_html_class( $custom_classes );?>" <?php echo $mobile_style ?>>
163
		<ul class="lasso--toolbar__inner lasso-editor-controls" <?php if ($is_mobile) {echo 'style="float:left;"';}?>>
164
			<?php do_action( 'lasso_toolbar_components_before' );?>
165
		    <li id="lasso-toolbar--bold" title="<?php esc_attr_e( 'Bold', 'lasso' );?>"></li>
166
		    <li id="lasso-toolbar--underline" title="<?php esc_attr_e( 'Underline', 'lasso' );?>"></li>
167
		    <li id="lasso-toolbar--italic" title="<?php esc_attr_e( 'Italicize', 'lasso' );?>"></li>
168
		    <li id="lasso-toolbar--strike" title="<?php esc_attr_e( 'Strikethrough', 'lasso' );?>"></li>
169
			<li id="lasso-toolbar--components" title="<?php esc_attr_e( 'Insert Component', 'lasso' );?>" style="color:#ffffa0;">
170
			    <ul id="lasso-toolbar--components__list" style="display:none;color:white;">
171
			    	<?php if ( 'ase-active' == $ase_status ): ?>
172
						<li data-type="image" title="<?php esc_attr_e( 'Image', 'lasso' );?>" class="lasso-toolbar--component__image"></li>
173
						<li data-type="character" title="<?php esc_attr_e( 'Character', 'lasso' );?>" class="lasso-toolbar--component__character"></li>
174
						<li data-type="quote" title="<?php esc_attr_e( 'Quote', 'lasso' );?>"  class="lasso-toolbar--component__quote"></li>
175
						<li data-type="content" title="<?php esc_attr_e( 'Content', 'lasso' );?>"  class="lasso-toolbar--component__content"></li>
176
						<li data-type="chapter" title="<?php esc_attr_e( 'Chapter', 'lasso' );?>"  class="lasso-toolbar--component__chapter"></li>
177
						<li data-type="parallax" title="<?php esc_attr_e( 'Parallax', 'lasso' );?>"  class="lasso-toolbar--component__parallax"></li>
178
						<li data-type="audio" title="<?php esc_attr_e( 'Audio', 'lasso' );?>"  class="lasso-toolbar--component__audio"></li>
179
						<li data-type="video" title="<?php esc_attr_e( 'Video', 'lasso' );?>"  class="lasso-toolbar--component__video"></li>
180
						<li data-type="map" title="<?php esc_attr_e( 'Map', 'lasso' );?>"  class="lasso-toolbar--component__map"></li>
181
						<li data-type="timeline_stop" title="<?php esc_attr_e( 'Timeline', 'lasso' );?>"  class="lasso-toolbar--component__timeline"></li>
182
						<li data-type="document" title="<?php esc_attr_e( 'Document', 'lasso' );?>"  class="lasso-toolbar--component__document"></li>
183
						<li data-type="collection" title="<?php esc_attr_e( 'Collection', 'lasso' );?>"  class="lasso-toolbar--component__collection"></li>
184
						<li data-type="gallery" title="<?php esc_attr_e( 'Gallery', 'lasso' );?>"  class="lasso-toolbar--component__gallery"></li>
185
						<?php if ( class_exists ('Aesop_GalleryPop') ) { ?>
186
						     <li data-type="gallery" title="<?php esc_attr_e( 'Gallery Pop', 'lasso' );?>"  class="lasso-toolbar--component__gallerypop"></li>
187
						<?php }?>
188
						<?php if ( class_exists ('Aesop_Events') ) { ?>
189
						     <li data-type="events" title="<?php esc_attr_e( 'Event', 'lasso' );?>"  class="lasso-toolbar--component__event"></li>
190
						<?php }?>
191 View Code Duplication
					<?php else: ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
192
						<li data-type="wpimg" title="<?php esc_attr_e( 'WordPress Image', 'lasso' );?>" class="image lasso-toolbar--component__image"></li>
193
						<li data-type="wpquote" title="<?php esc_attr_e( 'WordPress Quote', 'lasso' );?>" class="quote lasso-toolbar--component__quote"></li>
194
						<!--li data-type="wpvideo" title="<?php esc_attr_e( 'WordPress Video', 'lasso' );?>" class="video lasso-toolbar--component__video"></li-->
195
					<?php endif; ?>
196
					<?php do_action( 'lasso_toolbar_components' );?>
197
			    </ul>
198
			</li>
199
		    <?php if ( $toolbar_headings ): ?>
200
		    <li id="lasso-toolbar--h2" title="<?php esc_attr_e( 'H2 Heading', 'lasso' );?>"></li>
201
		    <li id="lasso-toolbar--h3" title="<?php esc_attr_e( 'H3 Heading', 'lasso' );?>"></li>
202
			<?php endif; ?>
203 View Code Duplication
			<?php if ( $toolbar_headings_h4 ): ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
204
		    <li id="lasso-toolbar--h4" title="<?php esc_attr_e( 'H4 Heading', 'lasso' );?>"></li>
205
		    <li id="lasso-toolbar--h5" title="<?php esc_attr_e( 'H5 Heading', 'lasso' );?>"></li>
206
			<li id="lasso-toolbar--h6" title="<?php esc_attr_e( 'H6 Heading', 'lasso' );?>"></li>
207
			<?php endif; ?>
208
			
209
			<?php if ( $show_color ): ?>
210
		    <li id="lasso-toolbar--color-set" title="<?php esc_attr_e( 'Set Color for Selected Text', 'lasso' );?>"></li>
211
		    <li id="lasso-toolbar--color-pick" title="<?php esc_attr_e( 'Choose Color', 'lasso' );?>"></li>
212
			<?php endif; ?>
213
					
214
		    
215
			<li id="lasso-toolbar--link" title="<?php esc_attr_e( 'Anchor Link', 'lasso' );?>">
216
		    	<div id="lasso-toolbar--link__wrap" <?php echo $mobile_style ?> >
217
		    		<div id="lasso-toolbar--link__inner" contenteditable="true" placeholder="<?php esc_attr_e( 'http://url.com', 'lasso' );?>"></div>
218
		    		<a href="#" title="<?php esc_attr_e( 'Create Link', 'lasso' );?>" class="lasso-toolbar--link__control" id="lasso-toolbar--link__create" ></a>
219
					<input class="styled-checkbox" type="checkbox" id="aesop-toolbar--link_newtab" checked/>
220
                    <label for="aesop-toolbar--link_newtab"><?php esc_attr_e( 'Open in a New Tab', 'lasso' );?></label>
221
		    	</div>
222
		    </li>
223
		    <?php do_action( 'lasso_toolbar_components_after' );?>
224
		    <li id="lasso-toolbar--html" title="<?php esc_attr_e( 'Insert HTML or Code', 'lasso' );?>">
225
		    	<div id="lasso-toolbar--html__wrap" <?php echo $mobile_style ?>>
226
		    		<div id="lasso-toolbar--html__inner" contenteditable="true" placeholder="<?php esc_attr_e( 'Enter HTML to insert', 'lasso' );?>"></div>
227
		    		<div id="lasso-toolbar--html__footer">
228
					<div id="lasso-toolbar--html__footer_desc" >
229
					<?php esc_attr_e( 'Enter HTML to insert', 'lasso' );?><br>
230
					<?php esc_attr_e( 'You can also use Shortcodes', 'lasso' );?><br>
231
					<?php esc_attr_e( 'You can also enter a URL to embed, such as Youtube, Vimeo and Twitter URLs.', 'lasso' );?>
232
					</div>
233
		    			<ul class="lasso-toolbar--html-snips">
234
						
235
		    				<?php if ( !$toolbar_headings ): ?>
236
		    				<li id="lasso-html--h2" title="<?php esc_attr_e( 'H2 Heading', 'lasso' );?>">
237
		    				<li id="lasso-html--h3" title="<?php esc_attr_e( 'H3 Heading', 'lasso' );?>">
238
		    				<?php endif; ?>
239
		    				<li id="lasso-html--ul" title="<?php esc_attr_e( 'Unordered List', 'lasso' );?>">
240
		    				<li id="lasso-html--ol" title="<?php esc_attr_e( 'Ordered List', 'lasso' );?>">
241
		    			</ul>
242
		    			<a class="lasso-toolbar--html__control lasso-toolbar--html__cancel" href="#"><?php _e( 'Cancel', 'lasso' );?></a>
243
		    			<a href="#" title="<?php esc_attr_e( 'Insert HTML or Code', 'lasso' );?>" class="lasso-toolbar--html__control" id="lasso-toolbar--html__insert" ><?php _e( 'Insert', 'lasso' );?></a>
244
		    		</div>
245
		    	</div>
246
		    </li>
247 View Code Duplication
			<?php if ( $show_align ): ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
248
		    <li id="lasso-toolbar--left-align" title="<?php esc_attr_e( 'Text Left Align', 'lasso' );?>"></li>
249
		    <li id="lasso-toolbar--center-align" title="<?php esc_attr_e( 'Text Center Align', 'lasso' );?>"></li>
250
			<li id="lasso-toolbar--right-align" title="<?php esc_attr_e( 'Text Right Align', 'lasso' );?>"></li>
251
			<?php endif; ?>
252
		</ul>
253 View Code Duplication
		<?php if ( is_singular() && $is_mobile ) { ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
254
255
				<div class="lasso--controls__right" data-posttype="<?php echo get_post_type( get_the_ID() );?>" data-status="<?php echo $status;?>" style="position:static;bottom:0px;right;0px;left:auto;">
256
257
					<a href="#" title="<?php esc_attr_e( 'Save Post', 'lasso' );?>" id="lasso--save" class="lasso-save-post lasso--button <?php echo $sc_saving_class;?>"></a>
0 ignored issues
show
Bug introduced by
The variable $sc_saving_class does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
258
259
					<?php if ( 'draft' == $status && ( lasso_user_can('publish_posts') || lasso_user_can('publish_pages') )  ) { ?>
260
						<a href="#" title="<?php esc_attr_e( 'Publish Post', 'lasso' );?>" id="lasso--publish" class="lasso-publish-post lasso--button <?php echo $sc_saving_class;?>"></a>
261
					<?php } ?>
262
263
				</div>
264
265
		<?php } ?>
266
	</div>
267
268
	<?php return ob_get_clean();
269
}
270
271
/**
272
 * Draw the controls used for teh component settings within each component
273
 *
274
 * @since 1.0
275
 */
276
function lasso_editor_settings_toolbar() {
277
278
	$delete_nonce = wp_create_nonce( 'lasso-delete-nonce' );
279
280
	ob_start();
281
282
283
	// let users add custom css classes
284
	$custom_classes = apply_filters( 'lasso_component_classes', '' );
285
286
	?>
287
	<ul class="lasso-component--controls <?php echo sanitize_html_class( $custom_classes );?>" contenteditable="false">
288
		<li class="lasso-drag" title="<?php esc_attr_e( 'Move', 'lasso' );?>"></li>
289
		<li id="lasso-component--settings__trigger" class="lasso-settings" title="<?php esc_attr_e( 'Settings', 'lasso' );?>"></li>
290
		<li class="lasso-clone" title="<?php esc_attr_e( 'Clone', 'lasso' );?>"></li>
291
		<li class="lasso-delete" data-postid="<?php echo get_the_ID();?>" data-nonce="<?php echo $delete_nonce;?>" title="<?php esc_attr_e( 'Delete', 'lasso' );?>"></li>
292
	</ul>
293
294
	<?php return ob_get_clean();
295
}
296
297
/**
298
 * Draws the controls used for changing the featured image
299
 *   These controls are appended based on the class set in the define
300
 *
301
 * @since 1.0
302
 */
303
function lasso_editor_image_controls() {
304
305
	ob_start();
306
307
308
	// has post thumbnail
309
	$has_thumbnail = has_post_thumbnail( get_the_ID() ) ? 'class="lasso--featImg--has-thumb"' : false;
310
311
	?>
312
	<ul id="lasso--featImgControls" <?php echo $has_thumbnail;?>>
313
		<li id="lasso--featImgUpload"><a title="<?php esc_attr_e( 'Replace Image', 'lasso' );?>" href="#"><i class="lasso-icon-image"></i></a></li>
314
		<li id="lasso--featImgDelete"><a title="<?php esc_attr_e( 'Delete Image', 'lasso' );?>" href="#"><i class="lasso-icon-bin2"></i></a></li>
315
		<li id="lasso--featImgSave"><a href="#"><?php esc_attr_e( 'save', 'lasso' );?></a></li>
316
	</ul>
317
318
	<?php return ob_get_clean();
319
}
320
321
322
/**
323
 * Used to house post settings like scheduling, slugs and draft status
324
 * Note: the "add new" will use the same object as the currently shown. For example, if the user
325
 * is currently on a post, and clicks add new, then it'll add a new post. If the user is on a
326
 * post type like "dog", then it will create a new post type called "dog"
327
 *
328
 * @since 1.0
329
 */
330
function lasso_editor_component_modal() {
331
332
	ob_start();
333
334
335
	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...
336
337
	$postid = get_the_ID();
338
339
	$status = get_post_status( $postid );
340
	$nonce = wp_create_nonce( 'lasso-update-post-settings' );
341
342
	// let users add custom css classes
343
	$custom_classes = apply_filters( 'lasso_modal_settings_classes', '' );
344
345
	// objects categories
346
	$categories 		= lasso_get_post_objects( $postid, 'category' );
347
	$tags 				= lasso_get_post_objects( $postid, 'tag' );
348
349
	// modal tabs
350
	$tabs  				= lasso_modal_addons('tab');
351
	$content 			= lasso_modal_addons('content');
352
	
353
	//editor options
354
	$allow_change_date = lasso_editor_get_option('allow_change_date', 'lasso_editor');
355
356
	// are we singular
357
	$is_singular 		= is_singular();
358
	$is_singular_class 	= $is_singular ? 'lasso--postsettings__2col' : 'lasso--postsettings__1col';
359
	$has_thumb_class    = has_post_thumbnail() ? 'has-thumbnail' : 'no-thumbnail';
360
	$theme_supports     = current_theme_supports('post-thumbnails');
361
	$default_image 		= LASSO_URL.'/admin/assets/img/empty-img.png';
362
363
?>
364
	<div id="lasso--post-settings__modal" class="lasso--modal lassoShowAnimate <?php echo sanitize_html_class( $custom_classes );?>">
365
		<div class="lasso--modal__inner">
366
367
			<?php if( $tabs ) { echo $tabs; } ?>
0 ignored issues
show
Bug Best Practice introduced by
The expression $tabs of type string|false is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
368
369
			<div class="lasso--modal__content modal__content--core visible" data-addon-content="core">
370
				<form id="lasso--postsettings__form" enctype="multipart/form-data" class="lasso--post-form <?php echo $is_singular_class.' '.$has_thumb_class;?>" >
371
372
					<?php if ( $is_singular && $theme_supports ) : ?>
373
					<div class="lasso--postsettings__left">
374
						<label><?php _e( 'Featured Image', 'lasso' );?><span class="lasso-util--help lasso-util--help-top" data-tooltip="<?php esc_attr_e( 'Change the featured image for this post.', 'lasso' );?>"><i class="lasso-icon-help"></i></span></label>
375
						<div class="lasso--post-thumb" data-default-thumb="<?php echo esc_url( $default_image );?>">
376
377
							<div id="lasso--post-thumb__controls" class="lasso--post-thumb__controls">
378
								<i id="lasso--post-thumb__add" title="<?php _e('Change Featured Image','lasso');?>" class="dashicons dashicons-edit"></i>
379
								<i id="lasso--post-thumb__delete" title="<?php _e('Delete Featured Image','lasso');?>" class="dashicons dashicons-no-alt"></i>
380
								<i id="lasso--save-status" class="lasso-icon lasso-icon-spinner6 not-visible"></i>
381
							</div>
382
383
							<?php echo has_post_thumbnail() ? get_the_post_thumbnail( $post->ID, 'medium' ) : '<img src="'.$default_image.'">'; ?>
384
385
						</div>
386
						<div id="lasso--featImgSave"><a href="#" class="not-visible">Save</a></div>
387
388
					</div>
389
					<?php endif; ?>
390
391
					<div class="lasso--postsettings__right">
392
393
						<?php if( lasso_user_can('publish_posts') || lasso_user_can('publish_pages') ): ?>
394
						<div class="lasso--postsettings__option story-status-option">
395
							<label><?php _e( 'Status', 'lasso' );?><span class="lasso-util--help lasso-util--help-top" data-tooltip="<?php esc_attr_e( 'Change the status of the post to draft or publish.', 'lasso' );?>"><i class="lasso-icon-help"></i></span></label>
396
							<ul class="story-status story-status-<?php echo sanitize_html_class( $status );?>">
397
								<li id="lasso--status-draft"><?php _e( 'Draft', 'lasso' );?></li>
398
								<li id="lasso--status-publish"><?php _e( 'Publish', 'lasso' );?></li>
399
							</ul>
400
							<div class="lasso--slider_wrap">
401
								<div id="lasso--slider"></div>
402
							</div>
403
						</div>
404
						<?php endif; ?>
405
406
						<?php if ( 'publish' == $status ): ?>
407
						<div class="lasso--postsettings__option story-slug-option">
408
							<label><?php _e( 'Post URL', 'lasso' );?><span class="lasso-util--help lasso-util--help-top" data-tooltip="<?php esc_attr_e( 'Change the URL (slug) of this post.', 'lasso' );?>"><i class="lasso-icon-help"></i></span></label>
409
							<input class="lasso--modal__trigger-footer" type="text" name="story_slug" value="<?php echo isset( $post ) ? esc_attr( $post->post_name ) : false;?>">
410
						</div>
411
						<?php endif; ?>
412
413
					</div>
414
415
					<div class="lasso--postsettings__middle">
416
417
						<div class="lasso--postsettings__option story-categories-option">
418
							<label style="width:120px;"><?php _e( 'Categories', 'lasso' );?><span class="lasso-util--help lasso-util--help-top" data-tooltip="<?php esc_attr_e( 'Type a category name and press enter.', 'lasso' );?>"><i class="lasso-icon-help"></i></span></label>
419
							<input id="lasso--cat-select" class="lasso--modal__trigger-footer" type="hidden" name="story_cats" value="<?php echo $categories;?>">
420
						</div>
421
422
						<div class="lasso--postsettings__option story-tags-option">
423
							<label><?php _e( 'Tags', 'lasso' );?><span class="lasso-util--help lasso-util--help-top" data-tooltip="<?php esc_attr_e( 'Type a tag name and press enter.', 'lasso' );?>"><i class="lasso-icon-help"></i></span></label>
424
							<input id="lasso--tag-select" class="lasso--modal__trigger-footer" type="hidden" name="story_tags" value="<?php echo $tags;?>">
425
						</div>
426
						<?php 
427
						if ($allow_change_date) { 
428
						    $dateformat = get_option( 'date_format' ); 
429
						?>
430
						    <label><?php _e( 'Post Date', 'lasso' ); ?></label>
431
							<input type="text" class="editus_custom_date" name="post_date" value="<?php echo get_the_time($dateformat, $postid);?>"/>
432
						<?php
433
						}?>
434
435
					</div>
436
					<!-- alternate way to display categories disabled now -->
437
					<!--div style="max-height:300px;overflow-y: scroll;"-->
438
                    <?php
439
							/*$allcats = explode(",",lasso_get_objects('category'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
440
							$currcats = explode(",",$categories);
441
							foreach ( $allcats  as $category ) {
442
								if (empty($category)) continue;
443
							   $checked ="";
444
							   if (  in_array( $category, $currcats ) ) {
445
									$checked = 'checked="checked"';
446
									
447
							   }
448
							   echo '<label><input type="checkbox" '.$checked.' name="categories" id="'.$category.'" >'.$category.'</label>';
449
							}*/
450
					?>
451
					<!--/div-->
452
453
					<?php do_action( 'lasso_modal_post_form' ); // action ?>
454
455
					<div class="lasso--postsettings__footer" >
456
						<a href="#" class="lasso--postsettings-cancel"><?php _e( 'Cancel', 'lasso' );?></a>
457
						<input type="hidden" name="status" value="">
458
						<input type="hidden" name="categories" value="">
459
						<input type="hidden" name="postid" value="<?php echo get_the_ID();?>">
460
						<input type="hidden" name="action" value="process_update-object_post">
461
						<input type="hidden" name="nonce" value="<?php echo $nonce;?>">
462
						<?php do_action( 'lasso_modal_post_form_footer' ); // action ?>
463
						<input type="submit" value="<?php esc_attr_e( 'Save', 'lasso' );?>">
464
					</div>
465
466
				</form>
467
			</div>
468
469
			<?php if( $tabs ) { echo $content; } ?>
0 ignored issues
show
Bug Best Practice introduced by
The expression $tabs of type string|false is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
470
471
		</div>
472
473
	</div>
474
	<div id="lasso--modal__overlay"></div>
475
476
	<?php return ob_get_clean();
477
}
478
479
/**
480
 * Used to house the form for creating a new post within amodal
481
 *
482
 * @since 1.0
483
 */
484
function lasso_editor_newpost_modal() {
485
486
	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...
487
488
	ob_start();
489
490
491
	$status = get_post_status( get_the_ID() );
0 ignored issues
show
Unused Code introduced by
$status is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
492
493
	$nonce = wp_create_nonce( 'lasso-editor-new-post' );
494
495
	// let users add custom css classes
496
	$custom_classes = apply_filters( 'lasso_modal_post_classes', '' );
497
498
	// return the post type
499
	$type = get_post_type( get_the_ID() );
500
501
	$mobile_style = "";
502
	if (wp_is_mobile()) {
503
		$mobile_style = 'style="top:140px !important;"';
504
	}
505
	?>
506
	<div id="lasso--post-new__modal" class="lasso--modal lasso--modal__med lassoShowAnimate <?php echo sanitize_html_class( $custom_classes );?>" <?php echo $mobile_style;?>">
507
		<div class="lasso--modal__inner lasso--hasnewform">
508
509
			<form id="lasso--postnew__form" enctype="multipart/form-data" class="lasso--post-form">
510
511
				<div class="lasso--postsettings__option story-slug-option lasso--last-option">
512
					<label><?php esc_attr_e( 'New <span>post</span> title', 'lasso' );?><span class="lasso-util--help lasso-util--help-top" data-tooltip="<?php esc_attr_e( 'Specify title for new post, then save to edit.', 'lasso' );?>"><i class="lasso-icon-help"></i></span></label>
513
					<input class="lasso--modal__trigger-footer" type="text" required name="story_title" value="" placeholder="<?php esc_attr_e( 'Grump Wizards Make Toxic Brew', 'lasso' );?>">
514
						<div class="lasso--select-wrap" style="width:90px">
515
						<select id="lasso--select-type" name="story_type">
516
517
							<?php
518
								$types = lasso_post_types();
519 View Code Duplication
								if ( !empty( $types ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
520
									foreach( $types as $type ) {					
521
										$type = preg_replace( '/s\b/','', $type );
522
										printf( '<option value="%s">%s</option>', lcfirst( esc_attr( $type ) ) , ucfirst( esc_attr( $type ) ) );
523
									}
524
525
								}
526
							?>
527
528
						</select>
529
					</div>
530
				</div>
531
532
				<div class="lasso--postsettings__footer">
533
					<a href="#" class="lasso--postsettings-cancel"><?php _e( 'Cancel', 'lasso' );?></a>
534
					<input type="hidden" name="action" value="process_new-object_post">
535
					<?php
536 View Code Duplication
						if ( !empty( $types ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
537
							// get the first element
538
						    $type = reset($types);							
539
							$type = preg_replace( '/s\b/','', $type );
540
							printf( '<input type="hidden" name="object" value="%s">', lcfirst( esc_attr( $type ) ) );		
541
						}
542
					?>
543
					<input type="hidden" name="nonce" value="<?php echo $nonce;?>">
544
					<input type="submit" value="<?php esc_attr_e( 'Create', 'lasso' );?>">
545
				</div>
546
547
			</form>
548
549
		</div>
550
	</div>
551
	<div id="lasso--modal__overlay"></div>
552
553
	<?php return ob_get_clean();
554
}
555
556
/**
557
 * Used to house the all posts pop-up
558
 *
559
 * @since 0.9.3
560
 */
561
function lasso_editor_allpost_modal() {
562
563
	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...
564
	
565
	global $wp_post_types;
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...
566
    $labels = &$wp_post_types['post']->labels;
567
    $labels->name = 'Articles';
568
569
	ob_start();
570
571
	// post status
572
	$status = get_post_status( get_the_ID() );
0 ignored issues
show
Unused Code introduced by
$status is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
573
574
	// let users add custom css classes
575
	$custom_classes = apply_filters( 'lasso_modal_all_post_classes', '' );
576
577
	?>
578
	<div id="lasso--all-posts__modal" class="lasso--modal lasso--modal__full lassoShowAnimate <?php echo sanitize_html_class( $custom_classes );?>" style="max-height:100%">
579
		<div class="lasso--modal__inner">
580
581
			<div class="lasso--post-filtering not-visible">
582
				<div class="lasso--search__results">
583
					<span id="lasso--results-found"></span><?php _e('results found','lasso');?>
584
				</div>
585
				<div class="lasso--search">
586
					<i id="lasso--search__toggle" class="dashicons dashicons-search"></i>
587
					<input id="lasso--search-field" type="text" placeholder="search...">
588
				</div>
589
			</div>
590
591
			<ul class="lasso--post-object-list">
592
				<?php
593
594
				$post_types = lasso_post_types_names();
595
				$rest_bases = lasso_post_types_rest_base();
596
597
				if ( ! empty( $post_types ) ) {
598
					$first = 'active';
599
					foreach( $post_types as $name => $label ) {
600
						if (array_key_exists($name, $rest_bases)) {
601
							printf( '<li class="%1s lasso--show-objects" data-post-type="%2s">%3s</li>', esc_attr( $first), esc_attr( $rest_bases[$name] ), esc_attr( $label ) );
602
						}
603
						$first = '';
604
					}
605
606
				}
607
608
				do_action('lasso_modal_post_objects');?>
609
610
			</ul>
611
			<div id="lasso--loading" class="lasso--loading"><div class="lasso--loader"></div></div>
612
613
			<ul id="lasso--post-list" class="lasso--post-list"></ul>
614
615
		</div>
616
	</div>
617
	<div id="lasso--modal__overlay"></div>
618
619
	<?php return ob_get_clean();
620
}
621
622 View Code Duplication
function lasso_editor_wpimg_edit() {
0 ignored issues
show
Duplication introduced by
This function 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...
623
624
	ob_start();
625
626
627
	// let users add custom css classes
628
	$custom_classes = apply_filters( 'lasso_wpimg_classes', '' );
629
630
	?>
631
	<ul class="lasso-component--controls <?php echo sanitize_html_class( $custom_classes );?>" contenteditable="false">
632
		<li class="lasso-drag" title="<?php esc_attr_e( 'Move', 'lasso' );?>"></li>
633
		<li id="lasso--wpimg-edit" class="lasso-settings" title="<?php esc_attr_e( 'Settings', 'lasso' );?>"></li>
634
		<li class="lasso-clone" title="<?php esc_attr_e( 'Clone', 'lasso' );?>"></li>
635
		<li class="lasso-delete" title="<?php esc_attr_e( 'Delete', 'lasso' );?>"></li>
636
	</ul>
637
638
	<?php return ob_get_clean();
639
}
640
641 View Code Duplication
function lasso_editor_wpvideo_edit() {
0 ignored issues
show
Duplication introduced by
This function 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...
642
643
	ob_start();
644
645
646
	// let users add custom css classes
647
	$custom_classes = apply_filters( 'lasso_wpimg_classes', '' );
648
649
	?>
650
	<ul class="lasso-component--controls <?php echo sanitize_html_class( $custom_classes );?>" contenteditable="false">
651
		<li class="lasso-drag" title="<?php esc_attr_e( 'Move', 'lasso' );?>"></li>
652
		<li id="lasso--wpvideo-edit" class="lasso-settings" title="<?php esc_attr_e( 'Settings', 'lasso' );?>"></li>
653
		<li class="lasso-clone" title="<?php esc_attr_e( 'Clone', 'lasso' );?>"></li>
654
		<li class="lasso-delete" title="<?php esc_attr_e( 'Delete', 'lasso' );?>"></li>
655
	</ul>
656
657
	<?php return ob_get_clean();
658
}
659
660
/**
661
 * Used to house the hidden input fields for actions and process saving for the map component
662
 *
663
 * @since 1.0
664
 */
665
function lasso_map_form_footer() {
666
667
	$nonce = wp_create_nonce( 'lasso-process-map' );
668
669
	ob_start();
670
671
	?>
672
	<div class="lasso--map-form__footer">
673
		<input type="hidden" name="postid" value="<?php echo get_the_ID();?>">
674
		<input type="hidden" name="nonce" value="<?php echo $nonce;?>">
675
		<input type="hidden" name="action" value="process_map_save">
676
		<input type="submit" class="lasso--map-form__submit" value="<?php esc_attr_e( 'Save Locations', 'lasso' );?>">
677
	</div>
678
679
	<?php return ob_get_clean();
680
681
}
682
683
/**
684
 * Some things aren't real-time updatable so we need to append a message in certain areas on certain actions
685
 *
686
 * @since 1.0
687
 */
688
function lasso_editor_refresh_message() {
689
690
	ob_start();
691
692
	?>
693
	<div id="lasso--pagerefresh" class="visible">
694
		<?php _e( 'Save this post and refesh the page to see these changes.', 'lasso' );?>
695
	</div>
696
697
	<?php return ob_get_clean();
698
}
699
700
/**
701
 * Draw out the settings field based on the shortcodes array with options foudn in Lasso Story Engine
702
 *  This was mostly backported from lasso story engine and modified to allow for non lasso shortcodes and components
703
 *
704
 * @since 1.0
705
 */
706
function lasso_editor_options_blob() {
707
708
	$codes   = function_exists( 'aesop_shortcodes' ) ? aesop_shortcodes() : apply_filters( 'lasso_custom_options', '' );
709
	$galleries  = function_exists( 'lasso_editor_galleries_exist' ) && lasso_editor_galleries_exist() ? 'has-galleries' : 'creating-gallery';
710
711
	$nonce = wp_create_nonce( 'lasso_gallery' );
712
713
	$blob = array();
714
715
	if ( empty( $codes ) )
716
		return;
717
718
	foreach ( $codes as $slug => $shortcode ) {
719
		$return = '';
720
		// Shortcode has atts
721
722
		if ( count( $shortcode['atts'] ) && $shortcode['atts'] ) {
723
724
			foreach ( $shortcode['atts'] as $attr_name => $attr_info ) {
725
726
727
				$prefix = isset( $attr_info['prefix'] ) ? sprintf( '<span class="lasso-option-prefix">%s</span>', $attr_info['prefix'] ) : null;
728
729
				$return .= '<form id="lasso--component-settings-form" class="'.$galleries.'" method="post">';
730
				$return .= '<p data-option="'.$attr_name.'" class="lasso-option aesop-'.$slug.'-'.$attr_name.'">';
731
				$return .= '<label for="aesop-generator-attr-' . $attr_name . '">' . $attr_info['desc'] . '</label>';
732
				$return .= '<small class="lasso-option-desc">'.$attr_info['tip'].'</small>';
733
				// Select
734
735
				if ( isset( $attr_info['values'] ) ) {
736
737
					$return .= '<select name="' . $attr_name . '" id="aesop-generator-attr-' . $attr_name . '" class="lasso-generator-attr">';
738
739
					$i=0;
740
741
					foreach ( $attr_info['values'] as $attr_value ) {
742
						$attr_value_selected = $attr_info['default'] == $attr_value ? ' selected="selected"' : '';
743
744
						$return .= '<option value="'.$attr_info['values'][$i]['value'].'" ' . $attr_value_selected . '>'.$attr_info['values'][$i]['name'].'</option>';
745
746
						$i++;
747
					}
748
749
					$return .= '</select>';
750
751
				} else {
752
753
					$attr_field_type = isset( $attr_info['type'] ) ? $attr_info['type'] : 'text';
754
755
					// image upload
756
					if ( 'media_upload' == $attr_info['type'] ) {
757
758
						$return .= '<input type="' . $attr_field_type . '" name="' . $attr_name . '" value="'.$attr_info['default'].'" id="aesop-generator-attr-' . $attr_name . '" class="lasso-generator-attr aesop-generator-attr-'.$attr_field_type.'" />';
759
						$return .= '<a href="#" id="lasso-upload-img" class="lasso-option-button" /></a>';
760
761
					} elseif ( 'color' == $attr_info['type'] ) {
762
763
						$return .= '<input type="color" name="' . $attr_name . '" value="'.$attr_info['default'].'" id="aesop-generator-attr-' . $attr_name . '" class="lasso-generator-attr aesop-generator-attr-'.$attr_field_type.'" />';
764
765
					} elseif ( 'text_area' == $attr_info['type'] ) {
766
767
						$return .= '<textarea name="' . $attr_name . '" id="aesop-generator-attr-' . $attr_name . '" class="lasso-generator-attr aesop-generator-attr-'.$attr_field_type.'" placeholder="'.$attr_info['default'].'" /></textarea>'.$prefix.'';
768
769
					} else {
770
						$return .= '<input type="' . $attr_field_type . '" name="' . $attr_name . '" value="'.$attr_info['default'].'" id="aesop-generator-attr-' . $attr_name . '" class="lasso-generator-attr aesop-generator-attr-'.$attr_field_type.'" />'.$prefix.'';
771
					}
772
				}
773
				$return .= '</p>';
774
775
			}
776
		}
777
778
		///////////////////////////
779
		// START GALLERY AND MAP FRONT END STUFFS
780
		///////////////////////////
781
		if ( isset( $shortcode['front'] ) && true == $shortcode['front'] ) {
782
783
			if ( 'gallery' == $shortcode['front_type'] ) {
784
785
				$return .= lasso_gallery_editor_module();
786
787
			}
788
		}
789
		///////////////////////////
790
		// END GALLERY AND MAP FRONT END STUFFS
791
		///////////////////////////
792
793
		// Single shortcode (not closed)
794
		if ( 'single' == $shortcode['type'] ) {
795
796
			$return .= '<input type="hidden" name="lasso-generator-content" id="lasso-generator-content" value="false" />';
797
798
		} else {
799
800
			$return .= '<p data-option="content" class="lasso-option lasso-c-comp-text"><label>' . __( 'Content', 'lasso' ) . '</label><textarea type="text" name="lasso-generator-content" id="lasso-generator-content" value="' . $shortcode['content'] . '" /></textarea></p>';
801
		}
802
803
		$return .= '<p class="lasso-buttoninsert-wrap"><a href="#" class="lasso-generator-cancel" id="lasso--sidebar__close">Cancel
804
</a><input type="submit" id="lasso-generator-insert" value="Save Settings"></p>';
805
		$return .= '<input class="component_type" type="hidden" name="component_type" value="">';
806
		$return .= '<input type="hidden" name="unique" value="">';
807
		$return .= '<input type="hidden" name="nonce" id="lasso-generator-nonce" value="'.$nonce.'" />';
808
		$return .= '</form>';
809
810
		// extra JS codes
811
        if (isset($shortcode['codes'])) {
812
		    $return .= $shortcode['codes'];
813
        }
814
		$blob[$slug] = $return;
815
	}
816
817
	return $blob;
818
}
819
820
/**
821
 * Revisions modal
822
 *
823
 * @since 0.9.8
824
 *
825
 * @return string
826
 */
827
function lasso_editor_revision_modal() {
828
829
	ob_start();
830
	?>
831
		<div id="lasso--revision__modal" class="lasso--modal lassoShowAnimate ">
832
833
			<div class="lasso--modal__inner">
834
				<div id="lasso--loading" class="lasso--loading"><div class="lasso--loader"></div></div>
835
				<div id="lasso--hide" style="display:none;" class="lasso--post-form">
836
					<i class="lasso-icon lasso-icon-move"></i>
837
					<label><?php _e( 'Revisions', 'lasso' );?><span class="lasso-util--help lasso-util--help-top" data-tooltip="<?php esc_attr_e( 'Use the slider to view the revision live on the page.', 'lasso' );?>"><i class="lasso-icon-help"></i></span></label>
838
					<div class="lasso--slider_wrap">
839
						<div id="lasso--slider"></div>
840
					</div>
841
					<ul id="lasso--revision-list"></ul>
842
					<div class="lasso--btn-group lasso--btn-group-small">
843
						<a href="#" class="lasso--btn-secondary" id="lasso--close-modal"><?php _e( 'Cancel', 'lasso' );?></a>
844
						<a href="#" class="lasso--btn-primary" id="lasso--select-revision"><?php _e( 'Select', 'lasso' );?></a>
845
					</div>
846
				</div>
847
848
			</div>
849
		</div>
850
	<?php
851
	return ob_get_clean();
852
}
853