Completed
Push — master ( ea40a4...a4569a )
by
unknown
02:51
created

public/includes/editor-modules.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 16 and the first side effect is on line 15.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/**
4
 * These functions are then localized and then appended with JS in enter-editor.js
5
 *  All are protectd under a capability and logged in check using a filterable function lasso_user_can()
6
 *
7
 * @since 1.0
8
 */
9
10
/**
11
 * Add the editor controls to any singular post object
12
 *
13
 * @since 1.0
14
 */
15
add_action( 'wp_footer', 'lasso_editor_controls' );
16
function lasso_editor_controls() {
17
18
	global $post;
19
20
	if ( lasso_user_can('edit_posts') ) {
21
22
		$status = get_post_status( get_the_ID() );
23
24
		// let users add custom css classes
25
		$custom_classes = apply_filters( 'lasso_control_classes', '' );
26
27
		$post_access_class   = '';
28
		$post_new_disabled   = lasso_editor_get_option( 'post_adding_disabled', 'lasso_editor' );
29
		$post_settings_disabled = lasso_editor_get_option( 'post_settings_disabled', 'lasso_editor' );
30
		$shortcodify_disabled = lasso_editor_get_option( 'shortcodify_disabled', 'lasso_editor' );
31
32
33
		// CSS class if adding new post objects is disabled
34
		if ( 'on' == $post_new_disabled ) { $post_access_class = 'lasso--post-new-disabled'; }
35
36
		// CSS class if adjust settings is disabled
37
		if ( 'on' == $post_settings_disabled ) { $post_access_class = 'lasso--post-settings-disabled'; }
38
39
		// CSS class if adding new post objects AND settings are disabled
40
		if ( 'on' == $post_new_disabled && 'on' == $post_settings_disabled ) { $post_access_class = 'lasso--post-all-disabled'; }
41
42
		// CSS class if shortcodify or (Aesop Shortcode Conversion) is disabled
43
		$sc_saving_class = 'on' == $shortcodify_disabled ? 'shortcodify-disabled' : 'shortcodify-enabled';
44
45
		// user is capable
46
		$is_capable = is_singular() && lasso_user_can('edit_post');
47
48
		?><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();?>" >
49
50
			<ul class="lasso--controls__center lasso-editor-controls lasso-editor-controls--wrap <?php echo $post_access_class;?> ">
51
52
				<?php do_action( 'lasso_editor_controls_before' );
53
54
				if ( $is_capable ) { ?>
55
56
					<li id="lasso--edit" title="<?php esc_attr_e( 'Edit Post', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
57
58
					<?php if ( 'off' == $post_settings_disabled || empty( $post_settings_disabled ) ) { ?>
59
						<li id="lasso--post-settings" title="<?php esc_attr_e( 'Post Settings', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
60
					<?php }
61
62
				} ?>
63
64
				<li id="lasso--post-all" title="<?php esc_attr_e( 'All Posts', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
65
66
				<?php if ( $is_capable && wp_revisions_enabled( $post ) ) { ?>
67
					<li id="lasso--post-revisions" title="<?php esc_attr_e( 'Revisions', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
68
				<?php } ?>
69
70
				<?php if ( ( 'off' == $post_new_disabled || empty( $post_new_disabled ) && lasso_user_can('publish_posts') ) ) { ?>
71
					<li id="lasso--post-new" title="<?php esc_attr_e( 'Add Post', 'lasso' );?>"><a href="#" class="lasso--button__primary"></a></li>
72
				<?php } ?>
73
74
				<?php do_action( 'lasso_editor_controls_after' );?>
75
76
			</ul>
77
78
			<?php if ( is_singular() ) { ?>
79
80
				<div class="lasso--controls__right">
81
82
					<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>
83
84
					<?php if ( 'draft' == $status && ( lasso_user_can('publish_posts') || lasso_user_can('publish_pages') )  ) { ?>
85
						<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>
86
					<?php } ?>
87
88
				</div>
89
90
			<?php } ?>
91
92
		</div>
93
94
	<?php }
95
}
96
97
/**
98
 * Draw the side panel that houses the component settings
99
 * This is opened when the settings icon is clicked on a single component
100
 * 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
101
 *
102
 * @since 1.0
103
 */
