Completed
Push — master ( 8d9355...4de7f8 )
by
unknown
01:45
created

components.php ➔ lasso_wp_image_block()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * The functions in this file register the components that will be shown in the component drop-up menu
4
 * and are filterable and pluggable
5
 *
6
 */
7
8
/**
9
 * Build an array of components that will be shown in the
10
 * component drop-up menu on click
11
 *
12
 * @return array of components
13
 * @since 1.0
14
 */
15
function lasso_editor_components() {
16
17
	$array = array(
18
		'quote' => array(
19
			'name'    => __('Quote','lasso'),
20
			'content' => lasso_quote_component(),
21
		),
22
		'image' => array(
23
			'name'    => __('Image','lasso'),
24
			'content' => lasso_image_component(),
25
		),
26
		'parallax' => array(
27
			'name'    => __('Parallax','lasso'),
28
			'content' => lasso_parallax_component(),
29
		),
30
		'audio' => array(
31
			'name'    => __('Audio','lasso'),
32
			'content' => lasso_audio_component(),
33
		),
34
		'content' => array(
35
			'name'    => __('Content','lasso'),
36
			'content' => lasso_content_component(),
37
		),
38
		'character' => array(
39
			'name'    => __('Character','lasso'),
40
			'content' => lasso_character_component(),
41
		),
42
		'collection' => array(
43
			'name'    => __('Collection','lasso'),
44
			'content' => lasso_collections_component(),
45
		),
46
		'document' => array(
47
			'name'    => __('Document','lasso'),
48
			'content' => lasso_document_component(),
49
		),
50
		'gallery' => array(
51
			'name'    => __('Gallery','lasso'),
52
			'content' => lasso_gallery_component(),
53
		),
54
		'chapter' => array(
55
			'name'    => __('Chapter','lasso'),
56
			'content' => lasso_heading_component(),
57
		),
58
		'map' => array(
59
			'name'    => __('Map','lasso'),
60
			'content' => lasso_map_component(),
61
		),
62
		'timeline_stop' => array(
63
			'name'    => __('Timeline','lasso'),
64
			'content' => lasso_timeline_component(),
65
		),
66
		'video' => array(
67
			'name'    => __('Video','lasso'),
68
			'content' => lasso_video_component(),
69
		),
70
		'wpimg' => array(
71
			'name'    => __('WordPress Image','lasso'),
72
			'content' => lasso_wp_image(),
73
		),
74
		'wpimg-block' => array(
75
			'name'    => __('WordPress Image Block','lasso'),
76
			'content' => lasso_wp_image_block(),
77
		),
78
		'wpquote' => array(
79
			'name'    => __('WordPress Quote','lasso'),
80
			'content' => lasso_wp_quote(),
81
		),
82
		'gallery_pop' => array(
83
			'name'    => __('Gallery Pop','lasso'),
84
			'content' => lasso_gallery_pop_component(),
85
		),
86
		'events' => array(
87
			'name'    => __('Events','lasso'),
88
			'content' => lasso_event_component(),
89
		),
90
		'wpvideo' => array(
91
			'name'    => __('WordPress Image','lasso'),
92
			'content' => lasso_wp_video(),
93
		),
94
	);
95
96
	return apply_filters( 'lasso_components', $array );
97
}
98
99
/**
100
 * Here each of the components content is being registered and retrieved above
101
 *
102
 * Notes:  - these functions are pluggable
103
 *     - custom modules must have data-component-type="whatever"
104
 *   - custom modules must have all options as data-attributes if utilizing settings panel
105
 *
106
 * 1.  Quote
107
 * 2.  Image
108
 * 3. Parallax
109
 * 4. Audio
110
 * 5. Content
111
 * 6. Character
112
 * 7. Collections
113
 * 8. Document
114
 * 9. Gallery
115
 * 10. Heading
116
 * 11. Map
117
 * 12. Timeline
118
 * 13. Video
119
 */
120
121
// 1
122
if ( !function_exists( 'lasso_quote_component' ) ):
123
	function lasso_quote_component() {
124
125
		return do_shortcode( '[aesop_quote quote="The Universe is made of stories, not of atoms."]' );
126
	}
127
endif;
128
129
// 2
130
if ( !function_exists( 'lasso_image_component' ) ):
131
	function lasso_image_component() {
132
133
		return do_shortcode( '[aesop_image img="'.LASSO_URL.'/public/assets/img/empty-img.png" align="center" imgwidth="100%"]' );
134
	}
135
endif;
136
137
// 3
138
if ( !function_exists( 'lasso_parallax_component' ) ):
139
	function lasso_parallax_component() {
140
141
		return do_shortcode( '[aesop_parallax img="'.LASSO_URL.'/public/assets/img/empty-img.png"]' );
142
	}
143
endif;
144
145
// 4
146
if ( !function_exists( 'lasso_audio_component' ) ):
147
	function lasso_audio_component() {
148
149
		return do_shortcode( '[aesop_audio src="http://users.skynet.be/fa046054/home/P22/track06.mp3"]' );
150
151
	}
152
endif;
153
154
// 5
155
if ( !function_exists( 'lasso_content_component' ) ):
156
	function lasso_content_component() {
157
158
		return do_shortcode( '[aesop_content]Start typing here...[/aesop_content]' );
159
	}
160
endif;
161
162
// 6
163
if ( !function_exists( 'lasso_character_component' ) ):
164
	function lasso_character_component() {
165
166
		return do_shortcode( '[aesop_character img="'.LASSO_URL.'/public/assets/img/empty-img.png" name="Joes Apartment" width="150px"]' );
167
168
	}
