sr_wp_code /wp-content/themes/platform/sections/section.soapbox.php

Language PHP Lines 304
MD5 Hash 71b3639958660e5f5f6205696bc3b569 Estimated Cost $5,169 (why?)
Repository https://bitbucket.org/crypticrod/sr_wp_code View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<?php
/*

	Section: PageLines Soapbox
	Author: Andrew Powers
	Description: Creates boxes and box layouts
	Version: 1.0.0
	
*/

class PageLinesSoapbox extends PageLinesSection {

   function __construct( $registered_settings = array() ) {
	
		$name = __('Soapboxes', 'pagelines');
		$id = 'soapbox';
		
		$default_settings = array(
			'description' 	=> 'Large boxes two per row; with up to three action links . <br/><small>Note: Uses a selected "box-set" for content.</small>',
			'icon'			=> CORE_IMAGES.'/admin/soap.png', 
			'version'		=> 'pro',
			'dependence'	=> 'PageLinesBoxes', 
			'posttype'		=> 'boxes',
		);
		
		$settings = wp_parse_args( $registered_settings, $default_settings );
		
		parent::__construct($name, $id, $settings);    
   }


	/*
		Loads php that will run on every page load (admin and site)
		Used for creating administrative information, like post types
	*/

	function section_persistent(){

		/*
			Meta Options
		*/
		
				/*
					Create meta fields for the post type
				*/
					$this->meta_array = array(
							'_soapbox_link_1' => array(
									'version' => 'pro',
									'type' => 'text_link',					
									'inputlabel' => 'Soapbox Link 1 URL',
									'exp' => 'Add a full link URL.'
								),
							'_soapbox_link_1_text' => array(
									'type' 			=> 'text',
									'inputlabel' 	=> $this->name.' Link 1 Text',						
									'exp' 		=> 'Add text to be used in this link.',
								),
							'_soapbox_link_1_class' => array(
									'type' 			=> 'text',
									'inputlabel' 	=> $this->name.' Link 1 Classes',						
									'exp' 		=> 'Add CSS classes to add to this link.  <strong>Tip:</strong> add <strong>"soapbox_callout"</strong> for a blue link or <strong>"fancybox"</strong> to use with the fancybox plugin.',
								),
							'_soapbox_link_2' => array(
									'version' => 'pro',
									'type' => 'text_link',					
									'inputlabel' => 'Soapbox Link 2 URL',
									'exp' => 'Add a full link URL.'
								),
							'_soapbox_link_2_text' => array(
									'type' 			=> 'text',
									'inputlabel' 	=> $this->name.' Link 2 Text',			
									'exp' 		=> 'Add text to be used in this link.',
								),
							'_soapbox_link_2_class' => array(
									'type' 			=> 'text',
									'inputlabel' 	=> $this->name.' Link 2 Classes',			
									'exp' 		=> 'Add CSS classes to add to this link.  <strong>Tip:</strong> add <strong>"soapbox_callout"</strong> for a blue link or <strong>"fancybox"</strong> to use with the fancybox plugin.',
								),
							'_soapbox_link_3' => array(
									'version' => 'pro',
									'type' => 'text_link',					
									'inputlabel' => 'Soapbox Link 3 URL',
									'exp' => 'Add a full link URL.'
								),
							'_soapbox_link_3_text' => array(
									'type' 			=> 'text',
									'inputlabel' 	=> $this->name.' Link 3 Text',						
									'exp' 		=> 'Add text to be used in this link.',
								),
							'_soapbox_link_3_class' => array(
									'type' 			=> 'text',
									'inputlabel' 	=> $this->name.' Link 3 Classes',						
									'exp' 		=> 'Add CSS classes to add to this link.  <strong>Tip:</strong> add <strong>"soapbox_callout"</strong> for a blue link or <strong>"fancybox"</strong> to use with the fancybox plugin.',
								),
							
					);

					$post_types = array($this->settings['posttype']);
					
					$this->meta_settings = array(
							'id' => 'soapbox-meta',
							'name' => THEMENAME." Soapbox Options (Soapbox Section Only)",
							'posttype' => $post_types
						);

					$this->meta_options =  new PageLinesMetaOptions($this->meta_array, $this->meta_settings);

					/*
						Create meta fields for the page template when using the Feature Template
					*/
						$meta_array = array(

								'_soapbox_set' => array(
									'version' => 'pro',
									'type' => 'select_taxonomy',

									'taxonomy_id'	=> "box-sets",				
									'inputlabel' => 'Select Box-Set To Use For Soapbox Section',
									'exp' => 'If you are using the soapbox section, select the box-set you would it to use on this page.'
								), 
								'_soapbox_items' => array(
									'type' 			=> 'text_small',
									'inputlabel' 	=> 'Soapbox Posts Limit',					
									'exp' 		=> 'Add the limit or soapboxes that can be shown on this page. Default is 10.',
									),
								'_soapbox_height_media' => array(
									'version' => 'pro',
									'type' => 'text_small',
									'inputlabel' => 'Soapbox Media Height (in Pixels)',
									'exp' => 'For the "soapboxes" to line up correctly, the height of the media needs to be set. Add it here in pixels.'
									), 
								'_soapbox_link_1_text' => array(
									'type' 			=> 'text',
									'inputlabel' 	=> $this->name.' Link 1 Text',						
									'exp' 		=> 'Add text to be used in this link. Can be overridden in the box meta options.',
									),	
								'_soapbox_link_1_class' => array(
									'type' 			=> 'text',
									'inputlabel' 	=> $this->name.' Link 1 Classes',						
									'exp' 		=> 'Add CSS classes to add to this link.  <strong>Tip:</strong> add <strong>"soapbox_callout"</strong> for a blue link or <strong>"fancybox"</strong> to use with the fancybox plugin.',
									),
								'_soapbox_link_2_text' => array(
									'type' 			=> 'text',
									'inputlabel' 	=> $this->name.' Link 2 Text',			
									'exp' 		=> 'Add text to be used in this link. Can be overridden in the box meta options.',
									),
								'_soapbox_link_2_class' => array(
									'type' 			=> 'text',
									'inputlabel' 	=> $this->name.' Link 2 Classes',			
									'exp' 		=> 'Add CSS classes to add to this link.  <strong>Tip:</strong> add <strong>"soapbox_callout"</strong> for a blue link or <strong>"fancybox"</strong> to use with the fancybox plugin.',
									),
								'_soapbox_link_3_text' => array(
									'type' 			=> 'text',
									'inputlabel' 	=> $this->name.' Link 3 Text - Callout Link',						
									'exp' 		=> 'Add text to be used in this link. Can be overridden in the box meta options.',
									),
								'_soapbox_link_3_class' => array(
									'type' 			=> 'text',
									'inputlabel' 	=> $this->name.' Link 3 Classes',						
									'exp' 		=> 'Add CSS classes to add to this link.  <strong>Tip:</strong> add <strong>"soapbox_callout"</strong> for a blue link or <strong>"fancybox"</strong> to use with the fancybox plugin.',
									),
						
							);
						$meta_settings = array(
								'id' => 'soapbox-template-meta',
								'name' => THEMENAME." Soapbox Options",
								'posttype' => 'page'
							);

						$this->meta_options =  new PageLinesMetaOptions($meta_array, $meta_settings);
	}