104
function lasso_editor_component_sidebar() {
105
106
	ob_start();
107
108
	if ( !lasso_user_can() )
109
		return;
110
111
	// let users add custom css classes
112
	$custom_classes = apply_filters( 'lasso_sidebar_classes', '' );
113
	?>
114
	<div id="lasso--sidebar" class="<?php echo sanitize_html_class( $custom_classes );?>" >
115
		<div class="lasso--sidebar__inner">
116
			<div id="lasso--component__settings"></div>
117
		</div>
118
	</div>
119
120
	<?php return ob_get_clean();
121
}
122
123
/**
124
 * Draw the main toolbar used to edit the text
125
 *
126
 * @since 1.0
127
 */
128
function lasso_editor_text_toolbar() {
129
130
	ob_start();
131
132
	if ( !lasso_user_can() )
133
		return;
134
135
	// check for lasso story engine and add a class doniting this
136
	$ase_status = class_exists( 'Aesop_Core' ) || defined( 'LASSO_CUSTOM' ) ? 'ase-active' : 'ase-not-active';
137
138
	// let users add custom css classes
139
	$custom_classes = apply_filters( 'lasso_toolbar_classes', '' );
140
141
	// are toolbar headings enabled
142
	$toolbar_headings      = lasso_editor_get_option( 'toolbar_headings', 'lasso_editor' );
143
144
	$toolbar_class  = $toolbar_headings ? 'toolbar-extended' : false;
145
146
	?>
147
	<div class="lasso--toolbar_wrap lasso-editor-controls--wrap <?php echo $toolbar_class.' '.$ase_status.' '.sanitize_html_class( $custom_classes );?>">
148
		<ul class="lasso--toolbar__inner lasso-editor-controls">
149
			<?php do_action( 'lasso_toolbar_components_before' );?>
150
		    <li id="lasso-toolbar--bold" title="<?php esc_attr_e( 'Bold', 'lasso' );?>"></li>
151
		    <li id="lasso-toolbar--underline" title="<?php esc_attr_e( 'Underline', 'lasso' );?>"></li>
152
		    <li id="lasso-toolbar--italic" title="<?php esc_attr_e( 'Italicize', 'lasso' );?>"></li>
153
		    <li id="lasso-toolbar--strike" title="<?php esc_attr_e( 'Strikethrough', 'lasso' );?>"></li>
154
		    <?php if ( $toolbar_headings ): ?>
155
		    <li id="lasso-toolbar--h2" title="<?php esc_attr_e( 'H2 Heading', 'lasso' );?>"></li>
156
		    <li id="lasso-toolbar--h3" title="<?php esc_attr_e( 'H3 Heading', 'lasso' );?>"></li>
157
			<?php endif; ?>
158
		    <li id="lasso-toolbar--link" title="<?php esc_attr_e( 'Anchor Link', 'lasso' );?>">
159
		    	<div id="lasso-toolbar--link__wrap">
160
		    		<div id="lasso-toolbar--link__inner" contenteditable="true" placeholder="<?php esc_attr_e( 'http://url.com', 'lasso' );?>"></div>
161
		    		<a href="#" title="<?php esc_attr_e( 'Create Link', 'lasso' );?>" class="lasso-toolbar--link__control" id="lasso-toolbar--link__create" ></a>
162
		    	</div>
163
		    </li>
164
		    <?php do_action( 'lasso_toolbar_components_after' );?>
165
		    <li id="lasso-toolbar--html" title="<?php esc_attr_e( 'Insert HTML', 'lasso' );?>">
166
		    	<div id="lasso-toolbar--html__wrap">
167
		    		<div id="lasso-toolbar--html__inner" contenteditable="true" placeholder="<?php esc_attr_e( 'Enter HTML to insert', 'lasso' );?>"></div>
168
		    		<div id="lasso-toolbar--html__footer">
169
		    			<ul class="lasso-toolbar--html-snips">
170
		    				<?php if ( !$toolbar_headings ): ?>
171
		    				<li id="lasso-html--h2" title="<?php esc_attr_e( 'H2 Heading', 'lasso' );?>">
172
		    				<li id="lasso-html--h3" title="<?php esc_attr_e( 'H3 Heading', 'lasso' );?>">
173
		    				<?php endif; ?>
174
		    				<li id="lasso-html--ul" title="<?php esc_attr_e( 'Unordered List', 'lasso' );?>">
175
		    				<li id="lasso-html--ol" title="<?php esc_attr_e( 'Ordered List', 'lasso' );?>">
176
		    			</ul>
177
		    			<a class="lasso-toolbar--html__control lasso-toolbar--html__cancel" href="#"><?php _e( 'Cancel', 'lasso' );?></a>
178
		    			<a href="#" title="<?php esc_attr_e( 'Insert HTML', 'lasso' );?>" class="lasso-toolbar--html__control" id="lasso-toolbar--html__insert" ><?php _e( 'Insert', 'lasso' );?></a>
179
		    		</div>
180
		    	</div>
181
		    </li>
182
		    <li id="lasso-toolbar--components" title="<?php esc_attr_e( 'Insert Component', 'lasso' );?>">
183
			    <ul id="lasso-toolbar--components__list">
184
			    	<?php if ( 'ase-active' == $ase_status ): ?>
185
						<li data-type="image" title="<?php esc_attr_e( 'Image', 'lasso' );?>" class="lasso-toolbar--component__image"></li>
186
						<li data-type="character" title="<?php esc_attr_e( 'Character', 'lasso' );?>" class="lasso-toolbar--component__character"></li>
187
						<li data-type="quote" title="<?php esc_attr_e( 'Quote', 'lasso' );?>"  class="lasso-toolbar--component__quote"></li>
188
						<li data-type="content" title="<?php esc_attr_e( 'Content', 'lasso' );?>"  class="lasso-toolbar--component__content"></li>
189
						<li data-type="chapter" title="<?php esc_attr_e( 'Chapter', 'lasso' );?>"  class="lasso-toolbar--component__chapter"></li>
190
						<li data-type="parallax" title="<?php esc_attr_e( 'Parallax', 'lasso' );?>"  class="lasso-toolbar--component__parallax"></li>
191
						<li data-type="audio" title="<?php esc_attr_e( 'Audio', 'lasso' );?>"  class="lasso-toolbar--component__audio"></li>
192
						<li data-type="video" title="<?php esc_attr_e( 'Video', 'lasso' );?>"  class="lasso-toolbar--component__video"></li>
193
						<li data-type="map" title="<?php esc_attr_e( 'Map', 'lasso' );?>"  class="lasso-toolbar--component__map"></li>
194
						<li data-type="timeline_stop" title="<?php esc_attr_e( 'Timeline', 'lasso' );?>"  class="lasso-toolbar--component__timeline"></li>
195
						<li data-type="document" title="<?php esc_attr_e( 'Document', 'lasso' );?>"  class="lasso-toolbar--component__document"></li>
196
						<li data-type="collection" title="<?php esc_attr_e( 'Collection', 'lasso' );?>"  class="lasso-toolbar--component__collection"></li>
197
						<li data-type="gallery" title="<?php esc_attr_e( 'Gallery', 'lasso' );?>"  class="lasso-toolbar--component__gallery"></li>
198
					<?php else: ?>
199
						<li data-type="wpimg" title="<?php esc_attr_e( 'WordPress Image', 'lasso' );?>" class="image lasso-toolbar--component__image"></li>
200
						<li data-type="wpquote" title="<?php esc_attr_e( 'WordPress Quote', 'lasso' );?>" class="quote lasso-toolbar--component__quote"></li>
201
					<?php endif; ?>
202
					<?php do_action( 'lasso_toolbar_components' );?>
203
			    </ul>
204
			</li>
205
		</ul>
206
	</div>
207
208
	<?php return ob_get_clean();
209
}
210
211
/**
212
 * Draw the controls used for teh component settings within each component
213
 *
214
 * @since 1.0
215
 */
