Completed
Push — master ( 6c5f1a...9f3b09 )
by
unknown
01:45
created

editor-modules.php ➔ lasso_editor_component_modal()   F

Complexity

Conditions 14
Paths 384

Size

Total Lines 154

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 14
nc 384
nop 0
dl 0
loc 154
rs 2.5066
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
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;
18
19
	if ( lasso_user_can('edit_posts') ) {
20
21
		$status = get_post_status( get_the_ID() );
22
		$use_old_ui   = lasso_editor_get_option( 'use_old_ui', 'lasso_editor' );
23
		$button_color1 = lasso_editor_get_option('button-color1', 'lasso_editor','#0000ff');
24
		$button_color2 = lasso_editor_get_option('button-color2', 'lasso_editor','#000000');
25
		$dialog_color = lasso_editor_get_option('dialog-color', 'lasso_editor','#000055');
26
		$text_color = lasso_editor_get_option('text-color', 'lasso_editor','#ffffff');
27
		$hover_color1 = lasso_editor_adjustBrightness($button_color1, 50);
28
		$hover_color2 = lasso_editor_adjustBrightness($button_color2, 50);
29
30
		// let users add custom css classes
31
		$custom_classes = apply_filters( 'lasso_control_classes', '' );
32
33
		$post_access_class   = '';
34
		$post_new_disabled   = lasso_editor_get_option( 'post_adding_disabled', 'lasso_editor' );
35
		$post_settings_disabled = lasso_editor_get_option( 'post_settings_disabled', 'lasso_editor' );
36
		$shortcodify_disabled = lasso_editor_get_option( 'shortcodify_disabled', 'lasso_editor' );
37
38
39
		// CSS class if adding new post objects is disabled
40
		if ( 'on' == $post_new_disabled ) { $post_access_class = 'lasso--post-new-disabled'; }
41
42
		// CSS class if adjust settings is disabled
43
		if ( 'on' == $post_settings_disabled ) { $post_access_class = 'lasso--post-settings-disabled'; }
44
45
		// CSS class if adding new post objects AND settings are disabled
46
		if ( 'on' == $post_new_disabled && 'on' == $post_settings_disabled ) { $post_access_class = 'lasso--post-all-disabled'; }
47
48
		// CSS class if shortcodify or (Aesop Shortcode Conversion) is disabled
49
		$sc_saving_class = 'on' == $shortcodify_disabled ? 'shortcodify-disabled' : 'shortcodify-enabled';
50
51
		// user is capable
52
		$is_capable = is_singular() && lasso_user_can('edit_post');
53
		$is_mobile = wp_is_mobile();
54
		
55
		$mobile_style = $is_mobile ? 'style="bottom:0px;"' : null;
56
		$can_publish = lasso_user_can('publish_posts') || lasso_user_can('publish_pages');
57
		
58
59
		if (!$use_old_ui) {
60
		?>
61
		<style>
62
		.lasso-editor-controls--wrap, #lasso--post-settings2,#lasso--save,#lasso--exit,#lasso--publish {
63
			background-image: -webkit-linear-gradient(top,<?php echo $button_color1;?> 0,<?php echo $button_color2;?> 100%);
64
			background-image: -o-linear-gradient(top,<?php echo $button_color1;?> 0,<?php echo $button_color2;?> 100%);
65
			background-image: linear-gradient(to bottom,<?php echo $button_color1;?> 0,<?php echo $button_color2;?> 100%);
66
			color: <?php echo $text_color;?>;
67
		}
68
		
69
		.lasso--controls__right a:before, #lasso-toolbar--html__footer_desc {
70
			color: <?php echo $text_color;?> !important;
71
		}
72
		
73
		ul.lasso-editor-controls li:hover, #lasso--exit:hover,#lasso--post-settings2:hover,#lasso--publish:hover,#lasso--save:hover {
74
			background-image: -webkit-linear-gradient(top,<?php echo $hover_color1;?> 0,<?php echo $hover_color2;?> 100%);
75
			background-image: -o-linear-gradient(top,<?php echo $hover_color1;?> 0,<?php echo $hover_color2;?> 100%);
76
			background-image: linear-gradient(to bottom,<?php echo $hover_color1;?> 0,<?php echo $hover_color2;?> 100%);
77
		}
78
		
79
		.lasso--modal__inner,.sweet-alert,#lasso-toolbar--components.toolbar--drop-up ul,#lasso-toolbar--components__list,#lasso-toolbar--html.html--drop-up #lasso-toolbar--html__wrap,
80
		#lasso-toolbar--link.link--drop-up #lasso-toolbar--link__wrap		{
81
			background: <?php echo $dialog_color;?>;
82
			color: <?php echo $text_color;?>;
83
		}
84
		.sweet-alert p,.lasso--modal__inner label,.lasso--toolbar__inner label {
85
			color: <?php echo $text_color;?> !important;
86
		}
87
		
88
		<?php if (!$is_mobile) { ?>
89
			.lasso-editor-controls--wrap {
90
				display:table;
91
			}
92
			ul.lasso-editor-controls {
93
				height:42px;
94
				font-size: 22px;
95
			}
96
			.lasso-editor-controls--wrap {
97
				height:42px;
98
			}
99
			#lasso--post-all:before {
100
				font-size: 22px;
101
			}
102
103
			ul.lasso-editor-controls li {
104
				height: 42px;
105
			}
106
		<?php
107
		} 
108
		?>
109
		
110
		
111
		</style>
112
		<?php
113
		} 
114
		?>
115
		<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();?>" >