	function section_template() {    
		global $post;
		$perline = 2;
		$count = $perline;
		
		$soapbox_height_media = ( get_pagelines_meta('_soapbox_height_media', $post->ID) ) ? get_pagelines_meta('_soapbox_height_media', $post->ID) : 200; 
		
		// Link text on parent page
		$soapbox_link_text[1] = ( get_pagelines_meta('_soapbox_link_1_text', $post->ID) ) ? get_pagelines_meta('_soapbox_link_1_text', $post->ID) : 'Link 1'; 
		$soapbox_link_text[2] = ( get_pagelines_meta('_soapbox_link_2_text', $post->ID) ) ? get_pagelines_meta('_soapbox_link_2_text', $post->ID) : 'Link 2'; 
		$soapbox_link_text[3] = ( get_pagelines_meta('_soapbox_link_3_text', $post->ID) ) ? get_pagelines_meta('_soapbox_link_3_text', $post->ID) : 'Link 3'; 
		
		$soapbox_link_class[1] = ( get_pagelines_meta('_soapbox_link_1_class', $post->ID) ) ? get_pagelines_meta('_soapbox_link_1_class', $post->ID) : ''; 
		$soapbox_link_class[2] = ( get_pagelines_meta('_soapbox_link_2_class', $post->ID) ) ? get_pagelines_meta('_soapbox_link_2_class', $post->ID) : ''; 
		$soapbox_link_class[3] = ( get_pagelines_meta('_soapbox_link_3_class', $post->ID) ) ? get_pagelines_meta('_soapbox_link_3_class', $post->ID) : ''; 
	
		
	?>		
	<div class="dcol_container_<?php echo $perline;?> fix">
	<?php 
			// Let's Do This...
		$theposts = $this->get_section_posts();
		$boxes = (is_array($theposts)) ? $theposts : array();
		
		foreach($boxes as $post) : setup_postdata($post);  ?>

				<div class="dcol_<?php echo $perline;?> dcol">
					<div class="dcol-pad">	
						<?php if(get_post_meta($post->ID, 'the_box_icon', true)):?>
								<div class="fboxgraphic" style="line-height: <?php echo $soapbox_height_media;?>px; height: <?php echo $soapbox_height_media;?>px">
									
									<?php if(get_post_meta($post->ID, 'the_box_icon_link', true)):?>
									<a href="<?php echo get_post_meta($post->ID, 'the_box_icon_link', true);?>" alt="">
									<?php endif;?>
									
									<img src="<?php echo get_post_meta($post->ID, 'the_box_icon', true);?>" >
									
									<?php if(get_post_meta($post->ID, 'the_box_icon_link', true)):?>
									</a>
									<?php endif;?>
					            </div>
						<?php endif;?>

							<div class="fboxinfo fix">
									<div class="fboxtitle"><h3><?php the_title(); ?></h3></div>
									<div class="fboxtext">
										<?php the_content(); ?>
									</div>
								<div class="soapbox-links">
									<?php for( $i = 1; $i <= 3; $i++):?>
											<?php if(get_post_meta($post->ID, '_soapbox_link_'.$i, true)):
												$link_text = ( get_post_meta($post->ID,'_soapbox_link_'.$i.'_text', true) ) ? get_post_meta($post->ID,'_soapbox_link_'.$i.'_text', true) : $soapbox_link_text[$i]; 
												$link_class = ( get_post_meta($post->ID, '_soapbox_link_'.$i.'_class', true) ) ?  get_post_meta($post->ID, '_soapbox_link_'.$i.'_class', true) : $soapbox_link_text[$i]; 
											?>
											<a class="soapbox_link <?php echo 'sblink_'.$i.' '.$link_class?>" href="<?php echo get_post_meta($post->ID, '_soapbox_link_'.$i, true);?>">
												<span class="soapbox_link-pad"><span class="soapbox_arrow"><?php echo $link_text; ?></span></span>
											</a>
											<?php endif;?>
									<?php endfor; ?>
									<?php pagelines_register_hook( 'pagelines_soapbox_links', $this->id ); // Hook ?>
									
									<?php edit_post_link(__('<small>[Edit Box]</small>', 'pagelines'), '', '');?>
								</div>
							</div>
							<?php pagelines_register_hook( 'pagelines_soapbox_inside_bottom', $this->id ); // Hook ?>
					</div>
				</div>
				<?php $end = ($count+1) / $perline;  if(is_int($end)):?>
					<div class="clear"></div>
				<?php endif; $count++;?>
		<?php endforeach;?>
	</div>
	<div class="clear"></div>
<?php	}

	
	function get_section_posts(){
		global $post;
		
		if((!isset($this->the_section_posts) || !is_array($this->the_section_posts)) && isset($post)){
			
			$query_args = array('post_type' => $this->settings['posttype'], 'orderby' =>'ID');
		
			if( get_pagelines_meta('_soapbox_set', $post->ID ) ){
				$query_args = array_merge($query_args, array( 'box-sets' => get_post_meta($post->ID, '_soapbox_set', true) ) );
			} elseif (pagelines_non_meta_data_page() && pagelines_option('soapbox_default_tax')){
				$query_args = array_merge($query_args, array( 'box-sets' => pagelines_option('soapbox_default_tax') ) );
			}
			
			$num_items = (pagelines_option('_soapbox_items', $post->ID)) ? pagelines_option('_soapbox_items', $post->ID) : 10;
			
			$query_args = array_merge($query_args, array( 'showposts' => $num_items ) );

	
		
			$section_query = new WP_Query( $query_args );
		
		 	$this->the_section_posts = $section_query->posts;
			
		 	if(is_array($this->the_section_posts)) return $this->the_section_posts;
			else return array();
			
		} elseif(isset($post)) {
			return $this->the_section_posts;
		}
	
	}

	
	function section_options($optionset = null, $location = null) {
		
		if($optionset == 'box_settings' && $location == 'bottom'){
			return array(
					'soapbox_default_tax' => array(
							'default' 		=> 'default-boxes',
							'version'		=> 'pro',
							'taxonomy_id'	=> 'box-sets',
							'type' 			=> 'select_taxonomy',
							'inputlabel' 	=> 'Select Soapbox Posts/404 Box-Set',
							'title' 		=> 'Posts Page and 404 Soapbox Box-Set',
							'shortexp' 		=> "Posts pages and similar pages (404) will use this Box-Set ID to source Soapboxes",
							'exp' 			=> "Posts pages and 404 pages in WordPress don't support meta data so you need to assign a set here. (If you want to use 'soapboxes' on these pages.)",
				)
			);
			
		}
	}

// End of Section Class //
}
Back to Top