216
function lasso_editor_settings_toolbar() {
217
218
	$delete_nonce = wp_create_nonce( 'lasso-delete-nonce' );
219
220
	ob_start();
221
222
	if ( !lasso_user_can() )
223
		return;
224
225
	// let users add custom css classes
226
	$custom_classes = apply_filters( 'lasso_component_classes', '' );
227
228
	?>
229
	<ul class="lasso-component--controls <?php echo sanitize_html_class( $custom_classes );?>" contenteditable="false">
230
		<li class="lasso-drag" title="<?php esc_attr_e( 'Move', 'lasso' );?>"></li>
231
		<li id="lasso-component--settings__trigger" class="lasso-settings" title="<?php esc_attr_e( 'Settings', 'lasso' );?>"></li>
232
		<li class="lasso-clone" title="<?php esc_attr_e( 'Clone', 'lasso' );?>"></li>
233
		<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>
234
	</ul>
235
236
	<?php return ob_get_clean();
237
}
238
239
/**
240
 * Draws the controls used for changing the featured image
241
 *   These controls are appended based on the class set in the define
242
 *
243
 * @since 1.0
244
 */
245
function lasso_editor_image_controls() {
246
247
	ob_start();
248
249
	if ( !lasso_user_can() )
250
		return;
251
252
	// has post thumbnail
253
	$has_thumbnail = has_post_thumbnail( get_the_ID() ) ? 'class="lasso--featImg--has-thumb"' : false;
254
255
	?>
256
	<ul id="lasso--featImgControls" <?php echo $has_thumbnail;?>>
257
		<li id="lasso--featImgUpload"><a title="<?php esc_attr_e( 'Replace Image', 'lasso' );?>" href="#"><i class="lasso-icon-image"></i></a></li>
258
		<li id="lasso--featImgDelete"><a title="<?php esc_attr_e( 'Delete Image', 'lasso' );?>" href="#"><i class="lasso-icon-bin2"></i></a></li>
259
		<li id="lasso--featImgSave"><a href="#"><?php esc_attr_e( 'save', 'lasso' );?></a></li>
260
	</ul>
261
262
	<?php return ob_get_clean();
263
}
264
265
266
/**
267
 * Used to house post settings like scheduling, slugs and draft status
268
 * Note: the "add new" will use the same object as the currently shown. For example, if the user
269
 * is currently on a post, and clicks add new, then it'll add a new post. If the user is on a
270
 * post type like "dog", then it will create a new post type called "dog"
271
 *
272
 * @since 1.0
273
 */
