Completed
Push — master ( 23d24e...f7fca3 )
by
unknown
01:57
created

editor-modules.php ➔ lasso_editor_allpost_modal()   B

Complexity

Conditions 4
Paths 2

Size

Total Lines 60

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 2
nop 0
dl 0
loc 60
rs 8.8727
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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