116
117
			<ul class="lasso--controls__center lasso-editor-controls lasso-editor-controls--wrap <?php echo $post_access_class;?> "  <?php echo $mobile_style ?> >
118
119
				<?php do_action( 'lasso_editor_controls_before' );
120
121
				if ( $is_capable ) { ?>
122
123
					<li id="lasso--edit" title="<?php esc_attr_e( 'Edit Post', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
124
125
					<?php if ( 'off' == $post_settings_disabled || empty( $post_settings_disabled ) ) { ?>
126
						<li id="lasso--post-settings" title="<?php esc_attr_e( 'Post Settings', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
127
					<?php }
128
129
				} ?>
130
131
				<li id="lasso--post-all" title="<?php esc_attr_e( 'All Posts', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
132
133
				<?php if ( $is_capable && wp_revisions_enabled( $post ) ) { ?>
134
					<li id="lasso--post-revisions" title="<?php esc_attr_e( 'Revisions', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
135
				<?php } ?>
136
137
				<?php if ( ( 'off' == $post_new_disabled || empty( $post_new_disabled ) && lasso_user_can('edit_posts') ) ) { ?>
138
					<li id="lasso--post-new" title="<?php esc_attr_e( 'Add Post', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
139
				<?php } ?>
140
141
				<?php do_action( 'lasso_editor_controls_after' );?>
142
143
			</ul>
144
145
			<?php if ( is_singular() && !$is_mobile ) { ?>
146
147
				<div class="lasso--controls__right" data-posttype="<?php echo get_post_type( get_the_ID() );?>" data-status="<?php echo $status;?>">
148
				
149
				<a href="#" title="<?php esc_attr_e( 'Post Settings', 'lasso' );?>" id="lasso--post-settings2" class="lasso-save-post lasso--button <?php echo $sc_saving_class;?>"></a>
150
151
152
					<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>
153
154
					<?php if ( ('draft' == $status ) || ('pending' == $status && $can_publish) ) { ?>
155
						<a href="#" title="<?php $can_publish ? esc_attr_e( 'Publish Post', 'lasso' ) : esc_attr_e( 'Submit For Review', 'lasso' );?>" id="lasso--publish" class="lasso-publish-post lasso--button <?php echo $sc_saving_class;?>"></a>
156
					<?php } ?>
157
158
				</div>
159
160
			<?php } ?>
161
162
		</div>
163
164
	<?php }
165
}
166
167
/**
168
 * Draw the side panel that houses the component settings
169
 * This is opened when the settings icon is clicked on a single component
170
 * 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
171
 *
172
 * @since 1.0
173
 */
174
function lasso_editor_component_sidebar() {
175
176
	ob_start();
177
178
179
	// let users add custom css classes
180
	$custom_classes = apply_filters( 'lasso_sidebar_classes', '' );
181
	?>
182
	<div id="lasso--sidebar" class="<?php echo sanitize_html_class( $custom_classes );?>" >
183
		<div class="lasso--sidebar__inner">
184
			<div id="lasso--component__settings"></div>
185
		</div>
186
	</div>
187
188
	<?php return ob_get_clean();
189
}
190
191
/**
192
 * Draw the main toolbar used to edit the text
193
 *
194
 * @since 1.0
195
 */