169
endif;
170
171
// 7
172
if ( !function_exists( 'lasso_collections_component' ) ):
173
	function lasso_collections_component() {
174
175
		return do_shortcode( '[aesop_collection]' );
176
	}
177
endif;
178
179
// 8
180
if ( !function_exists( 'lasso_document_component' ) ):
181
	function lasso_document_component() {
182
183
		return do_shortcode( '[aesop_document src="'.LASSO_URL.'/public/assets/img/empty-img.png" ]' );
184
185
	}
186
endif;
187
188
// 9
189
if ( !function_exists( 'lasso_gallery_component' ) ):
190
	function lasso_gallery_component() {
191
192
		return do_shortcode( '[aesop_gallery]' );
193
194
	}
195
endif;
196
197
// 10
198
if ( !function_exists( 'lasso_heading_component' ) ):
199
	function lasso_heading_component() {
200
201
		return do_shortcode( '[aesop_chapter title="Chapter One" img="'.LASSO_URL.'/public/assets/img/empty-img.png" full="on"]' );
202
	}
203
endif;
204
205
// 11
206
if ( !function_exists( 'lasso_map_component' ) ):
207
	function lasso_map_component() {
208
209
		return '<form id="lasso--map-form" class="aesop-component aesop-map-component lasso--map-drag-holder" enctype="multipart/form-data">
210
				'.lasso_map_form_footer().'
211
				'.do_shortcode( '[aesop_map sticky="off"]' ).'
212
			</form>';
213
214
	}
215
endif;
216
217
// 12
218
if ( !function_exists( 'lasso_timeline_component' ) ):
219
	function lasso_timeline_component() {
220
221
		return do_shortcode( '[aesop_timeline_stop num="Title" title="2014"]' );
222
223
	}
224
endif;
225
226
// 13
227
if ( !function_exists( 'lasso_video_component' ) ):
228
	function lasso_video_component() {
229
230
		return do_shortcode( '[aesop_video src="vimeo" id="59940289" width="100%" align="center"]' );
231
232
	}
233
endif;
234
235
// 14 - since 0.9.1
236
if ( !function_exists('lasso_wp_image') ):
237
238
	function lasso_wp_image(){
239
        $use_old_wpimg = lasso_editor_get_option('use_old_wpimg', 'lasso_editor','off');
240
        $use_wp_block_image = lasso_editor_get_option('use_wp_block_image', 'lasso_editor','off');
241
        if ($use_wp_block_image == 'on') {
242
        	return '<figure class="wp-block-image size-large" data-component-type="wpimg-block"><img  src="'.LASSO_URL.'/public/assets/img/empty-img.png"></figure><p><br></p>';
243
        }
244
        else if ($use_old_wpimg != 'on') {
245
        	return '<figure data-component-type="wpimg" class="lasso--wpimg__wrap lasso-component"><img  src="'.LASSO_URL.'/public/assets/img/empty-img.png"></figure><p><br></p>';
246
        } else {
247
            return '<figure data-component-type="wpimg" data-linkoption="img" class="lasso--wpimg__wrap lasso-component"><img  src="'.LASSO_URL.'/public/assets/img/empty-img.png"></figure><p><br></p>';
248
        }
249
	}
250
251
endif;
252
253
// 15 - since 0.9.2
254
if ( !function_exists('lasso_wp_quote') ):
255
256
	function lasso_wp_quote(){
257
		return '<blockquote data-component-type="wpquote" class="lasso--wpquote lasso-component"><p>The universe is made of stories.</p></blockquote><p><br></p>';
258
	}
259
260
endif;
261
262
// 16 gallery pop added but not fully supported as of 0.9.9.11 
263
264
if ( !function_exists( 'lasso_gallery_pop_component' ) ):
265
	function lasso_gallery_pop_component() {
266
		return do_shortcode( '[aesop_gallery_pop]' );
267
	}
268
endif;
269
270
// 17 - work in progress
271
272
if ( !function_exists( 'lasso_event_component' ) ):
273
	function lasso_event_component() {
274
		$id = editus_get_one_id('aesop_events');
0 ignored issues
show
Unused Code introduced by
$id 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...
275
		return '<div data-component-type="events" class="aesop-component lasso-component"><p>Aesop Event: After setting the event, save and reload the page.</p></div>';
276
	}
277
endif;
278
279
// 18 - work in progress
280
if ( !function_exists('lasso_wp_video') ):
281
282
	function lasso_wp_video(){
283
		return '<div data-component-type="wpvideo" class="lasso--wpvideo__wrap lasso-component"><video class="wp-video-0"></video>';
284
	}
285
286
endif;
287
288
if ( !function_exists('lasso_wp_image_block') ):
289
	function lasso_wp_image_block(){
290
        return '<figure class="wp-block-image size-large" data-component-type="wpimg-block"><img  src="'.LASSO_URL.'/public/assets/img/empty-img.png"></figure><p><br></p>';
291
	}
292
293
endif;
294
295
// helper function to retrieve one id for default option
296
function editus_get_one_id($type)
297
{
298
	$args = array( 'posts_per_page' => 1, 'post_type' => $type );
299
	$posts = get_posts( $args );
300
	if ( $posts ) {
301
		foreach ( $posts as $post ) {
302
			return $post->ID;
303
		}
304
	}
305
	return -1;
306
}
307
308
309