274
function lasso_editor_component_modal() {
275
276
	ob_start();
277
278
	if ( !lasso_user_can() )
279
		return;
280
281
	global $post;
282
283
	$postid = get_the_ID();
284
285
	$status = get_post_status( $postid );
286
	$nonce = wp_create_nonce( 'lasso-update-post-settings' );
287
288
	// let users add custom css classes
289
	$custom_classes = apply_filters( 'lasso_modal_settings_classes', '' );
290
291
	// objects categories
292
	$categories 		= lasso_get_post_objects( $postid, 'category' );
293
	$tags 				= lasso_get_post_objects( $postid, 'tag' );
294
295
	// modal tabs
296
	$tabs  				= lasso_modal_addons('tab');
297
	$content 			= lasso_modal_addons('content');
298
299
	// are we singular
300
	$is_singular 		= is_singular();
301
	$is_singular_class 	= $is_singular ? 'lasso--postsettings__2col' : 'lasso--postsettings__1col';
302
	$has_thumb_class    = has_post_thumbnail() ? 'has-thumbnail' : 'no-thumbnail';
303
	$theme_supports     = current_theme_supports('post-thumbnails');
304
	$default_image 		= LASSO_URL.'/admin/assets/img/empty-img.png';
305
306
?>
307
	<div id="lasso--post-settings__modal" class="lasso--modal lassoShowAnimate <?php echo sanitize_html_class( $custom_classes );?>">
308
		<div class="lasso--modal__inner">
309
310
			<?php if( $tabs ) { echo $tabs; } ?>
311
312
			<div class="lasso--modal__content modal__content--core visible" data-addon-content="core">
313
				<form id="lasso--postsettings__form" enctype="multipart/form-data" class="lasso--post-form <?php echo $is_singular_class.' '.$has_thumb_class;?>" >
314
315
					<?php if ( $is_singular && $theme_supports ) : ?>
316
					<div class="lasso--postsettings__left">
317
						<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>
318
						<div class="lasso--post-thumb" data-default-thumb="<?php echo esc_url( $default_image );?>">
319
320
							<div id="lasso--post-thumb__controls" class="lasso--post-thumb__controls">
321
								<i id="lasso--post-thumb__add" title="<?php _e('Change Featured Image','lasso');?>" class="dashicons dashicons-edit"></i>
322
								<i id="lasso--post-thumb__delete" title="<?php _e('Delete Featured Image','lasso');?>" class="dashicons dashicons-no-alt"></i>
323
								<i id="lasso--save-status" class="lasso-icon lasso-icon-spinner6 not-visible"></i>
324
							</div>
325
326
							<?php echo has_post_thumbnail() ? get_the_post_thumbnail( $post->ID, 'medium' ) : '<img src="'.$default_image.'">'; ?>
327
328
						</div>
329
						<div id="lasso--featImgSave"><a href="#" class="not-visible">Save</a></div>
330
331
					</div>
332
					<?php endif; ?>
333
334
					<div class="lasso--postsettings__right">
335
336
						<?php if( lasso_user_can('publish_posts') || lasso_user_can('publish_pages') ): ?>
337
						<div class="lasso--postsettings__option story-status-option">
338
							<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>
339
							<ul class="story-status story-status-<?php echo sanitize_html_class( $status );?>">
340
								<li id="lasso--status-draft"><?php _e( 'Draft', 'lasso' );?></li>
341
								<li id="lasso--status-publish"><?php _e( 'Publish', 'lasso' );?></li>
342
							</ul>
343
							<div class="lasso--slider_wrap">
344
								<div id="lasso--slider"></div>
345
							</div>
346
						</div>
347
						<?php endif; ?>
348
349
						<?php if ( 'publish' == $status ): ?>
350
						<div class="lasso--postsettings__option story-slug-option">
351
							<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>
352
							<input class="lasso--modal__trigger-footer" type="text" name="story_slug" value="<?php echo isset( $post ) ? esc_attr( $post->post_name ) : false;?>">
353
						</div>
354
						<?php endif; ?>
355
356
					</div>
357
358
					<div class="lasso--postsettings__middle">
359
360
						<div class="lasso--postsettings__option story-categories-option">
361
							<label><?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>
362
							<input id="lasso--cat-select" class="lasso--modal__trigger-footer" type="hidden" name="story_cats" value="<?php echo $categories;?>">
363
						</div>
364
365
						<div class="lasso--postsettings__option story-tags-option">
366
							<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>
367
							<input id="lasso--tag-select" class="lasso--modal__trigger-footer" type="hidden" name="story_tags" value="<?php echo $tags;?>">
368
						</div>
369
370
					</div>
371
372
					<?php do_action( 'lasso_modal_post_form' ); // action ?>
373
374
					<div class="lasso--postsettings__footer" style="display:none;">
375
						<a href="#" class="lasso--postsettings-cancel"><?php _e( 'Cancel', 'lasso' );?></a>
376
						<input type="hidden" name="status" value="">
377
						<input type="hidden" name="categories" value="">
378
						<input type="hidden" name="postid" value="<?php echo get_the_ID();?>">
379
						<input type="hidden" name="action" value="process_update-object_post">
380
						<input type="hidden" name="nonce" value="<?php echo $nonce;?>">
381
						<?php do_action( 'lasso_modal_post_form_footer' ); // action ?>
382
						<input type="submit" value="<?php esc_attr_e( 'Save', 'lasso' );?>">
383
					</div>
384
385
				</form>
386
			</div>
387
388
			<?php if( $tabs ) { echo $content; } ?>
389
390
		</div>
391
392
	</div>
393
	<div id="lasso--modal__overlay"></div>
394
395
	<?php return ob_get_clean();
396
}
397
398
/**
399
 * Used to house the form for creating a new post within amodal
400
 *
401
 * @since 1.0
402
 */