196
function lasso_editor_text_toolbar() {
197
198
	ob_start();
199
200
	
201
	$is_mobile = wp_is_mobile();
202
203
	// check for lasso story engine and add a class doniting this
204
	$ase_status = class_exists( 'Aesop_Core' ) || defined( 'LASSO_CUSTOM' ) ? 'ase-active' : 'ase-not-active';
205
206
	// let users add custom css classes
207
	$custom_classes = apply_filters( 'lasso_toolbar_classes', '' );
208
209
	// are toolbar headings enabled
210
	$toolbar_headings      = lasso_editor_get_option( 'toolbar_headings', 'lasso_editor' );
211
	$toolbar_headings_h4      = lasso_editor_get_option( 'toolbar_headings_h4', 'lasso_editor' );
212
213
	$toolbar_class  = $toolbar_headings ? 'toolbar-extended' : false;
214
	
215
	// mobile styles
216
    $mobile_class = $is_mobile ? 'lasso-mobile' : false;
217
	$mobile_style =$is_mobile ? 'style="bottom:0px;"' : null;
218
	
219
	//show color
220
	$show_color = lasso_editor_get_option('toolbar_show_color', 'lasso_editor');
221
	
222
	//show alignment
223
	$show_align = lasso_editor_get_option('toolbar_show_alignment', 'lasso_editor');
224
	
225
	$status = get_post_status( get_the_ID() );
226
	
227
	$shortcodify_disabled = lasso_editor_get_option( 'shortcodify_disabled', 'lasso_editor' );
228
	
229
	$sc_saving_class = 'on' == $shortcodify_disabled ? 'shortcodify-disabled' : 'shortcodify-enabled';
230
231
232
	?>
233
	<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 ?>>
234
		<ul class="lasso--toolbar__inner lasso-editor-controls" <?php if ($is_mobile) {echo 'style="float:left;"';}?>>
235
			<?php do_action( 'lasso_toolbar_components_before' );?>
236
		    <li id="lasso-toolbar--bold" title="<?php esc_attr_e( 'Bold', 'lasso' );?>"></li>
237
		    <li id="lasso-toolbar--underline" title="<?php esc_attr_e( 'Underline', 'lasso' );?>"></li>
238
		    <li id="lasso-toolbar--italic" title="<?php esc_attr_e( 'Italicize', 'lasso' );?>"></li>
239
		    <li id="lasso-toolbar--strike" title="<?php esc_attr_e( 'Strikethrough', 'lasso' );?>"></li>
240
			<li id="lasso-toolbar--components" title="<?php esc_attr_e( 'Insert Component', 'lasso' );?>" style="color:#ffffa0;">
241
			    <ul id="lasso-toolbar--components__list" style="display:none;color:white;">
242
			    	<?php if ( 'ase-active' == $ase_status ): ?>
243
						<li data-type="image" title="<?php esc_attr_e( 'Image', 'lasso' );?>" class="lasso-toolbar--component__image"></li>
244
						<li data-type="character" title="<?php esc_attr_e( 'Character', 'lasso' );?>" class="lasso-toolbar--component__character"></li>
245
						<li data-type="quote" title="<?php esc_attr_e( 'Quote', 'lasso' );?>"  class="lasso-toolbar--component__quote"></li>
246
						<li data-type="content" title="<?php esc_attr_e( 'Content', 'lasso' );?>"  class="lasso-toolbar--component__content"></li>
247
						<li data-type="chapter" title="<?php esc_attr_e( 'Chapter', 'lasso' );?>"  class="lasso-toolbar--component__chapter"></li>
248
						<li data-type="parallax" title="<?php esc_attr_e( 'Parallax', 'lasso' );?>"  class="lasso-toolbar--component__parallax"></li>
249
						<li data-type="audio" title="<?php esc_attr_e( 'Audio', 'lasso' );?>"  class="lasso-toolbar--component__audio"></li>
250
						<li data-type="video" title="<?php esc_attr_e( 'Video', 'lasso' );?>"  class="lasso-toolbar--component__video"></li>
251
						<li data-type="map" title="<?php esc_attr_e( 'Map', 'lasso' );?>"  class="lasso-toolbar--component__map"></li>
252
						<li data-type="timeline_stop" title="<?php esc_attr_e( 'Timeline', 'lasso' );?>"  class="lasso-toolbar--component__timeline"></li>
253
						<li data-type="document" title="<?php esc_attr_e( 'Document', 'lasso' );?>"  class="lasso-toolbar--component__document"></li>
254
						<li data-type="collection" title="<?php esc_attr_e( 'Collection', 'lasso' );?>"  class="lasso-toolbar--component__collection"></li>
255
						<li data-type="gallery" title="<?php esc_attr_e( 'Gallery', 'lasso' );?>"  class="lasso-toolbar--component__gallery"></li>
256
						<?php if ( class_exists ('Aesop_GalleryPop') ) { ?>
257
						     <li data-type="gallery" title="<?php esc_attr_e( 'Gallery Pop', 'lasso' );?>"  class="lasso-toolbar--component__gallerypop"></li>
258
						<?php }?>
259
						<?php if ( class_exists ('Aesop_Events') ) { ?>
260
						     <li data-type="events" title="<?php esc_attr_e( 'Event', 'lasso' );?>"  class="lasso-toolbar--component__event"></li>
261
						<?php }?>
262 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...
263
						<li data-type="wpimg" title="<?php esc_attr_e( 'WordPress Image', 'lasso' );?>" class="image lasso-toolbar--component__image"></li>
264
						<li data-type="wpquote" title="<?php esc_attr_e( 'WordPress Quote', 'lasso' );?>" class="quote lasso-toolbar--component__quote"></li>
265
						<!--li data-type="wpvideo" title="<?php esc_attr_e( 'WordPress Video', 'lasso' );?>" class="video lasso-toolbar--component__video"></li-->
266
					<?php endif; ?>
267
					<?php do_action( 'lasso_toolbar_components' );?>
268
			    </ul>
269
			</li>
270
		    <?php if ( $toolbar_headings ): ?>
271
		    <li id="lasso-toolbar--h2" title="<?php esc_attr_e( 'H2 Heading', 'lasso' );?>"></li>
272
		    <li id="lasso-toolbar--h3" title="<?php esc_attr_e( 'H3 Heading', 'lasso' );?>"></li>
273
			<?php endif; ?>
274 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...
275
		    <li id="lasso-toolbar--h4" title="<?php esc_attr_e( 'H4 Heading', 'lasso' );?>"></li>
276
		    <li id="lasso-toolbar--h5" title="<?php esc_attr_e( 'H5 Heading', 'lasso' );?>"></li>
277
			<li id="lasso-toolbar--h6" title="<?php esc_attr_e( 'H6 Heading', 'lasso' );?>"></li>
278
			<?php endif; ?>
279
			
280
			<?php if ( $show_color ): ?>
281
		    <li id="lasso-toolbar--color-set" title="<?php esc_attr_e( 'Set Color for Selected Text', 'lasso' );?>"></li>
282
		    <li id="lasso-toolbar--color-pick" title="<?php esc_attr_e( 'Choose Color', 'lasso' );?>"></li>
283
			<?php endif; ?>
284
					
285
		    
286
			<li id="lasso-toolbar--link" title="<?php esc_attr_e( 'Anchor Link', 'lasso' );?>">
287
		    	<div id="lasso-toolbar--link__wrap" <?php echo $mobile_style ?> >
288
		    		<div id="lasso-toolbar--link__inner" contenteditable="true" placeholder="<?php esc_attr_e( 'http://url.com', 'lasso' );?>"></div>
289
		    		<a href="#" title="<?php esc_attr_e( 'Create Link', 'lasso' );?>" class="lasso-toolbar--link__control" id="lasso-toolbar--link__create" ></a>
290
					<input class="styled-checkbox" type="checkbox" id="aesop-toolbar--link_newtab" checked/>
291
                    <label for="aesop-toolbar--link_newtab"><?php esc_attr_e( 'Open in a New Tab', 'lasso' );?></label>
292
		    	</div>
293
		    </li>
294
		    <?php do_action( 'lasso_toolbar_components_after' );?>
295
		    <li id="lasso-toolbar--html" title="<?php esc_attr_e( 'Insert HTML or Code', 'lasso' );?>">
296
		    	<div id="lasso-toolbar--html__wrap" <?php echo $mobile_style ?>>
297
		    		<div id="lasso-toolbar--html__inner" contenteditable="true" placeholder="<?php esc_attr_e( 'Enter HTML to insert', 'lasso' );?>"></div>
298
		    		<div id="lasso-toolbar--html__footer">
299
					<div id="lasso-toolbar--html__footer_desc" >
300
					<?php esc_attr_e( 'Enter HTML to insert', 'lasso' );?><br>
301
					<?php esc_attr_e( 'You can also use Shortcodes', 'lasso' );?><br>
302
					<?php esc_attr_e( 'You can also enter a URL to embed, such as Youtube, Vimeo and Twitter URLs.', 'lasso' );?>
303
					</div>
304
		    			<ul class="lasso-toolbar--html-snips">
305
						
306
		    				<?php if ( !$toolbar_headings ): ?>
307
		    				<li id="lasso-html--h2" title="<?php esc_attr_e( 'H2 Heading', 'lasso' );?>">
308
		    				<li id="lasso-html--h3" title="<?php esc_attr_e( 'H3 Heading', 'lasso' );?>">
309
		    				<?php endif; ?>
310
		    				<li id="lasso-html--ul" title="<?php esc_attr_e( 'Unordered List', 'lasso' );?>">
311
		    				<li id="lasso-html--ol" title="<?php esc_attr_e( 'Ordered List', 'lasso' );?>">
312
		    			</ul>
313
		    			<a class="lasso-toolbar--html__control lasso-toolbar--html__cancel" href="#"><?php _e( 'Cancel', 'lasso' );?></a>
314
		    			<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>
315
		    		</div>
316
		    	</div>
317
		    </li>
318 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...
319
		    <li id="lasso-toolbar--left-align" title="<?php esc_attr_e( 'Text Left Align', 'lasso' );?>"></li>
320
		    <li id="lasso-toolbar--center-align" title="<?php esc_attr_e( 'Text Center Align', 'lasso' );?>"></li>
321
			<li id="lasso-toolbar--right-align" title="<?php esc_attr_e( 'Text Right Align', 'lasso' );?>"></li>
322
			<?php endif; ?>
323
		</ul>
324
		<?php if ( is_singular() && $is_mobile ) { ?>
325
326
				<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;">
327
328
					<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>
329
330
					<?php if ( 'draft' == $status && ( lasso_user_can('publish_posts') || lasso_user_can('publish_pages') )  ) { ?>
331
						<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>
332
					<?php } ?>
333
334
				</div>
335
336
		<?php } ?>
337
	</div>
338
339
	<?php return ob_get_clean();
340
}
341
342
/**
343
 * Draw the controls used for teh component settings within each component
344
 *
345
 * @since 1.0
346
 */
