PageRenderTime 73ms CodeModel.GetById 45ms RepoModel.GetById 1ms app.codeStats 0ms

/public_html/wp-content/themes/eclipse/functions.php

https://bitbucket.org/jahmaiosullivan/seattledancehalltv
PHP | 321 lines | 203 code | 52 blank | 66 comment | 21 complexity | c36e16be7f057ea7d1d497d4c08adbb4 MD5 | raw file
  1. <?php
  2. /**
  3. * Theme functions used by Eclipse.
  4. *
  5. * Authors: Tyler Cunningham, Trent Lapinski
  6. * Copyright: © 2012
  7. * {@link http://cyberchimps.com/ CyberChimps LLC}
  8. *
  9. * Released under the terms of the GNU General Public License.
  10. * You should have received a copy of the GNU General Public License,
  11. * along with this software. In the main directory, see: /licensing/
  12. * If not, see: {@link http://www.gnu.org/licenses/}.
  13. *
  14. * @package Eclipse.
  15. * @since 1.0
  16. */
  17. /**
  18. * Establishes 'response' as the textdomain, sets $locale and file path
  19. *
  20. * @since 1.0
  21. */
  22. function response_text_domain() {
  23. load_theme_textdomain( 'response', get_template_directory() . '/core/languages' );
  24. $locale = get_locale();
  25. $locale_file = get_template_directory() . "/core/languages/$locale.php";
  26. if ( is_readable( $locale_file ) )
  27. require_once( $locale_file );
  28. return;
  29. }
  30. add_action('after_setup_theme', 'response_text_domain');
  31. function eclipse_url_filtered($fields){
  32. if(isset($fields['url']))
  33. unset($fields['url']);
  34. return $fields;
  35. }
  36. add_filter('comment_form_default_fields', 'eclipse_url_filtered');
  37. /**
  38. * Define global theme functions.
  39. */
  40. $ec_themename = 'eclipse';
  41. $ec_themenamefull = 'Eclipse';
  42. $ec_themeslug = 'ec';
  43. $ec_root = get_template_directory_uri();
  44. $ec_pagedocs = 'http://cyberchimps.com/question/using-the-eclipse-page-options/';
  45. $ec_sliderdocs = 'http://cyberchimps.com/question/using-the-eclipse-feature-slider/';
  46. /**
  47. * Set Content Width.
  48. */
  49. if ( ! isset( $content_width ) ) $content_width = 720; //Set content width
  50. /**
  51. * Basic theme setup.
  52. */
  53. function eclipse_theme_setup() {
  54. /**
  55. * Initialize response Core Framework and Pro Extension.
  56. */
  57. require_once ( get_template_directory() . '/core/core-init.php' );
  58. /**
  59. * Call additional files required by theme.
  60. */
  61. require_once ( get_template_directory() . '/includes/classy-options-init.php' ); // Theme options markup.
  62. require_once ( get_template_directory() . '/includes/options-functions.php' ); // Custom functions based on theme options.
  63. require_once ( get_template_directory() . '/includes/meta-box.php' ); // Meta options markup.
  64. require_once ( get_template_directory() . '/includes/presstrends.php' ); // Meta options markup.
  65. add_theme_support(
  66. 'post-formats',
  67. array('aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat')
  68. );
  69. add_theme_support( 'post-thumbnails' );
  70. set_post_thumbnail_size( 720, 240, true );
  71. add_theme_support('automatic-feed-links');
  72. add_editor_style();
  73. }
  74. add_action( 'after_setup_theme', 'eclipse_theme_setup' );
  75. /**
  76. * Redirect user to theme options page after activation.
  77. */
  78. if ( is_admin() && isset($_GET['activated'] ) && $pagenow =="themes.php" ) {
  79. wp_redirect( 'themes.php?page=eclipse' );
  80. }
  81. /**
  82. * Add link to theme options in Admin bar.
  83. */
  84. function eclipse_admin_link() {
  85. global $wp_admin_bar;
  86. $wp_admin_bar->add_menu( array( 'id' => 'Eclipse', 'title' => 'Eclipse Options', 'href' => admin_url('themes.php?page=eclipse') ) );
  87. }
  88. add_action( 'admin_bar_menu', 'eclipse_admin_link', 113 );
  89. /**
  90. * Custom markup for gallery posts in main blog index.
  91. */
  92. function eclipse_custom_gallery_post_format( $content ) {
  93. global $options, $ec_themeslug, $post;
  94. $ec_root = get_template_directory_uri();
  95. $featured_images = $options->get($ec_themeslug.'_show_featured_images');
  96. ob_start();
  97. ?>
  98. <div class="row">
  99. <div class="three columns"><?php response_post_byline(); ?></div>
  100. <div class="entry nine columns">
  101. <h2 class="posts_title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
  102. <?php if ( has_post_thumbnail() && $featured_images == '1' && !is_single()) {
  103. echo '<div class="featured-image">';
  104. echo '<a href="' . get_permalink($post->ID) . '" >';
  105. the_post_thumbnail();
  106. echo '</a>';
  107. echo '</div>';
  108. }
  109. ?>
  110. <?php if (!is_single()): ?>
  111. <?php $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
  112. if ( $images ) :
  113. $total_images = count( $images );
  114. $image = array_shift( $images );
  115. $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
  116. ?>
  117. <figure class="gallery-thumb">
  118. <a href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
  119. <br /><br />
  120. This gallery contains <?php echo $total_images ; ?> images
  121. <?php endif;?>
  122. </figure><!-- .gallery-thumb -->
  123. <?php endif;?>
  124. <?php if (is_single()): ?>
  125. <?php the_content(); ?>
  126. <?php endif;?>
  127. <!--Begin @Core link pages hook-->
  128. <?php response_link_pages(); ?>
  129. <!--End @Core link pages hook-->
  130. <!--Begin @Core post edit link hook-->
  131. <?php response_edit_link(); ?>
  132. <!--End @Core post edit link hook-->
  133. </div><!--end entry-->
  134. </div><!--end row-->
  135. <?php
  136. $content = ob_get_clean();
  137. return $content;
  138. }
  139. add_filter('response_post_formats_gallery_content', 'eclipse_custom_gallery_post_format' );
  140. /**
  141. * Set custom post excerpt link text based on theme option.
  142. */
  143. function eclipse_new_excerpt_more($more) {
  144. global $ec_themename, $ec_themeslug, $options, $custom_excerpt, $post, $ec_root;
  145. if ($options->get($ec_themeslug.'_excerpt_link_text') == '') {
  146. $linktext = 'Continue Reading';
  147. }
  148. elseif ($custom_excerpt == 'recent') {
  149. $linktext = 'Continue Reading';
  150. }
  151. else {
  152. $linktext = $options->get($ec_themeslug.'_excerpt_link_text');
  153. }
  154. return '&hellip;</p><div class="more-link"><span class="continue-arrow"><img src="'.$ec_root.'/images/continue.png"></span><a href="'. get_permalink($post->ID) . '"> '.$linktext.'</a></div>';
  155. }
  156. add_filter('excerpt_more', 'eclipse_new_excerpt_more');
  157. /**
  158. * Set custom post excerpt length based on theme option.
  159. */
  160. function eclipse_new_excerpt_length($length) {
  161. global $ec_themename, $ec_themeslug, $custom_excerpt, $options;
  162. if ($options->get($ec_themeslug.'_excerpt_length') == '') {
  163. $length = '55';
  164. }
  165. elseif ($custom_excerpt == 'recent') {
  166. $length = '15';
  167. }
  168. else {
  169. $length = $options->get($ec_themeslug.'_excerpt_length');
  170. }
  171. return $length;
  172. }
  173. add_filter('excerpt_length', 'eclipse_new_excerpt_length');
  174. /**
  175. * Attach CSS3PIE behavior to elements
  176. */
  177. function eclipse_render_ie_pie() { ?>
  178. <style type="text/css" media="screen">
  179. #wrapper input, textarea, #twitterbar, input[type=submit], input[type=reset], #imenu, .searchform, .post_container, .postformats, .postbar, .post-edit-link, .widget-container, .widget-title, .footer-widget-title, .comments_container, ol.commentlist li.even, ol.commentlist li.odd, .slider_nav, ul.metabox-tabs li, .tab-content, .list_item, .section-info, #of_container #header, .menu ul li a, .submit input, #of_container textarea, #of_container input, #of_container select, #of_container .screenshot img, #of_container .of_admin_bar, #of_container .subsection > h3, .subsection, #of_container #content .outersection .section, #carousel_list, #calloutwrap, #calloutbutton, .box1, .box2, .box3, .es-carousel-wrapper
  180. {
  181. behavior: url('<?php echo get_template_directory_uri(); ?>/core/library/pie/PIE.php');
  182. }
  183. </style>
  184. <?php
  185. }
  186. add_action('wp_head', 'eclipse_render_ie_pie', 8);
  187. /**
  188. * Google Analytics.
  189. */
  190. function eclipse_google_analytics() {
  191. global $ec_themename, $ec_themeslug, $options;
  192. echo stripslashes ($options->get($ec_themeslug.'_ga_code'));
  193. }
  194. add_action('wp_head', 'eclipse_google_analytics');
  195. /**
  196. * Register custom menus for header, footer.
  197. */
  198. function eclipse_register_menus() {
  199. register_nav_menus(
  200. array( 'header-menu' => __( 'Header Menu', 'response' ))
  201. );
  202. }
  203. add_action( 'init', 'eclipse_register_menus' );
  204. /**
  205. * Menu fallback if custom menu not used.
  206. */
  207. function eclipse_menu_fallback() {
  208. global $post; ?>
  209. <ul id="nav_menu">
  210. <?php wp_list_pages( 'title_li=&sort_column=menu_order&depth=3'); ?>
  211. </ul>
  212. <?php
  213. }
  214. /**
  215. * Register widgets.
  216. */
  217. function eclipse_widgets_init() {
  218. register_sidebar(array(
  219. 'name' => 'Full Sidebar',
  220. 'id' => 'sidebar-widgets',
  221. 'description' => 'These are widgets for the sidebar.',
  222. 'before_widget' => '<div id="%1$s" class="widget-container">',
  223. 'after_widget' => '</div>',
  224. 'before_title' => '<h2 class="widget-title">',
  225. 'after_title' => '</h2>'
  226. ));
  227. register_sidebar(array(
  228. 'name' => 'Left Half Sidebar',
  229. 'id' => 'sidebar-left',
  230. 'description' => 'These are widgets for the left sidebar.',
  231. 'before_widget' => '<div id="%1$s" class="widget-container">',
  232. 'after_widget' => '</div>',
  233. 'before_title' => '<h2 class="widget-title">',
  234. 'after_title' => '</h2>'
  235. ));
  236. register_sidebar(array(
  237. 'name' => 'Right Half Sidebar',
  238. 'id' => 'sidebar-right',
  239. 'description' => 'These are widgets for the right sidebar.',
  240. 'before_widget' => '<div id="%1$s" class="widget-container">',
  241. 'after_widget' => '</div>',
  242. 'before_title' => '<h2 class="widget-title">',
  243. 'after_title' => '</h2>'
  244. ));
  245. register_sidebar(array(
  246. 'name' => 'Footer',
  247. 'id' => 'footer-widgets',
  248. 'description' => 'These are the footer widgets',
  249. 'before_widget' => '<div class="three columns footer-widgets">',
  250. 'after_widget' => '</div>',
  251. 'before_title' => '<h3 class="footer-widget-title">',
  252. 'after_title' => '</h3>',
  253. ));
  254. register_sidebar(array(
  255. 'name' => 'get_post_list_with_thumbs',
  256. 'before_widget' => '',
  257. 'after_widget' => '',
  258. 'before_title' => '',
  259. 'after_title' => '',
  260. ));
  261. }
  262. add_action ('widgets_init', 'eclipse_widgets_init');
  263. function home_page_menu_args( $args ) {
  264. $args['show_home'] = true;
  265. return $args;
  266. }
  267. add_filter( 'wp_page_menu_args', 'home_page_menu_args' );
  268. add_filter('widget_text', 'do_shortcode');
  269. ?>