PageRenderTime 50ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 303 lines | 230 code | 50 blank | 23 comment | 17 complexity | 71b3639958660e5f5f6205696bc3b569 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0
  1. <?php
  2. /*
  3. Section: PageLines Soapbox
  4. Author: Andrew Powers
  5. Description: Creates boxes and box layouts
  6. Version: 1.0.0
  7. */
  8. class PageLinesSoapbox extends PageLinesSection {
  9. function __construct( $registered_settings = array() ) {
  10. $name = __('Soapboxes', 'pagelines');
  11. $id = 'soapbox';
  12. $default_settings = array(
  13. 'description' => 'Large boxes two per row; with up to three action links . <br/><small>Note: Uses a selected "box-set" for content.</small>',
  14. 'icon' => CORE_IMAGES.'/admin/soap.png',
  15. 'version' => 'pro',
  16. 'dependence' => 'PageLinesBoxes',
  17. 'posttype' => 'boxes',
  18. );
  19. $settings = wp_parse_args( $registered_settings, $default_settings );
  20. parent::__construct($name, $id, $settings);
  21. }
  22. /*
  23. Loads php that will run on every page load (admin and site)
  24. Used for creating administrative information, like post types
  25. */
  26. function section_persistent(){
  27. /*
  28. Meta Options
  29. */
  30. /*
  31. Create meta fields for the post type
  32. */
  33. $this->meta_array = array(
  34. '_soapbox_link_1' => array(
  35. 'version' => 'pro',
  36. 'type' => 'text_link',
  37. 'inputlabel' => 'Soapbox Link 1 URL',
  38. 'exp' => 'Add a full link URL.'
  39. ),
  40. '_soapbox_link_1_text' => array(
  41. 'type' => 'text',
  42. 'inputlabel' => $this->name.' Link 1 Text',
  43. 'exp' => 'Add text to be used in this link.',
  44. ),
  45. '_soapbox_link_1_class' => array(
  46. 'type' => 'text',
  47. 'inputlabel' => $this->name.' Link 1 Classes',
  48. '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.',
  49. ),
  50. '_soapbox_link_2' => array(
  51. 'version' => 'pro',
  52. 'type' => 'text_link',
  53. 'inputlabel' => 'Soapbox Link 2 URL',
  54. 'exp' => 'Add a full link URL.'
  55. ),
  56. '_soapbox_link_2_text' => array(
  57. 'type' => 'text',
  58. 'inputlabel' => $this->name.' Link 2 Text',
  59. 'exp' => 'Add text to be used in this link.',
  60. ),
  61. '_soapbox_link_2_class' => array(
  62. 'type' => 'text',
  63. 'inputlabel' => $this->name.' Link 2 Classes',
  64. '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.',
  65. ),
  66. '_soapbox_link_3' => array(
  67. 'version' => 'pro',
  68. 'type' => 'text_link',
  69. 'inputlabel' => 'Soapbox Link 3 URL',
  70. 'exp' => 'Add a full link URL.'
  71. ),
  72. '_soapbox_link_3_text' => array(
  73. 'type' => 'text',
  74. 'inputlabel' => $this->name.' Link 3 Text',
  75. 'exp' => 'Add text to be used in this link.',
  76. ),
  77. '_soapbox_link_3_class' => array(
  78. 'type' => 'text',
  79. 'inputlabel' => $this->name.' Link 3 Classes',
  80. '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.',
  81. ),
  82. );
  83. $post_types = array($this->settings['posttype']);
  84. $this->meta_settings = array(
  85. 'id' => 'soapbox-meta',
  86. 'name' => THEMENAME." Soapbox Options (Soapbox Section Only)",
  87. 'posttype' => $post_types
  88. );
  89. $this->meta_options = new PageLinesMetaOptions($this->meta_array, $this->meta_settings);
  90. /*
  91. Create meta fields for the page template when using the Feature Template
  92. */
  93. $meta_array = array(
  94. '_soapbox_set' => array(
  95. 'version' => 'pro',
  96. 'type' => 'select_taxonomy',
  97. 'taxonomy_id' => "box-sets",
  98. 'inputlabel' => 'Select Box-Set To Use For Soapbox Section',
  99. 'exp' => 'If you are using the soapbox section, select the box-set you would it to use on this page.'
  100. ),
  101. '_soapbox_items' => array(
  102. 'type' => 'text_small',
  103. 'inputlabel' => 'Soapbox Posts Limit',
  104. 'exp' => 'Add the limit or soapboxes that can be shown on this page. Default is 10.',
  105. ),
  106. '_soapbox_height_media' => array(
  107. 'version' => 'pro',
  108. 'type' => 'text_small',
  109. 'inputlabel' => 'Soapbox Media Height (in Pixels)',
  110. 'exp' => 'For the "soapboxes" to line up correctly, the height of the media needs to be set. Add it here in pixels.'
  111. ),
  112. '_soapbox_link_1_text' => array(
  113. 'type' => 'text',
  114. 'inputlabel' => $this->name.' Link 1 Text',
  115. 'exp' => 'Add text to be used in this link. Can be overridden in the box meta options.',
  116. ),
  117. '_soapbox_link_1_class' => array(
  118. 'type' => 'text',
  119. 'inputlabel' => $this->name.' Link 1 Classes',
  120. '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.',
  121. ),
  122. '_soapbox_link_2_text' => array(
  123. 'type' => 'text',
  124. 'inputlabel' => $this->name.' Link 2 Text',
  125. 'exp' => 'Add text to be used in this link. Can be overridden in the box meta options.',
  126. ),
  127. '_soapbox_link_2_class' => array(
  128. 'type' => 'text',
  129. 'inputlabel' => $this->name.' Link 2 Classes',
  130. '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.',
  131. ),
  132. '_soapbox_link_3_text' => array(
  133. 'type' => 'text',
  134. 'inputlabel' => $this->name.' Link 3 Text - Callout Link',
  135. 'exp' => 'Add text to be used in this link. Can be overridden in the box meta options.',
  136. ),
  137. '_soapbox_link_3_class' => array(
  138. 'type' => 'text',
  139. 'inputlabel' => $this->name.' Link 3 Classes',
  140. '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.',
  141. ),
  142. );
  143. $meta_settings = array(
  144. 'id' => 'soapbox-template-meta',
  145. 'name' => THEMENAME." Soapbox Options",
  146. 'posttype' => 'page'
  147. );
  148. $this->meta_options = new PageLinesMetaOptions($meta_array, $meta_settings);
  149. }
  150. function section_template() {
  151. global $post;
  152. $perline = 2;
  153. $count = $perline;
  154. $soapbox_height_media = ( get_pagelines_meta('_soapbox_height_media', $post->ID) ) ? get_pagelines_meta('_soapbox_height_media', $post->ID) : 200;
  155. // Link text on parent page
  156. $soapbox_link_text[1] = ( get_pagelines_meta('_soapbox_link_1_text', $post->ID) ) ? get_pagelines_meta('_soapbox_link_1_text', $post->ID) : 'Link 1';
  157. $soapbox_link_text[2] = ( get_pagelines_meta('_soapbox_link_2_text', $post->ID) ) ? get_pagelines_meta('_soapbox_link_2_text', $post->ID) : 'Link 2';
  158. $soapbox_link_text[3] = ( get_pagelines_meta('_soapbox_link_3_text', $post->ID) ) ? get_pagelines_meta('_soapbox_link_3_text', $post->ID) : 'Link 3';
  159. $soapbox_link_class[1] = ( get_pagelines_meta('_soapbox_link_1_class', $post->ID) ) ? get_pagelines_meta('_soapbox_link_1_class', $post->ID) : '';
  160. $soapbox_link_class[2] = ( get_pagelines_meta('_soapbox_link_2_class', $post->ID) ) ? get_pagelines_meta('_soapbox_link_2_class', $post->ID) : '';
  161. $soapbox_link_class[3] = ( get_pagelines_meta('_soapbox_link_3_class', $post->ID) ) ? get_pagelines_meta('_soapbox_link_3_class', $post->ID) : '';
  162. ?>
  163. <div class="dcol_container_<?php echo $perline;?> fix">
  164. <?php
  165. // Let's Do This...
  166. $theposts = $this->get_section_posts();
  167. $boxes = (is_array($theposts)) ? $theposts : array();
  168. foreach($boxes as $post) : setup_postdata($post); ?>
  169. <div class="dcol_<?php echo $perline;?> dcol">
  170. <div class="dcol-pad">
  171. <?php if(get_post_meta($post->ID, 'the_box_icon', true)):?>
  172. <div class="fboxgraphic" style="line-height: <?php echo $soapbox_height_media;?>px; height: <?php echo $soapbox_height_media;?>px">
  173. <?php if(get_post_meta($post->ID, 'the_box_icon_link', true)):?>
  174. <a href="<?php echo get_post_meta($post->ID, 'the_box_icon_link', true);?>" alt="">
  175. <?php endif;?>
  176. <img src="<?php echo get_post_meta($post->ID, 'the_box_icon', true);?>" >
  177. <?php if(get_post_meta($post->ID, 'the_box_icon_link', true)):?>
  178. </a>
  179. <?php endif;?>
  180. </div>
  181. <?php endif;?>
  182. <div class="fboxinfo fix">
  183. <div class="fboxtitle"><h3><?php the_title(); ?></h3></div>
  184. <div class="fboxtext">
  185. <?php the_content(); ?>
  186. </div>
  187. <div class="soapbox-links">
  188. <?php for( $i = 1; $i <= 3; $i++):?>
  189. <?php if(get_post_meta($post->ID, '_soapbox_link_'.$i, true)):
  190. $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];
  191. $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];
  192. ?>
  193. <a class="soapbox_link <?php echo 'sblink_'.$i.' '.$link_class?>" href="<?php echo get_post_meta($post->ID, '_soapbox_link_'.$i, true);?>">
  194. <span class="soapbox_link-pad"><span class="soapbox_arrow"><?php echo $link_text; ?></span></span>
  195. </a>
  196. <?php endif;?>
  197. <?php endfor; ?>
  198. <?php pagelines_register_hook( 'pagelines_soapbox_links', $this->id ); // Hook ?>
  199. <?php edit_post_link(__('<small>[Edit Box]</small>', 'pagelines'), '', '');?>
  200. </div>
  201. </div>
  202. <?php pagelines_register_hook( 'pagelines_soapbox_inside_bottom', $this->id ); // Hook ?>
  203. </div>
  204. </div>
  205. <?php $end = ($count+1) / $perline; if(is_int($end)):?>
  206. <div class="clear"></div>
  207. <?php endif; $count++;?>
  208. <?php endforeach;?>
  209. </div>
  210. <div class="clear"></div>
  211. <?php }
  212. function get_section_posts(){
  213. global $post;
  214. if((!isset($this->the_section_posts) || !is_array($this->the_section_posts)) && isset($post)){
  215. $query_args = array('post_type' => $this->settings['posttype'], 'orderby' =>'ID');
  216. if( get_pagelines_meta('_soapbox_set', $post->ID ) ){
  217. $query_args = array_merge($query_args, array( 'box-sets' => get_post_meta($post->ID, '_soapbox_set', true) ) );
  218. } elseif (pagelines_non_meta_data_page() && pagelines_option('soapbox_default_tax')){
  219. $query_args = array_merge($query_args, array( 'box-sets' => pagelines_option('soapbox_default_tax') ) );
  220. }
  221. $num_items = (pagelines_option('_soapbox_items', $post->ID)) ? pagelines_option('_soapbox_items', $post->ID) : 10;
  222. $query_args = array_merge($query_args, array( 'showposts' => $num_items ) );
  223. $section_query = new WP_Query( $query_args );
  224. $this->the_section_posts = $section_query->posts;
  225. if(is_array($this->the_section_posts)) return $this->the_section_posts;
  226. else return array();
  227. } elseif(isset($post)) {
  228. return $this->the_section_posts;
  229. }
  230. }
  231. function section_options($optionset = null, $location = null) {
  232. if($optionset == 'box_settings' && $location == 'bottom'){
  233. return array(
  234. 'soapbox_default_tax' => array(
  235. 'default' => 'default-boxes',
  236. 'version' => 'pro',
  237. 'taxonomy_id' => 'box-sets',
  238. 'type' => 'select_taxonomy',
  239. 'inputlabel' => 'Select Soapbox Posts/404 Box-Set',
  240. 'title' => 'Posts Page and 404 Soapbox Box-Set',
  241. 'shortexp' => "Posts pages and similar pages (404) will use this Box-Set ID to source Soapboxes",
  242. '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.)",
  243. )
  244. );
  245. }
  246. }
  247. // End of Section Class //
  248. }