347
function lasso_editor_settings_toolbar() {
348
349
	$delete_nonce = wp_create_nonce( 'lasso-delete-nonce' );
350
351
	ob_start();
352
353
354
	// let users add custom css classes
355
	$custom_classes = apply_filters( 'lasso_component_classes', '' );
356
357
	?>
358
	<ul class="lasso-component--controls <?php echo sanitize_html_class( $custom_classes );?>" contenteditable="false">
359
		<li class="lasso-drag" title="<?php esc_attr_e( 'Move', 'lasso' );?>"></li>
360
		<li id="lasso-component--settings__trigger" class="lasso-settings" title="<?php esc_attr_e( 'Settings', 'lasso' );?>"></li>
361
		<li class="lasso-clone" title="<?php esc_attr_e( 'Clone', 'lasso' );?>"></li>
362
		<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>
363
	</ul>
364
365
	<?php return ob_get_clean();
366
}
367
368
/**
369
 * Draws the controls used for changing the featured image
370
 *   These controls are appended based on the class set in the define
371
 *
372
 * @since 1.0
373
 */
374
function lasso_editor_image_controls() {
375
376
	ob_start();
377
378
379
	// has post thumbnail
380
	$has_thumbnail = has_post_thumbnail( get_the_ID() ) ? 'class="lasso--featImg--has-thumb"' : false;
381
382
	?>
383
	<ul id="lasso--featImgControls" <?php echo $has_thumbnail;?>>
384
		<li id="lasso--featImgUpload"><a title="<?php esc_attr_e( 'Replace Image', 'lasso' );?>" href="#"><i class="lasso-icon-image"></i></a></li>
385
		<li id="lasso--featImgDelete"><a title="<?php esc_attr_e( 'Delete Image', 'lasso' );?>" href="#"><i class="lasso-icon-bin2"></i></a></li>
386
		<li id="lasso--featImgSave"><a href="#"><?php esc_attr_e( 'save', 'lasso' );?></a></li>
387
	</ul>
388
389
	<?php return ob_get_clean();
390
}
391
392
393
/**
394
 * Used to house post settings like scheduling, slugs and draft status
395
 * Note: the "add new" will use the same object as the currently shown. For example, if the user
396
 * is currently on a post, and clicks add new, then it'll add a new post. If the user is on a
397
 * post type like "dog", then it will create a new post type called "dog"
398
 *
399
 * @since 1.0
400
 */