403
function lasso_editor_newpost_modal() {
404
405
	global $post;
406
407
	ob_start();
408
409
	if ( !lasso_user_can('edit_posts') )
410
		return;
411
412
	$status = get_post_status( get_the_ID() );
413
414
	$nonce = wp_create_nonce( 'lasso-editor-new-post' );
415
416
	// let users add custom css classes
417
	$custom_classes = apply_filters( 'lasso_modal_post_classes', '' );
418
419
	// return the post type
420
	$type = get_post_type( get_the_ID() );
421
422
	?>
423
	<div id="lasso--post-new__modal" class="lasso--modal lasso--modal__med lassoShowAnimate <?php echo sanitize_html_class( $custom_classes );?>">
424
		<div class="lasso--modal__inner">
425
426
			<form id="lasso--postnew__form" enctype="multipart/form-data" class="lasso--post-form">
427
428
				<div class="lasso--postsettings__option story-slug-option lasso--last-option">
429
					<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>
430
					<input class="lasso--modal__trigger-footer" type="text" required name="story_title" value="" placeholder="<?php esc_attr_e( 'Grump Wizards Make Toxic Brew', 'lasso' );?>">
431
						<div class="lasso--select-wrap">
432
						<select id="lasso--select-type" name="story_type">
433
434
							<?php
435
								$types = lasso_post_types();
436
437
								if ( !empty( $types ) ) {
438
439
									foreach( $types as $type ) {
440
441
										$type = preg_replace( '/s\b/','', $type );
442
443
										printf( '<option value="%s">%s</option>', lcfirst( esc_attr( $type ) ) , ucfirst( esc_attr( $type ) ) );
444
									}
445
446
								}
447
							?>
448
449
						</select>
450
					</div>
451
				</div>
452
453
				<div class="lasso--postsettings__footer" style="display:none;">
454
					<a href="#" class="lasso--postsettings-cancel"><?php _e( 'Cancel', 'lasso' );?></a>
455
					<input type="hidden" name="action" value="process_new-object_post">
456
					<input type="hidden" name="object" value="post">
457
					<input type="hidden" name="nonce" value="<?php echo $nonce;?>">
458
					<input type="submit" value="<?php esc_attr_e( 'Create', 'lasso' );?>">
459
				</div>
460
461
			</form>
462
463
		</div>
464
	</div>
465
	<div id="lasso--modal__overlay"></div>
466
467
	<?php return ob_get_clean();
468
}
469
470
/**
471
 * Used to house the all posts pop-up
472
 *
473
 * @since 0.9.3
474
 */