401
function lasso_editor_component_modal() {
402
403
	ob_start();
404
405
406
	global $post;
407
408
	$postid = get_the_ID();
409
410
	$status = get_post_status( $postid );
411
	$nonce = wp_create_nonce( 'lasso-update-post-settings' );
412
413
	// let users add custom css classes
414
	$custom_classes = apply_filters( 'lasso_modal_settings_classes', '' );
415
416
	// objects categories
417
	$categories 		= lasso_get_post_objects( $postid, 'category' );
418
	$tags 				= lasso_get_post_objects( $postid, 'tag' );
419
420
	// modal tabs
421
	$tabs  				= lasso_modal_addons('tab');
422
	$content 			= lasso_modal_addons('content');
423
	
424
	//editor options
425
	$allow_change_date = lasso_editor_get_option('allow_change_date', 'lasso_editor');
426
427
	// are we singular
428
	$is_singular 		= is_singular();
429
	$is_singular_class 	= $is_singular ? 'lasso--postsettings__2col' : 'lasso--postsettings__1col';
430
	$has_thumb_class    = has_post_thumbnail() ? 'has-thumbnail' : 'no-thumbnail';
431
	$theme_supports     = current_theme_supports('post-thumbnails');
432
	$default_image 		= LASSO_URL.'/admin/assets/img/empty-img.png';
433
	
434
	// do we support pending status
435
	$no_pending_status = lasso_editor_get_option('no_pending_status', 'lasso_editor');
436
437
?>
438
	<div id="lasso--post-settings__modal" class="lasso--modal lassoShowAnimate <?php echo sanitize_html_class( $custom_classes );?>">
439
		<div class="lasso--modal__inner">
440
441
			<?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...
442
443
			<div class="lasso--modal__content modal__content--core visible" data-addon-content="core">
444
				<form id="lasso--postsettings__form" enctype="multipart/form-data" class="lasso--post-form <?php echo $is_singular_class.' '.$has_thumb_class;?>" >
445
446
					<?php if ( $is_singular && $theme_supports ) : ?>
447
					<div class="lasso--postsettings__left">
448
						<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>
449
						<div class="lasso--post-thumb" data-default-thumb="<?php echo esc_url( $default_image );?>">
450
451
							<div id="lasso--post-thumb__controls" class="lasso--post-thumb__controls">
452
								<i id="lasso--post-thumb__add" title="<?php _e('Change Featured Image','lasso');?>" class="dashicons dashicons-edit"></i>
453
								<i id="lasso--post-thumb__delete" title="<?php _e('Delete Featured Image','lasso');?>" class="dashicons dashicons-no-alt"></i>
454
								<i id="lasso--save-status" class="lasso-icon lasso-icon-spinner6 not-visible"></i>
455
							</div>
456
457
							<?php echo has_post_thumbnail() ? get_the_post_thumbnail( $post->ID, 'medium' ) : '<img src="'.$default_image.'">'; ?>
458
459
						</div>
460
						<div id="lasso--featImgSave"><a href="#" class="not-visible">Save</a></div>
461
462
					</div>
463
					<?php endif; ?>
464
465
					<div class="lasso--postsettings__right">
466
467
						<?php if( lasso_user_can('publish_posts') || lasso_user_can('publish_pages') ): ?>
468
						<div class="lasso--postsettings__option story-status-option">
469
							<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>
470
							<ul class="story-status story-status-<?php echo sanitize_html_class( $status );?>">
471
								<li id="lasso--status-draft"><?php _e( 'Draft', 'lasso' );?></li>
472
								<?php if( !$no_pending_status ): ?>								
473
								<li id="lasso--status-pending"><?php _e( 'Pending', 'lasso' );?></li>
474
								<?php endif; ?>
475
								<li id="lasso--status-publish"><?php _e( 'Publish', 'lasso' );?></li>
476
							</ul>
477
							<div class="lasso--slider_wrap">
478
								<div id="lasso--slider"></div>
479
							</div>
480
						</div>
481
						<?php endif; ?>
482
483
						<?php if ( 'publish' == $status ): ?>
484
						<div class="lasso--postsettings__option story-slug-option">
485
							<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>
486
							<input class="lasso--modal__trigger-footer" type="text" name="story_slug" value="<?php echo isset( $post ) ? esc_attr( $post->post_name ) : false;?>">
487
						</div>
488
						<?php endif; ?>
489
490
					</div>
491
492
					<div class="lasso--postsettings__middle">
493
494
						<div class="lasso--postsettings__option story-categories-option">
495
							<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>
496
							<input id="lasso--cat-select" class="lasso--modal__trigger-footer" type="hidden" name="story_cats" value="<?php echo $categories;?>">
497
						</div>
498
499
						<div class="lasso--postsettings__option story-tags-option">
500
							<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>
501
							<input id="lasso--tag-select" class="lasso--modal__trigger-footer" type="hidden" name="story_tags" value="<?php echo $tags;?>">
502
						</div>
503
						<?php 
504
						if ($allow_change_date) { 
505
						    $dateformat = get_option( 'date_format' ); 
506
						?>
507
						    <label><?php _e( 'Post Date', 'lasso' ); ?></label>
508
							<input type="text" class="editus_custom_date" name="post_date" value="<?php echo get_the_time($dateformat, $postid);?>"/>
509
						<?php
510
						}?>
511
512
					</div>
513
					<!-- alternate way to display categories disabled now -->
514
					<!--div style="max-height:300px;overflow-y: scroll;"-->
515
                    <?php
516
							/*$allcats = explode(",",lasso_get_objects('category'));
517
							$currcats = explode(",",$categories);
518
							foreach ( $allcats  as $category ) {
519
								if (empty($category)) continue;
520
							   $checked ="";
521
							   if (  in_array( $category, $currcats ) ) {
522
									$checked = 'checked="checked"';
523
									
524
							   }
525
							   echo '<label><input type="checkbox" '.$checked.' name="categories" id="'.$category.'" >'.$category.'</label>';
526
							}*/
527
					?>
528
					<!--/div-->
529
530
					<?php do_action( 'lasso_modal_post_form' ); // action ?>
531
532
					<div class="lasso--postsettings__footer" >
533
						<a href="#" class="lasso--postsettings-cancel"><?php _e( 'Cancel', 'lasso' );?></a>
534
						<input type="hidden" name="status" value="">
535
						<input type="hidden" name="categories" value="">
536
						<input type="hidden" name="postid" value="<?php echo get_the_ID();?>">
537
						<input type="hidden" name="action" value="process_update-object_post">
538
						<input type="hidden" name="nonce" value="<?php echo $nonce;?>">
539
						<?php do_action( 'lasso_modal_post_form_footer' ); // action ?>
540
						<input type="submit" id="lasso--postsettings-submit" value="<?php esc_attr_e( 'Save', 'lasso' );?>">
541
					</div>
542
543
				</form>
544
			</div>
545
546
			<?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...
547
548
		</div>
549
550
	</div>
551
	<div id="lasso--modal__overlay"></div>
552
553
	<?php return ob_get_clean();
554
}
555
556
/**
557
 * Used to house the form for creating a new post within amodal
558
 *
559
 * @since 1.0
560
 */
561
function lasso_editor_newpost_modal() {
562
563
	global $post;
564
565
	ob_start();
566
567
568
	$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...
569
570
	$nonce = wp_create_nonce( 'lasso-editor-new-post' );
571
572
	// let users add custom css classes
573
	$custom_classes = apply_filters( 'lasso_modal_post_classes', '' );
574
575
	// return the post type
576
	$type = get_post_type( get_the_ID() );
0 ignored issues
show
Unused Code introduced by
$type 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...
577
578
	$mobile_style = "";
579
	if (wp_is_mobile()) {
580
		$mobile_style = 'style="top:140px !important;"';
581
	}
582
	?>
583
	<div id="lasso--post-new__modal" class="lasso--modal lasso--modal__med lassoShowAnimate <?php echo sanitize_html_class( $custom_classes );?>" <?php echo $mobile_style;?>">
584
		<div class="lasso--modal__inner lasso--hasnewform">
585
586
			<form id="lasso--postnew__form" enctype="multipart/form-data" class="lasso--post-form">
587
588
				<div class="lasso--postsettings__option story-slug-option lasso--last-option">
589
					<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>
590
					<input class="lasso--modal__trigger-footer" type="text" required name="story_title" value="" placeholder="<?php esc_attr_e( 'Type Your Title Here', 'lasso' );?>">
591
						<div class="lasso--select-wrap" style="width:90px">
592
						<select id="lasso--select-type" name="story_type">
593
594
							<?php
595
								$types = lasso_post_types_names();
596
								if ( !empty( $types ) ) {
597
									foreach( $types as $name => $label ) {										
598
										$type = preg_replace( '/s\b/','', $name );
599
										if ($type == 'page' && !current_user_can('edit_pages')) {
600
											continue;
601
										}
602
										printf( '<option value="%s">%s</option>', lcfirst( esc_attr( $type ) ) , ucfirst( esc_attr( $label ) ) );
603
									}
604
605
								}
606
							?>
607
608
						</select>
609
					</div>
610
				</div>
611
612
				<div class="lasso--postsettings__footer">
613
					<a href="#" class="lasso--postsettings-cancel"><?php _e( 'Cancel', 'lasso' );?></a>
614
					<input type="hidden" name="action" value="process_new-object_post">
615
					<?php
616
						if ( !empty( $types ) ) {
617
							// get the first element
618
							$keys = array_keys($types);
619
						    $type =$keys[0];						
620
							$type = preg_replace( '/s\b/','', $type );
621
							printf( '<input type="hidden" name="object" value="%s">', lcfirst( esc_attr( $type ) ) );		
622
						}
623
					?>
624
					<input type="hidden" name="nonce" value="<?php echo $nonce;?>">
625
					<input type="submit" value="<?php esc_attr_e( 'Create', 'lasso' );?>">
626
				</div>
627
628
			</form>
629
630
		</div>
631
	</div>
632
	<div id="lasso--modal__overlay"></div>
633
634
	<?php return ob_get_clean();
635
}
636
637
/**
638
 * Used to house the all posts pop-up
639
 *
640
 * @since 0.9.3
641
 */