475
function lasso_editor_allpost_modal() {
476
477
	global $post;
478
479
	ob_start();
480
481
	// post status
482
	$status = get_post_status( get_the_ID() );
483
484
	// let users add custom css classes
485
	$custom_classes = apply_filters( 'lasso_modal_all_post_classes', '' );
486
487
	?>
488
	<div id="lasso--all-posts__modal" class="lasso--modal lasso--modal__full lassoShowAnimate <?php echo sanitize_html_class( $custom_classes );?>">
489
		<div class="lasso--modal__inner">
490
491
			<div class="lasso--post-filtering not-visible">
492
				<div class="lasso--search__results">
493
					<span id="lasso--results-found"></span><?php _e('results found','lasso');?>
494
				</div>
495
				<div class="lasso--search">
496
					<i id="lasso--search__toggle" class="dashicons dashicons-search"></i>
497
					<input id="lasso--search-field" type="text" placeholder="search...">
498
				</div>
499
			</div>
500
501
			<ul class="lasso--post-object-list">
502
				<?php
503
504
				$post_types = lasso_post_types();
505
506
				if ( ! empty( $post_types ) ) {
507
					$first = 'active';
508
					foreach( $post_types as $name => $label ) {
509
						printf( '<li class="%1s lasso--show-objects" data-post-type="%2s">%3s</li>', esc_attr( $first), esc_attr( $name ), esc_attr( $label ) );
510
						$first = '';
511
					}
512
513
				}
514
515
				do_action('lasso_modal_post_objects');?>
516
517
			</ul>
518
			<div id="lasso--loading" class="lasso--loading"><div class="lasso--loader"></div></div>
519
520
			<ul id="lasso--post-list" class="lasso--post-list"></ul>
521
522
		</div>
523
	</div>
524
	<div id="lasso--modal__overlay"></div>
525
526
	<?php return ob_get_clean();
527
}
528
529
function lasso_editor_wpimg_edit() {
530
531
	ob_start();
532
533
	if ( !lasso_user_can() )
534
		return;
535
536
	// let users add custom css classes
537
	$custom_classes = apply_filters( 'lasso_wpimg_classes', '' );
538
539
	?>
540
	<ul class="lasso-component--controls <?php echo sanitize_html_class( $custom_classes );?>" contenteditable="false">
541
		<li class="lasso-drag" title="<?php esc_attr_e( 'Move', 'lasso' );?>"></li>
542
		<li id="lasso--wpimg-edit" class="lasso-settings" title="<?php esc_attr_e( 'Settings', 'lasso' );?>"></li>
543
		<li class="lasso-clone" title="<?php esc_attr_e( 'Clone', 'lasso' );?>"></li>
544
		<li class="lasso-delete" title="<?php esc_attr_e( 'Delete', 'lasso' );?>"></li>
545
	</ul>
546
547
	<?php return ob_get_clean();
548
}
549
550
/**
551
 * Used to house the hidden input fields for actions and process saving for the map component
552
 *
553
 * @since 1.0
554
 */