642
function lasso_editor_allpost_modal() {
643
644
	global $post;
645
	
646
	global $wp_post_types;
647
    $labels = &$wp_post_types['post']->labels;
648
    $labels->name = 'Articles';
649
650
	ob_start();
651
652
	// post status
653
	$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...
654
655
	// let users add custom css classes
656
	$custom_classes = apply_filters( 'lasso_modal_all_post_classes', '' );
657
658
	?>
659
	<div id="lasso--all-posts__modal" class="lasso--modal lasso--modal__full lassoShowAnimate <?php echo sanitize_html_class( $custom_classes );?>" style="max-height:100%">
660
		<div class="lasso--modal__inner">
661
662
			<div class="lasso--post-filtering not-visible">
663
				<div class="lasso--search__results">
664
					<span id="lasso--results-found"></span><?php _e('results found','lasso');?>
665
				</div>
666
				<div class="lasso--search">
667
					<i id="lasso--search__toggle" class="dashicons dashicons-search"></i>
668
					<input id="lasso--search-field" type="text" placeholder="search...">
669
				</div>
670
			</div>
671
672
			<ul class="lasso--post-object-list">
673
				<?php
674
675
				$post_types = lasso_post_types_names();
676
				$rest_bases = lasso_post_types_rest_base();
677
678
				if ( ! empty( $post_types ) ) {
679
					$first = 'active';
680
					foreach( $post_types as $name => $label ) {
681
						if (array_key_exists($name, $rest_bases)) {
682
							printf( '<li class="%1s lasso--show-objects" data-post-type="%2s">%3s</li>', esc_attr( $first), esc_attr( $rest_bases[$name] ), esc_attr( $label ) );
683
						}
684
						$first = '';
685
					}
686
687
				}
688
689
				do_action('lasso_modal_post_objects');?>
690
691
			</ul>
692
			<div id="lasso--loading" class="lasso--loading"><div class="lasso--loader"></div></div>
693
694
			<ul id="lasso--post-list" class="lasso--post-list"></ul>
695
696
		</div>
697
	</div>
698
	<div id="lasso--modal__overlay"></div>
699
700
	<?php return ob_get_clean();
701
}
702
703 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...
704
705
	ob_start();
706
707
708
	// let users add custom css classes
709
	$custom_classes = apply_filters( 'lasso_wpimg_classes', '' );
710
711
	?>
712
	<ul class="lasso-component--controls <?php echo sanitize_html_class( $custom_classes );?>" contenteditable="false">
713
		<li class="lasso-drag" title="<?php esc_attr_e( 'Move', 'lasso' );?>"></li>
714
		<li id="lasso--wpimg-edit" class="lasso-settings" title="<?php esc_attr_e( 'Settings', 'lasso' );?>"></li>
715
		<li class="lasso-clone" title="<?php esc_attr_e( 'Clone', 'lasso' );?>"></li>
716
		<li class="lasso-delete" title="<?php esc_attr_e( 'Delete', 'lasso' );?>"></li>
717
	</ul>
718
719
	<?php return ob_get_clean();
720
}
721
722 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...
723
724
	ob_start();
725
726
727
	// let users add custom css classes
728
	$custom_classes = apply_filters( 'lasso_wpimg_classes', '' );
729
730
	?>
731
	<ul class="lasso-component--controls <?php echo sanitize_html_class( $custom_classes );?>" contenteditable="false">
732
		<li class="lasso-drag" title="<?php esc_attr_e( 'Move', 'lasso' );?>"></li>
733
		<li id="lasso--wpvideo-edit" class="lasso-settings" title="<?php esc_attr_e( 'Settings', 'lasso' );?>"></li>
734
		<li class="lasso-clone" title="<?php esc_attr_e( 'Clone', 'lasso' );?>"></li>
735
		<li class="lasso-delete" title="<?php esc_attr_e( 'Delete', 'lasso' );?>"></li>
736
	</ul>
737
738
	<?php return ob_get_clean();
739
}
740
741
/**
742
 * Used to house the hidden input fields for actions and process saving for the map component
743
 *
744
 * @since 1.0
745
 */
746
function lasso_map_form_footer() {
747
748
	$nonce = wp_create_nonce( 'lasso-process-map' );
749
750
	ob_start();
751
752
	?>
753
	<div class="lasso--map-form__footer">
754
		<input type="hidden" name="postid" value="<?php echo get_the_ID();?>">
755
		<input type="hidden" name="nonce" value="<?php echo $nonce;?>">
756
		<input type="hidden" name="action" value="process_map_save">
757
		<input type="submit" class="lasso--map-form__submit" value="<?php esc_attr_e( 'Save Locations', 'lasso' );?>">
758
	</div>
759
760
	<?php return ob_get_clean();
761
762
}
763
764
/**
765
 * Some things aren't real-time updatable so we need to append a message in certain areas on certain actions
766
 *
767
 * @since 1.0
768
 */
769
function lasso_editor_refresh_message() {
770
771
	ob_start();
772
773
	?>
774
	<div id="lasso--pagerefresh" class="visible">
775
		<?php _e( 'Save this post and refesh the page to see these changes.', 'lasso' );?>
776
	</div>
777
778
	<?php return ob_get_clean();
779
}
780
781
/**
782
 * Draw out the settings field based on the shortcodes array with options foudn in Aesop Story Engine
783
 *  This was mostly backported from aesop story engine and modified to allow for non aesop shortcodes and components
784
 *
785
 * @since 1.0
786
 */
787
function lasso_editor_options_blob() {
788
789
	$codes   = function_exists( 'aesop_shortcodes' ) ? aesop_shortcodes() : apply_filters( 'lasso_custom_options', '' );
790
	$galleries  = function_exists( 'lasso_editor_galleries_exist' ) && lasso_editor_galleries_exist() ? 'has-galleries' : 'creating-gallery';
791
792
	$nonce = wp_create_nonce( 'lasso_gallery' );
793
794
	$blob = array();
795
796
	if ( empty( $codes ) )
797
		return;
798
799
	foreach ( $codes as $slug => $shortcode ) {
800
		$return = '';
801
		// Shortcode has atts
802
803
		if ( count( $shortcode['atts'] ) && $shortcode['atts'] ) {
804
805
			foreach ( $shortcode['atts'] as $attr_name => $attr_info ) {
806
807
808
				$prefix = isset( $attr_info['prefix'] ) ? sprintf( '<span class="lasso-option-prefix">%s</span>', $attr_info['prefix'] ) : null;
809
810
				$return .= '<form id="lasso--component-settings-form" class="'.$galleries.'" method="post">';
811
				$return .= '<p data-option="'.$attr_name.'" class="lasso-option aesop-'.$slug.'-'.$attr_name.'">';
812
				$return .= '<label for="aesop-generator-attr-' . $attr_name . '">' . $attr_info['desc'] . '</label>';
813
				$return .= '<small class="lasso-option-desc">'.$attr_info['tip'].'</small>';
814
				// Select
815
816
				if ( isset( $attr_info['values'] ) ) {
817
818
					$return .= '<select name="' . $attr_name . '" id="aesop-generator-attr-' . $attr_name . '" class="lasso-generator-attr">';
819
820
					$i=0;
821
822
					foreach ( $attr_info['values'] as $attr_value ) {
823
						$attr_value_selected = $attr_info['default'] == $attr_value ? ' selected="selected"' : '';
824
825
						$return .= '<option value="'.$attr_info['values'][$i]['value'].'" ' . $attr_value_selected . '>'.$attr_info['values'][$i]['name'].'</option>';
826
827
						$i++;
828
					}
829
830
					$return .= '</select>';
831
832
				} else {
833
834
					$attr_field_type = isset( $attr_info['type'] ) ? $attr_info['type'] : 'text';
835
836
					// image upload
837
					if ( 'media_upload' == $attr_info['type'] ) {
838
839
						$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.'" />';
840
						$return .= '<a href="#" id="lasso-upload-img" class="lasso-option-button" /></a>';
841
842
					} elseif ( 'color' == $attr_info['type'] ) {
843
844
						$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.'" />';
845
846
					} elseif ( 'text_area' == $attr_info['type'] ) {
847
848
						$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.'';
849
850
					} else {
851
						$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.'';
852
					}
853
				}
854
				$return .= '</p>';
855
856
			}
857
		}
858
859
		///////////////////////////
860
		// START GALLERY AND MAP FRONT END STUFFS
861
		///////////////////////////
862
		if ( isset( $shortcode['front'] ) && true == $shortcode['front'] ) {
863
864
			if ( 'gallery' == $shortcode['front_type'] ) {
865
866
				$return .= lasso_gallery_editor_module();
867
868
			}
869
		}
870
		///////////////////////////
871
		// END GALLERY AND MAP FRONT END STUFFS
872
		///////////////////////////
873
874
		// Single shortcode (not closed)
875
		if ( 'single' == $shortcode['type'] ) {
876
877
			$return .= '<input type="hidden" name="lasso-generator-content" id="lasso-generator-content" value="false" />';
878
879
		} else {
880
881
			$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>';
882
		}
883
884
		$return .= '<p class="lasso-buttoninsert-wrap"><a href="#" class="lasso-generator-cancel" id="lasso--sidebar__close">Cancel</a><input type="submit" id="lasso-generator-insert" value="Save Settings"></p>';
885
		$return .= '<input class="component_type" type="hidden" name="component_type" value="">';
886
		$return .= '<input type="hidden" name="unique" value="">';
887
		$return .= '<input type="hidden" name="nonce" id="lasso-generator-nonce" value="'.$nonce.'" />';
888
		$return .= '</form>';
889
890
		// extra JS codes
891
        if (isset($shortcode['codes'])) {
892
		    $return .= $shortcode['codes'];
893
        }
894
		$blob[$slug] = $return;
895
	}
896
897
	return $blob;
898
}
899
900
/**
901
 * Revisions modal
902
 *
903
 * @since 0.9.8
904
 *
905
 * @return string
906
 */
907
function lasso_editor_revision_modal() {
908
909
	ob_start();
910
	?>
911
		<div id="lasso--revision__modal" class="lasso--modal lassoShowAnimate ">
912
913
			<div class="lasso--modal__inner">
914
				<div id="lasso--loading" class="lasso--loading"><div class="lasso--loader"></div></div>
915
				<div id="lasso--hide" style="display:none;" class="lasso--post-form">
916
					<i class="lasso-icon lasso-icon-move"></i>
917
					<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>
918
					<div class="lasso--slider_wrap">
919
						<div id="lasso--slider"></div>
920
					</div>
921
					<ul id="lasso--revision-list"></ul>
922
					<div class="lasso--btn-group lasso--btn-group-small">
923
						<a href="#" class="lasso--btn-secondary" id="lasso--close-modal"><?php _e( 'Cancel', 'lasso' );?></a>
924
						<a href="#" class="lasso--btn-primary" id="lasso--select-revision"><?php _e( 'Select', 'lasso' );?></a>
925
					</div>
926
				</div>
927
928
			</div>
929
		</div>
930
	<?php
931
	return ob_get_clean();
932
}
933
934
/**
935
 * 
936
 * Takes a color code and returns an adjusted value
937
 * @since 1.0.0
938
 * Steps should be between -255 and 255. Negative = darker, positive = lighter
939
 * @return string
940
 */
941
function lasso_editor_adjustBrightness($hex, $steps) { 
942
    $steps = max(-255, min(255, $steps));
943
944
    // Normalize into a six character long hex string
945
    $hex = str_replace('#', '', $hex);
946
    if (strlen($hex) == 3) {
947
        $hex = str_repeat(substr($hex,0,1), 2).str_repeat(substr($hex,1,1), 2).str_repeat(substr($hex,2,1), 2);
948
    }
949
950
    // Split into three parts: R, G and B
951
    $color_parts = str_split($hex, 2);
952
    $return = '#';
953
954
    foreach ($color_parts as $color) {
955
        $color   = hexdec($color); // Convert to decimal
956
        $color   = max(0,min(255,$color + $steps)); // Adjust color
957
        $return .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); // Make two char hex code
958
    }
959
960
    return $return;
961
}
962