555
function lasso_map_form_footer() {
556
557
	$nonce = wp_create_nonce( 'lasso-process-map' );
558
559
	ob_start();
560
561
	?>
562
	<div class="lasso--map-form__footer">
563
		<input type="hidden" name="postid" value="<?php echo get_the_ID();?>">
564
		<input type="hidden" name="nonce" value="<?php echo $nonce;?>">
565
		<input type="hidden" name="action" value="process_map_save">
566
		<input type="submit" class="lasso--map-form__submit" value="<?php esc_attr_e( 'Save Locations', 'lasso' );?>">
567
	</div>
568
569
	<?php return ob_get_clean();
570
571
}
572
573
/**
574
 * Some things aren't real-time updatable so we need to append a message in certain areas on certain actions
575
 *
576
 * @since 1.0
577
 */
578
function lasso_editor_refresh_message() {
579
580
	ob_start();
581
582
	?>
583
	<div id="lasso--pagerefresh" class="visible">
584
		<?php _e( 'Save this post and refesh the page to see these changes.', 'lasso' );?>
585
	</div>
586
587
	<?php return ob_get_clean();
588
}
589
590
/**
591
 * Draw out the settings field based on the shortcodes array with options foudn in Lasso Story Engine
592
 *  This was mostly backported from lasso story engine and modified to allow for non lasso shortcodes and components
593
 *
594
 * @since 1.0
595
 */
596
function lasso_editor_options_blob() {
597
598
	$codes   = function_exists( 'aesop_shortcodes' ) ? aesop_shortcodes() : apply_filters( 'lasso_custom_options', '' );
599
	$galleries  = function_exists( 'lasso_editor_galleries_exist' ) && lasso_editor_galleries_exist() ? 'has-galleries' : 'creating-gallery';
600
601
	$nonce = wp_create_nonce( 'lasso_gallery' );
602
603
	$blob = array();
604
605
	if ( empty( $codes ) )
606
		return;
607
608
	foreach ( $codes as $slug => $shortcode ) {
609
		$return = '';
610
		// Shortcode has atts
611
612
		if ( count( $shortcode['atts'] ) && $shortcode['atts'] ) {
613
614
			foreach ( $shortcode['atts'] as $attr_name => $attr_info ) {
615
616
617
				$prefix = isset( $attr_info['prefix'] ) ? sprintf( '<span class="lasso-option-prefix">%s</span>', $attr_info['prefix'] ) : null;
618
619
				$return .= '<form id="lasso--component-settings-form" class="'.$galleries.'" method="post">';
620
				$return .= '<p data-option="'.$attr_name.'" class="lasso-option lasso-'.$slug.'-'.$attr_name.'">';
621
				$return .= '<label for="lasso-generator-attr-' . $attr_name . '">' . $attr_info['desc'] . '</label>';
622
				$return .= '<small class="lasso-option-desc">'.$attr_info['tip'].'</small>';
623
				// Select
624
625
				if ( isset( $attr_info['values'] ) ) {
626
627
					$return .= '<select name="' . $attr_name . '" id="lasso-generator-attr-' . $attr_name . '" class="lasso-generator-attr">';
628
629
					$i=0;
630
631
					foreach ( $attr_info['values'] as $attr_value ) {
632
						$attr_value_selected = $attr_info['default'] == $attr_value ? ' selected="selected"' : '';
633
634
						$return .= '<option value="'.$attr_info['values'][$i]['value'].'" ' . $attr_value_selected . '>'.$attr_info['values'][$i]['name'].'</option>';
635
636
						$i++;
637
					}
638
639
					$return .= '</select>';
640
641
				} else {
642
643
					$attr_field_type = isset( $attr_info['type'] ) ? $attr_info['type'] : 'text';
644
645
					// image upload
646
					if ( 'media_upload' == $attr_info['type'] ) {
647
648
						$return .= '<input type="' . $attr_field_type . '" name="' . $attr_name . '" value="'.$attr_info['default'].'" id="lasso-generator-attr-' . $attr_name . '" class="lasso-generator-attr lasso-generator-attr-'.$attr_field_type.'" />';
649
						$return .= '<a href="#" id="lasso-upload-img" class="lasso-option-button" /></a>';
650
651
					} elseif ( 'color' == $attr_info['type'] ) {
652
653
						$return .= '<input type="color" name="' . $attr_name . '" value="'.$attr_info['default'].'" id="lasso-generator-attr-' . $attr_name . '" class="lasso-generator-attr lasso-generator-attr-'.$attr_field_type.'" />';
654
655
					} elseif ( 'text_area' == $attr_info['type'] ) {
656
657
						$return .= '<textarea name="' . $attr_name . '" id="lasso-generator-attr-' . $attr_name . '" class="lasso-generator-attr lasso-generator-attr-'.$attr_field_type.'" placeholder="'.$attr_info['default'].'" /></textarea>'.$prefix.'';
658
659
					} else {
660
						$return .= '<input type="' . $attr_field_type . '" name="' . $attr_name . '" value="'.$attr_info['default'].'" id="lasso-generator-attr-' . $attr_name . '" class="lasso-generator-attr lasso-generator-attr-'.$attr_field_type.'" />'.$prefix.'';
661
					}
662
				}
663
				$return .= '</p>';
664
665
			}
666
		}
667
668
		///////////////////////////
669
		// START GALLERY AND MAP FRONT END STUFFS
670
		///////////////////////////
671
		if ( isset( $shortcode['front'] ) && true == $shortcode['front'] ) {
672
673
			if ( 'gallery' == $shortcode['front_type'] ) {
674
675
				$return .= lasso_gallery_editor_module();
676
677
			}
678
		}
679
		///////////////////////////
680
		// END GALLERY AND MAP FRONT END STUFFS
681
		///////////////////////////
682
683
		// Single shortcode (not closed)
684
		if ( 'single' == $shortcode['type'] ) {
685
686
			$return .= '<input type="hidden" name="lasso-generator-content" id="lasso-generator-content" value="false" />';
687
688
		} else {
689
690
			$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>';
691
		}
692
693
		$return .= '<p class="lasso-buttoninsert-wrap"><a href="#" class="lasso-generator-cancel" id="lasso--sidebar__close">Cancel
694
</a><input type="submit" id="lasso-generator-insert" value="Save Settings"></p>';
695
		$return .= '<input class="component_type" type="hidden" name="component_type" value="">';
696
		$return .= '<input type="hidden" name="unique" value="">';
697
		$return .= '<input type="hidden" name="nonce" id="lasso-generator-nonce" value="'.$nonce.'" />';
698
		$return .= '</form>';
699
700
		$blob[$slug] = $return;
701
	}
702
703
	return $blob;
704
}
705
706
/**
707
 * Revisions modal
708
 *
709
 * @since 0.9.8
710
 *
711
 * @return string
712
 */
713
function lasso_editor_revision_modal() {
714
715
	ob_start();
716
	?>
717
		<div id="lasso--revision__modal" class="lasso--modal lassoShowAnimate ">
718
719
			<div class="lasso--modal__inner">
720
				<div id="lasso--loading" class="lasso--loading"><div class="lasso--loader"></div></div>
721
				<div id="lasso--hide" style="display:none;" class="lasso--post-form">
722
					<i class="lasso-icon lasso-icon-move"></i>
723
					<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>
724
					<div class="lasso--slider_wrap">
725
						<div id="lasso--slider"></div>
726
					</div>
727
					<ul id="lasso--revision-list"></ul>
728
					<div class="lasso--btn-group lasso--btn-group-small">
729
						<a href="#" class="lasso--btn-secondary" id="lasso--close-modal">Cancel</a>
730
						<a href="#" class="lasso--btn-primary" id="lasso--select-revision">Select</a>
731
					</div>
732
				</div>
733
734
			</div>
735
		</div>
736
	<?php
737
	return ob_get_clean();
738
}
739